@Override public <T> T read(byte[] data) throws RepositoryException, InterruptedException { return read(new DataInputImpl(data)); }
Set<DependencyEntry> deserializeDependenciesForward(byte[] serialized) throws IOException { final DataInputImpl dataInput = new DataInputImpl(serialized); final int nDependencies = dataInput.readInt(); final Set<DependencyEntry> result = new HashSet<DependencyEntry>(nDependencies); while (result.size() < nDependencies) { final int tableLength = dataInput.readInt(); final String table = Bytes.toString(dataInput.readBytes(tableLength)); final int masterBytesLength = dataInput.readInt(); final byte[] masterBytes = dataInput.readBytes(masterBytesLength); final DerefMapVariantPropertiesPattern variantPropertiesPattern = deserializeVariantPropertiesPattern(dataInput); result.add(new DependencyEntry(new AbsoluteRecordIdImpl(table, idGenerator.newRecordId(idGenerator.fromBytes(masterBytes), variantPropertiesPattern.getConcreteProperties())), variantPropertiesPattern.getPatternProperties())); } return result; }
@Override public double readDouble() { return Double.longBitsToDouble(readLong()); }
@Override public float readFloat() { return Float.intBitsToFloat(readInt()); }
@Override public RecordId fromBytes(byte[] bytes) { return fromBytes(new DataInputImpl(bytes)); }
DerefMapVariantPropertiesPattern deserializeVariantPropertiesPattern(byte[] serialized) { return deserializeVariantPropertiesPattern(new DataInputImpl(serialized)); }
/** * Reads a long stored in variable-length format. Reads between one and * nine bytes. Smaller values take fewer bytes. Negative numbers are not * supported. */ @Override public long readVLong() { byte b = readByte(); long i = b & 0x7F; for (int shift = 7; (b & 0x80) != 0; shift += 7) { b = readByte(); i |= (b & 0x7FL) << shift; } return i; }
public String toString() { if (string == null) { if (uuid == null) { DataInput dataInput = new DataInputImpl(bytes); this.uuid = new UUID(dataInput.readLong(), dataInput.readLong()); } this.string = uuid.toString(); } return string; }
/** * Reads an int stored in variable-length format. Reads between one and * five bytes. Smaller values take fewer bytes. Negative numbers are not * supported. */ @Override public int readVInt() { byte b = readByte(); int i = b & 0x7F; for (int shift = 7; (b & 0x80) != 0; shift += 7) { b = readByte(); i |= (b & 0x7F) << shift; } return i; }
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; } }
/** * * @param clearBytes should be false for read operations, true for write operations. * The idea is that as long as the record is not modified, the * existing bytes can be reused. */ private synchronized void decode(boolean clearBytes) { if (delegate == null) { try { delegate = (IdRecord)recordValueType.read(new DataInputImpl(bytes)); } catch (RepositoryException e) { throw new RuntimeException("Failed to decode record "); } catch (InterruptedException e) { Thread.currentThread().interrupt(); } } if (clearBytes) { bytes = null; } }
public Record convertRecord(ByteBuffer recordData, LRepository repository) throws RepositoryException, InterruptedException { return RecordAsBytesConverter.read(new DataInputImpl(asArray(recordData)), repository); }
public IdRecord convertIdRecord(ByteBuffer avroIdRecord, LRepository repository) throws RepositoryException, InterruptedException { return RecordAsBytesConverter.readIdRecord(new DataInputImpl(asArray(avroIdRecord)), repository); }
@Override public DataInput[] splitInMasterAndVariant(DataInput dataInput) { // Search for separator byte int sepPos = dataInput.indexOf(VARIANT_SEPARATOR); if (sepPos == -1) { return new DataInput[]{dataInput, null}; } else { DataInput keyInput = new DataInputImpl(((DataInputImpl) dataInput), dataInput.getPosition(), sepPos - dataInput.getPosition()); DataInput variantInput = new DataInputImpl(((DataInputImpl) dataInput), sepPos + 1, dataInput.getSize() - (sepPos + 1)); return new DataInput[]{keyInput, variantInput}; } }
public static QName decodeName(byte[] bytes) { DataInput dataInput = new DataInputImpl(bytes); String namespace = dataInput.readUTF(); String name = dataInput.readUTF(); return new QName(namespace, name); }