EntityCentricIndex extends AbstractAccumuloIndexer { public static RyaStatement deserializeStatement(final Key key, final Value value) throws RyaTypeResolverException, IOException { assert key != null; assert value != null; final byte[] entityBytes = key.getRowData().toArray(); final byte[] predicateBytes = key.getColumnFamilyData().toArray(); final byte[] data = key.getColumnQualifierData().toArray(); final long timestamp = key.getTimestamp(); final byte[] columnVisibility = key.getColumnVisibilityData().toArray(); final byte[] valueBytes = value.get(); int split = Bytes.indexOf(data, DELIM_BYTES); final byte[] columnFamily = Arrays.copyOf(data, split); final byte[] edgeBytes = Arrays.copyOfRange(data, split + DELIM_BYTES.length, data.length); split = Bytes.indexOf(edgeBytes, DELIM_BYTES); final String otherNodeVar = new String(Arrays.copyOf(edgeBytes, split), StandardCharsets.UTF_8); final byte[] otherNodeBytes = Arrays.copyOfRange(edgeBytes, split + DELIM_BYTES.length, edgeBytes.length); split = Bytes.indexOf(otherNodeBytes, TYPE_DELIM_BYTES); final byte[] otherNodeData = Arrays.copyOf(otherNodeBytes, split); final byte[] typeBytes = Arrays.copyOfRange(otherNodeBytes, split, otherNodeBytes.length); byte[] objectBytes; RyaIRI subject; final RyaIRI predicate = new RyaIRI(new String(predicateBytes, StandardCharsets.UTF_8)); RyaType object; RyaIRI context = null; switch (otherNodeVar) { case SUBJECT: subject = new RyaIRI(new String(otherNodeData, StandardCharsets.UTF_8)); objectBytes = Bytes.concat(entityBytes, typeBytes); break; case OBJECT: subject = new RyaIRI(new String(entityBytes, StandardCharsets.UTF_8)); objectBytes = Bytes.concat(otherNodeData, typeBytes); break; default: throw new IOException("Failed to deserialize entity-centric index row. " + "Expected 'subject' or 'object', encountered: '" + otherNodeVar + "'"); } object = RyaContext.getInstance().deserialize(objectBytes); if (columnFamily != null && columnFamily.length > 0) { context = new RyaIRI(new String(columnFamily, StandardCharsets.UTF_8)); } return new RyaStatement(subject, predicate, object, context, null, columnVisibility, valueBytes, timestamp); }  @Override Configuration getConf(); @Override void setConf(final Configuration conf); @Override String getTableName(); static String getTableName(final Configuration conf); static String makeTableName(final String ryaInstanceName); @Override void setMultiTableBatchWriter(final MultiTableBatchWriter writer); @Override void storeStatement(final RyaStatement stmt); @Override void deleteStatement(final RyaStatement stmt); static Collection<Mutation> createMutations(final RyaStatement stmt); static RyaStatement deserializeStatement(final Key key, final Value value); static RyaType getRyaType(final Key key, final Value value); @Override void init(); @Override void setConnector(final Connector connector); @Override void destroy(); @Override void purge(final RdfCloudTripleStoreConfiguration configuration); @Override void dropAndDestroy(); @Override Set<IRI> getIndexablePredicates();  }
@Test public void testDeserializeSubjectRow() throws RyaTypeResolverException, IOException { RyaStatement deserialized = EntityCentricIndex.deserializeStatement(subjectCentricKey, value); Assert.assertEquals("Deserialization of subject-centric row failed to produce equivalent RyaStatement.", ryaStatement, deserialized); }
@Test public void testDeserializeObjectRow() throws RyaTypeResolverException, IOException { RyaStatement deserialized = EntityCentricIndex.deserializeStatement(objectCentricKey, value); Assert.assertEquals("Deserialization of object-centric row failed to produce equivalent RyaStatement.", ryaStatement, deserialized); }