Java Code Examples for org.apache.tinkerpop.gremlin.process.traversal.step.util.ElementValueComparator#getValueComparator()
The following examples show how to use
org.apache.tinkerpop.gremlin.process.traversal.step.util.ElementValueComparator#getValueComparator() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: HasStepFolder.java From grakn with GNU Affero General Public License v3.0 | 6 votes |
static boolean validJanusGraphOrder(OrderGlobalStep orderGlobalStep, Traversal rootTraversal, boolean isVertexOrder) { List<Pair<Traversal.Admin, Object>> comparators = orderGlobalStep.getComparators(); for (Pair<Traversal.Admin, Object> comp : comparators) { String key; if (comp.getValue0() instanceof ElementValueTraversal && comp.getValue1() instanceof Order) { key = ((ElementValueTraversal) comp.getValue0()).getPropertyKey(); } else if (comp.getValue1() instanceof ElementValueComparator) { ElementValueComparator evc = (ElementValueComparator) comp.getValue1(); if (!(evc.getValueComparator() instanceof Order)) return false; key = evc.getPropertyKey(); } else { // do not fold comparators that include nested traversals that are not simple ElementValues return false; } JanusGraphTransaction tx = JanusGraphTraversalUtil.getTx(rootTraversal.asAdmin()); PropertyKey pKey = tx.getPropertyKey(key); if (pKey == null || !(Comparable.class.isAssignableFrom(pKey.dataType())) || (isVertexOrder && pKey.cardinality() != Cardinality.SINGLE)) { return false; } } return true; }
Example 2
Source File: HasStepFolder.java From titan1withtp3.1 with Apache License 2.0 | 5 votes |
public static boolean validTitanOrder(OrderGlobalStep ostep, Traversal rootTraversal, boolean isVertexOrder) { for (Comparator comp : (List<Comparator>) ostep.getComparators()) { if (!(comp instanceof ElementValueComparator)) return false; ElementValueComparator evc = (ElementValueComparator) comp; if (!(evc.getValueComparator() instanceof Order)) return false; TitanTransaction tx = TitanTraversalUtil.getTx(rootTraversal.asAdmin()); String key = evc.getPropertyKey(); PropertyKey pkey = tx.getPropertyKey(key); if (pkey == null || !(Comparable.class.isAssignableFrom(pkey.dataType()))) return false; if (isVertexOrder && pkey.cardinality() != Cardinality.SINGLE) return false; } return true; }