/*
(non-Javadoc)

@see
com.impetus.client.hbase.admin.DataHandler#writeData(java.lang.String,
com.impetus.kundera.metadata.model.EntityMetadata, java.lang.Object,
java.lang.Object, java.util.List, boolean)
979238
@Override
    public void writeData(String tableName, EntityMetadata m, Object entity, Object rowId,
            List<RelationHolder> relations, boolean showQuery) throws IOException
    {
        HBaseRow hbaseRow = createHbaseRow(m, entity, rowId, relations);
        writeHbaseRowInATable(tableName, hbaseRow);
    }
1123845
@Override
    public void write(List<? extends SnapshotContentItem> items) throws Exception {
        for (SnapshotContentItem item : items) {
            Map<String, String> props = PropertiesSerializer.deserialize(item.getMetadata());
            String contentId = item.getContentId();
            String checksum = props.get(ContentStore.CONTENT_CHECKSUM);

            // verify that manifest contains every item from the database except
            // SNAPSHOT_PROPS_FILENAME
            if (!contentId.equals(Constants.SNAPSHOT_PROPS_FILENAME)) {
                if (!this.manifestSet.contains(ManifestFileHelper.formatManifestSetString(contentId, checksum))) {
                    addError(MessageFormat.format("Content item {0} with checksum {1} not found in manifest "
                                                  + "for snapshot {2}", contentId, checksum, this.snapshotName));
                }
            }
        }
    }
739076
public static <T> void writeListTo(LinkedBuffer buffer,
            List<T> messages, Schema<T> schema, boolean numeric)
    {
        if (buffer.start != buffer.offset)
        {
            throw new IllegalArgumentException("Buffer previously used and had not been reset.");
        }

        if (messages.isEmpty())
        {
            return;
        }

        MsgpackXOutput output = new MsgpackXOutput(buffer, numeric, schema);

        try
        {

            for (T m : messages)
            {

                LinkedBuffer objectStarter = output.writeStartObject();
                schema.writeTo(output, m);

                if (output.isLastRepeated())
                {
                    output.writeEndArray();
                }

                output.writeEndObject(objectStarter);

            }

        }
        catch (IOException e)
        {
            throw new RuntimeException("Serializing to a byte array threw an IOException " +
                    "(should never happen).", e);
        }
    }
921110
private void writePropertyData() {
		try (PrintStream out = new PrintStream(openResultFileOuputStream(
				resultDirectory, "properties.json"))) {
			out.println("{");

			int count = 0;
			for (Entry<Integer, PropertyRecord> propertyEntry : this.propertyRecords
					.entrySet()) {
				if (count > 0) {
					out.println(",");
				}
				out.print("\"" + propertyEntry.getKey() + "\":");
				mapper.writeValue(out, propertyEntry.getValue());
				count++;
			}
			out.println("\n}");

			System.out.println(" Serialized information for " + count
					+ " properties.");
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
1285533
private void writeClassData() {
		try (PrintStream out = new PrintStream(
				ExampleHelpers.openExampleFileOuputStream("classes.csv"))) {

			out.println("Id" + ",Label" + ",Description" + ",URL" + ",Image"
					+ ",Number of direct instances"
					+ ",Number of direct subclasses" + ",Direct superclasses"
					+ ",All superclasses" + ",Related properties");

			List<Entry<EntityIdValue, ClassRecord>> list = new ArrayList<>(
					this.classRecords.entrySet());
			Collections.sort(list, new ClassUsageRecordComparator());
			for (Entry<EntityIdValue, ClassRecord> entry : list) {
				if (entry.getValue().itemCount > 0
						|| entry.getValue().subclassCount > 0) {
					printClassRecord(out, entry.getValue(), entry.getKey());
				}
			}

		} catch (IOException e) {
			e.printStackTrace();
		}
	}
271171
public void putPropertyMetadata(PropertyMetadata propertyMetadata) {
    String mappedName = propertyMetadata.getMappedName();
    PropertyMetadata old = propertyMetadataMap.put(mappedName, propertyMetadata);
    if (old != null) {
      String format = "Class %s has two fields, %s and %s, both mapped to the same property "
          + "name, %s";
      String message = String.format(format, clazz.getName(), old.getName(),
          propertyMetadata.getName(), mappedName);
      throw new EntityManagerException(message);
    }
  }
583331
public void setData(List<CmsAliasTableRow> data, List<CmsRewriteAliasTableRow> rewriteData) {

        m_table.getLiveDataList().clear();
        m_table.getLiveDataList().addAll(data);
        m_rewriteTable.getLiveDataList().clear();
        m_rewriteTable.getLiveDataList().addAll(rewriteData);
    }
202448
@Override
    public void persistJoinTable(JoinTableData joinTableData)
    {
        String joinTableName = joinTableData.getJoinTableName();
        String invJoinColumnName = joinTableData.getInverseJoinColumnName();
        Map<Object, Set<Object>> joinTableRecords = joinTableData.getJoinTableRecords();
        String tableName = HBaseUtils.getHTableName(joinTableData.getSchemaName(), joinTableName);
        for (Object key : joinTableRecords.keySet())
        {
            Set<Object> values = joinTableRecords.get(key);
            Object joinColumnValue = key;
            Map<String, Object> columns = new HashMap<String, Object>();
            for (Object childValue : values)
            {
                columns.put(invJoinColumnName + "_" + childValue, childValue);
            }
            if (columns != null && !columns.isEmpty())
            {
                try
                {
                    handler.writeJoinTableData(tableName, joinColumnValue, columns, joinTableName);
                    KunderaCoreUtils.printQuery("Persist Join Table:" + joinTableName, showQuery);
                }
                catch (IOException e)
                {
                    throw new PersistenceException(e);
                }
            }
        }
    }
117158
private void writeMetaData(ByteArrayOutputStream baos)
            throws UnsupportedEncodingException, IOException {
        if (settings.getMetadata() == null) {
            return;
        }

        for (Iterator<String> i = settings.getMetadata().iterator();
                i.hasNext();) {
            Object obj = i.next();
            if (obj instanceof String) {
                baos.write(((String)obj).getBytes(DEFAULT_ENCODING));
            } else if (obj instanceof File) {
                InputStream is = null;
                try {
                    is = new BufferedInputStream(
                        new FileInputStream((File)obj));
                    byte [] buffer = new byte[4096];
                    for (int read = -1; (read = is.read(buffer)) != -1;) {
                        baos.write(buffer, 0, read);
                    }
                } finally {
                    if (is != null) {
                        is.close();
                    }
                }
            } else if (obj != null) {
                logger.severe("Unsupported metadata type: " + obj);
            }
        }
        return;
    }
1129952
private void writePropertyData() {
		try (PrintStream out = new PrintStream(
				ExampleHelpers.openExampleFileOuputStream("properties.csv"))) {

			out.println("Id" + ",Label" + ",Description" + ",URL" + ",Datatype"
					+ ",Uses in statements" + ",Items with such statements"
					+ ",Uses in statements with qualifiers"
					+ ",Uses in qualifiers" + ",Uses in references"
					+ ",Uses total" + ",Related properties");

			List<Entry<PropertyIdValue, PropertyRecord>> list = new ArrayList<Entry<PropertyIdValue, PropertyRecord>>(
					this.propertyRecords.entrySet());
			Collections.sort(list, new UsageRecordComparator());
			for (Entry<PropertyIdValue, PropertyRecord> entry : list) {
				printPropertyRecord(out, entry.getValue(), entry.getKey());
			}

		} catch (IOException e) {
			e.printStackTrace();
		}
	}
609048
@Override
	protected void writeDataBlock(byte[] data, int offset, int len, int blockHandle) throws DataStoreException
    {
    	try
        {
	        dataRandomAccessFile.seek((long)blockHandle*blockSize);
	        dataRandomAccessFile.write(data,offset,len);
        }
    	catch (IOException e)
    	{
    		throw new DataStoreException("Cannot write data block "+blockHandle+" : "+dataFile.getAbsolutePath(),e);
    	}
    }
1045096
def _WriteStorageMetadata(self):
    """"""
    self._cursor.execute(self._CREATE_METADATA_TABLE_QUERY)

    query = 'INSERT INTO metadata (key, value) VALUES (?, ?)'

    key = 'format_version'
    value = '{0:d}'.format(self._FORMAT_VERSION)
    self._cursor.execute(query, (key, value))

    key = 'compression_format'
    value = self.compression_format
    self._cursor.execute(query, (key, value))

    key = 'serialization_format'
    value = self.serialization_format
    self._cursor.execute(query, (key, value))

    key = 'storage_type'
    value = self.storage_type
    self._cursor.execute(query, (key, value))
752410
public void addEntityMetadata(Class<?> clazz, EntityMetadata entityMetadata)
    {
        getEntityMetadataMap().put(clazz.getName(), entityMetadata);
    }
1043267
private function writeStoredRoutineMetadata(): void
  {
    $json_data = json_encode($this->phpStratumMetadata, JSON_PRETTY_PRINT);
    if (json_last_error()!=JSON_ERROR_NONE)
    {
      throw new RuntimeException("Error of encoding to JSON: '%s'.", json_last_error_msg());
    }

    // Save the metadata.
    $this->writeTwoPhases($this->phpStratumMetadataFilename, $json_data);
  }
16274
public void writeBodyFeed(List<?> entities) throws ODataRenderException {
        checkNotNull(entities);
        try {
            for (Object entity : entities) {
                writeEntry(entity, true);
            }
        } catch (XMLStreamException | IllegalAccessException | NoSuchFieldException | ODataEdmException e) {
            LOG.error("Not possible to marshall feed stream XML");
            throw new ODataRenderException("Not possible to marshall feed stream XML: ", e);
        }
    }
1348942
@Override
    public ProcessorResult handleWrite(Object entity) throws ODataException {
        if (ODataUriUtil.isRefPathUri(getoDataUri())) {
            return processLink((ODataLink) entity);
        } else {
            if (entity != null) {
                throw new ODataBadRequestException("The body of a DELETE request must be empty.");
            }

            return processEntity();
        }
    }
1013240
protected Collection<JavaWriter> writeExtraData(SchemaDefinition definition, Function<File,JavaWriter> writerGenerator){
        return Collections.emptyList();
    }