当前位置: 首页>>代码示例>>Java>>正文


Java Path类代码示例

本文整理汇总了Java中org.apache.tinkerpop.gremlin.process.traversal.Path的典型用法代码示例。如果您正苦于以下问题:Java Path类的具体用法?Java Path怎么用?Java Path使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Path类属于org.apache.tinkerpop.gremlin.process.traversal包,在下文中一共展示了Path类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: projectTraverser

import org.apache.tinkerpop.gremlin.process.traversal.Path; //导入依赖的package包/类
@Override
public JSONObject projectTraverser(final Traverser.Admin<Path> traverser) {
    final JSONObject root = new JSONObject();
    JSONObject currentNode = root;
    for (final Object object : traverser.get()) {
        if (object instanceof Map) {
            for(final Map.Entry entry : (Set<Map.Entry>)((Map)object).entrySet()) {
                if(entry.getKey().equals(T.id))
                    currentNode.put(T.id.getAccessor(),entry.getValue());
                else if(entry.getKey().equals(T.label))
                    currentNode.put(T.label.getAccessor(),entry.getValue());
                else
                    currentNode.put(entry.getKey(),entry.getValue());
            }
        }
        else if (object instanceof String)
            currentNode.put(object, currentNode = new JSONObject());
    }
    return root;
}
 
开发者ID:okram,项目名称:mongodb-gremlin,代码行数:21,代码来源:MongoDBQueryStep.java

示例2: DetachedPath

import org.apache.tinkerpop.gremlin.process.traversal.Path; //导入依赖的package包/类
protected DetachedPath(final Path path, final boolean withProperties) {
    path.forEach((object, labels) -> {
        if (object instanceof DetachedElement || object instanceof DetachedProperty || object instanceof DetachedPath) {
            this.objects.add(object);
            this.labels.add(labels);
        } else if (object instanceof Element) {
            this.objects.add(DetachedFactory.detach((Element) object, withProperties));
            this.labels.add(labels);
        } else if (object instanceof Property) {
            this.objects.add(DetachedFactory.detach((Property) object));
            this.labels.add(labels);
        } else if (object instanceof Path) {
            this.objects.add(DetachedFactory.detach((Path) object, withProperties));
            this.labels.add(labels);
        } else {
            this.objects.add(object);
            this.labels.add(labels);
        }
    });
}
 
开发者ID:PKUSilvester,项目名称:LiteGraph,代码行数:21,代码来源:DetachedPath.java

示例3: ReferencePath

import org.apache.tinkerpop.gremlin.process.traversal.Path; //导入依赖的package包/类
protected ReferencePath(final Path path) {
    path.forEach((object, labels) -> {
        if (object instanceof ReferenceElement || object instanceof ReferenceProperty || object instanceof ReferencePath) {
            this.objects.add(object);
            this.labels.add(new HashSet<>(labels));
        } else if (object instanceof Element) {
            this.objects.add(ReferenceFactory.detach((Element) object));
            this.labels.add(new HashSet<>(labels));
        } else if (object instanceof Property) {
            this.objects.add(ReferenceFactory.detach((Property) object));
            this.labels.add(new HashSet<>(labels));
        } else if (object instanceof Path) {
            this.objects.add(ReferenceFactory.detach((Path) object));
            this.labels.add(new HashSet<>(labels));
        } else {
            this.objects.add(object);
            this.labels.add(new HashSet<>(labels));
        }
    });
}
 
开发者ID:PKUSilvester,项目名称:LiteGraph,代码行数:21,代码来源:ReferencePath.java

示例4: g_V_optionalXout_optionalXoutXX_path

