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


Java Element类代码示例

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


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

示例1: apply

import org.apache.tinkerpop.gremlin.structure.Element; //导入依赖的package包/类
@Override
@SneakyThrows
public GraphTraversal<Element, Element> apply(GraphTraversalSource g) {
  GraphTraversal traversal = g.addV(element.label());
  if (element.id() != null && HasFeature.Verifier.of(g)
      .verify(supportsUserSuppliedIds(element))) {
    traversal.property(T.id, element.id());
  }
  for (Field field : keyFields(element)) {
    String key = propertyKey(field);
    Object value = propertyValue(field, element);
    if (isMissing(value)) {
      throw org.apache.tinkerpop.gremlin.object.structure.Element.Exceptions.requiredKeysMissing(
          element.getClass(), key);
    }
    traversal.property(key, value);
  }
  return traversal;
}
 
开发者ID:karthicks,项目名称:gremlin-ogm,代码行数:20,代码来源:AddV.java

示例2: apply

import org.apache.tinkerpop.gremlin.structure.Element; //导入依赖的package包/类
@Override
public GraphTraversal<Element, Map<String, Object>> apply(
    GraphTraversal<Element, Element> traversal) {
  GraphTraversal<Element, Map<String, Object>> selectTraversal;
  if (selectKey2 == null) {
    selectTraversal = traversal.select(selectKey1);
  } else {
    selectTraversal =
        traversal.select(selectKey1, selectKey2, otherSelectKeys.toArray(new String[] {}));
  }
  if (selectKey1 != null) {
    selectTraversal.by();
  }
  if (selectKey2 != null) {
    selectTraversal.by();
  }
  otherSelectKeys.forEach(otherSelectKey -> {
    selectTraversal.by();
  });
  return selectTraversal;
}
 
开发者ID:karthicks,项目名称:gremlin-ogm,代码行数:22,代码来源:Select.java

示例3: createElementIterator

import org.apache.tinkerpop.gremlin.structure.Element; //导入依赖的package包/类
private <T extends Element> Iterator<T> createElementIterator(final Class<T> clazz, final Map<Object, T> elements,
                                                              final IdManager idManager,
                                                              final Object... ids) {
    final Iterator<T> iterator;
    if (0 == ids.length) {
        iterator = elements.values().iterator();
    } else {
        final List<Object> idList = Arrays.asList(ids);
        validateHomogenousIds(idList);

        // if the type is of Element - have to look each up because it might be an Attachable instance or
        // other implementation. the assumption is that id conversion is not required for detached
        // stuff - doesn't seem likely someone would detach a Titan vertex then try to expect that
        // vertex to be findable in OrientDB
        return clazz.isAssignableFrom(ids[0].getClass()) ?
                IteratorUtils.filter(IteratorUtils.map(idList, id -> elements.get(clazz.cast(id).id())).iterator(), Objects::nonNull)
                : IteratorUtils.filter(IteratorUtils.map(idList, id -> elements.get(idManager.convert(id))).iterator(), Objects::nonNull);
    }
    return TinkerHelper.inComputerMode(this) ?
            (Iterator<T>) (clazz.equals(Vertex.class) ?
                    IteratorUtils.filter((Iterator<Vertex>) iterator, t -> this.graphComputerView.legalVertex(t)) :
                    IteratorUtils.filter((Iterator<Edge>) iterator, t -> this.graphComputerView.legalEdge(t.outVertex(), t))) :
            iterator;
}
 
开发者ID:ShiftLeftSecurity,项目名称:tinkergraph-gremlin,代码行数:25,代码来源:TinkerGraph.java

示例4: apply

