@Override @SuppressWarnings("unchecked") public LocalDate read(DataInput dataInput) { // Read the encoding version byte, but ignore it for the moment since there is only one encoding dataInput.readByte(); // Always construct UTC such that it is not depending on the default timezone of the current host return new LocalDate(dataInput.readLong(), DateTimeZone.UTC); }
/** * See write for the byte format. */ @Override @SuppressWarnings("unchecked") public Blob read(DataInput dataInput) { // Read the encoding version byte, but ignore it for the moment since there is only one encoding dataInput.readByte(); int keyLength = dataInput.readVInt(); byte[] key = null; if (keyLength > 0) { key = dataInput.readBytes(keyLength); } String mediaType = dataInput.readUTF(); Long size = dataInput.readLong(); if (size == -1) { size = null; } String filename = dataInput.readUTF(); return new Blob(key, mediaType, size, filename); }
private static QName readNullOrQName(DataInput input) { byte nullMarker = input.readByte(); if (nullMarker == NULL_MARKER) { return null; } else { return readQName(input); } }
@Override @SuppressWarnings("unchecked") public Record read(DataInput dataInput) throws RepositoryException, InterruptedException { Record record = new RecordImpl(); dataInput.readByte(); // Ignore, there is currently only one encoding : 1 int length = dataInput.readVInt(); byte[] recordTypeId = dataInput.readBytes(length); Long recordTypeVersion = dataInput.readLong(); RecordType recordType = typeManager.getRecordTypeById(new SchemaIdImpl(recordTypeId), recordTypeVersion); record.setRecordType(recordType.getName(), recordTypeVersion); Map<SchemaId, QName> idToQNameMapping = new HashMap<SchemaId, QName>(); List<FieldType> fieldTypes = getSortedFieldTypes(recordType); for (FieldType fieldType : fieldTypes) { byte readByte = dataInput.readByte(); if (DEFINED == readByte) { Object value = fieldType.getValueType().read(dataInput); record.setField(fieldType.getName(), value); idToQNameMapping.put(fieldType.getId(), fieldType.getName()); } } Map<Scope, SchemaId> recordTypeIds = new EnumMap<Scope, SchemaId>(Scope.class); recordTypeIds.put(Scope.NON_VERSIONED, recordType.getId()); return new IdRecordImpl(record, idToQNameMapping, recordTypeIds); }
private static Integer readNullOrVInt(DataInput input) { byte nullMarker = input.readByte(); if (nullMarker == NULL_MARKER) { return null; } else { return input.readVInt(); } }
@Override @SuppressWarnings("unchecked") public DateTime read(DataInput dataInput) { // Read the encoding version byte, but ignore it for the moment since there is only one encoding dataInput.readByte(); // Always construct UTC such that it is not depending on the default timezone of the current host return new DateTime(dataInput.readLong(), DateTimeZone.UTC); }
@Override @SuppressWarnings("unchecked") public String read(DataInput dataInput) { // Read the encoding version byte, but ignore it for the moment since there is only one encoding dataInput.readByte(); return dataInput.readUTF(); }
private static byte[] readNullOrBytes(DataInput input) { byte nullMarker = input.readByte(); if (nullMarker == NULL_MARKER) { return null; } else { return readBytes(input); } }
private static Long readNullOrVLong(DataInput input) { byte nullMarker = input.readByte(); if (nullMarker == NULL_MARKER) { return null; } else { return input.readVLong(); } }
@Override public Link read(DataInput dataInput) { // Read the encoding version byte, but ignore it for the moment since there is only one encoding byte version = dataInput.readByte(); Link link; switch (version) { case VERSION_ONE: link = Lily11RecordIdDecoder.decodeLink(dataInput, idGenerator); break; case VERSION_TWO: link = Lily20LinkDecoder.decode(dataInput, idGenerator); break; case VERSION_THREE: link = Link.read(dataInput, idGenerator); break; default: throw new RuntimeException("Unsupported encoding version for link value type: " + version); } return link; }
@Override public RecordId fromBytes(DataInput dataInput) { byte idType = dataInput.readByte(); // Note: will throw arrayindexoutofbounds if id is not known IdType id = ID_TYPES[idType]; DataInput[] splitted = id.factory.splitInMasterAndVariant(dataInput); DataInput masterIdInput = splitted[0]; DataInput variantParamsInput = splitted[1]; RecordId masterRecordId = id.factory.fromBytes(masterIdInput, this); if (variantParamsInput != null) { return new VariantRecordId(masterRecordId, variantParamsInput, this); } else { return masterRecordId; } }
private ValueType decodeValueType(byte[] bytes) throws RepositoryException, InterruptedException { DataInput dataInput = new DataInputImpl(bytes); if (valueTypeEncodingVersion != dataInput.readByte()) { throw new TypeException("Unknown value type encoding version encountered in schema"); } return getValueType(dataInput.readUTF()); }
public static Metadata read(DataInput input) { MetadataBuilder metadataBuilder = new MetadataBuilder(); // read fields int size = input.readVInt(); for (int i = 0; i < size; i++) { String key = input.readVUTF(); byte valueType = input.readByte(); ValueSerDeser serdeser = BYTE_TO_SERDESER.get(valueType); if (serdeser == null) { throw new IllegalArgumentException("Unsupported kind of metadata value: type byte " + (int)valueType); } Object value = serdeser.deserialize(input); metadataBuilder.object(key, value); } // read deleted fields size = input.readVInt(); for (int i = 0; i < size; i++) { metadataBuilder.delete(input.readVUTF()); } return metadataBuilder.build(); }
int size = dataInput.getSize(); dataInput.setPosition(size - 1); byte identifierByte = dataInput.readByte(); dataInput.setPosition(pos);