import org.apache.tinkerpop.gremlin.process.traversal.Path; //导入依赖的package包/类
@Test
@LoadGraphWith(MODERN)
public void g_V_optionalXout_optionalXoutXX_path() {
    final Traversal<Vertex, Path> traversal = get_g_V_optionalXout_optionalXoutXX_path();
    printTraversalForm(traversal);
    List<Path> paths = traversal.toList();
    assertEquals(10, paths.size());
    List<Predicate<Path>> pathsToAssert = Arrays.asList(
            p -> p.size() == 2 && p.get(0).equals(convertToVertex(this.graph, "marko")) && p.get(1).equals(convertToVertex(this.graph, "lop")),
            p -> p.size() == 2 && p.get(0).equals(convertToVertex(this.graph, "marko")) && p.get(1).equals(convertToVertex(this.graph, "vadas")),
            p -> p.size() == 3 && p.get(0).equals(convertToVertex(this.graph, "marko")) && p.get(1).equals(convertToVertex(this.graph, "josh")) && p.get(2).equals(convertToVertex(this.graph, "lop")),
            p -> p.size() == 3 && p.get(0).equals(convertToVertex(this.graph, "marko")) && p.get(1).equals(convertToVertex(this.graph, "josh")) && p.get(2).equals(convertToVertex(this.graph, "ripple")),
            p -> p.size() == 1 && p.get(0).equals(convertToVertex(this.graph, "vadas")),
            p -> p.size() == 1 && p.get(0).equals(convertToVertex(this.graph, "lop")),
            p -> p.size() == 2 && p.get(0).equals(convertToVertex(this.graph, "josh")) && p.get(1).equals(convertToVertex(this.graph, "lop")),
            p -> p.size() == 2 && p.get(0).equals(convertToVertex(this.graph, "josh")) && p.get(1).equals(convertToVertex(this.graph, "ripple")),
            p -> p.size() == 1 && p.get(0).equals(convertToVertex(this.graph, "ripple")),
            p -> p.size() == 2 && p.get(0).equals(convertToVertex(this.graph, "peter")) && p.get(1).equals(convertToVertex(this.graph, "lop"))
    );
    for (Predicate<Path> pathPredicate : pathsToAssert) {
        Optional<Path> path = paths.stream().filter(pathPredicate).findAny();
        assertTrue(path.isPresent());
        assertTrue(paths.remove(path.get()));
    }
    assertTrue(paths.isEmpty());
}
 
开发者ID:PKUSilvester,项目名称:LiteGraph,代码行数:27,代码来源:OptionalTest.java

示例5: getRegistration

import org.apache.tinkerpop.gremlin.process.traversal.Path; //导入依赖的package包/类
@Override
public Registration getRegistration(final Class clazz) {
    // force all instances of Vertex, Edge, VertexProperty, etc. to their respective interface
    final Class type;
    if (!ReferenceVertex.class.isAssignableFrom(clazz) && !DetachedVertex.class.isAssignableFrom(clazz) && Vertex.class.isAssignableFrom(clazz))
        type = Vertex.class;
    else if (!ReferenceEdge.class.isAssignableFrom(clazz) && !DetachedEdge.class.isAssignableFrom(clazz) && Edge.class.isAssignableFrom(clazz))
        type = Edge.class;
    else if (!ReferenceVertexProperty.class.isAssignableFrom(clazz) && !DetachedVertexProperty.class.isAssignableFrom(clazz) && VertexProperty.class.isAssignableFrom(clazz))
        type = VertexProperty.class;
    else if (!ReferenceProperty.class.isAssignableFrom(clazz) && !DetachedProperty.class.isAssignableFrom(clazz) && !DetachedVertexProperty.class.isAssignableFrom(clazz) && Property.class.isAssignableFrom(clazz))
        type = Property.class;
    else if (!ReferencePath.class.isAssignableFrom(clazz) && !DetachedPath.class.isAssignableFrom(clazz) && Path.class.isAssignableFrom(clazz))
        type = Path.class;
    else
        type = clazz;

    if (type == memoizedClass) return memoizedClassValue;
    final Registration registration = classToRegistration.get(type);
    if (registration != null) {
        memoizedClass = type;
        memoizedClassValue = registration;
    }

    return registration;
}
 
开发者ID:PKUSilvester,项目名称:LiteGraph,代码行数:27,代码来源:GryoClassResolver.java

示例6: g_VX1X_out_name_injectXdanielX_asXaX_mapXlengthX_path

import org.apache.tinkerpop.gremlin.process.traversal.Path; //导入依赖的package包/类
@Test
@LoadGraphWith(MODERN)
public void g_VX1X_out_name_injectXdanielX_asXaX_mapXlengthX_path() {
    final Traversal<Vertex, Path> traversal = get_g_VX1X_out_name_injectXdanielX_asXaX_mapXlengthX_path(convertToVertexId("marko"));
    printTraversalForm(traversal);
    int counter = 0;
    while (traversal.hasNext()) {
        counter++;
        final Path path = traversal.next();
        if (path.get("a").equals("daniel")) {
            assertEquals(2, path.size());
            assertEquals(6, (int) path.get(1));
        } else {
            assertEquals(4, path.size());
            assertEquals(path.<String>get("a").length(), (int) path.get(3));
        }
    }
    assertEquals(4, counter);
}
 
开发者ID:PKUSilvester,项目名称:LiteGraph,代码行数:20,代码来源:InjectTest.java

示例7: hasMatched

import org.apache.tinkerpop.gremlin.process.traversal.Path; //导入依赖的package包/类
private boolean hasMatched(final ConnectiveStep.Connective connective, final Traverser.Admin<S> traverser) {
    int counter = 0;
    boolean matched = false;
    for (final Traversal.Admin<Object, Object> matchTraversal : this.matchTraversals) {
        if (traverser.getTags().contains(matchTraversal.getStartStep().getId())) {
            if (connective == ConnectiveStep.Connective.OR) {
                matched = true;
                break;
            }
            counter++;
        }
    }
    if (!matched)
        matched = this.matchTraversals.size() == counter;
    if (matched && this.dedupLabels != null) {
        final Path path = traverser.path();
        final List<Object> objects = new ArrayList<>(this.dedupLabels.size());
        for (final String label : this.dedupLabels) {
            objects.add(path.get(Pop.last, label));
        }
        this.dedups.add(objects);
    }
    return matched;
}
 
开发者ID:PKUSilvester,项目名称:LiteGraph,代码行数:25,代码来源:MatchStep.java

示例8: processNextStart

import org.apache.tinkerpop.gremlin.process.traversal.Path; //导入依赖的package包/类
@Override
protected Traverser.Admin<Object> processNextStart() throws NoSuchElementException {
    if (null == this.parent)
        this.parent = ((MatchStep) this.getTraversal().getParent().asStep());

    while (true) {
        final Traverser.Admin traverser = this.starts.next();
        // no end label
        if (null == this.matchKey) {
            // if (this.traverserStepIdAndLabelsSetByChild) -- traverser equality is based on stepId, lets ensure they are all at the parent
            traverser.setStepId(this.parent.getId());
            this.parent.getMatchAlgorithm().recordEnd(traverser, this.getTraversal());
            return this.retractUnnecessaryLabels(traverser);
        }
        // TODO: sideEffect check?
        // path check
        final Path path = traverser.path();
        if (!path.hasLabel(this.matchKey) || traverser.get().equals(path.get(Pop.last, this.matchKey))) {
            // if (this.traverserStepIdAndLabelsSetByChild) -- traverser equality is based on stepId and thus, lets ensure they are all at the parent
            traverser.setStepId(this.parent.getId());
            traverser.addLabels(this.matchKeyCollection);
            this.parent.getMatchAlgorithm().recordEnd(traverser, this.getTraversal());
            return this.retractUnnecessaryLabels(traverser);
        }
    }
}
 
开发者ID:PKUSilvester,项目名称:LiteGraph,代码行数:27,代码来源:MatchStep.java

示例9: map

import org.apache.tinkerpop.gremlin.process.traversal.Path; //导入依赖的package包/类
@Override
protected S map(final Traverser.Admin<S> traverser) {
    // We may consider optimizing the iteration of these containers using subtype-specific interfaces.  For
    // example, we could use descendingIterator if we have a Deque.  But in general, we cannot reliably iterate a
    // collection in reverse, so we use the range algorithm with dynamically computed boundaries.
    final S start = traverser.get();
    final long high =
            start instanceof Map ? ((Map) start).size() :
                    start instanceof Collection ? ((Collection) start).size() :
                            start instanceof Path ? ((Path) start).size() :
                                    start instanceof Iterable ? IteratorUtils.count((Iterable) start) :
                                            this.limit;
    final long low = high - this.limit;
    final S result = RangeLocalStep.applyRange(start, low, high);
    return result;
}
 
开发者ID:PKUSilvester,项目名称:LiteGraph,代码行数:17,代码来源:TailLocalStep.java

示例10: g_V_asXaX_outXcreatedX_asXbX_inXcreatedX_asXcX_dedupXa_bX_path

import org.apache.tinkerpop.gremlin.process.traversal.Path; //导入依赖的package包/类
@Test
@LoadGraphWith(MODERN)
public void g_V_asXaX_outXcreatedX_asXbX_inXcreatedX_asXcX_dedupXa_bX_path() {
    final Traversal<Vertex, Path> traversal = get_g_V_asXaX_outXcreatedX_asXbX_inXcreatedX_asXcX_dedupXa_bX_path();
    printTraversalForm(traversal);
    int counter = 0;
    final Set<List<Vertex>> results = new HashSet<>();
    while (traversal.hasNext()) {
        final Path path = traversal.next();
        assertEquals(3, path.size());
        assertTrue(results.add(Arrays.asList(path.get("a"), path.get("b"))));
        counter++;
    }
    assertEquals(4, counter);
    assertEquals(4, results.size());
}
 
开发者ID:PKUSilvester,项目名称:LiteGraph,代码行数:17,代码来源:DedupTest.java

示例11: g_V_hasLabelXpersonX_optionalXoutXknowsX_optionalXoutXcreatedXXX_path

import org.apache.tinkerpop.gremlin.process.traversal.Path; //导入依赖的package包/类
@Test
@LoadGraphWith(MODERN)
public void g_V_hasLabelXpersonX_optionalXoutXknowsX_optionalXoutXcreatedXXX_path() {
    final Traversal<Vertex, Path> traversal = get_g_V_hasLabelXpersonX_optionalXoutXknowsX_optionalXoutXcreatedXXX_path();
    printTraversalForm(traversal);
    List<Path> paths = traversal.toList();
    assertEquals(6, paths.size());
    List<Predicate<Path>> pathsToAssert = Arrays.asList(
            p -> p.size() == 2 && p.get(0).equals(convertToVertex(this.graph, "marko")) && p.get(1).equals(convertToVertex(this.graph, "vadas")),
            p -> p.size() == 3 && p.get(0).equals(convertToVertex(this.graph, "marko")) && p.get(1).equals(convertToVertex(this.graph, "josh")) && p.get(2).equals(convertToVertex(this.graph, "ripple")),
            p -> p.size() == 3 && p.get(0).equals(convertToVertex(this.graph, "marko")) && p.get(1).equals(convertToVertex(this.graph, "josh")) && p.get(2).equals(convertToVertex(this.graph, "lop")),
            p -> p.size() == 1 && p.get(0).equals(convertToVertex(this.graph, "vadas")),
            p -> p.size() == 1 && p.get(0).equals(convertToVertex(this.graph, "josh")),
            p -> p.size() == 1 && p.get(0).equals(convertToVertex(this.graph, "peter"))
    );
    for (Predicate<Path> pathPredicate : pathsToAssert) {
        Optional<Path> path = paths.stream().filter(pathPredicate).findAny();
        assertTrue(path.isPresent());
        assertTrue(paths.remove(path.get()));
    }
    assertTrue(paths.isEmpty());
}
 
开发者ID:PKUSilvester,项目名称:LiteGraph,代码行数:23,代码来源:OptionalTest.java

示例12: retract

