UNPKG

gremlin_patch

Version:

JavaScript Gremlin Language Variant

375 lines (316 loc) 14.6 kB
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>JSDoc: Source: process/traversal-strategy.js</title> <script src="scripts/prettify/prettify.js"> </script> <script src="scripts/prettify/lang-css.js"> </script> <!--[if lt IE 9]> <script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script> <![endif]--> <link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css"> <link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css"> </head> <body> <div id="main"> <h1 class="page-title">Source: process/traversal-strategy.js</h1> <section> <article> <pre class="prettyprint source linenums"><code>/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ /** * @author Jorge Bay Gondra */ 'use strict'; const Traversal = require('./traversal').Traversal; class TraversalStrategies { /** * Creates a new instance of TraversalStrategies. * @param {TraversalStrategies} [parent] The parent strategies from where to clone the values from. * @constructor */ constructor(parent) { if (parent) { // Clone the strategies this.strategies = [...parent.strategies]; } else { this.strategies = []; } } /** @param {TraversalStrategy} strategy */ addStrategy(strategy) { this.strategies.push(strategy); } /** @param {TraversalStrategy} strategy */ removeStrategy(strategy) { const idx = this.strategies.findIndex(s => s.fqcn === strategy.fqcn); if (idx !== -1) { return this.strategies.splice(idx, 1)[0]; } return undefined; } /** * @param {Traversal} traversal * @returns {Promise} */ applyStrategies(traversal) { // Apply all strategies serially return this.strategies.reduce((promise, strategy) => { return promise.then(() => strategy.apply(traversal)); }, Promise.resolve()); } } /** @abstract */ class TraversalStrategy { /** * @param {String} fqcn fully qualified class name in Java of the strategy * @param {Object} configuration for the strategy */ constructor(fqcn, configuration = {}) { this.fqcn = fqcn; this.configuration = configuration; } /** * @abstract * @param {Traversal} traversal * @returns {Promise} */ apply(traversal) { } } class ConnectiveStrategy extends TraversalStrategy { constructor() { super("org.apache.tinkerpop.gremlin.process.traversal.strategy.decoration.ConnectiveStrategy"); } } class ElementIdStrategy extends TraversalStrategy { constructor() { super("org.apache.tinkerpop.gremlin.process.traversal.strategy.decoration.ElementIdStrategy"); } } class HaltedTraverserStrategy extends TraversalStrategy { /** * @param {String} haltedTraverserFactory full qualified class name in Java of a {@code HaltedTraverserFactory} implementation */ constructor(haltedTraverserFactory) { super("org.apache.tinkerpop.gremlin.process.traversal.strategy.decoration.HaltedTraverserStrategy"); if (haltedTraverserFactory !== undefined) this.configuration["haltedTraverserFactory"] = haltedTraverserFactory; } } class OptionsStrategy extends TraversalStrategy { constructor(options) { super("org.apache.tinkerpop.gremlin.process.traversal.strategy.decoration.OptionsStrategy", options); } } class PartitionStrategy extends TraversalStrategy { /** * @param {Object} [options] * @param {String} [options.partitionKey] name of the property key to partition by * @param {String} [options.writePartition] the value of the currently write partition * @param {Array&lt;String>} [options.readPartitions] list of strings representing the partitions to include for reads * @param {boolean} [options.includeMetaProperties] determines if meta-properties should be included in partitioning defaulting to false */ constructor(options) { super("org.apache.tinkerpop.gremlin.process.traversal.strategy.decoration.PartitionStrategy", options); } } class SubgraphStrategy extends TraversalStrategy { /** * @param {Object} [options] * @param {GraphTraversal} [options.vertices] name of the property key to partition by * @param {GraphTraversal} [options.edges] the value of the currently write partition * @param {GraphTraversal} [options.vertexProperties] list of strings representing the partitions to include for reads * @param {boolean} [options.checkAdjacentVertices] enables the strategy to apply the {@code vertices} filter to the adjacent vertices of an edge. */ constructor(options) { super("org.apache.tinkerpop.gremlin.process.traversal.strategy.decoration.SubgraphStrategy", options); if (this.configuration.vertices instanceof Traversal) this.configuration.vertices = this.configuration.vertices.bytecode; if (this.configuration.edges instanceof Traversal) this.configuration.edges = this.configuration.edges.bytecode; if (this.configuration.vertexProperties instanceof Traversal) this.configuration.vertexProperties = this.configuration.vertexProperties.bytecode; } } class VertexProgramStrategy extends TraversalStrategy { constructor(options) { super("org.apache.tinkerpop.gremlin.process.computer.traversal.strategy.decoration.VertexProgramStrategy", options); } } class MatchAlgorithmStrategy extends TraversalStrategy { /** * @param matchAlgorithm */ constructor(matchAlgorithm) { super("org.apache.tinkerpop.gremlin.process.traversal.strategy.finalization.MatchAlgorithmStrategy"); if (matchAlgorithm !== undefined) this.configuration["matchAlgorithm"] = matchAlgorithm; } } class AdjacentToIncidentStrategy extends TraversalStrategy { constructor() { super("org.apache.tinkerpop.gremlin.process.traversal.strategy.optimization.AdjacentToIncidentStrategy"); } } class FilterRankingStrategy extends TraversalStrategy { constructor() { super("org.apache.tinkerpop.gremlin.process.traversal.strategy.optimization.FilterRankingStrategy"); } } class IdentityRemovalStrategy extends TraversalStrategy { constructor() { super("org.apache.tinkerpop.gremlin.process.traversal.strategy.optimization.IdentityRemovalStrategy"); } } class IncidentToAdjacentStrategy extends TraversalStrategy { constructor() { super("org.apache.tinkerpop.gremlin.process.traversal.strategy.optimization.IncidentToAdjacentStrategy"); } } class InlineFilterStrategy extends TraversalStrategy { constructor() { super("org.apache.tinkerpop.gremlin.process.traversal.strategy.optimization.InlineFilterStrategy"); } } class LazyBarrierStrategy extends TraversalStrategy { constructor() { super("org.apache.tinkerpop.gremlin.process.traversal.strategy.optimization.LazyBarrierStrategy"); } } class MatchPredicateStrategy extends TraversalStrategy { constructor() { super("org.apache.tinkerpop.gremlin.process.traversal.strategy.optimization.MatchPredicateStrategy"); } } class OrderLimitStrategy extends TraversalStrategy { constructor() { super("org.apache.tinkerpop.gremlin.process.traversal.strategy.optimization.OrderLimitStrategy"); } } class PathProcessorStrategy extends TraversalStrategy { constructor() { super("org.apache.tinkerpop.gremlin.process.traversal.strategy.optimization.PathProcessorStrategy"); } } class PathRetractionStrategy extends TraversalStrategy { constructor() { super("org.apache.tinkerpop.gremlin.process.traversal.strategy.optimization.PathRetractionStrategy"); } } class CountStrategy extends TraversalStrategy { constructor() { super("org.apache.tinkerpop.gremlin.process.traversal.strategy.optimization.CountStrategy"); } } class RepeatUnrollStrategy extends TraversalStrategy { constructor() { super("org.apache.tinkerpop.gremlin.process.traversal.strategy.optimization.RepeatUnrollStrategy"); } } class GraphFilterStrategy extends TraversalStrategy { constructor() { super("org.apache.tinkerpop.gremlin.process.traversal.strategy.optimization.GraphFilterStrategy"); } } class EarlyLimitStrategy extends TraversalStrategy { constructor() { super("org.apache.tinkerpop.gremlin.process.traversal.strategy.optimization.EarlyLimitStrategy"); } } class LambdaRestrictionStrategy extends TraversalStrategy { constructor() { super("org.apache.tinkerpop.gremlin.process.traversal.strategy.verification.LambdaRestrictionStrategy"); } } class ReadOnlyStrategy extends TraversalStrategy { constructor() { super("org.apache.tinkerpop.gremlin.process.traversal.strategy.verification.ReadOnlyStrategy"); } } class EdgeLabelVerificationStrategy extends TraversalStrategy { /** * @param {boolean} logWarnings determines if warnings should be written to the logger when verification fails * @param {boolean} throwException determines if exceptions should be thrown when verifications fails */ constructor(logWarnings = false, throwException=false) { super("org.apache.tinkerpop.gremlin.process.traversal.strategy.verification.EdgeLabelVerificationStrategy", {logWarnings: logWarnings, throwException: throwException}); } } class ReservedKeysVerificationStrategy extends TraversalStrategy { /** * @param {boolean} logWarnings determines if warnings should be written to the logger when verification fails * @param {boolean} throwException determines if exceptions should be thrown when verifications fails * @param {Array&lt;String>} keys the list of reserved keys to verify */ constructor(logWarnings = false, throwException=false, keys=["id", "label"]) { super("org.apache.tinkerpop.gremlin.process.traversal.strategy.verification.EdgeLabelVerificationStrategy", {logWarnings: logWarnings, throwException: throwException, keys: keys}); } } module.exports = { TraversalStrategies: TraversalStrategies, TraversalStrategy: TraversalStrategy, // decoration ConnectiveStrategy: ConnectiveStrategy, ElementIdStrategy: ElementIdStrategy, HaltedTraverserStrategy: HaltedTraverserStrategy, OptionsStrategy: OptionsStrategy, PartitionStrategy: PartitionStrategy, SubgraphStrategy: SubgraphStrategy, VertexProgramStrategy: VertexProgramStrategy, // finalization MatchAlgorithmStrategy: MatchAlgorithmStrategy, // optimization AdjacentToIncidentStrategy: AdjacentToIncidentStrategy, FilterRankingStrategy: FilterRankingStrategy, IdentityRemovalStrategy: IdentityRemovalStrategy, IncidentToAdjacentStrategy: IncidentToAdjacentStrategy, InlineFilterStrategy: InlineFilterStrategy, LazyBarrierStrategy: LazyBarrierStrategy, MatchPredicateStrategy: MatchPredicateStrategy, OrderLimitStrategy: OrderLimitStrategy, PathProcessorStrategy: PathProcessorStrategy, PathRetractionStrategy: PathRetractionStrategy, CountStrategy: CountStrategy, RepeatUnrollStrategy: RepeatUnrollStrategy, GraphFilterStrategy: GraphFilterStrategy, EarlyLimitStrategy: EarlyLimitStrategy, // verification EdgeLabelVerificationStrategy: EdgeLabelVerificationStrategy, LambdaRestrictionStrategy: LambdaRestrictionStrategy, ReadOnlyStrategy: ReadOnlyStrategy, ReservedKeysVerificationStrategy: ReservedKeysVerificationStrategy };</code></pre> </article> </section> </div> <nav> <h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="AnonymousTraversalSource.html">AnonymousTraversalSource</a></li><li><a href="Authenticator.html">Authenticator</a></li><li><a href="Bytecode.html">Bytecode</a></li><li><a href="Client.html">Client</a></li><li><a href="Connection.html">Connection</a></li><li><a href="DriverRemoteConnection.html">DriverRemoteConnection</a></li><li><a href="EdgeLabelVerificationStrategy.html">EdgeLabelVerificationStrategy</a></li><li><a href="Graph.html">Graph</a></li><li><a href="GraphSON2Reader.html">GraphSON2Reader</a></li><li><a href="GraphSON2Writer.html">GraphSON2Writer</a></li><li><a href="GraphSON3Reader.html">GraphSON3Reader</a></li><li><a href="GraphSON3Writer.html">GraphSON3Writer</a></li><li><a href="GraphTraversal.html">GraphTraversal</a></li><li><a href="GraphTraversalSource.html">GraphTraversalSource</a></li><li><a href="HaltedTraverserStrategy.html">HaltedTraverserStrategy</a></li><li><a href="MatchAlgorithmStrategy.html">MatchAlgorithmStrategy</a></li><li><a href="P.html">P</a></li><li><a href="PartitionStrategy.html">PartitionStrategy</a></li><li><a href="Path.html">Path</a></li><li><a href="PlainTextSaslAuthenticator.html">PlainTextSaslAuthenticator</a></li><li><a href="RemoteConnection.html">RemoteConnection</a></li><li><a href="RemoteStrategy.html">RemoteStrategy</a></li><li><a href="RemoteTraversal.html">RemoteTraversal</a></li><li><a href="ReservedKeysVerificationStrategy.html">ReservedKeysVerificationStrategy</a></li><li><a href="ResponseError.html">ResponseError</a></li><li><a href="ResultSet.html">ResultSet</a></li><li><a href="SaslAuthenticator.html">SaslAuthenticator</a></li><li><a href="SaslMechanismBase.html">SaslMechanismBase</a></li><li><a href="SaslMechanismPlain.html">SaslMechanismPlain</a></li><li><a href="SubgraphStrategy.html">SubgraphStrategy</a></li><li><a href="TextP.html">TextP</a></li><li><a href="Transaction.html">Transaction</a></li><li><a href="Translator.html">Translator</a></li><li><a href="TraversalStrategies.html">TraversalStrategies</a></li><li><a href="TraversalStrategy.html">TraversalStrategy</a></li><li><a href="TypeSerializer.html">TypeSerializer</a></li></ul><h3>Global</h3><ul><li><a href="global.html#statics">statics</a></li></ul> </nav> <br class="clear"> <footer> Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.7</a> on Wed May 17 2023 13:49:50 GMT+0800 (China Standard Time) </footer> <script> prettyPrint(); </script> <script src="scripts/linenumber.js"> </script> </body> </html>