@Test public void testSplits() throws Exception { AccumuloGraphConfiguration cfg; // Tests for splits string. cfg = AccumuloGraphTestUtils.generateGraphConfig("nullSplits").setSplits((String) null); AccumuloGraph graph = (AccumuloGraph) GraphFactory.open(cfg.getConfiguration()); for (String table : cfg.getTableNames()) { assertEquals(0, cfg.getConnector().tableOperations().listSplits(table).size()); } graph.shutdown(); cfg = AccumuloGraphTestUtils.generateGraphConfig("emptySplits").setSplits(""); graph = (AccumuloGraph) GraphFactory.open(cfg.getConfiguration()); for (String table : cfg.getTableNames()) { assertEquals(0, cfg.getConnector().tableOperations().listSplits(table).size()); } graph.shutdown(); cfg = AccumuloGraphTestUtils.generateGraphConfig("threeSplits").setSplits(" a b c "); graph = (AccumuloGraph) GraphFactory.open(cfg.getConfiguration()); for (String table : cfg.getTableNames()) { Collection<Text> splits = cfg.getConnector().tableOperations().listSplits(table); assertEquals(3, splits.size()); List<Text> arr = new ArrayList<Text>(splits); assertEquals("a", arr.get(0).toString()); assertEquals("b", arr.get(1).toString()); assertEquals("c", arr.get(2).toString()); } graph.shutdown(); // Tests for splits array. cfg = AccumuloGraphTestUtils.generateGraphConfig("nullSplitsArray").setSplits((String[]) null); graph = (AccumuloGraph) GraphFactory.open(cfg.getConfiguration()); for (String table : cfg.getTableNames()) { assertEquals(0, cfg.getConnector().tableOperations().listSplits(table).size()); } graph.shutdown(); cfg = AccumuloGraphTestUtils.generateGraphConfig("emptySplitsArray").setSplits(new String[] {}); graph = (AccumuloGraph) GraphFactory.open(cfg.getConfiguration()); for (String table : cfg.getTableNames()) { assertEquals(0, cfg.getConnector().tableOperations().listSplits(table).size()); } graph.shutdown(); cfg = AccumuloGraphTestUtils.generateGraphConfig("threeSplitsArray") .setSplits(new String[] {"d", "e", "f"}); graph = (AccumuloGraph) GraphFactory.open(cfg.getConfiguration()); for (String table : cfg.getTableNames()) { Collection<Text> splits = cfg.getConnector().tableOperations().listSplits(table); assertEquals(3, splits.size()); List<Text> arr = new ArrayList<Text>(splits); assertEquals("d", arr.get(0).toString()); assertEquals("e", arr.get(1).toString()); assertEquals("f", arr.get(2).toString()); } graph.shutdown(); }
public static void main(String[] args) { Graph usergrid = GraphFactory.open( "/Users/nishitarao/dev/usergrid-blueprints/src/main/resources/usergrid.properties"); Vertex v1 = usergrid.addVertex("person:Nishita"); // Adds a vertex Vertex testGet = usergrid.getVertex(v1.getId()); // Gets vertex using getVetex which in turn uses getId System.out.println(testGet); usergrid.removeVertex(v1); // Delete a vertex Vertex v2 = usergrid.addVertex("restaurant:Amici"); // Adds a vertex v2.setProperty("tag", "Amici"); // Sets a property System.out.println(v2.getProperty("tag")); // Gets a property System.out.println(v2); // v2.removeProperty("tag"); //TODO: Have to check whether Usergrid supports this // System.out.println(v2); v2.remove(); // Deletes the vertex }
protected Graph initializeGraphDB() { LOG.info("Initializing graph db"); Configuration graphConfig = getConfiguration(); return GraphFactory.open(graphConfig); }