import org.apache.tinkerpop.gremlin.process.traversal.Path; //导入依赖的package包/类
@Override
public Path retract(final Set<String> labels) {
    if (labels.isEmpty())
        return this;

    // get all the immutable path sections
    final List<ImmutablePath> immutablePaths = new ArrayList<>();
    ImmutablePath currentPathSection = this;
    while (true) {
        immutablePaths.add(0, currentPathSection);
        if (currentPathSection.previousPath instanceof TailPath)
            break;
        else
            currentPathSection = (ImmutablePath) currentPathSection.previousPath;
    }
    // build a new immutable path using the respective path sections that are not to be retracted
    Path newPath = TailPath.instance();
    for (final ImmutablePath immutablePath : immutablePaths) {
        final Set<String> temp = new LinkedHashSet<>(immutablePath.currentLabels);
        temp.removeAll(labels);
        if (!temp.isEmpty())
            newPath = newPath.extend(immutablePath.currentObject, temp);
    }
    return newPath;
}
 
开发者ID:PKUSilvester,项目名称:LiteGraph,代码行数:26,代码来源:ImmutablePath.java

示例13: get

import org.apache.tinkerpop.gremlin.process.traversal.Path; //导入依赖的package包/类
@Override
public <A> A get(final Pop pop, final String label) {
    if (Pop.all == pop) {
        // Recursively build the list to avoid building objects/labels collections.
        final List<A> list = this.previousPath.get(Pop.all, label);
        // Add our object, if our step labels match.
        if (this.currentLabels.contains(label))
            list.add((A) currentObject);
        return (A) list;
    } else {
        // Delegate to the non-throwing, optimized head/tail calculations.
        final A single = Pop.first == pop ? this.getSingleTail(label) : this.getSingleHead(label);
        // Throw if we didn't find the label.
        if (null == single)
            throw Path.Exceptions.stepWithProvidedLabelDoesNotExist(label);
        return single;
    }
}
 
开发者ID:PKUSilvester,项目名称:LiteGraph,代码行数:19,代码来源:ImmutablePath.java

示例14: equals

import org.apache.tinkerpop.gremlin.process.traversal.Path; //导入依赖的package包/类
@Override
public boolean equals(final Object other) {
    if (!(other instanceof Path))
        return false;
    final Path otherPath = (Path) other;
    int size = this.size();
    if (otherPath.size() != size)
        return false;
    if (size > 0) {
        ImmutablePath currentPathSection = this;
        final List<Object> otherObjects = otherPath.objects();
        final List<Set<String>> otherLabels = otherPath.labels();
        for (int i = otherLabels.size() - 1; i >= 0; i--) {
            if (!currentPathSection.currentObject.equals(otherObjects.get(i)))
                return false;
            if (!currentPathSection.currentLabels.equals(otherLabels.get(i)))
                return false;
            if (currentPathSection.previousPath instanceof TailPath)
                break;
            else
                currentPathSection = (ImmutablePath) currentPathSection.previousPath;
        }
    }
    return true;
}
 
开发者ID:PKUSilvester,项目名称:LiteGraph,代码行数:26,代码来源:ImmutablePath.java

示例15: assertPath

import org.apache.tinkerpop.gremlin.process.traversal.Path; //导入依赖的package包/类
private static void assertPath(final Traversal<Vertex, Path> traversal) {
    int path1 = 0;
    int path2 = 0;
    int path3 = 0;
    while (traversal.hasNext()) {
        final Path path = traversal.next();
        if (path.size() == 1) {
            path1++;
        } else if (path.size() == 2) {
            path2++;
        } else if (path.size() == 3) {
            path3++;
        } else {
            fail("Only path lengths of 1, 2, or 3 should be seen");
        }
    }
    assertEquals(6, path1);
    assertEquals(6, path2);
    assertEquals(2, path3);
}
 
开发者ID:PKUSilvester,项目名称:LiteGraph,代码行数:21,代码来源:RepeatTest.java


注:本文中的org.apache.tinkerpop.gremlin.process.traversal.Path类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。