use of org.apache.accumulo.core.client.MultiTableBatchWriter in project accumulo by apache.
the class MockConnectorTest method testMockMultiTableBatchWriter.
@Test
public void testMockMultiTableBatchWriter() throws Exception {
Connector c = new MockConnector("root", new MockInstance());
c.tableOperations().create("a");
c.tableOperations().create("b");
MultiTableBatchWriter bw = c.createMultiTableBatchWriter(new BatchWriterConfig());
Mutation m1 = new Mutation("r1");
m1.put("cf1", "cq1", 1, "v1");
BatchWriter b = bw.getBatchWriter("a");
b.addMutation(m1);
b.flush();
b = bw.getBatchWriter("b");
b.addMutation(m1);
b.flush();
Scanner scanner = c.createScanner("a", Authorizations.EMPTY);
int count = Iterators.size(scanner.iterator());
assertEquals(1, count);
scanner = c.createScanner("b", Authorizations.EMPTY);
count = Iterators.size(scanner.iterator());
assertEquals(1, count);
}
use of org.apache.accumulo.core.client.MultiTableBatchWriter in project incubator-rya by apache.
the class RyaOutputFormat method getFreeTextIndexer.
private static FreeTextIndexer getFreeTextIndexer(final Configuration conf) throws IOException {
if (!conf.getBoolean(ENABLE_FREETEXT, true)) {
return null;
}
final AccumuloFreeTextIndexer freeText = new AccumuloFreeTextIndexer();
freeText.setConf(conf);
Connector connector;
try {
connector = ConfigUtils.getConnector(conf);
} catch (AccumuloException | AccumuloSecurityException e) {
throw new IOException("Error when attempting to create a connection for writing the freeText index.", e);
}
final MultiTableBatchWriter mtbw = connector.createMultiTableBatchWriter(new BatchWriterConfig());
freeText.setConnector(connector);
freeText.setMultiTableBatchWriter(mtbw);
freeText.init();
return freeText;
}
use of org.apache.accumulo.core.client.MultiTableBatchWriter in project incubator-rya by apache.
the class RyaOutputFormatTest method testTemporalIndexing.
@Test
public void testTemporalIndexing() throws Exception {
final TemporalInstant[] instants = { new TemporalInstantRfc3339(2015, 12, 30, 12, 00, 01), new TemporalInstantRfc3339(2015, 12, 30, 12, 00, 02), new TemporalInstantRfc3339(2015, 12, 30, 12, 00, 03), new TemporalInstantRfc3339(2015, 12, 30, 12, 00, 03) };
final Statement[] statements = new Statement[instants.length];
RyaOutputFormat.setCoreTablesEnabled(job, false);
RyaOutputFormat.setFreeTextEnabled(job, false);
RyaOutputFormat.setTemporalEnabled(job, true);
RyaOutputFormat.setEntityEnabled(job, false);
final ValueFactory vf = new ValueFactoryImpl();
for (int i = 0; i < instants.length; i++) {
final RyaType time = RdfToRyaConversions.convertLiteral(vf.createLiteral(instants[i].toString()));
final RyaStatement input = RyaStatement.builder().setSubject(new RyaURI(GRAPH + ":s")).setPredicate(new RyaURI(GRAPH + ":p")).setObject(time).build();
write(input);
statements[i] = RyaToRdfConversions.convertStatement(input);
}
final AccumuloTemporalIndexer temporal = new AccumuloTemporalIndexer();
temporal.setConf(conf);
Connector connector = ConfigUtils.getConnector(conf);
MultiTableBatchWriter mtbw = connector.createMultiTableBatchWriter(new BatchWriterConfig());
temporal.setConnector(connector);
temporal.setMultiTableBatchWriter(mtbw);
temporal.init();
final Set<Statement> empty = new HashSet<>();
final Set<Statement> head = new HashSet<>();
final Set<Statement> tail = new HashSet<>();
head.add(statements[0]);
tail.add(statements[2]);
tail.add(statements[3]);
Assert.assertEquals(empty, getSet(temporal.queryInstantBeforeInstant(instants[0], new StatementConstraints())));
Assert.assertEquals(empty, getSet(temporal.queryInstantAfterInstant(instants[3], new StatementConstraints())));
Assert.assertEquals(head, getSet(temporal.queryInstantBeforeInstant(instants[1], new StatementConstraints())));
Assert.assertEquals(tail, getSet(temporal.queryInstantAfterInstant(instants[1], new StatementConstraints())));
temporal.close();
}
use of org.apache.accumulo.core.client.MultiTableBatchWriter in project incubator-rya by apache.
the class RyaOutputFormat method getTemporalIndexer.
private static TemporalIndexer getTemporalIndexer(final Configuration conf) throws IOException {
if (!conf.getBoolean(ENABLE_TEMPORAL, true)) {
return null;
}
final AccumuloTemporalIndexer temporal = new AccumuloTemporalIndexer();
temporal.setConf(conf);
Connector connector;
try {
connector = ConfigUtils.getConnector(conf);
} catch (AccumuloException | AccumuloSecurityException e) {
throw new IOException("Error when attempting to create a connection for writing the temporal index.", e);
}
final MultiTableBatchWriter mtbw = connector.createMultiTableBatchWriter(new BatchWriterConfig());
temporal.setConnector(connector);
temporal.setMultiTableBatchWriter(mtbw);
temporal.init();
return temporal;
}
use of org.apache.accumulo.core.client.MultiTableBatchWriter in project incubator-rya by apache.
the class AccumuloTemporalIndexerTest method setUp.
/**
* @throws java.lang.Exception
*/
@Before
public void setUp() throws Exception {
conf = new Configuration();
conf.set(RdfCloudTripleStoreConfiguration.CONF_TBL_PREFIX, "triplestore_");
conf.setBoolean(ConfigUtils.USE_MOCK_INSTANCE, true);
// The temporal predicates are from http://linkedevents.org/ontology
// and http://motools.sourceforge.net/event/event.html
conf.setStrings(ConfigUtils.TEMPORAL_PREDICATES_LIST, "" + URI_PROPERTY_AT_TIME + "," + URI_PROPERTY_CIRCA + "," + URI_PROPERTY_EVENT_TIME);
tIndexer = new AccumuloTemporalIndexer();
tIndexer.setConf(conf);
Connector connector = ConfigUtils.getConnector(conf);
MultiTableBatchWriter mt_bw = connector.createMultiTableBatchWriter(new BatchWriterConfig());
tIndexer.setConnector(connector);
tIndexer.setMultiTableBatchWriter(mt_bw);
tIndexer.init();
}
Aggregations