本文整理汇总了Java中org.apache.tinkerpop.gremlin.process.traversal.TraversalStrategies.removeStrategies方法的典型用法代码示例。如果您正苦于以下问题:Java TraversalStrategies.removeStrategies方法的具体用法?Java TraversalStrategies.removeStrategies怎么用?Java TraversalStrategies.removeStrategies使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.tinkerpop.gremlin.process.traversal.TraversalStrategies
的用法示例。
在下文中一共展示了TraversalStrategies.removeStrategies方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: shouldBeFaster
import org.apache.tinkerpop.gremlin.process.traversal.TraversalStrategies; //导入方法依赖的package包/类
@Test
public void shouldBeFaster() throws Exception {
final TraversalStrategies withStrategyUnderTest = new DefaultTraversalStrategies();
withStrategyUnderTest.addStrategies(getStrategyUnderTestInstance());
final TraversalStrategies withoutStrategyUnderTest = new DefaultTraversalStrategies();
withoutStrategyUnderTest.removeStrategies(getStrategyUnderTest());
final int clockRuns = getClockRuns();
final Iterator<GraphTraversal> iterator = getTraversalIterator();
int faster = 0, numTraversals = 0;
while (iterator.hasNext()) {
final GraphTraversal traversal = iterator.next();
final GraphTraversal.Admin original = traversal.asAdmin();
final GraphTraversal.Admin optimized = original.clone();
original.setStrategies(withoutStrategyUnderTest);
optimized.setStrategies(withStrategyUnderTest);
final double originalTime, optimizedTime;
if (RANDOM.nextBoolean()) {
originalTime = TimeUtil.clock(clockRuns, () -> original.clone().iterate());
optimizedTime = TimeUtil.clock(clockRuns, () -> optimized.clone().iterate());
} else {
optimizedTime = TimeUtil.clock(clockRuns, () -> optimized.clone().iterate());
originalTime = TimeUtil.clock(clockRuns, () -> original.clone().iterate());
}
final List originalResult = original.toList();
final List optimizedResult = optimized.toList();
if (originalTime > optimizedTime) {
LOGGER.debug("Original traversal ({} ms): {}", originalTime, original);
LOGGER.debug("Optimized traversal ({} ms): {}", optimizedTime, optimized);
} else {
LOGGER.warn("Original traversal ({} ms): {}", originalTime, original);
LOGGER.warn("Optimized traversal ({} ms): {}", optimizedTime, optimized);
}
if (getAssertionPercentile() >= 100) assertTrue(originalTime > optimizedTime);
else {
if (originalTime > optimizedTime)
faster++;
numTraversals++;
}
assertEquals(originalResult, optimizedResult);
}
if (getAssertionPercentile() < 100 && numTraversals > 0)
assertTrue(((faster * 100.0) / numTraversals) >= getAssertionPercentile());
}
示例2: initializeJanusGraph
import org.apache.tinkerpop.gremlin.process.traversal.TraversalStrategies; //导入方法依赖的package包/类
private JanusGraph initializeJanusGraph(boolean createMode)
{
LOG.fine("Initializing graph.");
Path lucene = graphDir.resolve("graphsearch");
Path berkeley = graphDir.resolve("titangraph");
// TODO: Externalize this.
conf = new BaseConfiguration();
// Sets a unique id in order to fix WINDUP-697. This causes Titan to not attempt to generate and ID,
// as the Titan id generation code fails on machines with broken network configurations.
conf.setProperty("graph.unique-instance-id", "windup_" + System.nanoTime() + "_" + RandomStringUtils.randomAlphabetic(6));
conf.setProperty("storage.directory", berkeley.toAbsolutePath().toString());
conf.setProperty("storage.backend", "berkeleyje");
// Sets the berkeley cache to a relatively small value to reduce the memory footprint.
// This is actually more important than performance on some of the smaller machines out there, and
// the performance decrease seems to be minimal.
conf.setProperty("storage.berkeleydb.cache-percentage", 1);
// Set READ UNCOMMITTED to improve performance
conf.setProperty("storage.berkeleydb.lock-mode", LockMode.READ_UNCOMMITTED);
conf.setProperty("storage.berkeleydb.isolation-level", BerkeleyJEStoreManager.IsolationLevel.READ_UNCOMMITTED);
// Increase storage write buffer since we basically do a large bulk load during the first phases.
// See http://s3.thinkaurelius.com/docs/titan/current/bulk-loading.html
conf.setProperty("storage.buffer-size", "4096");
// Turn off transactions to improve performance
conf.setProperty("storage.transactions", false);
conf.setProperty("ids.block-size", 25000);
// conf.setProperty("ids.flush", true);
// conf.setProperty("", false);
//
// turn on a db-cache that persists across txn boundaries, but make it relatively small
conf.setProperty("cache.db-cache", true);
conf.setProperty("cache.db-cache-clean-wait", 0);
conf.setProperty("cache.db-cache-size", .09);
conf.setProperty("cache.db-cache-time", 0);
conf.setProperty("index.search.backend", "lucene");
conf.setProperty("index.search.directory", lucene.toAbsolutePath().toString());
writeToPropertiesFile(conf, graphDir.resolve("TitanConfiguration.properties").toFile());
JanusGraph janusGraph = JanusGraphFactory.open(conf);
/*
* We only need to setup the eventing system when initializing a graph, not when loading it later for
* reporting.
*/
if (createMode)
{
TraversalStrategies graphStrategies = TraversalStrategies.GlobalCache
.getStrategies(StandardJanusGraph.class)
.clone();
// Remove any old listeners
if (graphStrategies.getStrategy(EventStrategy.class) != null)
graphStrategies.removeStrategies(EventStrategy.class);
graphStrategies.addStrategies(EventStrategy.build().addListener(mutationListener).create());
TraversalStrategies.GlobalCache.registerStrategies(StandardJanusGraph.class, graphStrategies);
mutationListener.setGraph(this);
}
return janusGraph;
}