@SuppressWarnings("unchecked") @Override protected EntityId getEntityId(final byte[] row) { try { return new EntitySeed(((ToBytesSerialiser) schema.getVertexSerialiser()) .deserialise(ByteArrayEscapeUtils.unEscape(Arrays.copyOfRange(row, 0, row.length - 2)))); } catch (final SerialisationException e) { throw new AccumuloElementConversionException("Failed to create EntityId from Accumulo row key", e); } }
@Override public byte[] serialiseVertex(final Object vertex) { try { return ByteArrayEscapeUtils.escape(((ToBytesSerialiser) schema.getVertexSerialiser()).serialise(vertex)); } catch (final SerialisationException e) { throw new AccumuloElementConversionException( "Failed to serialise given identifier object for use in the bloom filter", e); } }
protected byte[] getSerialisedDestination(final Edge edge) { try { return ByteArrayEscapeUtils.escape(((ToBytesSerialiser) schema.getVertexSerialiser()).serialise(edge.getDestination())); } catch (final SerialisationException e) { throw new AccumuloElementConversionException("Failed to serialise Edge Destination", e); } }
protected EdgeId getEdgeId(final byte[] row, final boolean includeMatchedVertex) { final byte[][] result = new byte[2][]; final EdgeDirection direction = getSourceAndDestinationFromRowKey(row, result); final EdgeId.MatchedVertex matchedVertex; if (!includeMatchedVertex) { matchedVertex = null; } else if (EdgeDirection.DIRECTED_REVERSED == direction) { matchedVertex = EdgeId.MatchedVertex.DESTINATION; } else { matchedVertex = EdgeId.MatchedVertex.SOURCE; } try { return new EdgeSeed(((ToBytesSerialiser) schema.getVertexSerialiser()).deserialise(result[0]), ((ToBytesSerialiser) schema.getVertexSerialiser()).deserialise(result[1]), direction.isDirected(), matchedVertex); } catch (final SerialisationException e) { throw new AccumuloElementConversionException("Failed to create EdgeId from Accumulo row key", e); } }
@Override protected byte[] getRowKeyFromEntity(final Entity entity) { try { return ByteArrayEscapeUtils.escape(((ToBytesSerialiser) schema.getVertexSerialiser()).serialise(entity.getVertex()), ByteArrayEscapeUtils.DELIMITER, ByteEntityPositions.ENTITY); } catch (final SerialisationException e) { throw new AccumuloElementConversionException("Failed to serialise Entity Identifier", e); } }
protected byte[] getSerialisedSource(final Edge edge) { try { return ByteArrayEscapeUtils.escape(((ToBytesSerialiser) schema.getVertexSerialiser()).serialise(edge.getSource())); } catch (final SerialisationException e) { throw new AccumuloElementConversionException("Failed to serialise Edge Source", e); } }
@Override protected EntityId getEntityId(final byte[] row) { try { return new EntitySeed(((ToBytesSerialiser) schema.getVertexSerialiser()) .deserialise(ByteArrayEscapeUtils.unEscape(row))); } catch (final SerialisationException e) { throw new AccumuloElementConversionException("Failed to create EntityId from Accumulo row key", e); } }
@Override protected byte[] getRowKeyFromEntity(final Entity entity) { // No Delimiters but need to escape bytes // because later we check how many delimiter characters there are try { return ByteArrayEscapeUtils.escape(((ToBytesSerialiser) schema.getVertexSerialiser()).serialise(entity.getVertex())); } catch (final SerialisationException e) { throw new AccumuloElementConversionException("Failed to serialise Entity Identifier", e); } }
final boolean isEntity = gafferSchema.getEntityGroups().contains(group); final StringBuilder schemaString = new StringBuilder("message Element {\n"); Serialiser serialiser = gafferSchema.getVertexSerialiser();
@Override protected Entity getEntityFromKey(final Key key, final byte[] row) { try { final Entity entity = new Entity(getGroupFromKey(key), ((ToBytesSerialiser) schema.getVertexSerialiser()) .deserialise(ByteArrayEscapeUtils.unEscape(row, 0, row.length - 2))); addPropertiesToElement(entity, key); return entity; } catch (final SerialisationException e) { throw new AccumuloElementConversionException("Failed to re-create Entity from key", e); } }
@Override protected Entity getEntityFromKey(final Key key, final byte[] row) { try { final Entity entity = new Entity(getGroupFromKey(key), ((ToBytesSerialiser) schema.getVertexSerialiser()) .deserialise(ByteArrayEscapeUtils.unEscape(row))); addPropertiesToElement(entity, key); return entity; } catch (final SerialisationException e) { throw new AccumuloElementConversionException("Failed to re-create Entity from key", e); } }
serialisedVertex = ByteArrayEscapeUtils.escape(((ToBytesSerialiser) schema.getVertexSerialiser()).serialise(vertex)); } catch (final SerialisationException e) { throw new RangeFactoryException("Failed to serialise identifier", e);
@SuppressWarnings("WeakerAccess") protected Edge getEdgeFromKey(final Key key, final byte[] row, final boolean includeMatchedVertex) { final byte[][] result = new byte[2][]; final EdgeDirection direction = getSourceAndDestinationFromRowKey(row, result); final EdgeId.MatchedVertex matchedVertex; if (!includeMatchedVertex) { matchedVertex = null; } else if (EdgeDirection.DIRECTED_REVERSED == direction) { matchedVertex = EdgeId.MatchedVertex.DESTINATION; } else { matchedVertex = EdgeId.MatchedVertex.SOURCE; } final String group = getGroupFromColumnFamily(key.getColumnFamilyData().getBackingArray()); try { final Edge edge = new Edge(group, ((ToBytesSerialiser) schema.getVertexSerialiser()).deserialise(result[0]), ((ToBytesSerialiser) schema.getVertexSerialiser()).deserialise(result[1]), direction.isDirected(), matchedVertex, null); addPropertiesToElement(edge, key); return edge; } catch (final SerialisationException e) { throw new AccumuloElementConversionException("Failed to re-create Edge from key", e); } }
@Override protected void addAdditionalOperationHandlers() { addOperationHandler(AddElementsFromHdfs.class, new AddElementsFromHdfsHandler()); addOperationHandler(GetElementsBetweenSets.class, new GetElementsBetweenSetsHandler()); addOperationHandler(GetElementsWithinSet.class, new GetElementsWithinSetHandler()); addOperationHandler(SplitStoreFromFile.class, new HdfsSplitStoreFromFileHandler()); addOperationHandler(SplitStoreFromIterable.class, new SplitStoreFromIterableHandler()); addOperationHandler(SplitStore.class, new SplitStoreHandler()); addOperationHandler(SampleElementsForSplitPoints.class, new SampleElementsForSplitPointsHandler()); addOperationHandler(SampleDataForSplitPoints.class, new SampleDataForSplitPointsHandler()); addOperationHandler(ImportAccumuloKeyValueFiles.class, new ImportAccumuloKeyValueFilesHandler()); if (null == getSchema().getVertexSerialiser() || getSchema().getVertexSerialiser().preservesObjectOrdering()) { addOperationHandler(SummariseGroupOverRanges.class, new SummariseGroupOverRangesHandler()); addOperationHandler(GetElementsInRanges.class, new GetElementsInRangesHandler()); } else { LOGGER.warn("Accumulo range scan operations will not be available on this store as the vertex serialiser does not preserve object ordering. Vertex serialiser: {}", getSchema().getVertexSerialiser().getClass().getName()); } }
final ToBytesSerialiser vertexSerialiser = (ToBytesSerialiser) schema.getVertexSerialiser();
protected Key getKeyFromEdgeId(final Object source, final Object destination, final boolean directed, final boolean endKey) throws RangeFactoryException { final ToBytesSerialiser vertexSerialiser = (ToBytesSerialiser) schema.getVertexSerialiser(); final byte directionFlag = directed ? ByteEntityPositions.CORRECT_WAY_DIRECTED_EDGE : ByteEntityPositions.UNDIRECTED_EDGE; byte[] sourceValue; try { sourceValue = ByteArrayEscapeUtils.escape(vertexSerialiser.serialise(source)); } catch (final SerialisationException e) { throw new RangeFactoryException("Failed to serialise Edge Source", e); } byte[] destinationValue; try { destinationValue = ByteArrayEscapeUtils.escape(vertexSerialiser.serialise(destination)); } catch (final SerialisationException e) { throw new RangeFactoryException("Failed to serialise Edge Destination", e); } byte[] key = getKey(endKey, directionFlag, sourceValue, destinationValue); return new Key(key, AccumuloStoreConstants.EMPTY_BYTES, AccumuloStoreConstants.EMPTY_BYTES, AccumuloStoreConstants.EMPTY_BYTES, Long.MAX_VALUE); }
serialisedVertex = ByteArrayEscapeUtils.escape(((ToBytesSerialiser) schema.getVertexSerialiser()).serialise(vertex)); } catch (final SerialisationException e) { throw new RangeFactoryException("Failed to serialise identifier", e);