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

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

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

Element.value介绍

[英]Get the value of a Property given it's key. The default implementation calls Element#property and then returns the associated value.
[中]获取给定属性键的属性值。默认实现调用元素#属性,然后返回关联的值。

代码示例

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

  1. public static void verifyElementOrder(Iterator<? extends Element> elements, String key, Order order, int expectedCount) {
  2. Comparable previous = null;
  3. int count = 0;
  4. while (elements.hasNext()) {
  5. Element element = elements.next();
  6. Comparable current = element.value(key);
  7. if (previous != null) {
  8. int cmp = previous.compareTo(current);
  9. assertTrue(previous + " <> " + current + " @ " + count,
  10. order == Order.ASC ? cmp <= 0 : cmp >= 0);
  11. }
  12. previous = current;
  13. count++;
  14. }
  15. assertEquals(expectedCount, count);
  16. }

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

  1. public static void verifyElementOrder(Iterator<? extends Element> elements, String key, Order order, int expectedCount) {
  2. Comparable previous = null;
  3. int count = 0;
  4. while (elements.hasNext()) {
  5. final Element element = elements.next();
  6. final Comparable current = element.value(key);
  7. if (previous != null) {
  8. final int cmp = previous.compareTo(current);
  9. assertTrue(previous + " <> " + current + " @ " + count,
  10. order == Order.ASC ? cmp <= 0 : cmp >= 0);
  11. }
  12. previous = current;
  13. count++;
  14. }
  15. assertEquals(expectedCount, count);
  16. }

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

  1. @Override
  2. public <V> V value(final String key) throws NoSuchElementException {
  3. return this.element.value(key);
  4. }

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

  1. @Override
  2. public int compare(final Element elementA, final Element elementB) {
  3. return this.valueComparator.compare(elementA.value(this.propertyKey), elementB.value(this.propertyKey));
  4. }

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

  1. @Override
  2. public void addStart(final Traverser.Admin<Element> start) {
  3. this.value = null == this.bypassTraversal ? start.get().value(this.propertyKey) : TraversalUtil.apply(start, this.bypassTraversal);
  4. }

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

  1. /**
  2. * Retrieve the properties associated with a particular element.
  3. * The result is a Object[] where odd indices are String keys and even indices are the values.
  4. *
  5. * @param element the element to retrieve properties from
  6. * @param includeId include Element.ID in the key/value list
  7. * @param includeLabel include Element.LABEL in the key/value list
  8. * @param propertiesToCopy the properties to include with an empty list meaning copy all properties
  9. * @return a key/value array of properties where odd indices are String keys and even indices are the values.
  10. */
  11. public static Object[] getProperties(final Element element, final boolean includeId, final boolean includeLabel, final Set<String> propertiesToCopy) {
  12. final List<Object> keyValues = new ArrayList<>();
  13. if (includeId) {
  14. keyValues.add(T.id);
  15. keyValues.add(element.id());
  16. }
  17. if (includeLabel) {
  18. keyValues.add(T.label);
  19. keyValues.add(element.label());
  20. }
  21. element.keys().forEach(key -> {
  22. if (propertiesToCopy.isEmpty() || propertiesToCopy.contains(key)) {
  23. keyValues.add(key);
  24. keyValues.add(element.value(key));
  25. }
  26. });
  27. return keyValues.toArray(new Object[keyValues.size()]);
  28. }

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

  1. @Test
  2. @LoadGraphWith(MODERN)
  3. public void g_V_hasXage_isXgt_30XX() {
  4. final Traversal<Vertex, Vertex> traversal = get_g_V_hasXage_isXgt_30XX();
  5. printTraversalForm(traversal);
  6. final List<Vertex> list = traversal.toList();
  7. assertEquals(2, list.size());
  8. for (final Element v : list) {
  9. assertTrue(v.<Integer>value("age") > 30);
  10. }
  11. }

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

  1. @Test
  2. @LoadGraphWith(MODERN)
  3. public void g_V_hasXage_gt_30X() {
  4. final Traversal<Vertex, Vertex> traversal = get_g_V_hasXage_gt_30X();
  5. printTraversalForm(traversal);
  6. final List<Vertex> list = traversal.toList();
  7. assertEquals(2, list.size());
  8. for (final Element v : list) {
  9. assertTrue(v.<Integer>value("age") > 30);
  10. }
  11. }

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

  1. @Override
  2. public <V> V value(final String key) throws NoSuchElementException {
  3. return this.element.value(key);
  4. }

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

  1. @Override
  2. public int compare(final Element elementA, final Element elementB) {
  3. return this.valueComparator.compare(elementA.value(this.propertyKey), elementB.value(this.propertyKey));
  4. }

代码示例来源:origin: HuygensING/timbuctoo

  1. private void updateExistingProperties(LogOutput dbLog) {
  2. Set<String> existing = Sets.intersection(newKeys, oldKeys);
  3. existing.forEach(key -> {
  4. Property<Object> latestProperty = element.property(key);
  5. if (!Objects.equals(latestProperty.value(), prevElement.value(key))) {
  6. dbLog.updateProperty(latestProperty);
  7. }
  8. });
  9. }

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

  1. @Override
  2. public void addStart(final Traverser.Admin<Element> start) {
  3. this.value = null == this.bypassTraversal ? start.get().value(this.propertyKey) : TraversalUtil.apply(start, this.bypassTraversal);
  4. }

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

  1. /**
  2. * Retrieve the properties associated with a particular element.
  3. * The result is a Object[] where odd indices are String keys and even indices are the values.
  4. *
  5. * @param element the element to retrieve properties from
  6. * @param includeId include Element.ID in the key/value list
  7. * @param includeLabel include Element.LABEL in the key/value list
  8. * @param propertiesToCopy the properties to include with an empty list meaning copy all properties
  9. * @return a key/value array of properties where odd indices are String keys and even indices are the values.
  10. */
  11. public static Object[] getProperties(final Element element, final boolean includeId, final boolean includeLabel, final Set<String> propertiesToCopy) {
  12. final List<Object> keyValues = new ArrayList<>();
  13. if (includeId) {
  14. keyValues.add(T.id);
  15. keyValues.add(element.id());
  16. }
  17. if (includeLabel) {
  18. keyValues.add(T.label);
  19. keyValues.add(element.label());
  20. }
  21. element.keys().forEach(key -> {
  22. if (propertiesToCopy.isEmpty() || propertiesToCopy.contains(key)) {
  23. keyValues.add(key);
  24. keyValues.add(element.value(key));
  25. }
  26. });
  27. return keyValues.toArray(new Object[keyValues.size()]);
  28. }

