/** * Get the type byte of a {@link PropertyValue} instance. It's the first one of the * raw representation of a PropertyValue. * * @param value the {@link PropertyValue} to extract the type byte * @return the type byte as array */ public static byte[] getTypeByte(PropertyValue value) { byte[] typeByte = new byte[1]; typeByte[0] = value.getRawBytes()[0]; return typeByte; }
/** * Get the raw byte representation of a {@link PropertyValue} instance without the type byte as prefix. * * @param value the {@link PropertyValue} to extract the bytes * @return a byte array containing the value without type information */ public static byte[] getRawBytesWithoutType(PropertyValue value) { return Arrays.copyOfRange(value.getRawBytes(), 1, value.getRawBytes().length); }
/** * Writes the byte representation of a property into the target byte array * starting at the specified offset * @param value PropertyValue that will be written * @param target Target byte array * @param offset offset the value will be written to */ private void writeProperty(PropertyValue value, byte[] target, int offset) { writeInt(value.getByteSize(), target, offset); offset += Integer.BYTES; System.arraycopy(value.getRawBytes(), 0, target, offset, value.getByteSize()); }
/** * Writes the byte representation of a property into the target byte array * starting at the specified offset * @param value PropertyValue that will be written * @param target Target byte array * @param offset offset the value will be written to */ private void writeProperty(PropertyValue value, byte[] target, int offset) { writeInt(value.getByteSize(), target, offset); offset += Integer.BYTES; System.arraycopy(value.getRawBytes(), 0, target, offset, value.getByteSize()); }
/** * Test static function {@link PropertyValueUtils.Bytes#createFromTypeValueBytes(byte[], byte[])}} */ @Test public void testCreateFromTypeValueBytes() { assertEquals(propertyValue, PropertyValueUtils.Bytes .createFromTypeValueBytes(new byte[] {type}, Arrays.copyOfRange(propertyValue.getRawBytes(), 1, propertyValue.getRawBytes().length))); } }
/** * Test static function {@link PropertyValueUtils.Bytes#getRawBytesWithoutType(PropertyValue)} */ @Test public void testGetRawBytesWithoutType() { assertArrayEquals(Arrays.copyOfRange(propertyValue.getRawBytes(), 1, propertyValue.getRawBytes().length), PropertyValueUtils.Bytes.getRawBytesWithoutType(propertyValue)); }
@Override public Mutation writeRow( Mutation mutation, EPGMGraphHead record ) { mutation.put(AccumuloTables.KEY.LABEL, AccumuloTables.KEY.NONE, record.getLabel()); Iterable<String> keys = record.getPropertyKeys(); if (keys != null) { keys.forEach(key -> mutation.put( /*cf*/AccumuloTables.KEY.PROPERTY, /*cq*/key, /*value*/new Value(record.getPropertyValue(key).getRawBytes()))); } return mutation; }
@Override public Mutation writeRow( Mutation mutation, EPGMVertex record ) { mutation.put(AccumuloTables.KEY.LABEL, AccumuloTables.KEY.NONE, record.getLabel()); //encode properties value bytes as base64 string Iterable<String> keys = record.getPropertyKeys(); if (keys != null) { keys.forEach(key -> mutation.put( /*cf*/AccumuloTables.KEY.PROPERTY, /*cq*/key, /*value*/new Value(record.getPropertyValue(key).getRawBytes()))); } //write graph ids GradoopIdSet ids = record.getGraphIds(); if (ids != null) { ids.forEach( id -> mutation.put(AccumuloTables.KEY.GRAPH, id.toString(), AccumuloTables.KEY.NONE)); } return mutation; }
@Override public Mutation writeRow( Mutation mutation, EPGMEdge record ) { mutation.put(AccumuloTables.KEY.LABEL, AccumuloTables.KEY.NONE, record.getLabel()); mutation.put(AccumuloTables.KEY.SOURCE, AccumuloTables.KEY.NONE, record.getSourceId().toString()); mutation.put(AccumuloTables.KEY.TARGET, AccumuloTables.KEY.NONE, record.getTargetId().toString()); //encode properties value bytes as base64 string Iterable<String> keys = record.getPropertyKeys(); if (keys != null) { keys.forEach(key -> mutation.put( /*cf*/AccumuloTables.KEY.PROPERTY, /*cq*/key, /*value*/new Value(record.getPropertyValue(key).getRawBytes()))); } //write graph ids GradoopIdSet ids = record.getGraphIds(); if (ids != null) { ids.forEach( id -> mutation.put(AccumuloTables.KEY.GRAPH, id.toString(), AccumuloTables.KEY.NONE)); } return mutation; }