/** * Returns the number of properties that match this query * * @return Number of properties that match this query */ public default long propertyCount() { return Iterables.size(properties()); }
public Iterable<TitanRelation> executeQuery(TitanVertexQuery query) { switch (this) { case EDGE: return (Iterable)query.edges(); case PROPERTY: return (Iterable)query.properties(); case RELATION: return query.relations(); default: throw new AssertionError(); } }
public static Set<String> getPropertyKeys(TitanVertex v) { final Set<String> s = new HashSet<>(); v.query().properties().forEach( p -> s.add(p.propertyKey().name())); return s; }
public static Iterable<Object> getValues(TitanElement element, PropertyKey key) { if (element instanceof TitanRelation) { Object value = element.valueOrNull(key); if (value==null) return Collections.EMPTY_LIST; else return ImmutableList.of(value); } else { assert element instanceof TitanVertex; return Iterables.transform((((TitanVertex) element).query()).keys(key.name()).properties(), new Function<TitanVertexProperty, Object>() { @Nullable @Override public Object apply(@Nullable TitanVertexProperty titanProperty) { return titanProperty.value(); } }); } }
private int getPartitionIDbyKey(TitanVertex vertex) { Preconditions.checkState(idManager!=null && key!=null,"PropertyPlacementStrategy has not been initialized correctly"); assert idManager.getPartitionBound()<=Integer.MAX_VALUE; int partitionBound = (int)idManager.getPartitionBound(); TitanVertexProperty p = (TitanVertexProperty)Iterables.getFirst(vertex.query().keys(key).properties(),null); if (p==null) return -1; int hashPid = Math.abs(p.value().hashCode())%partitionBound; assert hashPid>=0 && hashPid<partitionBound; if (isExhaustedPartition(hashPid)) { //We keep trying consecutive partition ids until we find a non-exhausted one int newPid=hashPid; do { newPid = (newPid+1)%partitionBound; if (newPid==hashPid) //We have gone full circle - no more ids to try throw new IDPoolExhaustedException("Could not find non-exhausted partition"); } while (isExhaustedPartition(newPid)); return newPid; } else return hashPid; } }
@Override protected Iterator<E> flatMap(final Traverser.Admin<Element> traverser) { if (useMultiQuery) { //it is guaranteed that all elements are vertices assert multiQueryResults != null; return convertIterator(multiQueryResults.get(traverser.get())); } else if (traverser.get() instanceof Vertex) { TitanVertexQuery query = makeQuery((TitanTraversalUtil.getTitanVertex(traverser)).query()); return convertIterator(query.properties()); } else { //It is some other element (edge or vertex property) Iterator<E> iter; if (getReturnType().forValues()) { assert orders.isEmpty() && hasContainers.isEmpty(); iter = traverser.get().values(getPropertyKeys()); } else { //this asks for properties assert orders.isEmpty(); //HasContainers don't apply => empty result set if (!hasContainers.isEmpty()) return Collections.emptyIterator(); iter = (Iterator<E>) traverser.get().properties(getPropertyKeys()); } if (limit!=Query.NO_LIMIT) iter = Iterators.limit(iter,limit); return iter; } }
props = qb.properties(); } else { props = vertex.query().keys(key.name()).properties();
case PROPERTY: elements = Lists.newArrayList(); for (TitanVertexProperty p : addIndexSchemaConstraint(vertex.query(),indexType).properties()) { elements.add(p);
switch (resultType) { case PROPERTY: result = query.properties(); break; case EDGE:
int sum = 0; int index = values.size(); for (TitanVertexProperty<String> p : v.query().labels(foo).properties()) { assertTrue(values.contains(p.value())); int wint = p.value(weight);
assertEquals(10.12345, v.<Double>value("precise").doubleValue(), 0.000001); assertCount(3, v.properties("any")); for (TitanVertexProperty prop : v.query().labels("any").properties()) { Object value = prop.value(); if (value instanceof String) assertEquals("Hello", value); assertEquals(10.12345, v.<Double>value("precise").doubleValue(), 0.000001); assertCount(3, v.properties("any")); for (TitanVertexProperty prop : v.query().labels("any").properties()) { Object value = prop.value(); if (value instanceof String) assertEquals("Hello", value);
assertEquals(1, size(v.query().properties())); assertEquals(1, size(v.query().keys("name").properties())); assertEquals(1, size(v.query().properties())); assertEquals(1, size(v.query().keys("name").properties()));
assertEquals("v1", v.value("uid")); assertCount(2, v.properties("name")); for (TitanVertexProperty<String> prop : v.query().labels("name").properties()) { String nstr = prop.value(); assertTrue(nstr.equals("Bob") || nstr.equals("John")); for (TitanVertexProperty<Double> prop : v.query().labels("value").properties()) { double prec = prop.value().doubleValue(); assertEquals(prec * 2, prop.<Number>value("weight").doubleValue(), 0.00001); assertEquals("v1", v.value("uid")); assertCount(2, v.properties("name")); for (TitanVertexProperty<String> prop : v.query().labels("name").properties()) { String nstr = prop.value(); assertTrue(nstr.equals("Bob") || nstr.equals("John")); assertTrue(Iterables.size(v.query().labels("value").properties()) >= 3); for (TitanVertexProperty<Double> prop : v.query().labels("value").properties()) { double prec = prop.value().doubleValue(); assertEquals(prec * 2, prop.<Number>value("weight").doubleValue(), 0.00001);
/** * Returns the number of properties that match this query * * @return Number of properties that match this query */ public default long propertyCount() { return Iterables.size(properties()); }
public Iterable<TitanRelation> executeQuery(TitanVertexQuery query) { switch (this) { case EDGE: return (Iterable)query.edges(); case PROPERTY: return (Iterable)query.properties(); case RELATION: return query.relations(); default: throw new AssertionError(); } }
public Iterable<TitanRelation> executeQuery(TitanVertexQuery query) { switch (this) { case EDGE: return (Iterable)query.edges(); case PROPERTY: return (Iterable)query.properties(); case RELATION: return query.relations(); default: throw new AssertionError(); } }
public static Set<String> getPropertyKeys(TitanVertex v) { final Set<String> s = new HashSet<>(); v.query().properties().forEach( p -> s.add(p.propertyKey().name())); return s; }
public static final Iterable<Object> getValues(TitanElement element, PropertyKey key) { if (element instanceof TitanRelation) { Object value = element.getProperty(key); if (value==null) return Collections.EMPTY_LIST; else return ImmutableList.of(value); } else { assert element instanceof TitanVertex; return Iterables.transform((((TitanVertex) element).query()).keys(key.getName()).properties(), new Function<TitanProperty, Object>() { @Nullable @Override public Object apply(@Nullable TitanProperty titanProperty) { return titanProperty.getValue(); } }); } }
public static Iterable<Object> getValues(TitanElement element, PropertyKey key) { if (element instanceof TitanRelation) { Object value = element.valueOrNull(key); if (value==null) return Collections.EMPTY_LIST; else return ImmutableList.of(value); } else { assert element instanceof TitanVertex; return Iterables.transform((((TitanVertex) element).query()).keys(key.name()).properties(), new Function<TitanVertexProperty, Object>() { @Nullable @Override public Object apply(@Nullable TitanVertexProperty titanProperty) { return titanProperty.value(); } }); } }
for (TitanVertexProperty<String> p : v.query().labels("name").properties()) { if (p.<Long>value("time") < (numV / 2)) p.remove();