@Override @SuppressWarnings("unchecked") public List<Object> read(DataInput dataInput) throws RepositoryException, InterruptedException { int nrOfValues = dataInput.readInt(); List<Object> result = new ArrayList<Object>(nrOfValues); for (int i = 0 ; i < nrOfValues; i++) { result.add(valueType.read(dataInput)); } return result; }
@Override @SuppressWarnings("unchecked") public HierarchyPath read(DataInput dataInput) throws RepositoryException, InterruptedException { int nrOfValues = dataInput.readInt(); List<Object> result = new ArrayList<Object>(nrOfValues); for (int i = 0 ; i < nrOfValues; i++) { result.add(valueType.read(dataInput)); } return new HierarchyPath(result.toArray(new Object[result.size()])); }
decodedValue = Fields.DELETED; } else { decodedValue = fieldType.getValueType().read(new DataInputImpl(EncodingUtil.stripPrefix(value)));
public List<MutationCondition> convertFromAvro(List<AvroMutationCondition> avroConditions, LRepository repository) throws RepositoryException, InterruptedException { if (avroConditions == null) { return null; } List<MutationCondition> conditions = new ArrayList<MutationCondition>(avroConditions.size()); for (AvroMutationCondition avroCond : avroConditions) { QName name = convert(avroCond.getName()); // value is optional Object value = null; if (avroCond.getValue() != null) { ValueType valueType = repository.getTypeManager().getValueType(avroCond.getValueType()); value = valueType.read(avroCond.getValue().array()); } CompareOp op = convert(avroCond.getOperator()); boolean allowMissing = avroCond.getAllowMissing(); conditions.add(new MutationCondition(name, op, value, allowMissing)); } return conditions; }
byte[] value = cell.getValue(); if (!isDeleteMarker(value)) { blobValue = valueType.read(EncodingUtil.stripPrefix(value));
@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 ExtractedField extractField(byte[] key, byte[] prefixedValue, ReadContext context, FieldTypes fieldTypes) throws RepositoryException, InterruptedException { byte flags = prefixedValue[0]; if (FieldFlags.isDeletedField(flags)) { return null; } FieldType fieldType = fieldTypes.getFieldType(new SchemaIdImpl(Bytes.tail(key, key.length - 1))); if (context != null) { context.addFieldType(fieldType); } ValueType valueType = fieldType.getValueType(); Metadata metadata = null; int metadataSpace = 0; // space taken up by metadata (= metadata itself + length suffix) int metadataEncodingVersion = FieldFlags.getFieldMetadataVersion(flags); if (metadataEncodingVersion == 0) { // there is no metadata } else if (metadataEncodingVersion == 1) { int metadataSize = Bytes.toInt(prefixedValue, prefixedValue.length - Bytes.SIZEOF_INT, Bytes.SIZEOF_INT); metadataSpace = metadataSize + Bytes.SIZEOF_INT; metadata = MetadataSerDeser.read( new DataInputImpl(prefixedValue, prefixedValue.length - metadataSpace, metadataSize)); } else { throw new RuntimeException("Unsupported field metadata encoding version: " + metadataEncodingVersion); } Object value = valueType.read(new DataInputImpl(prefixedValue, FieldFlags.SIZE_OF_FIELD_FLAGS, prefixedValue.length - FieldFlags.SIZE_OF_FIELD_FLAGS - metadataSpace)); return new ExtractedField(fieldType, value, metadata); }
String valueTypeName = input.readUTF(); ValueType valueType = typeManager.getValueType(valueTypeName); Object value = valueType.read(input); record.setField(name, value);