List of usage examples for org.apache.commons.configuration Configuration containsKey
boolean containsKey(String key);
From source file:org.apache.tinkerpop.gremlin.process.computer.bulkloading.OneTimeBulkLoader.java
/** * {@inheritDoc}//w ww . j a v a 2 s .c o m */ @Override public void configure(final Configuration configuration) { if (configuration.containsKey(BulkLoaderVertexProgram.USER_SUPPLIED_IDS_CFG_KEY)) { userSuppliedIds = configuration.getBoolean(BulkLoaderVertexProgram.USER_SUPPLIED_IDS_CFG_KEY); } }
From source file:org.apache.tinkerpop.gremlin.process.computer.clustering.peerpressure.PeerPressureVertexProgram.java
@Override public void loadState(final Graph graph, final Configuration configuration) { if (configuration.containsKey(EDGE_TRAVERSAL)) { this.edgeTraversal = PureTraversal.loadState(configuration, EDGE_TRAVERSAL, graph); this.voteScope = MessageScope.Local.of(() -> this.edgeTraversal.get().clone()); this.countScope = MessageScope.Local .of(new MessageScope.Local.ReverseTraversalSupplier(this.voteScope)); }/*from w w w. ja va 2s. c om*/ this.property = configuration.getString(PROPERTY, CLUSTER); this.maxIterations = configuration.getInt(MAX_ITERATIONS, 30); this.distributeVote = configuration.getBoolean(DISTRIBUTE_VOTE, false); }
From source file:org.apache.tinkerpop.gremlin.process.computer.lambda.LambdaVertexProgram.java
@Override public void loadState(final Configuration configuration) { this.setupLambdaHolder = LambdaHolder.loadState(configuration, SETUP_LAMBDA); this.executeLambdaHolder = LambdaHolder.loadState(configuration, EXECUTE_LAMBDA); this.terminateLambdaHolder = LambdaHolder.loadState(configuration, TERMINATE_LAMBDA); this.setupLambda = null == this.setupLambdaHolder ? s -> { } : this.setupLambdaHolder.get(); this.executeLambda = null == this.executeLambdaHolder ? (v, m, s) -> { } : this.executeLambdaHolder.get(); this.terminateLambda = null == this.terminateLambdaHolder ? s -> true : this.terminateLambdaHolder.get(); try {//from www . jav a2 s .com this.elementComputeKeys = configuration.containsKey(ELEMENT_COMPUTE_KEYS) ? VertexProgramHelper.deserialize(configuration, ELEMENT_COMPUTE_KEYS) : Collections.emptySet(); this.memoryComputeKeys = configuration.containsKey(MEMORY_COMPUTE_KEYS) ? VertexProgramHelper.deserialize(configuration, MEMORY_COMPUTE_KEYS) : Collections.emptySet(); } catch (Exception e) { throw new IllegalStateException(e.getMessage(), e); } }
From source file:org.apache.tinkerpop.gremlin.process.computer.ranking.pagerank.PageRankVertexProgram.java
@Override public void loadState(final Graph graph, final Configuration configuration) { if (configuration.containsKey(INITIAL_RANK_TRAVERSAL)) this.initialRankTraversal = PureTraversal.loadState(configuration, INITIAL_RANK_TRAVERSAL, graph); if (configuration.containsKey(EDGE_TRAVERSAL)) { this.edgeTraversal = PureTraversal.loadState(configuration, EDGE_TRAVERSAL, graph); this.incidentMessageScope = MessageScope.Local.of(() -> this.edgeTraversal.get().clone()); this.countMessageScope = MessageScope.Local .of(new MessageScope.Local.ReverseTraversalSupplier(this.incidentMessageScope)); }/* w ww. ja v a 2 s. c o m*/ this.vertexCountAsDouble = configuration.getDouble(VERTEX_COUNT, 1.0d); this.alpha = configuration.getDouble(ALPHA, 0.85d); this.totalIterations = configuration.getInt(TOTAL_ITERATIONS, 30); this.property = configuration.getString(PROPERTY, PAGE_RANK); this.vertexComputeKeys = new HashSet<>( Arrays.asList(VertexComputeKey.of(this.property, false), VertexComputeKey.of(EDGE_COUNT, true))); }
From source file:org.apache.tinkerpop.gremlin.process.computer.traversal.TraversalVertexProgram.java
@Override public void loadState(final Graph graph, final Configuration configuration) { if (!configuration.containsKey(TRAVERSAL)) throw new IllegalArgumentException("The configuration does not have a traversal: " + TRAVERSAL); this.traversal = PureTraversal.loadState(configuration, TRAVERSAL, graph); if (!this.traversal.get().isLocked()) this.traversal.get().applyStrategies(); /// traversal is compiled and ready to be introspected this.traversalMatrix = new TraversalMatrix<>(this.traversal.get()); // if results will be serialized out, don't save halted traversers across the cluster this.keepDistributedHaltedTraversers = !(this.traversal.get().getParent().asStep() .getNextStep() instanceof ComputerResultStep || // if its just going to stream it out, don't distribute this.traversal.get().getParent().asStep().getNextStep() instanceof EmptyStep); // same as above, but if using TraversalVertexProgramStep directly // register traversal side-effects in memory final TraversalSideEffects sideEffects = ((MemoryTraversalSideEffects) this.traversal.get() .getSideEffects()).getSideEffects(); sideEffects.keys().forEach(key -> this.memoryComputeKeys .add(MemoryComputeKey.of(key, sideEffects.getReducer(key), true, false))); // register MapReducer memory compute keys this.memoryComputeKeys.add(MemoryComputeKey.of(VOTE_TO_HALT, Operator.and, false, true)); for (final MapReducer<?, ?, ?, ?, ?> mapReducer : TraversalHelper .getStepsOfAssignableClassRecursively(MapReducer.class, this.traversal.get())) { this.mapReducers.add(mapReducer.getMapReduce()); this.memoryComputeKeys.add( MemoryComputeKey.of(mapReducer.getMapReduce().getMemoryKey(), Operator.assign, false, false)); }/* w w w. jav a2 s .com*/ // register memory computing steps that use memory compute keys for (final MemoryComputing<?> memoryComputing : TraversalHelper .getStepsOfAssignableClassRecursively(MemoryComputing.class, this.traversal.get())) { this.memoryComputeKeys.add(memoryComputing.getMemoryComputeKey()); } // register TraversalVertexProgram specific memory compute keys this.memoryComputeKeys.add(MemoryComputeKey.of(HALTED_TRAVERSERS, Operator.addAll, false, this.keepDistributedHaltedTraversers)); // only keep if it will be preserved this.memoryComputeKeys.add(MemoryComputeKey.of(ACTIVE_TRAVERSERS, Operator.addAll, true, true)); this.memoryComputeKeys.add(MemoryComputeKey.of(MUTATED_MEMORY_KEYS, Operator.addAll, false, true)); this.memoryComputeKeys.add(MemoryComputeKey.of(COMPLETED_BARRIERS, Operator.addAll, true, true)); }
From source file:org.apache.tinkerpop.gremlin.process.computer.util.LambdaHolder.java
public static <T> LambdaHolder<T> loadState(final Configuration configuration, final String configKeyPrefix) { if (!configuration.containsKey(configKeyPrefix.concat(DOT_TYPE))) return null; if (!configuration.containsKey(configKeyPrefix.concat(DOT_OBJECT))) return null; final LambdaHolder<T> lambdaHolder = new LambdaHolder<>(); lambdaHolder.configKeyPrefix = configKeyPrefix; lambdaHolder.type = Type.valueOf(configuration.getString(lambdaHolder.configKeyPrefix.concat(DOT_TYPE))); if (lambdaHolder.type.equals(Type.OBJECT)) { lambdaHolder.configObject = configuration.getProperty(lambdaHolder.configKeyPrefix.concat(DOT_OBJECT)); lambdaHolder.realObject = lambdaHolder.configObject; } else if (lambdaHolder.type.equals(Type.SERIALIZED_OBJECT)) { lambdaHolder.configObject = VertexProgramHelper.deserialize(configuration, lambdaHolder.configKeyPrefix.concat(DOT_OBJECT)); lambdaHolder.realObject = lambdaHolder.configObject; } else if (lambdaHolder.type.equals(Type.CLASS)) { try {/*from w w w .j a v a 2 s. c o m*/ final Class klass = (Class) Class .forName(configuration.getString(lambdaHolder.configKeyPrefix.concat(DOT_OBJECT))); lambdaHolder.configObject = klass; lambdaHolder.realObject = klass.newInstance(); } catch (final Exception e) { throw new IllegalStateException(e.getMessage(), e); } } else { // SCRIPT final String[] script = VertexProgramHelper.deserialize(configuration, lambdaHolder.configKeyPrefix.concat(DOT_OBJECT)); lambdaHolder.configObject = script; lambdaHolder.realObject = new ScriptEngineLambda(script[0], script[1]); } return lambdaHolder; }
From source file:org.apache.tinkerpop.gremlin.process.remote.RemoteGraph.java
/** * Creates a new {@link RemoteGraph} instance using the specified configuration, which allows {@link RemoteGraph} * to be compliant with {@link GraphFactory}. Expects key for {@link #GREMLIN_REMOTE_GRAPH_REMOTE_CONNECTION_CLASS} * as well as any configuration required by the underlying {@link RemoteConnection} which will be instantiated. * Note that the {@code Configuration} object is passed down without change to the creation of the * {@link RemoteConnection} instance./*from www . j ava 2 s.c om*/ */ public static RemoteGraph open(final Configuration conf) { if (!conf.containsKey(GREMLIN_REMOTE_GRAPH_REMOTE_CONNECTION_CLASS)) throw new IllegalArgumentException( "Configuration must contain the '" + GREMLIN_REMOTE_GRAPH_REMOTE_CONNECTION_CLASS + "' key"); final RemoteConnection remoteConnection; try { final Class<? extends RemoteConnection> clazz = Class .forName(conf.getString(GREMLIN_REMOTE_GRAPH_REMOTE_CONNECTION_CLASS)) .asSubclass(RemoteConnection.class); final Constructor<? extends RemoteConnection> ctor = clazz.getConstructor(Configuration.class); remoteConnection = ctor.newInstance(conf); } catch (Exception ex) { throw new IllegalStateException(ex); } return new RemoteGraph(remoteConnection); }
From source file:org.apache.tinkerpop.gremlin.process.traversal.strategy.decoration.ElementIdStrategy.java
public static ElementIdStrategy create(final Configuration configuration) { final ElementIdStrategy.Builder builder = ElementIdStrategy.build(); if (configuration.containsKey(ID_MAKER)) builder.idMaker((Supplier) configuration.getProperty(ID_MAKER)); if (configuration.containsKey(ID_PROPERTY_KEY)) builder.idPropertyKey(configuration.getString(ID_PROPERTY_KEY)); return builder.create(); }
From source file:org.apache.tinkerpop.gremlin.process.traversal.strategy.decoration.PartitionStrategy.java
public static PartitionStrategy create(final Configuration configuration) { final PartitionStrategy.Builder builder = PartitionStrategy.build(); if (configuration.containsKey(INCLUDE_META_PROPERTIES)) builder.includeMetaProperties(configuration.getBoolean(INCLUDE_META_PROPERTIES)); if (configuration.containsKey(WRITE_PARTITION)) builder.writePartition(configuration.getString(WRITE_PARTITION)); if (configuration.containsKey(PARTITION_KEY)) builder.partitionKey(configuration.getString(PARTITION_KEY)); if (configuration.containsKey(READ_PARTITIONS)) builder.readPartitions(new ArrayList((Collection) configuration.getProperty(READ_PARTITIONS))); return builder.create(); }
From source file:org.apache.tinkerpop.gremlin.process.traversal.strategy.decoration.SubgraphStrategy.java
public static SubgraphStrategy create(final Configuration configuration) { final Builder builder = SubgraphStrategy.build(); if (configuration.containsKey(VERTICES)) builder.vertices((Traversal) configuration.getProperty(VERTICES)); if (configuration.containsKey(EDGES)) builder.edges((Traversal) configuration.getProperty(EDGES)); if (configuration.containsKey(VERTEX_PROPERTIES)) builder.vertexProperties((Traversal) configuration.getProperty(VERTEX_PROPERTIES)); return builder.create(); }