org.apache.tinkerpop.gremlin.structure.Element.properties()方法的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(8.7k)|赞(0)|评价(0)|浏览(278)

本文整理了Java中org.apache.tinkerpop.gremlin.structure.Element.properties()方法的一些代码示例,展示了Element.properties()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Element.properties()方法的具体详情如下:
包路径:org.apache.tinkerpop.gremlin.structure.Element
类名称:Element
方法名:properties

Element.properties介绍

[英]Get an Iterator of properties where the propertyKeys is meant to be a filter on the available keys. If no keys are provide then return all the properties.
[中]获取属性迭代器,其中propertyKeys是可用键的过滤器。如果未提供任何键,则返回所有属性。

代码示例

代码示例来源:origin: thinkaurelius/titan

  1. @Override
  2. protected Iterator<E> flatMap(final Traverser.Admin<Element> traverser) {
  3. if (useMultiQuery) { //it is guaranteed that all elements are vertices
  4. assert multiQueryResults != null;
  5. return convertIterator(multiQueryResults.get(traverser.get()));
  6. } else if (traverser.get() instanceof Vertex) {
  7. TitanVertexQuery query = makeQuery((TitanTraversalUtil.getTitanVertex(traverser)).query());
  8. return convertIterator(query.properties());
  9. } else {
  10. //It is some other element (edge or vertex property)
  11. Iterator<E> iter;
  12. if (getReturnType().forValues()) {
  13. assert orders.isEmpty() && hasContainers.isEmpty();
  14. iter = traverser.get().values(getPropertyKeys());
  15. } else {
  16. //this asks for properties
  17. assert orders.isEmpty();
  18. //HasContainers don't apply => empty result set
  19. if (!hasContainers.isEmpty()) return Collections.emptyIterator();
  20. iter = (Iterator<E>) traverser.get().properties(getPropertyKeys());
  21. }
  22. if (limit!=Query.NO_LIMIT) iter = Iterators.limit(iter,limit);
  23. return iter;
  24. }
  25. }

代码示例来源:origin: JanusGraph/janusgraph

  1. @Override
  2. protected Iterator<E> flatMap(final Traverser.Admin<Element> traverser) {
  3. if (useMultiQuery) { //it is guaranteed that all elements are vertices
  4. assert multiQueryResults != null;
  5. return convertIterator(multiQueryResults.get(traverser.get()));
  6. } else if (traverser.get() instanceof JanusGraphVertex || traverser.get() instanceof WrappedVertex) {
  7. final JanusGraphVertexQuery query = makeQuery((JanusGraphTraversalUtil.getJanusGraphVertex(traverser)).query());
  8. return convertIterator(query.properties());
  9. } else {
  10. //It is some other element (edge or vertex property)
  11. Iterator<E> iterator;
  12. if (getReturnType().forValues()) {
  13. assert orders.isEmpty() && hasContainers.isEmpty();
  14. iterator = traverser.get().values(getPropertyKeys());
  15. } else {
  16. //this asks for properties
  17. assert orders.isEmpty();
  18. //HasContainers don't apply => empty result set
  19. if (!hasContainers.isEmpty()) return Collections.emptyIterator();
  20. iterator = (Iterator<E>) traverser.get().properties(getPropertyKeys());
  21. }
  22. if (limit!=Query.NO_LIMIT) iterator = Iterators.limit(iterator,limit);
  23. return iterator;
  24. }
  25. }

代码示例来源:origin: apache/tinkerpop

  1. public static Map<String, Property> propertyMap(final Element element, final String... propertyKeys) {
  2. final Map<String, Property> propertyMap = new HashMap<>();
  3. element.properties(propertyKeys).forEachRemaining(property -> propertyMap.put(property.key(), property));
  4. return propertyMap;
  5. }

代码示例来源:origin: apache/tinkerpop

  1. /**
  2. * Get the keys of the properties associated with this element.
  3. * The default implementation iterators the properties and stores the keys into a {@link HashSet}.
  4. *
  5. * @return The property key set
  6. */
  7. public default Set<String> keys() {
  8. final Set<String> keys = new HashSet<>();
  9. this.properties().forEachRemaining(property -> keys.add(property.key()));
  10. return Collections.unmodifiableSet(keys);
  11. }

代码示例来源:origin: apache/tinkerpop

  1. /**
  2. * Add or set a property value for the {@code Element} given its key.
  3. */
  4. public <V> Property<V> property(final String key, final V value);

代码示例来源:origin: apache/tinkerpop

  1. public static Map<String, Object> propertyValueMap(final Element element, final String... propertyKeys) {
  2. final Map<String, Object> values = new HashMap<>();
  3. element.properties(propertyKeys).forEachRemaining(property -> values.put(property.key(), property.value()));
  4. return values;
  5. }

代码示例来源:origin: apache/tinkerpop

  1. @Override
  2. public <V> Iterator<? extends Property<V>> properties(final String... propertyKeys) {
  3. return (Iterator) IteratorUtils.filter(this.element.properties(propertyKeys), property -> !computeKeys.contains(property.key()));
  4. }

代码示例来源:origin: apache/tinkerpop

  1. /**
  2. * Get the values of properties as an {@link Iterator}.
  3. */
  4. public default <V> Iterator<V> values(final String... propertyKeys) {
  5. return IteratorUtils.map(this.<V>properties(propertyKeys), property -> property.value());
  6. }

代码示例来源:origin: apache/tinkerpop

  1. private static void writeElementProperties(final KryoShim kryo, final OutputShim output, final Element element) {
  2. final Iterator<? extends Property> properties = element.properties();
  3. output.writeBoolean(properties.hasNext());
  4. while (properties.hasNext()) {
  5. final Property p = properties.next();
  6. output.writeString(p.key());
  7. kryo.writeClassAndObject(output, p.value());
  8. output.writeBoolean(properties.hasNext());
  9. }
  10. }
  11. }

代码示例来源:origin: apache/tinkerpop

  1. @Override
  2. protected Iterator<E> flatMap(final Traverser.Admin<Element> traverser) {
  3. return this.returnType.equals(PropertyType.VALUE) ?
  4. traverser.get().values(this.propertyKeys) :
  5. (Iterator) traverser.get().properties(this.propertyKeys);
  6. }

代码示例来源:origin: apache/tinkerpop

  1. element.properties(this.propertyKeys) :
  2. TraversalUtil.applyAll(traverser, this.propertyTraversal);

代码示例来源:origin: apache/tinkerpop

  1. public final boolean test(final Element element) {
  2. // it is OK to evaluate equality of ids via toString(), given that the test suite enforces the value of
  3. // id().toString() to be a first class representation of the identifier. a string test is only executed
  4. // if the predicate value is a String. this allows stuff like: g.V().has(id,lt(10)) to work properly
  5. if (this.key.equals(T.id.getAccessor()))
  6. return testingIdString ? testIdAsString(element) : testId(element);
  7. else if (this.key.equals(T.label.getAccessor()))
  8. return testLabel(element);
  9. else if (element instanceof VertexProperty && this.key.equals(T.value.getAccessor()))
  10. return testValue((VertexProperty) element);
  11. else if (element instanceof VertexProperty && this.key.equals(T.key.getAccessor()))
  12. return testKey((VertexProperty) element);
  13. else {
  14. if (element instanceof Vertex) {
  15. final Iterator<? extends Property> itty = element.properties(this.key);
  16. while (itty.hasNext()) {
  17. if (testValue(itty.next()))
  18. return true;
  19. }
  20. return false;
  21. } else {
  22. final Property property = element.property(this.key);
  23. return property.isPresent() && testValue(property);
  24. }
  25. }
  26. }

代码示例来源:origin: org.jboss.windup.graph/windup-graph-api

  1. @Override
  2. public void deinit(Element element)
  3. {
  4. element.properties(WindupFrame.TYPE_PROP).forEachRemaining(Property::remove);
  5. }

代码示例来源:origin: org.apache.tinkerpop/gremlin-core

  1. public static Map<String, Property> propertyMap(final Element element, final String... propertyKeys) {
  2. final Map<String, Property> propertyMap = new HashMap<>();
  3. element.properties(propertyKeys).forEachRemaining(property -> propertyMap.put(property.key(), property));
  4. return propertyMap;
  5. }

代码示例来源:origin: org.apache.tinkerpop/gremlin-core

  1. /**
  2. * Get the keys of the properties associated with this element.
  3. * The default implementation iterators the properties and stores the keys into a {@link HashSet}.
  4. *
  5. * @return The property key set
  6. */
  7. public default Set<String> keys() {
  8. final Set<String> keys = new HashSet<>();
  9. this.properties().forEachRemaining(property -> keys.add(property.key()));
  10. return Collections.unmodifiableSet(keys);
  11. }

代码示例来源:origin: org.apache.tinkerpop/gremlin-core

  1. public static Map<String, Object> propertyValueMap(final Element element, final String... propertyKeys) {
  2. final Map<String, Object> values = new HashMap<>();
  3. element.properties(propertyKeys).forEachRemaining(property -> values.put(property.key(), property.value()));
  4. return values;
  5. }

代码示例来源:origin: rmagen/elastic-gremlin

  1. private Map propertiesMap(Element element) {
  2. if(element instanceof BaseElement)
  3. return ((BaseElement)element).allFields();
  4. Map<String, Object> map = new HashMap<>();
  5. element.properties().forEachRemaining(property -> map.put(property.key(), property.value()));
  6. return map;
  7. }

代码示例来源:origin: org.apache.tinkerpop/gremlin-core

  1. /**
  2. * Get the values of properties as an {@link Iterator}.
  3. */
  4. public default <V> Iterator<V> values(final String... propertyKeys) {
  5. return IteratorUtils.map(this.<V>properties(propertyKeys), property -> property.value());
  6. }

代码示例来源:origin: unipop-graph/unipop

  1. public static <E extends Element> Map<String, Object> fullProperties(E element) {
  2. Map<String, Object> properties = new HashMap<>();
  3. properties.put(T.id.getAccessor(), element.id());
  4. properties.put(T.label.getAccessor(), element.label());
  5. element.properties().forEachRemaining(property -> properties.put(property.key(), property.value()));
  6. return properties;
  7. }

代码示例来源:origin: org.apache.tinkerpop/gremlin-core

  1. private static void writeElementProperties(final KryoShim kryo, final OutputShim output, final Element element) {
  2. final Iterator<? extends Property> properties = element.properties();
  3. output.writeBoolean(properties.hasNext());
  4. while (properties.hasNext()) {
  5. final Property p = properties.next();
  6. output.writeString(p.key());
  7. kryo.writeClassAndObject(output, p.value());
  8. output.writeBoolean(properties.hasNext());
  9. }
  10. }
  11. }

相关文章