• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java Element类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: apply

import org.apache.tinkerpop.gremlin.structure.Element; //导入依赖的package包/类
@Override
@SneakyThrows
public GraphTraversal<Element, Element> apply(GraphTraversal<Element, Element> traversal) {
  traversal.hasLabel(element.label());
  List<Field> fields;
  if (keyType != null) {
    if (is(keyType, PrimaryKey.class)) {
      fields = primaryKeyFields(element);
    } else if (is(keyType, OrderingKey.class)) {
      fields = orderingKeyFields(element);
    } else {
      throw org.apache.tinkerpop.gremlin.object.structure.Element.Exceptions
          .invalidAnnotationType(keyType);
    }
  } else {
    fields = keyFields(element);
  }
  for (Field field : fields) {
    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.has(key, value);
  }
  return traversal;
}
 
开发者ID:karthicks,项目名称:gremlin-ogm,代码行数:29,代码来源:HasKeys.java


示例17: property

import org.apache.tinkerpop.gremlin.structure.Element; //导入依赖的package包/类
@Override
public Element property(Element element, Update update) {
  if (update.getKeyValues() != null) {
    ((Vertex) element).property(update.getCardinality(),
        update.getKey(),
        update.getValue(),
        update.getKeyValues());
  } else {
    element.property(update.getKey(), update.getValue());
  }
  return element;
}
 
开发者ID:karthicks,项目名称:gremlin-ogm,代码行数:13,代码来源:UpdateBy.java


示例18: setUp

import org.apache.tinkerpop.gremlin.structure.Element; //导入依赖的package包/类
@Before
public void setUp() {
  sanFrancisco = City.of("San Francisco");
  traversal = (GraphTraversal<Element, O>) mock(GraphTraversal.class);
  when(traversal.property(anyString(), any())).thenReturn(traversal);
  when(traversal.hasLabel(anyString())).thenReturn(traversal);
  when(traversal.count()).thenReturn((GraphTraversal) traversal);
  g = mock(GraphTraversalSource.class);
  when(g.V()).thenReturn((GraphTraversal) traversal);
  when(g.addV(anyString())).thenReturn((GraphTraversal) traversal);
}
 
开发者ID:karthicks,项目名称:gremlin-ogm,代码行数:12,代码来源:TraversalTest.java


示例19: createIndex

import org.apache.tinkerpop.gremlin.structure.Element; //导入依赖的package包/类
/**
 * Create an index for said element class ({@link Vertex} or {@link Edge}) and said property key.
 * Whenever an element has the specified key mutated, the index is updated.
 * When the index is created, all existing elements are indexed to ensure that they are captured by the index.
 *
 * @param key          the property key to index
 * @param elementClass the element class to index
 * @param <E>          The type of the element class
 */
public <E extends Element> void createIndex(final String key, final Class<E> elementClass) {
    if (Vertex.class.isAssignableFrom(elementClass)) {
        if (null == this.vertexIndex) this.vertexIndex = new TinkerIndex<>(this, TinkerVertex.class);
        this.vertexIndex.createKeyIndex(key);
    } else if (Edge.class.isAssignableFrom(elementClass)) {
        if (null == this.edgeIndex) this.edgeIndex = new TinkerIndex<>(this, TinkerEdge.class);
        this.edgeIndex.createKeyIndex(key);
    } else {
        throw new IllegalArgumentException("Class is not indexable: " + elementClass);
    }
}
 
开发者ID:ShiftLeftSecurity,项目名称:tinkergraph-gremlin,代码行数:21,代码来源:TinkerGraph.java


示例20: dropIndex

import org.apache.tinkerpop.gremlin.structure.Element; //导入依赖的package包/类
/**
 * Drop the index for the specified element class ({@link Vertex} or {@link Edge}) and key.
 *
 * @param key          the property key to stop indexing
 * @param elementClass the element class of the index to drop
 * @param <E>          The type of the element class
 */
public <E extends Element> void dropIndex(final String key, final Class<E> elementClass) {
    if (Vertex.class.isAssignableFrom(elementClass)) {
        if (null != this.vertexIndex) this.vertexIndex.dropKeyIndex(key);
    } else if (Edge.class.isAssignableFrom(elementClass)) {
        if (null != this.edgeIndex) this.edgeIndex.dropKeyIndex(key);
    } else {
        throw new IllegalArgumentException("Class is not indexable: " + elementClass);
    }
}
 
开发者ID:ShiftLeftSecurity,项目名称:tinkergraph-gremlin,代码行数:17,代码来源:TinkerGraph.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java MaxIterationsExceededException类代码示例发布时间:2022-05-21
下一篇:
Java Transport类代码示例发布时间:2022-05-21
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap