@Override public Object deserialize(DataInput dataInput) { return dataInput.readVInt(); } }
private static Integer readNullOrVInt(DataInput input) { byte nullMarker = input.readByte(); if (nullMarker == NULL_MARKER) { return null; } else { return input.readVInt(); } }
private static byte[] readBytes(DataInput input) { int length = input.readVInt(); return input.readBytes(length); }
public static Set<String> deserialize(byte[] stringsAsBytes) { Set<String> permissions = new HashSet<String>(); DataInput input = new DataInputImpl(stringsAsBytes); int permCount = input.readVInt(); for (int i = 0; i < permCount; i++) { permissions.add(input.readVUTF()); } return permissions; } }
@Override public Object deserialize(DataInput dataInput) { int size = dataInput.readVInt(); return new ByteArray(dataInput.readBytes(size)); } }
public static AuthorizationContext deserialiaze(byte[] data) { DataInput input = new DataInputImpl(data); String name = input.readVUTF(); String tenant = input.readVUTF(); Set<String> roles = new HashSet<String>(); int roleCnt = input.readVInt(); for (int i = 0; i < roleCnt; i++) { roles.add(input.readVUTF()); } return new AuthorizationContext(name, tenant, roles); } }
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(); }
public static final IdRecord readIdRecord(DataInput input, LRepository repository) throws RepositoryException, InterruptedException { Record record = read(input, repository); IdGenerator idGenerator = repository.getIdGenerator(); int size = input.readVInt(); Map<SchemaId, QName> idToQNameMapping = new HashMap<SchemaId, QName>(); for (int i = 0; i < size; i++) { byte[] schemaIdBytes = readBytes(input); QName name = readQName(input); SchemaId schemaId = idGenerator.getSchemaId(schemaIdBytes); idToQNameMapping.put(schemaId, name); } Map<Scope, SchemaId> recordTypeIds = new EnumMap(Scope.class); for (Scope scope : Scope.values()) { byte[] schemaIdBytes = readNullOrBytes(input); if (schemaIdBytes != null) { SchemaId schemaId = idGenerator.getSchemaId(schemaIdBytes); recordTypeIds.put(scope, schemaId); } } return new IdRecordImpl(record, idToQNameMapping, recordTypeIds); }
/** * 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); }
@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); }
int size = input.readVInt(); for (int i = 0; i < size; i++) { QName name = readQName(input); size = input.readVInt(); for (int i = 0; i < size; i++) { record.getFieldsToDelete().add(readQName(input)); size = input.readVInt(); for (int i = 0; i < size; i++) { String key = input.readUTF(); size = input.readVInt(); for (int i = 0; i < size; i++) { QName fieldName = readQName(input);