/** * Overwrites all configurations from values passed using {@link GraphTraversal#with(String, Object)}. */ private void addParametersToConfiguration(final Graph graph) { parameters.getRaw(IO.writer, IO.writer, IO.registry).entrySet().forEach(kv -> { if (kv.getValue().size() == 1) graph.configuration().setProperty(kv.getKey().toString(), kv.getValue().get(0)); else { // reset the default configuration with the first option then add to that for List options for (int ix = 0; ix < kv.getValue().size(); ix++) { if (ix == 0) graph.configuration().setProperty(kv.getKey().toString(), kv.getValue().get(ix)); else graph.configuration().addProperty(kv.getKey().toString(), kv.getValue().get(ix)); } } }); }
private void configureForRead(final Graph graph) { final String inputFormatClassNameOrKeyword = parameters.get(IO.reader, this::detectReader).get(0); String inputFormatClassName; if (inputFormatClassNameOrKeyword.equals(IO.graphson)) inputFormatClassName = GraphSONInputFormat.class.getName(); else if (inputFormatClassNameOrKeyword.equals(IO.gryo)) inputFormatClassName = GryoInputFormat.class.getName(); else if (inputFormatClassNameOrKeyword.equals(IO.graphml)) throw new IllegalStateException("GraphML is not a supported file format for OLAP"); else inputFormatClassName = inputFormatClassNameOrKeyword; graph.configuration().setProperty(Constants.GREMLIN_HADOOP_GRAPH_READER, inputFormatClassName); graph.configuration().setProperty(Constants.GREMLIN_HADOOP_INPUT_LOCATION, file); addParametersToConfiguration(graph); }
private void configureForWrite(final Graph graph) { final String outputFormatClassNameOrKeyword = parameters.get(IO.writer, this::detectWriter).get(0); String outputFormatClassName; if (outputFormatClassNameOrKeyword.equals(IO.graphson)) outputFormatClassName = GraphSONOutputFormat.class.getName(); else if (outputFormatClassNameOrKeyword.equals(IO.gryo)) outputFormatClassName = GryoOutputFormat.class.getName(); else if (outputFormatClassNameOrKeyword.equals(IO.graphml)) throw new IllegalStateException("GraphML is not a supported file format for OLAP"); else outputFormatClassName = outputFormatClassNameOrKeyword; graph.configuration().setProperty(Constants.GREMLIN_HADOOP_GRAPH_WRITER, outputFormatClassName); graph.configuration().setProperty(Constants.GREMLIN_HADOOP_OUTPUT_LOCATION, file); addParametersToConfiguration(graph); }
@SuppressWarnings("unchecked") @Override public VertexProgramQ create(final Graph graph) { if (graph != null) { ConfigurationUtils.append(graph.configuration().subset(VERTEX_PROGRAM_Q_CFG_PREFIX), configuration); } return (VertexProgramQ) VertexProgram.createVertexProgram(graph, configuration); }
@SuppressWarnings("unchecked") @Override public BulkLoaderVertexProgram create(final Graph graph) { ConfigurationUtils.append(graph.configuration().subset(BULK_LOADER_VERTEX_PROGRAM_CFG_PREFIX), configuration); return (BulkLoaderVertexProgram) VertexProgram.createVertexProgram(graph, configuration); }
@SuppressWarnings("unchecked") @Override public VertexProgramR create(final Graph graph) { if (graph != null) { ConfigurationUtils.append(graph.configuration().subset(SIMPLE_VERTEX_PROGRAM_CFG_PREFIX), configuration); } return (VertexProgramR) VertexProgram.createVertexProgram(graph, configuration); }
/** * A {@link Graph} should maintain the original {@code Configuration} object passed to it via {@link GraphFactory}. */ @Test public void shouldMaintainOriginalConfigurationObjectGivenToFactory() throws Exception { final Configuration originalConfig = graphProvider.newGraphConfiguration("temp2", this.getClass(), name.getMethodName(), null); final Graph createdGraph = GraphFactory.open(originalConfig); final Configuration configInGraph = createdGraph.configuration(); final AtomicInteger keyCount = new AtomicInteger(0); originalConfig.getKeys().forEachRemaining(k -> { assertTrue(configInGraph.containsKey(k)); keyCount.incrementAndGet(); }); // need some keys in the originalConfig for this test to be meaningful assertTrue(keyCount.get() > 0); assertEquals(keyCount.get(), IteratorUtils.count(configInGraph.getKeys())); graphProvider.clear(createdGraph, originalConfig); } }
/** * Check to allow if provider specific implementations should be allowed. Generally the only time this is not true * is while we are running tests. */ private boolean allowProviderImplementation(Graph graph) { return graph.configuration().subset("bdio").getBoolean("allowProviderImplementation", true); }
private BlackDuckIo(Builder builder) { graph = Objects.requireNonNull(builder.graph); version = Objects.requireNonNull(builder.version); onMapper = Optional.ofNullable(builder.onMapper); mapperConfiguration = Objects.requireNonNull(builder.mapperConfiguration); options = Optional.ofNullable(builder.options) .orElseGet(() -> BlackDuckIoOptions.create(graph.configuration().subset("bdio"))); }
@SuppressWarnings("unchecked") @Override public BulkLoaderVertexProgram create(final Graph graph) { ConfigurationUtils.append(graph.configuration().subset(BULK_LOADER_VERTEX_PROGRAM_CFG_PREFIX), configuration); return (BulkLoaderVertexProgram) VertexProgram.createVertexProgram(graph, configuration); }
private void doClose() { try { g.close(); } catch (Exception e) { getMonitor().warn("Error closing graph " + g.configuration(), e); } finally { g = null; } } }
private void doClose() { try { g.close(); } catch (Exception e) { getMonitor().warn("Error closing graph " + g.configuration(), e); } finally { g = null; } } }
@SuppressWarnings("unchecked") @Override public VertexProgramR create(final Graph graph) { if (graph != null) { ConfigurationUtils.append(graph.configuration().subset(SIMPLE_VERTEX_PROGRAM_CFG_PREFIX), configuration); } return (VertexProgramR) VertexProgram.createVertexProgram(graph, configuration); }
@SuppressWarnings("unchecked") @Override public VertexProgramQ create(final Graph graph) { if (graph != null) { ConfigurationUtils.append(graph.configuration().subset(VERTEX_PROGRAM_Q_CFG_PREFIX), configuration); } return (VertexProgramQ) VertexProgram.createVertexProgram(graph, configuration); }
private void doClose() { try { g.close(); } catch (Exception e) { getMonitor().warn("Error closing graph " + g.configuration(), e); } finally { g = null; } } }
private void doClose() { try { g.close(); } catch (Exception e) { getMonitor().warn("Error closing graph " + g.configuration(), e); } finally { g = null; } } }
@Override protected void doDestroy() { try { driver.close(); } catch (Exception e) { getMonitor().warn("Error closing graph " + createGraph().configuration(), e); } super.doDestroy(); } }
@Override protected void doDestroy() { try { driver.close(); } catch (Exception e) { getMonitor().warn("Error closing graph " + createGraph().configuration(), e); } super.doDestroy(); } }
@Override protected void doDestroy() { try { driver.close(); } catch (Exception e) { getMonitor().warn("Error closing graph " + createGraph().configuration(), e); } super.doDestroy(); } }
@Override protected void doDestroy() { try { driver.close(); } catch (Exception e) { getMonitor().warn("Error closing graph " + createGraph().configuration(), e); } super.doDestroy(); } }