Skip to content

Commit

Permalink
Fixes #859
Browse files Browse the repository at this point in the history
  • Loading branch information
mbroecheler committed Apr 18, 2015
1 parent 867fb39 commit bdefb1f
Show file tree
Hide file tree
Showing 4 changed files with 115 additions and 112 deletions.
@@ -1,5 +1,6 @@
package com.thinkaurelius.titan.core; package com.thinkaurelius.titan.core;


import com.google.common.collect.Iterables;
import com.thinkaurelius.titan.graphdb.query.TitanPredicate; import com.thinkaurelius.titan.graphdb.query.TitanPredicate;
import org.apache.tinkerpop.gremlin.structure.Direction; import org.apache.tinkerpop.gremlin.structure.Direction;
import org.apache.tinkerpop.gremlin.structure.Order; import org.apache.tinkerpop.gremlin.structure.Order;
Expand Down Expand Up @@ -95,19 +96,32 @@ public interface TitanVertexQuery<Q extends TitanVertexQuery<Q>> extends BaseVer
*/ */
public Iterable<TitanRelation> relations(); public Iterable<TitanRelation> relations();


/**
* Returns the number of relations that match this query
*
* @return Number of relations that match this query
*/
public default long count() {
return Iterables.size(relations());
}

/** /**
* Returns the number of edges that match this query * Returns the number of edges that match this query
* *
* @return Number of edges that match this query * @return Number of edges that match this query
*/ */
public long count(); public default long edgeCount() {
return vertexIds().size();
}


/** /**
* Returns the number of properties that match this query * Returns the number of properties that match this query
* *
* @return Number of properties that match this query * @return Number of properties that match this query
*/ */
public long propertyCount(); public default long propertyCount() {
return Iterables.size(properties());
}


/** /**
* Retrieves all vertices connected to this query's base vertex by edges * Retrieves all vertices connected to this query's base vertex by edges
Expand Down
Expand Up @@ -105,15 +105,4 @@ public VertexList vertexIds() {
return execute(RelationCategory.EDGE,new VertexIdConstructor()); return execute(RelationCategory.EDGE,new VertexIdConstructor());
} }


//#### COUNTS

@Override
public long count() {
return vertexIds().size();
}

@Override
public long propertyCount() {
return Iterables.size(properties());
}
} }

0 comments on commit bdefb1f

Please sign in to comment.