import org.apache.tinkerpop.gremlin.structure.Element; //导入依赖的package包/类
@Override
public void apply(final Traversal.Admin<?, ?> traversal) {
    if (!(traversal.getParent() instanceof EmptyStep) || TraversalHelper.onGraphComputer(traversal))
        return;
    final List<Step> steps = traversal.getSteps();
    if (steps.size() < 2 ||
            !(steps.get(0) instanceof GraphStep) ||
            0 != ((GraphStep) steps.get(0)).getIds().length ||
            !(steps.get(steps.size() - 1) instanceof CountGlobalStep))
        return;
    for (int i = 1; i < steps.size() - 1; i++) {
        final Step current = steps.get(i);
        if (!(current instanceof MapStep ||
                current instanceof IdentityStep ||
                current instanceof NoOpBarrierStep ||
                current instanceof CollectingBarrierStep) ||
                (current instanceof TraversalParent &&
                        TraversalHelper.anyStepRecursively(s -> (s instanceof SideEffectStep || s instanceof AggregateStep), (TraversalParent) current)))
            return;
    }
    final Class<? extends Element> elementClass = ((GraphStep<?, ?>) steps.get(0)).getReturnClass();
    TraversalHelper.removeAllSteps(traversal);
    traversal.addStep(new TinkerCountGlobalStep<>(traversal, elementClass));
}
 
开发者ID:ShiftLeftSecurity,项目名称:tinkergraph-gremlin,代码行数:25,代码来源:TinkerGraphCountStrategy.java

示例5: createKeyIndex

import org.apache.tinkerpop.gremlin.structure.Element; //导入依赖的package包/类
@Override
public <T extends Element> void createKeyIndex(String key, Class<T> elementType) {
    beginWrite();

    try {
        if (elementType == null) {
            throw new IllegalArgumentException("Element type in createKeyIndex() can not be null");
        } else if (elementType.equals(Vertex.class)) {
            vIndexMap.createKeyIndex(key, getAllVertices().iterator());
        } else if (elementType.equals(Edge.class)) {
            eIndexMap.createKeyIndex(key, getAllEdges().iterator());
        } else {
            throw new BitsyException(BitsyErrorCodes.UNSUPPORTED_INDEX_TYPE, "Encountered index type: " + elementType);
        }
    } finally {
        endWrite();
    }
}
 
开发者ID:lambdazen,项目名称:bitsy,代码行数:19,代码来源:MemoryGraphStore.java

示例6: dropKeyIndex

import org.apache.tinkerpop.gremlin.structure.Element; //导入依赖的package包/类
@Override
public <T extends Element> void dropKeyIndex(String key, Class<T> elementType) {
    beginWrite();

    try {
        if (elementType == null) {
            throw new IllegalArgumentException("Element type in dropKeyIndex() can not be null");
        } else if (elementType.equals(Vertex.class)) {
            vIndexMap.dropKeyIndex(key);
        } else if (elementType.equals(Edge.class)) {
            eIndexMap.dropKeyIndex(key);
        } else {
            throw new BitsyException(BitsyErrorCodes.UNSUPPORTED_INDEX_TYPE, "Encountered index type: " + elementType);
        }
    } finally {
        endWrite();
    }
}
 
开发者ID:lambdazen,项目名称:bitsy,代码行数:19,代码来源:MemoryGraphStore.java

示例7: getIndexedKeys

import org.apache.tinkerpop.gremlin.structure.Element; //导入依赖的package包/类
@Override
public <T extends Element> Set<String> getIndexedKeys(Class<T> elementType) {
    // Getting a write lock because this method accesses the list of index names which isn't thread-safe
    beginWrite();

    try {
        if (elementType == null) {
            throw new IllegalArgumentException("Element type in getIndexedKeys() can not be null");
        } else if (elementType.equals(Vertex.class)) {
            return vIndexMap.getIndexedKeys();
        } else if (elementType.equals(Edge.class)) {
            return eIndexMap.getIndexedKeys();
        } else {
            throw new BitsyException(BitsyErrorCodes.UNSUPPORTED_INDEX_TYPE, "Encountered index type: " + elementType);
        }
    } finally {
        endWrite();
    }
}
 
开发者ID:lambdazen,项目名称:bitsy,代码行数:20,代码来源:MemoryGraphStore.java

示例8: shouldDeterminePropertiesAreNotEqualWhenElementsAreDifferent

import org.apache.tinkerpop.gremlin.structure.Element; //导入依赖的package包/类
@Test
public void shouldDeterminePropertiesAreNotEqualWhenElementsAreDifferent() {
    final Property mockPropertyA = mock(Property.class);
    final Property mockPropertyB = mock(Property.class);
    final Element mockElement = mock(Element.class);
    final Element mockElementDifferent = mock(Element.class);
    when(mockPropertyA.isPresent()).thenReturn(true);
    when(mockPropertyB.isPresent()).thenReturn(true);
    when(mockPropertyA.element()).thenReturn(mockElement);
    when(mockPropertyB.element()).thenReturn(mockElementDifferent);
    when(mockPropertyA.key()).thenReturn("k");
    when(mockPropertyB.key()).thenReturn("k");
    when(mockPropertyA.value()).thenReturn("v");
    when(mockPropertyB.value()).thenReturn("v");

    assertFalse(ElementHelper.areEqual(mockPropertyA, mockPropertyB));
}
 
开发者ID:PKUSilvester,项目名称:LiteGraph,代码行数:18,代码来源:ElementHelperTest.java

示例9: applyFragments

import org.apache.tinkerpop.gremlin.structure.Element; //导入依赖的package包/类
private GraphTraversal<Vertex, Map<String, Element>> applyFragments(
        GraknTx graph, Set<Var> vars, ImmutableList<Fragment> fragmentList,
        GraphTraversal<Vertex, ? extends Element> traversal
) {
    Set<Var> foundVars = new HashSet<>();

    // Apply fragments in order into one single traversal
    Var currentName = null;

    for (Fragment fragment : fragmentList) {
        // Apply fragment to traversal
        fragment.applyTraversal(traversal, graph, foundVars, currentName);
        currentName = fragment.end() != null ? fragment.end() : fragment.start();
    }

    // Select all the variable names
    return selectVars(traversal, Sets.intersection(vars, foundVars));
}
 
开发者ID:graknlabs,项目名称:grakn,代码行数:19,代码来源:GraqlTraversal.java

示例10: ser

import org.apache.tinkerpop.gremlin.structure.Element; //导入依赖的package包/类
private static void ser(final Tree tree, final JsonGenerator jsonGenerator, final TypeSerializer typeSerializer)
        throws IOException {
    jsonGenerator.writeStartObject(); 
    if (typeSerializer != null) jsonGenerator.writeStringField(GraphSONTokens.CLASS, HashMap.class.getName());
    
    Set<Map.Entry<Element, Tree>> set = tree.entrySet();
    for(Map.Entry<Element, Tree> entry : set)
    {
        jsonGenerator.writeObjectFieldStart(entry.getKey().id().toString());
        if (typeSerializer != null) jsonGenerator.writeStringField(GraphSONTokens.CLASS, HashMap.class.getName());
        jsonGenerator.writeObjectField(GraphSONTokens.KEY, entry.getKey()); 
        jsonGenerator.writeObjectField(GraphSONTokens.VALUE, entry.getValue());
        jsonGenerator.writeEndObject();
    }
    jsonGenerator.writeEndObject();
}
 
开发者ID:PKUSilvester,项目名称:LiteGraph,代码行数:17,代码来源:GraphSONSerializers.java

示例11: shouldSortElement

import org.apache.tinkerpop.gremlin.structure.Element; //导入依赖的package包/类
@Test
public void shouldSortElement() {
    final Element a = mock(Element.class);
    when(a.id()).thenReturn("Ant");
    final Element b = mock(Element.class);
    when(b.id()).thenReturn("Bat");
    final Element c = mock(Element.class);
    when(c.id()).thenReturn("Cat");

    final List<Element> l = Arrays.asList(c, b, a);
    l.sort(Comparators.ELEMENT_COMPARATOR);

    assertEquals(a.id(), l.get(0).id());
    assertEquals(b.id(), l.get(1).id());
    assertEquals(c.id(), l.get(2).id());
}
 
开发者ID:PKUSilvester,项目名称:LiteGraph,代码行数:17,代码来源:ComparatorsTest.java

示例12: shouldDeterminePropertiesAreEqual

import org.apache.tinkerpop.gremlin.structure.Element; //导入依赖的package包/类
@Test
public void shouldDeterminePropertiesAreEqual() {
    final Property mockPropertyA = mock(Property.class);
    final Property mockPropertyB = mock(Property.class);
    final Element mockElement = mock(Element.class);
    when(mockPropertyA.isPresent()).thenReturn(true);
    when(mockPropertyB.isPresent()).thenReturn(true);
    when(mockPropertyA.element()).thenReturn(mockElement);
    when(mockPropertyB.element()).thenReturn(mockElement);
    when(mockPropertyA.key()).thenReturn("k");
    when(mockPropertyB.key()).thenReturn("k");
    when(mockPropertyA.value()).thenReturn("v");
    when(mockPropertyB.value()).thenReturn("v");

    assertTrue(ElementHelper.areEqual(mockPropertyA, mockPropertyB));
}
 
开发者ID:PKUSilvester,项目名称:LiteGraph,代码行数:17,代码来源:ElementHelperTest.java

示例13: createProperty

import org.apache.tinkerpop.gremlin.structure.Element; //导入依赖的package包/类
public static Property createProperty(final Attachable<Property> attachableProperty, final Graph hostGraph) {
    final Property baseProperty = attachableProperty.get();
    final Element baseElement = baseProperty.element();
    if (baseElement instanceof Vertex) {
        return Method.createVertexProperty((Attachable) attachableProperty, hostGraph);
    } else if (baseElement instanceof Edge) {
        final Iterator<Edge> edgeIterator = hostGraph.edges(baseElement.id());
        if (edgeIterator.hasNext())
            return edgeIterator.next().property(baseProperty.key(), baseProperty.value());
        throw new IllegalStateException("Could not find edge to create the attachable property on");
    } else { // vertex property
        final Iterator<Vertex> vertexIterator = hostGraph.vertices(((VertexProperty) baseElement).element().id());
        if (vertexIterator.hasNext()) {
            final Vertex vertex = vertexIterator.next();
            final Iterator<VertexProperty<Object>> vertexPropertyIterator = vertex.properties(((VertexProperty) baseElement).key());
            while (vertexPropertyIterator.hasNext()) {
                final VertexProperty<Object> vp = vertexPropertyIterator.next();
                if (ElementHelper.areEqual(vp, baseElement))
                    return vp.property(baseProperty.key(), baseProperty.value());
            }
        }
        throw new IllegalStateException("Could not find vertex property to create the attachable property on");
    }
}
 
开发者ID:PKUSilvester,项目名称:LiteGraph,代码行数:25,代码来源:Attachable.java

示例14: apply

import org.apache.tinkerpop.gremlin.structure.Element; //导入依赖的package包/类
@Override
@SneakyThrows
public GraphTraversal<Element, Element> apply(GraphTraversal<Element, Element> traversal) {
  return traversal
      .hasLabel(org.apache.tinkerpop.gremlin.object.reflect.Label.of(elementType))
      .range(low, high);
}
 
开发者ID:karthicks,项目名称:gremlin-ogm,代码行数:8,代码来源:Page.java

示例15: of

import org.apache.tinkerpop.gremlin.structure.Element; //导入依赖的package包/类
@SuppressWarnings("PMD.ShortMethodName")
public static HasKeys of(org.apache.tinkerpop.gremlin.object.structure.Element element,
    Class<? extends Annotation> keyType) {
  return HasKeys.builder()
      .element(element)
      .keyType(keyType)
      .build();
}
 
开发者ID:karthicks,项目名称:gremlin-ogm,代码行数:9,代码来源:HasKeys.java


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