List of usage examples for org.apache.hadoop.fs FileSystem getLocal
public static LocalFileSystem getLocal(Configuration conf) throws IOException
From source file:gaffer.accumulo.TestAccumuloBackedGraphUpdatingConf.java
License:Apache License
@Test public void testSetConfigurationWithRollUpOff() throws Exception { String instanceName = "testSetConfigurationWithRollUpOff"; AccumuloBackedGraph graph = setUpGraphAndMockAccumulo(instanceName); AccumuloConfig accumuloConfig = setUpAccumuloConfig(instanceName); graph.rollUpOverTimeAndVisibility(false); JobConf conf = new JobConf(); conf.set("fs.default.name", "file:///"); conf.set("mapred.job.tracker", "local"); Pair<TypeValue> pair = new Pair<TypeValue>(new TypeValue("customer", "A"), new TypeValue("product", "P")); graph.setConfigurationFromPairs(conf, pair, accumuloConfig); FileSystem fs = FileSystem.getLocal(conf); // Run//from w ww .j a va2 s . c o m Driver driver = new Driver(); driver.setConf(conf); String outputDir = tempFolder.newFolder().getAbsolutePath(); FileUtils.deleteDirectory(outputDir); assertEquals(0, driver.run(new String[] { outputDir })); // Read results in Set<GraphElementWithStatistics> results = new HashSet<GraphElementWithStatistics>(); int count = readResults(fs, new Path(outputDir), results); // There should be 3 edges assertEquals(3, count); Set<GraphElementWithStatistics> expectedResults = new HashSet<GraphElementWithStatistics>(); Edge edge1 = new Edge("customer", "A", "product", "P", "purchase", "instore", true, visibilityString1, sevenDaysBefore, sixDaysBefore); SetOfStatistics statistics1 = new SetOfStatistics(); statistics1.addStatistic("count", new Count(1)); expectedResults.add(new GraphElementWithStatistics(new GraphElement(edge1), statistics1)); Edge edge2 = new Edge("customer", "A", "product", "P", "purchase", "instore", true, visibilityString1, sixDaysBefore, fiveDaysBefore); SetOfStatistics statistics2 = new SetOfStatistics(); statistics2.addStatistic("count", new Count(19)); statistics2.addStatistic("anotherCount", new Count(1000000)); expectedResults.add(new GraphElementWithStatistics(new GraphElement(edge2), statistics2)); Edge edge4 = new Edge("customer", "A", "product", "P", "purchase", "instore", false, visibilityString2, sixDaysBefore, fiveDaysBefore); SetOfStatistics statistics4 = new SetOfStatistics(); statistics4.addStatistic("countSomething", new Count(123456)); expectedResults.add(new GraphElementWithStatistics(new GraphElement(edge4), statistics4)); assertEquals(expectedResults, results); }
From source file:gaffer.accumulo.TestAccumuloBackedGraphUpdatingConf.java
License:Apache License
@Test public void testSetConfigurationFullTableScan() throws Exception { String instanceName = "testSetConfigurationFullTableScan"; AccumuloBackedGraph graph = setUpGraphAndMockAccumulo(instanceName); AccumuloConfig accumuloConfig = setUpAccumuloConfig(instanceName); JobConf conf = new JobConf(); conf.set("fs.default.name", "file:///"); conf.set("mapred.job.tracker", "local"); graph.setConfiguration(conf, accumuloConfig); FileSystem fs = FileSystem.getLocal(conf); // Run/*from ww w .java 2 s. co m*/ Driver driver = new Driver(); driver.setConf(conf); String outputDir = tempFolder.newFolder().getAbsolutePath(); FileUtils.deleteDirectory(outputDir); assertEquals(0, driver.run(new String[] { outputDir })); // Read results in Set<GraphElementWithStatistics> results = new HashSet<GraphElementWithStatistics>(); int count = readResults(fs, new Path(outputDir), results); // There should be 3 edges and 2 entities assertEquals(5, count); Set<GraphElementWithStatistics> expectedResults = new HashSet<GraphElementWithStatistics>(); // Edge 1 and some statistics for it Edge edge1 = new Edge("customer", "A", "product", "P", "purchase", "instore", true, visibilityString1, sevenDaysBefore, fiveDaysBefore); SetOfStatistics statistics1 = new SetOfStatistics(); statistics1.addStatistic("count", new Count(20)); statistics1.addStatistic("anotherCount", new Count(1000000)); expectedResults.add(new GraphElementWithStatistics(new GraphElement(edge1), statistics1)); Edge edge4 = new Edge("customer", "A", "product", "P", "purchase", "instore", false, visibilityString2, sixDaysBefore, fiveDaysBefore); SetOfStatistics statistics4 = new SetOfStatistics(); statistics4.addStatistic("countSomething", new Count(123456)); expectedResults.add(new GraphElementWithStatistics(new GraphElement(edge4), statistics4)); Edge edge5 = new Edge("customer", "B", "product", "Q", "purchase", "instore", true, visibilityString2, sixDaysBefore, fiveDaysBefore); SetOfStatistics statistics5 = new SetOfStatistics(); statistics5.addStatistic("count", new Count(99)); expectedResults.add(new GraphElementWithStatistics(new GraphElement(edge5), statistics5)); Entity entity1 = new Entity("customer", "A", "purchase", "count", visibilityString1, sevenDaysBefore, sixDaysBefore); SetOfStatistics statisticsEntity1 = new SetOfStatistics(); statisticsEntity1.addStatistic("entity_count", new Count(1000000)); expectedResults.add(new GraphElementWithStatistics(new GraphElement(entity1), statisticsEntity1)); Entity entity2 = new Entity("product", "R", "purchase", "count", visibilityString1, sevenDaysBefore, sixDaysBefore); SetOfStatistics statisticsEntity2 = new SetOfStatistics(); statisticsEntity2.addStatistic("entity_count", new Count(12345)); expectedResults.add(new GraphElementWithStatistics(new GraphElement(entity2), statisticsEntity2)); assertEquals(expectedResults, results); }
From source file:gaffer.accumulo.TestAccumuloBackedGraphUpdatingConf.java
License:Apache License
@Test public void testSetConfigurationDirectedEdgesOnly() throws Exception { String instanceName = "testSetConfigurationDirectedEdgesOnly"; AccumuloBackedGraph graph = setUpGraphAndMockAccumulo(instanceName); AccumuloConfig accumuloConfig = setUpAccumuloConfig(instanceName); JobConf conf = new JobConf(); conf.set("fs.default.name", "file:///"); conf.set("mapred.job.tracker", "local"); graph.setDirectedEdgesOnly();//from www . ja v a2s .c om graph.setConfiguration(conf, accumuloConfig); FileSystem fs = FileSystem.getLocal(conf); // Run Driver driver = new Driver(); driver.setConf(conf); String outputDir = tempFolder.newFolder().getAbsolutePath(); FileUtils.deleteDirectory(outputDir); assertEquals(0, driver.run(new String[] { outputDir })); // Read results in Set<GraphElementWithStatistics> results = new HashSet<GraphElementWithStatistics>(); int count = readResults(fs, new Path(outputDir), results); // There should be 2 edges and 2 entities assertEquals(4, count); Set<GraphElementWithStatistics> expectedResults = new HashSet<GraphElementWithStatistics>(); // Edge 1 and some statistics for it Edge edge1 = new Edge("customer", "A", "product", "P", "purchase", "instore", true, visibilityString1, sevenDaysBefore, fiveDaysBefore); SetOfStatistics statistics1 = new SetOfStatistics(); statistics1.addStatistic("count", new Count(20)); statistics1.addStatistic("anotherCount", new Count(1000000)); expectedResults.add(new GraphElementWithStatistics(new GraphElement(edge1), statistics1)); Edge edge5 = new Edge("customer", "B", "product", "Q", "purchase", "instore", true, visibilityString2, sixDaysBefore, fiveDaysBefore); SetOfStatistics statistics5 = new SetOfStatistics(); statistics5.addStatistic("count", new Count(99)); expectedResults.add(new GraphElementWithStatistics(new GraphElement(edge5), statistics5)); Entity entity1 = new Entity("customer", "A", "purchase", "count", visibilityString1, sevenDaysBefore, sixDaysBefore); SetOfStatistics statisticsEntity1 = new SetOfStatistics(); statisticsEntity1.addStatistic("entity_count", new Count(1000000)); expectedResults.add(new GraphElementWithStatistics(new GraphElement(entity1), statisticsEntity1)); Entity entity2 = new Entity("product", "R", "purchase", "count", visibilityString1, sevenDaysBefore, sixDaysBefore); SetOfStatistics statisticsEntity2 = new SetOfStatistics(); statisticsEntity2.addStatistic("entity_count", new Count(12345)); expectedResults.add(new GraphElementWithStatistics(new GraphElement(entity2), statisticsEntity2)); assertEquals(expectedResults, results); }
From source file:gaffer.accumulo.TestAccumuloBackedGraphUpdatingConf.java
License:Apache License
@Test public void testSetConfigurationUndirectedEdgesOnly() throws Exception { String instanceName = "testSetConfigurationUndirectedEdgesOnly"; AccumuloBackedGraph graph = setUpGraphAndMockAccumulo(instanceName); AccumuloConfig accumuloConfig = setUpAccumuloConfig(instanceName); JobConf conf = new JobConf(); conf.set("fs.default.name", "file:///"); conf.set("mapred.job.tracker", "local"); graph.setUndirectedEdgesOnly();/* ww w . j a v a 2 s. c o m*/ graph.setConfiguration(conf, accumuloConfig); FileSystem fs = FileSystem.getLocal(conf); // Run Driver driver = new Driver(); driver.setConf(conf); String outputDir = tempFolder.newFolder().getAbsolutePath(); FileUtils.deleteDirectory(outputDir); assertEquals(0, driver.run(new String[] { outputDir })); // Read results in Set<GraphElementWithStatistics> results = new HashSet<GraphElementWithStatistics>(); int count = readResults(fs, new Path(outputDir), results); // There should be 1 edge and 2 entities assertEquals(3, count); Set<GraphElementWithStatistics> expectedResults = new HashSet<GraphElementWithStatistics>(); // Edge 4 and some statistics for it Edge edge4 = new Edge("customer", "A", "product", "P", "purchase", "instore", false, visibilityString2, sixDaysBefore, fiveDaysBefore); SetOfStatistics statistics4 = new SetOfStatistics(); statistics4.addStatistic("countSomething", new Count(123456)); expectedResults.add(new GraphElementWithStatistics(new GraphElement(edge4), statistics4)); Entity entity1 = new Entity("customer", "A", "purchase", "count", visibilityString1, sevenDaysBefore, sixDaysBefore); SetOfStatistics statisticsEntity1 = new SetOfStatistics(); statisticsEntity1.addStatistic("entity_count", new Count(1000000)); expectedResults.add(new GraphElementWithStatistics(new GraphElement(entity1), statisticsEntity1)); Entity entity2 = new Entity("product", "R", "purchase", "count", visibilityString1, sevenDaysBefore, sixDaysBefore); SetOfStatistics statisticsEntity2 = new SetOfStatistics(); statisticsEntity2.addStatistic("entity_count", new Count(12345)); expectedResults.add(new GraphElementWithStatistics(new GraphElement(entity2), statisticsEntity2)); assertEquals(expectedResults, results); }
From source file:gaffer.accumulo.TestAccumuloBackedGraphUpdatingConf.java
License:Apache License
@Test public void testSetConfigurationUndirectedEdgesOnlyNoEntities() throws Exception { String instanceName = "testSetConfigurationUndirectedEdgesOnlyNoEntities"; AccumuloBackedGraph graph = setUpGraphAndMockAccumulo(instanceName); AccumuloConfig accumuloConfig = setUpAccumuloConfig(instanceName); JobConf conf = new JobConf(); conf.set("fs.default.name", "file:///"); conf.set("mapred.job.tracker", "local"); graph.setUndirectedEdgesOnly();//from w w w . j av a 2 s . c o m graph.setReturnEdgesOnly(); graph.setConfiguration(conf, accumuloConfig); FileSystem fs = FileSystem.getLocal(conf); // Run Driver driver = new Driver(); driver.setConf(conf); String outputDir = tempFolder.newFolder().getAbsolutePath(); FileUtils.deleteDirectory(outputDir); assertEquals(0, driver.run(new String[] { outputDir })); // Read results in Set<GraphElementWithStatistics> results = new HashSet<GraphElementWithStatistics>(); int count = readResults(fs, new Path(outputDir), results); // There should be 1 edge assertEquals(1, count); Set<GraphElementWithStatistics> expectedResults = new HashSet<GraphElementWithStatistics>(); // Edge 4 and some statistics for it Edge edge4 = new Edge("customer", "A", "product", "P", "purchase", "instore", false, visibilityString2, sixDaysBefore, fiveDaysBefore); SetOfStatistics statistics4 = new SetOfStatistics(); statistics4.addStatistic("countSomething", new Count(123456)); expectedResults.add(new GraphElementWithStatistics(new GraphElement(edge4), statistics4)); assertEquals(expectedResults, results); }
From source file:gaffer.accumulo.TestAccumuloBackedGraphUpdatingConf.java
License:Apache License
/** * Tests that calling {@link AccumuloBackedGraph#setOutgoingEdgesOnly} doesn't cause any problems * with full table scans (where that option should be ignored as there is nothing to be outgoing * from)./*from w ww . ja v a 2s . c o m*/ * * @throws Exception */ @Test public void testSetConfigurationOutgoingEdgesOnlyFullTable() throws Exception { String instanceName = "testSetConfigurationOutgoingEdgesOnlyFullTable"; AccumuloBackedGraph graph = setUpGraphAndMockAccumulo(instanceName); AccumuloConfig accumuloConfig = setUpAccumuloConfig(instanceName); JobConf conf = new JobConf(); conf.set("fs.default.name", "file:///"); conf.set("mapred.job.tracker", "local"); graph.setOutgoingEdgesOnly(); graph.setConfiguration(conf, accumuloConfig); FileSystem fs = FileSystem.getLocal(conf); // Run Driver driver = new Driver(); driver.setConf(conf); String outputDir = tempFolder.newFolder().getAbsolutePath(); FileUtils.deleteDirectory(outputDir); assertEquals(0, driver.run(new String[] { outputDir })); // Read results in Set<GraphElementWithStatistics> results = new HashSet<GraphElementWithStatistics>(); int count = readResults(fs, new Path(outputDir), results); // There should be 3 edges and 2 entities assertEquals(5, count); Set<GraphElementWithStatistics> expectedResults = new HashSet<GraphElementWithStatistics>(); // Edge 1 and some statistics for it Edge edge1 = new Edge("customer", "A", "product", "P", "purchase", "instore", true, visibilityString1, sevenDaysBefore, fiveDaysBefore); SetOfStatistics statistics1 = new SetOfStatistics(); statistics1.addStatistic("count", new Count(20)); statistics1.addStatistic("anotherCount", new Count(1000000)); expectedResults.add(new GraphElementWithStatistics(new GraphElement(edge1), statistics1)); Edge edge4 = new Edge("customer", "A", "product", "P", "purchase", "instore", false, visibilityString2, sixDaysBefore, fiveDaysBefore); SetOfStatistics statistics4 = new SetOfStatistics(); statistics4.addStatistic("countSomething", new Count(123456)); expectedResults.add(new GraphElementWithStatistics(new GraphElement(edge4), statistics4)); Edge edge5 = new Edge("customer", "B", "product", "Q", "purchase", "instore", true, visibilityString2, sixDaysBefore, fiveDaysBefore); SetOfStatistics statistics5 = new SetOfStatistics(); statistics5.addStatistic("count", new Count(99)); expectedResults.add(new GraphElementWithStatistics(new GraphElement(edge5), statistics5)); Entity entity1 = new Entity("customer", "A", "purchase", "count", visibilityString1, sevenDaysBefore, sixDaysBefore); SetOfStatistics statisticsEntity1 = new SetOfStatistics(); statisticsEntity1.addStatistic("entity_count", new Count(1000000)); expectedResults.add(new GraphElementWithStatistics(new GraphElement(entity1), statisticsEntity1)); Entity entity2 = new Entity("product", "R", "purchase", "count", visibilityString1, sevenDaysBefore, sixDaysBefore); SetOfStatistics statisticsEntity2 = new SetOfStatistics(); statisticsEntity2.addStatistic("entity_count", new Count(12345)); expectedResults.add(new GraphElementWithStatistics(new GraphElement(entity2), statisticsEntity2)); assertEquals(expectedResults, results); }
From source file:gaffer.accumulo.TestAccumuloBackedGraphUpdatingConf.java
License:Apache License
/** * Tests that calling {@link AccumuloBackedGraph#setOutgoingEdgesOnly} is correctly applied to * confs when a query range is specified. * * @throws Exception/*from w w w .j a v a 2 s. co m*/ */ @Test public void testSetConfigurationOutgoingEdgesOnlyQuery() throws Exception { String instanceName = "testSetConfigurationOutgoingEdgesOnlyQuery"; AccumuloBackedGraph graph = setUpGraphAndMockAccumulo(instanceName); AccumuloConfig accumuloConfig = setUpAccumuloConfig(instanceName); // First query for customer|B: should find the edge customer|B -> product|Q as that // is outgoing from B JobConf conf = new JobConf(); conf.set("fs.default.name", "file:///"); conf.set("mapred.job.tracker", "local"); graph.setOutgoingEdgesOnly(); graph.setConfiguration(conf, new TypeValue("customer", "B"), accumuloConfig); FileSystem fs = FileSystem.getLocal(conf); // Run Driver driver = new Driver(); driver.setConf(conf); String outputDir = tempFolder.newFolder().getAbsolutePath(); FileUtils.deleteDirectory(outputDir); assertEquals(0, driver.run(new String[] { outputDir })); // Read results in Set<GraphElementWithStatistics> results = new HashSet<GraphElementWithStatistics>(); int count = readResults(fs, new Path(outputDir), results); // There should be 1 edge assertEquals(1, count); Set<GraphElementWithStatistics> expectedResults = new HashSet<GraphElementWithStatistics>(); Edge edge5 = new Edge("customer", "B", "product", "Q", "purchase", "instore", true, visibilityString2, sixDaysBefore, fiveDaysBefore); SetOfStatistics statistics5 = new SetOfStatistics(); statistics5.addStatistic("count", new Count(99)); expectedResults.add(new GraphElementWithStatistics(new GraphElement(edge5), statistics5)); assertEquals(expectedResults, results); // Now query for product|Q: should find no edges (as there are no outgoing edges from Q) conf = new JobConf(); conf.set("fs.default.name", "file:///"); conf.set("mapred.job.tracker", "local"); graph.setOutgoingEdgesOnly(); graph.setConfiguration(conf, new TypeValue("product", "Q"), accumuloConfig); // Run driver = new Driver(); driver.setConf(conf); outputDir = tempFolder.newFolder().getAbsolutePath(); FileUtils.deleteDirectory(outputDir); assertEquals(0, driver.run(new String[] { outputDir })); // Read results in results = new HashSet<GraphElementWithStatistics>(); count = readResults(fs, new Path(outputDir), results); // There should be no results assertEquals(0, count); }
From source file:gaffer.accumulo.TestAccumuloBackedGraphUpdatingConf.java
License:Apache License
@Test public void testSetConfigurationOutgoingEdgesOnlyQueryFromRanges() throws Exception { String instanceName = "testSetConfigurationOutgoingEdgesOnlyQueryFromRanges"; AccumuloBackedGraph graph = setUpGraphAndMockAccumulo(instanceName); AccumuloConfig accumuloConfig = setUpAccumuloConfig(instanceName); // First query for range of all customers - should find edges A->B, A->P JobConf conf = new JobConf(); conf.set("fs.default.name", "file:///"); conf.set("mapred.job.tracker", "local"); graph.setReturnEdgesOnly();/* w ww .j av a 2 s. c o m*/ graph.setOutgoingEdgesOnly(); graph.setConfigurationFromRanges(conf, new TypeValueRange("customer", "", "customer", "Z"), accumuloConfig); FileSystem fs = FileSystem.getLocal(conf); // Run Driver driver = new Driver(); driver.setConf(conf); String outputDir = tempFolder.newFolder().getAbsolutePath(); FileUtils.deleteDirectory(outputDir); assertEquals(0, driver.run(new String[] { outputDir })); // Read results in Set<GraphElementWithStatistics> results = new HashSet<GraphElementWithStatistics>(); int count = readResults(fs, new Path(outputDir), results); // There should be 3 edges assertEquals(3, count); Set<GraphElementWithStatistics> expectedResults = new HashSet<GraphElementWithStatistics>(); Edge edge1 = new Edge("customer", "A", "product", "P", "purchase", "instore", true, visibilityString1, sevenDaysBefore, fiveDaysBefore); SetOfStatistics statistics1 = new SetOfStatistics(); statistics1.addStatistic("count", new Count(20)); statistics1.addStatistic("anotherCount", new Count(1000000)); expectedResults.add(new GraphElementWithStatistics(new GraphElement(edge1), statistics1)); Edge edge4 = new Edge("customer", "A", "product", "P", "purchase", "instore", false, visibilityString2, sixDaysBefore, fiveDaysBefore); SetOfStatistics statistics4 = new SetOfStatistics(); statistics4.addStatistic("countSomething", new Count(123456)); expectedResults.add(new GraphElementWithStatistics(new GraphElement(edge4), statistics4)); Edge edge5 = new Edge("customer", "B", "product", "Q", "purchase", "instore", true, visibilityString2, sixDaysBefore, fiveDaysBefore); SetOfStatistics statistics5 = new SetOfStatistics(); statistics5.addStatistic("count", new Count(99)); expectedResults.add(new GraphElementWithStatistics(new GraphElement(edge5), statistics5)); assertEquals(expectedResults, results); // Now query for all products should find no edges (as there are no outgoing directed edges from products) conf = new JobConf(); conf.set("fs.default.name", "file:///"); conf.set("mapred.job.tracker", "local"); graph.setReturnEdgesOnly(); graph.setDirectedEdgesOnly(); graph.setOutgoingEdgesOnly(); graph.setConfigurationFromRanges(conf, new TypeValueRange("product", "", "product", "Z"), accumuloConfig); // Run driver = new Driver(); driver.setConf(conf); outputDir = tempFolder.newFolder().getAbsolutePath(); FileUtils.deleteDirectory(outputDir); assertEquals(0, driver.run(new String[] { outputDir })); // Read results in results = new HashSet<GraphElementWithStatistics>(); count = readResults(fs, new Path(outputDir), results); // There should be no results assertEquals(0, count); }
From source file:gaffer.accumulo.TestAccumuloBackedGraphUpdatingConf.java
License:Apache License
@Test public void testSetConfigurationOutgoingEdgesOnlyQueryFromPairs() throws Exception { String instanceName = "testSetConfigurationOutgoingEdgesOnlyQueryFromPairs"; AccumuloBackedGraph graph = setUpGraphAndMockAccumulo(instanceName); AccumuloConfig accumuloConfig = setUpAccumuloConfig(instanceName); // First query for pair customer|B, product|Q - should find edge B->Q JobConf conf = new JobConf(); conf.set("fs.default.name", "file:///"); conf.set("mapred.job.tracker", "local"); graph.setOutgoingEdgesOnly();/*from w ww .j a va 2s .c o m*/ graph.setConfigurationFromPairs(conf, new Pair<TypeValue>(new TypeValue("customer", "B"), new TypeValue("product", "Q")), accumuloConfig); FileSystem fs = FileSystem.getLocal(conf); // Run Driver driver = new Driver(); driver.setConf(conf); String outputDir = tempFolder.newFolder().getAbsolutePath(); FileUtils.deleteDirectory(outputDir); assertEquals(0, driver.run(new String[] { outputDir })); // Read results in Set<GraphElementWithStatistics> results = new HashSet<GraphElementWithStatistics>(); int count = readResults(fs, new Path(outputDir), results); // There should be 1 edge assertEquals(1, count); Set<GraphElementWithStatistics> expectedResults = new HashSet<GraphElementWithStatistics>(); Edge edge5 = new Edge("customer", "B", "product", "Q", "purchase", "instore", true, visibilityString2, sixDaysBefore, fiveDaysBefore); SetOfStatistics statistics5 = new SetOfStatistics(); statistics5.addStatistic("count", new Count(99)); expectedResults.add(new GraphElementWithStatistics(new GraphElement(edge5), statistics5)); assertEquals(expectedResults, results); // Now query for pair product|Q, customer|B - shouldn't find any edges conf = new JobConf(); conf.set("fs.default.name", "file:///"); conf.set("mapred.job.tracker", "local"); graph.setOutgoingEdgesOnly(); graph.setConfigurationFromPairs(conf, new Pair<TypeValue>(new TypeValue("product", "Q"), new TypeValue("customer", "B")), accumuloConfig); // Run driver = new Driver(); driver.setConf(conf); outputDir = tempFolder.newFolder().getAbsolutePath(); FileUtils.deleteDirectory(outputDir); assertEquals(0, driver.run(new String[] { outputDir })); // Read results in results = new HashSet<GraphElementWithStatistics>(); count = readResults(fs, new Path(outputDir), results); // There should be no results assertEquals(0, count); }
From source file:gaffer.accumulo.TestAccumuloBackedGraphUpdatingConf.java
License:Apache License
@Test public void testSetConfigurationIncomingEdgesOnlyQueryFromPairs() throws Exception { String instanceName = "testSetConfigurationIncomingEdgesOnlyQueryFromPairs"; AccumuloBackedGraph graph = setUpGraphAndMockAccumulo(instanceName); AccumuloConfig accumuloConfig = setUpAccumuloConfig(instanceName); // First query for pair product|Q, customer|B - should find edge B->Q JobConf conf = new JobConf(); conf.set("fs.default.name", "file:///"); conf.set("mapred.job.tracker", "local"); graph.setIncomingEdgesOnly();/*from ww w. j av a 2 s . c om*/ graph.setConfigurationFromPairs(conf, new Pair<TypeValue>(new TypeValue("product", "Q"), new TypeValue("customer", "B")), accumuloConfig); FileSystem fs = FileSystem.getLocal(conf); // Run Driver driver = new Driver(); driver.setConf(conf); String outputDir = tempFolder.newFolder().getAbsolutePath(); FileUtils.deleteDirectory(outputDir); assertEquals(0, driver.run(new String[] { outputDir })); // Read results in Set<GraphElementWithStatistics> results = new HashSet<GraphElementWithStatistics>(); int count = readResults(fs, new Path(outputDir), results); // There should be 1 edge assertEquals(1, count); Set<GraphElementWithStatistics> expectedResults = new HashSet<GraphElementWithStatistics>(); Edge edge5 = new Edge("customer", "B", "product", "Q", "purchase", "instore", true, visibilityString2, sixDaysBefore, fiveDaysBefore); SetOfStatistics statistics5 = new SetOfStatistics(); statistics5.addStatistic("count", new Count(99)); expectedResults.add(new GraphElementWithStatistics(new GraphElement(edge5), statistics5)); assertEquals(expectedResults, results); // Now query for pair customer|B, product|Q - shouldn't find any edges conf = new JobConf(); conf.set("fs.default.name", "file:///"); conf.set("mapred.job.tracker", "local"); graph.setIncomingEdgesOnly(); graph.setConfigurationFromPairs(conf, new Pair<TypeValue>(new TypeValue("customer", "B"), new TypeValue("product", "Q")), accumuloConfig); // Run driver = new Driver(); driver.setConf(conf); outputDir = tempFolder.newFolder().getAbsolutePath(); FileUtils.deleteDirectory(outputDir); assertEquals(0, driver.run(new String[] { outputDir })); // Read results in results = new HashSet<GraphElementWithStatistics>(); count = readResults(fs, new Path(outputDir), results); // There should be no results assertEquals(0, count); }