AccumuloRdfCountTool extends AbstractAccumuloMRTool implements Tool { public static void main(final String[] args) { try { ToolRunner.run(new Configuration(), new AccumuloRdfCountTool(), args); } catch (final Exception e) { e.printStackTrace(); } }  static void main(final String[] args); @Override int run(final String[] strings);  }
@Test public void testMR() throws Exception { RyaIRI test1 = RdfToRyaConversions.convertIRI(VF.createIRI(litdupsNS, "test1")); RyaIRI pred1 = RdfToRyaConversions.convertIRI(VF.createIRI(litdupsNS, "pred1")); dao.add(new RyaStatement(test1, pred1, RdfToRyaConversions.convertLiteral(VF.createLiteral(0)))); dao.add(new RyaStatement(test1, pred1, RdfToRyaConversions.convertLiteral(VF.createLiteral(1)))); dao.add(new RyaStatement(test1, pred1, RdfToRyaConversions.convertLiteral(VF.createLiteral(2)))); dao.add(new RyaStatement(test1, pred1, RdfToRyaConversions.convertLiteral(VF.createLiteral(3)))); dao.add(new RyaStatement(test1, pred1, RdfToRyaConversions.convertLiteral(VF.createLiteral(4)))); dao.add(new RyaStatement(test1, pred1, RdfToRyaConversions.convertLiteral(VF.createLiteral(5)))); dao.add(new RyaStatement(test1, pred1, RdfToRyaConversions.convertLiteral(VF.createLiteral(6)))); dao.add(new RyaStatement(test1, pred1, RdfToRyaConversions.convertLiteral(VF.createLiteral(7)))); dao.add(new RyaStatement(test1, pred1, RdfToRyaConversions.convertLiteral(VF.createLiteral(8)))); dao.add(new RyaStatement(test1, pred1, RdfToRyaConversions.convertLiteral(VF.createLiteral(9)))); dao.add(new RyaStatement(test1, pred1, RdfToRyaConversions.convertLiteral(VF.createLiteral(10)))); AccumuloRdfCountTool.main(new String[]{ "-Dac.mock=true", "-Dac.instance=" + instance, "-Dac.username=" + user, "-Dac.pwd=" + pwd, "-Drdf.tablePrefix=" + tablePrefix, }); Map<String, Key> expectedValues = new HashMap<String, Key>(); String row = test1.getData(); expectedValues.put(row, new Key(new Text(row), RdfCloudTripleStoreConstants.SUBJECT_CF_TXT, RdfCloudTripleStoreConstants.EMPTY_TEXT)); row = pred1.getData(); expectedValues.put(row, new Key(new Text(row), RdfCloudTripleStoreConstants.PRED_CF_TXT, RdfCloudTripleStoreConstants.EMPTY_TEXT)); Scanner scanner = connector.createScanner(tablePrefix + RdfCloudTripleStoreConstants.TBL_EVAL_SUFFIX, auths); scanner.setRange(new Range()); int count = 0; for (Map.Entry<Key, Value> entry : scanner) { assertTrue(expectedValues.get(entry.getKey().getRow().toString()).equals(entry.getKey(), PartialKey.ROW_COLFAM_COLQUAL)); assertEquals(11, Long.parseLong(entry.getValue().toString())); count++; } assertEquals(2, count); }
@Test public void testTTL() throws Exception { RyaIRI test1 = RdfToRyaConversions.convertIRI(VF.createIRI(litdupsNS, "test1")); RyaIRI pred1 = RdfToRyaConversions.convertIRI(VF.createIRI(litdupsNS, "pred1")); dao.add(new RyaStatement(test1, pred1, RdfToRyaConversions.convertLiteral(VF.createLiteral(0)))); dao.add(new RyaStatement(test1, pred1, RdfToRyaConversions.convertLiteral(VF.createLiteral(1)))); dao.add(new RyaStatement(test1, pred1, RdfToRyaConversions.convertLiteral(VF.createLiteral(2)))); dao.add(new RyaStatement(test1, pred1, RdfToRyaConversions.convertLiteral(VF.createLiteral(3)))); dao.add(new RyaStatement(test1, pred1, RdfToRyaConversions.convertLiteral(VF.createLiteral(4)))); dao.add(new RyaStatement(test1, pred1, RdfToRyaConversions.convertLiteral(VF.createLiteral(5)))); dao.add(new RyaStatement(test1, pred1, RdfToRyaConversions.convertLiteral(VF.createLiteral(6)))); dao.add(new RyaStatement(test1, pred1, RdfToRyaConversions.convertLiteral(VF.createLiteral(7)))); dao.add(new RyaStatement(test1, pred1, RdfToRyaConversions.convertLiteral(VF.createLiteral(8)))); dao.add(new RyaStatement(test1, pred1, RdfToRyaConversions.convertLiteral(VF.createLiteral(9)))); dao.add(new RyaStatement(test1, pred1, RdfToRyaConversions.convertLiteral(VF.createLiteral(10)))); AccumuloRdfCountTool.main(new String[]{ "-Dac.mock=true", "-Dac.instance=" + instance, "-Dac.username=" + user, "-Dac.pwd=" + pwd, "-Dac.ttl=0", "-Drdf.tablePrefix=" + tablePrefix, }); Scanner scanner = connector.createScanner(tablePrefix + RdfCloudTripleStoreConstants.TBL_EVAL_SUFFIX, auths); scanner.setRange(new Range()); int count = 0; for (Map.Entry<Key, Value> entry : scanner) { count++; } assertEquals(0, count); }
@Test public void testContext() throws Exception { RyaIRI test1 = RdfToRyaConversions.convertIRI(VF.createIRI(litdupsNS, "test1")); RyaIRI pred1 = RdfToRyaConversions.convertIRI(VF.createIRI(litdupsNS, "pred1")); RyaIRI cntxt = RdfToRyaConversions.convertIRI(VF.createIRI(litdupsNS, "cntxt")); dao.add(new RyaStatement(test1, pred1, RdfToRyaConversions.convertLiteral(VF.createLiteral(0)), cntxt)); dao.add(new RyaStatement(test1, pred1, RdfToRyaConversions.convertLiteral(VF.createLiteral(1)), cntxt)); dao.add(new RyaStatement(test1, pred1, RdfToRyaConversions.convertLiteral(VF.createLiteral(2)), cntxt)); dao.add(new RyaStatement(test1, pred1, RdfToRyaConversions.convertLiteral(VF.createLiteral(3)), cntxt)); dao.add(new RyaStatement(test1, pred1, RdfToRyaConversions.convertLiteral(VF.createLiteral(4)), cntxt)); dao.add(new RyaStatement(test1, pred1, RdfToRyaConversions.convertLiteral(VF.createLiteral(5)), cntxt)); dao.add(new RyaStatement(test1, pred1, RdfToRyaConversions.convertLiteral(VF.createLiteral(6)), cntxt)); dao.add(new RyaStatement(test1, pred1, RdfToRyaConversions.convertLiteral(VF.createLiteral(7)), cntxt)); dao.add(new RyaStatement(test1, pred1, RdfToRyaConversions.convertLiteral(VF.createLiteral(8)), cntxt)); dao.add(new RyaStatement(test1, pred1, RdfToRyaConversions.convertLiteral(VF.createLiteral(9)), cntxt)); dao.add(new RyaStatement(test1, pred1, RdfToRyaConversions.convertLiteral(VF.createLiteral(10)), cntxt)); AccumuloRdfCountTool.main(new String[]{ "-Dac.mock=true", "-Dac.instance=" + instance, "-Dac.username=" + user, "-Dac.pwd=" + pwd, "-Drdf.tablePrefix=" + tablePrefix, }); Map<String, Key> expectedValues = new HashMap<String, Key>(); String row = test1.getData(); expectedValues.put(row, new Key(new Text(row), RdfCloudTripleStoreConstants.SUBJECT_CF_TXT, new Text(cntxt.getData()))); row = pred1.getData(); expectedValues.put(row, new Key(new Text(row), RdfCloudTripleStoreConstants.PRED_CF_TXT, new Text(cntxt.getData()))); Scanner scanner = connector.createScanner(tablePrefix + RdfCloudTripleStoreConstants.TBL_EVAL_SUFFIX, auths); scanner.setRange(new Range()); int count = 0; for (Map.Entry<Key, Value> entry : scanner) { assertTrue(expectedValues.get(entry.getKey().getRow().toString()).equals(entry.getKey(), PartialKey.ROW_COLFAM_COLQUAL)); assertEquals(11, Long.parseLong(entry.getValue().toString())); count++; } assertEquals(2, count); }