private static void writeBytes(byte[] bytes, DataOutput output) { output.writeVInt(bytes.length); output.writeBytes(bytes); }
@Override public void write(Object value, DataOutput dataOutput, IdentityRecordStack parentRecords) throws RepositoryException, InterruptedException { if (value instanceof RecordRvtImpl) { byte[] bytes = ((RecordRvtImpl)value).getBytes(); if (bytes != null) { dataOutput.writeBytes(bytes); return; } } encodeData(value, dataOutput, parentRecords); }
public void write(DataOutput dataOutput) { // The bytes format is as follows: // [byte representation of table, byte representation of master record id, if not null][args: bytes of the string representation] byte[] tableBytes = table == null ? new byte[0] : table.getBytes(); dataOutput.writeInt(tableBytes.length); if (tableBytes.length > 0) { dataOutput.writeBytes(tableBytes); } byte[] recordIdBytes = masterRecordId == null ? new byte[0] : masterRecordId.toBytes(); dataOutput.writeInt(recordIdBytes.length); if (recordIdBytes.length > 0) { dataOutput.writeBytes(recordIdBytes); } StringBuilder argsBuilder = new StringBuilder(); argstoString(argsBuilder); dataOutput.writeUTF(argsBuilder.toString()); }
@Override public void writeBytes(DataOutput dataOutput) { if (uuidBytes == null) { dataOutput.writeByte(IdGeneratorImpl.IdType.UUID.getIdentifierByte()); dataOutput.writeLong(uuid.getMostSignificantBits()); dataOutput.writeLong(uuid.getLeastSignificantBits()); } else { dataOutput.writeBytes(uuidBytes); } }
@Override public final void writeBytes(DataOutput dataOutput) { if (recordIdBytes == null) { masterRecordId.writeBytes(dataOutput); // TODO this needs to be designed some other way if (masterRecordId instanceof UserRecordId) { dataOutput.writeByte((byte) 0); } Set<Entry<String, String>> entrySet = variantProperties.entrySet(); for (Entry<String, String> entry : entrySet) { // entry consists of the dimension and the dimension value dataOutput.writeVUTF(entry.getKey()); dataOutput.writeVUTF(entry.getValue()); } } else { dataOutput.writeBytes(recordIdBytes); } }
@Override public void writeBytes(DataOutput dataOutput) { if (recordIdBytes == null) { dataOutput.writeByte(IdGeneratorImpl.IdType.USER.getIdentifierByte()); dataOutput.writeUTF(basicRecordIdString, false); } else { dataOutput.writeBytes(recordIdBytes); } }
@Override public void serialize(Object value, DataOutput dataOutput) { dataOutput.writeVInt(((ByteArray)value).length()); dataOutput.writeBytes(((ByteArray) value).getBytesUnsafe()); }
@Override public void write(Object value, DataOutput dataOutput, IdentityRecordStack parentRecords) { ByteArray byteArray = (ByteArray) value; dataOutput.writeInt(byteArray.length()); // We can use getBytesUnsafe here since we know that in this use case // the // dataOutput will be a DataOutputImpl which copies the byte[] when // writing it. dataOutput.writeBytes(byteArray.getBytesUnsafe()); }
public static void writeMetadataWithLengthSuffix(Metadata metadata, DataOutput output) { DataOutput tmp = new DataOutputImpl(); MetadataSerDeser.write(metadata, tmp); byte[] metadataBytes = tmp.toByteArray(); output.writeBytes(metadataBytes); output.writeInt(metadataBytes.length); }
/** * Format of the bytes written : * - Length of the blob value : int of 4 bytes * - Blob Value * - Blob Media Type : UTF (which starts with an int of 4 bytes indicating its length) * - Blob size : long of 8 bytes * - Blob name : UTF (which starts with an int of 4 bytes indicating its length) * * <p> IMPORTANT: Any changes on this format has an impact on the {@link ContainsValueComparator} */ @Override public void write(Object value, DataOutput dataOutput, IdentityRecordStack parentRecords) { dataOutput.writeByte((byte)1); // Encoding version 1 Blob blob = (Blob)value; byte[] key = blob.getValue(); if (key == null) { dataOutput.writeVInt(0); } else { dataOutput.writeVInt(key.length); dataOutput.writeBytes(key); } dataOutput.writeUTF(blob.getMediaType()); Long size = blob.getSize(); if (size == null) { size = Long.valueOf(-1); } dataOutput.writeLong(size); dataOutput.writeUTF(blob.getName()); }
byte[] recordIdBytes = recordType.getId().getBytes(); dataOutput.writeVInt(recordIdBytes.length); dataOutput.writeBytes(recordIdBytes); dataOutput.writeLong(recordType.getVersion());