代码示例来源:origin: MartinHaeusler/chronos

  1. @SuppressWarnings("unchecked")
  2. private void assertNamesEqual(final Object... objects) {
  3. List<Object> list = Lists.newArrayList(objects);
  4. Object last = list.get(list.size() - 1);
  5. Set<Element> elements = null;
  6. if (last instanceof Iterable) {
  7. elements = Sets.newHashSet((Iterable<Element>) last);
  8. } else if (last instanceof Iterator) {
  9. elements = Sets.newHashSet((Iterator<Element>) last);
  10. } else if (last instanceof GraphFinalizableQueryBuilder) {
  11. elements = ((GraphFinalizableQueryBuilder<Element>) last).toSet();
  12. } else {
  13. String typeName = "NULL";
  14. if (last != null) {
  15. typeName = last.getClass().getName();
  16. }
  17. fail("Last element of 'assertNamesEqual' varargs must either be a Iterable<Element> or a Iterator<Element> (found: " + typeName + ")");
  18. }
  19. Set<String> elementNames = elements.stream().map(e -> (String) e.value("name")).collect(Collectors.toSet());
  20. Set<String> names = list.subList(0, list.size() - 1).stream().map(k -> (String) k).collect(Collectors.toSet());
  21. assertEquals(names, elementNames);
  22. }

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

  1. @Test
  2. @LoadGraphWith(MODERN)
  3. public void g_V_hasXage_isXgt_30XX() {
  4. final Traversal<Vertex, Vertex> traversal = get_g_V_hasXage_isXgt_30XX();
  5. printTraversalForm(traversal);
  6. final List<Vertex> list = traversal.toList();
  7. assertEquals(2, list.size());
  8. for (final Element v : list) {
  9. assertTrue(v.<Integer>value("age") > 30);
  10. }
  11. }

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

  1. @Test
  2. @LoadGraphWith(MODERN)
  3. public void g_V_hasXage_gt_30X() {
  4. final Traversal<Vertex, Vertex> traversal = get_g_V_hasXage_gt_30X();
  5. printTraversalForm(traversal);
  6. final List<Vertex> list = traversal.toList();
  7. assertEquals(2, list.size());
  8. for (final Element v : list) {
  9. assertTrue(v.<Integer>value("age") > 30);
  10. }
  11. }

代码示例来源:origin: pietermartin/sqlg

  1. public <S, E> boolean test(final Traverser.Admin<S> traverser, final Traversal.Admin<S, E> traversal) {
  2. if (this.untilHasContainer != null) {
  3. Element e = (Element) traverser.get();
  4. return this.untilHasContainer.getPredicate().test(e.value(this.untilHasContainer.getKey()));
  5. this.untilHasContainer = this.untilHasContainers.get(0);
  6. Element e = (Element) traverser.get();
  7. return this.untilHasContainer.getPredicate().test(e.value(this.untilHasContainer.getKey()));

代码示例来源:origin: org.umlg/sqlg-core

  1. public <S, E> boolean test(final Traverser.Admin<S> traverser, final Traversal.Admin<S, E> traversal) {
  2. if (this.untilHasContainer != null) {
  3. Element e = (Element) traverser.get();
  4. return this.untilHasContainer.getPredicate().test(e.value(this.untilHasContainer.getKey()));
  5. this.untilHasContainer = this.untilHasContainers.get(0);
  6. Element e = (Element) traverser.get();
  7. return this.untilHasContainer.getPredicate().test(e.value(this.untilHasContainer.getKey()));

代码示例来源:origin: MartinHaeusler/chronos

  1. @Override
  2. public boolean apply(final V element) {
  3. ChronoElement chronoElement = (ChronoElement) element;
  4. if (chronoElement.isRemoved()) {
  5. // never consider removed elements
  6. return false;
  7. }
  8. for (SearchSpecification<?> searchSpec : this.searchSpecifications) {
  9. if (element.property(searchSpec.getProperty()).isPresent() == false) {
  10. // the property in question is not present, it is NOT possible to make
  11. // any decision if it matches the given search criterion or not. In particular,
  12. // when the search is negated (e.g. 'not equals'), we decide to have a non-match
  13. // for non-existing properties
  14. return false;
  15. }
  16. Object propertyValue = element.value(searchSpec.getProperty());
  17. boolean searchSpecApplies = ChronoGraphQueryUtil.searchSpecApplies(searchSpec, propertyValue);
  18. if (searchSpecApplies == false) {
  19. // element failed to pass this filter
  20. return false;
  21. }
  22. }
  23. // element passed all filters
  24. return true;
  25. }

代码示例来源:origin: HuygensING/timbuctoo

  1. for (; results.hasNext(); ) {
  2. Element element = results.next();
  3. String modifiedString = element.value("modified");

相关文章