EntityCentricIndex extends AbstractAccumuloIndexer { private static List<TripleRow> serializeStatement(final RyaStatement stmt) throws RyaTypeResolverException { final RyaIRI subject = stmt.getSubject(); final RyaIRI predicate = stmt.getPredicate(); final RyaType object = stmt.getObject(); final RyaIRI context = stmt.getContext(); final Long timestamp = stmt.getTimestamp(); final byte[] columnVisibility = stmt.getColumnVisibility(); final byte[] value = stmt.getValue(); assert subject != null && predicate != null && object != null; final byte[] cf = (context == null) ? EMPTY_BYTES : context.getData().getBytes(StandardCharsets.UTF_8); final byte[] subjBytes = subject.getData().getBytes(StandardCharsets.UTF_8); final byte[] predBytes = predicate.getData().getBytes(StandardCharsets.UTF_8); final byte[][] objBytes = RyaContext.getInstance().serializeType(object); return Lists.newArrayList(new TripleRow(subjBytes, predBytes, Bytes.concat(cf, DELIM_BYTES, OBJECT.getBytes(StandardCharsets.UTF_8), DELIM_BYTES, objBytes[0], objBytes[1]), timestamp, columnVisibility, value), new TripleRow(objBytes[0], predBytes, Bytes.concat(cf, DELIM_BYTES, SUBJECT.getBytes(StandardCharsets.UTF_8), DELIM_BYTES, subjBytes, objBytes[1]), timestamp, columnVisibility, value)); }  @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 testSerializeStatement() throws RyaTypeResolverException { Collection<Mutation> indexMutations = EntityCentricIndex.createMutations(ryaStatement); Assert.assertEquals("Serialization should produce two rows: subject-centric and object-centric.", 2, indexMutations.size()); Assert.assertTrue("Serialization of RyaStatement failed to create equivalent subject-centric row.", indexMutations.contains(createMutationFromKeyValue(subjectCentricKey, value))); Assert.assertTrue("Serialization of RyaStatement failed to create equivalent object-centric row.", indexMutations.contains(createMutationFromKeyValue(objectCentricKey, value))); }