|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.hypergraphdb.HGQuery.hg
public static final class HGQuery.hg
This class serves as a namespace to a set of syntactically concise functions for constructing HyperGraph query conditions and performing HyperGraph queries. With a Java 5+ compiler, you can import the class into your file's namespace and build HG condition with a much simpler syntax than constructing the expression tree explicitly. For example:
...other imports ...
import org.hypergraphdb.HGQuery.hg;
public void f(HyperGraph graph)
{
// find all link with weight > 1.5
HGSearchResult rs = graph.find(hg.and(hg.type(MyLink.class), hg.gt("weight", 1.5)));
}
or, even more concisely, if there is no naming conflict, import all the function names directly:
...other imports ...
import org.hypergraphdb.HGQuery.hg.*;
public void f(HyperGraph graph)
{
// find all link with weight > 1.5
HGSearchResult rs = graph.find(and(type(MyLink.class), gt("weight", 1.5)));
}
In addition, several methods names get* and find* will
execute queries and return their results in the form of individual objects or Java
collections, thus saving you from the burden of paying attention to always properly
close result sets.
| Constructor Summary | |
|---|---|
HGQuery.hg()
|
|
| Method Summary | ||
|---|---|---|
static HGHandle |
addUnique(HyperGraph graph,
java.lang.Object instance,
java.lang.Class javaClass,
HGQueryCondition condition)
|
|
static HGHandle |
addUnique(HyperGraph graph,
java.lang.Object instance,
HGHandle typeHandle,
HGQueryCondition condition)
|
|
static HGHandle |
addUnique(HyperGraph graph,
java.lang.Object instance,
HGQueryCondition condition)
|
|
static HGQueryCondition |
all()
|
|
static And |
and(HGQueryCondition... clauses)
|
|
static HGHandle |
anyHandle()
|
|
static HGQueryCondition |
apply(Mapping<?,?> m,
HGQueryCondition c)
|
|
static ArityCondition |
arity(int i)
|
|
static BFSCondition |
bfs(HGHandle start)
|
|
static BFSCondition |
bfs(HGHandle start,
HGAtomPredicate lp,
HGAtomPredicate sp)
|
|
static BFSCondition |
bfs(HGHandle start,
HGAtomPredicate lp,
HGAtomPredicate sp,
boolean returnPreceeding,
boolean returnSucceeding)
|
|
static long |
count(HGQuery<?> query)
Count the result set from executing the given query. |
|
static long |
count(HyperGraph graph,
HGQueryCondition cond)
Count the number of atoms that match the query condition parameter. |
|
static Mapping<HGHandle,java.lang.Object> |
deref(HyperGraph graph)
|
|
static DFSCondition |
dfs(HGHandle start)
|
|
static DFSCondition |
dfs(HGHandle start,
HGAtomPredicate lp,
HGAtomPredicate sp)
|
|
static DFSCondition |
dfs(HGHandle start,
HGAtomPredicate lp,
HGAtomPredicate sp,
boolean returnPreceeding,
boolean returnSucceeding)
|
|
static AtomValueCondition |
eq(java.lang.Object x)
|
|
static AtomPartCondition |
eq(java.lang.String path,
java.lang.Object x)
|
|
static
|
findAll(HGQuery<T> query)
|
|
static
|
findAll(HyperGraph graph,
HGQueryCondition condition)
Run a query based on the specified condition and put all HGHandles
from the result set into a java.util.List. |
|
static
|
findOne(HyperGraph graph,
HGQueryCondition condition)
Run a query based on the passed in condition. |
|
static
|
getAll(HyperGraph graph,
HGQueryCondition condition)
Run a query based on the specified condition and put all atom instances from the result set into a java.util.List. |
|
static
|
getOne(HyperGraph graph,
HGQueryCondition condition)
Run a query based on the passed in condition. |
|
static AtomValueCondition |
gt(java.lang.Object x)
|
|
static AtomPartCondition |
gt(java.lang.String path,
java.lang.Object x)
|
|
static AtomValueCondition |
gte(java.lang.Object x)
|
|
static AtomPartCondition |
gte(java.lang.String path,
java.lang.Object x)
|
|
static IncidentCondition |
incident(HGHandle h)
|
|
static LinkCondition |
link(HGHandle... h)
|
|
static Mapping<HGLink,HGHandle> |
linkProjection(int targetPosition)
|
|
static AtomValueCondition |
lt(java.lang.Object x)
|
|
static AtomPartCondition |
lt(java.lang.String path,
java.lang.Object x)
|
|
static AtomValueCondition |
lte(java.lang.Object x)
|
|
static AtomPartCondition |
lte(java.lang.String path,
java.lang.Object x)
|
|
static Not |
not(HGAtomPredicate c)
|
|
static Or |
or(HGQueryCondition... clauses)
|
|
static OrderedLinkCondition |
orderedLink(HGHandle... h)
|
|
static AtomPartCondition |
part(java.lang.String path,
java.lang.Object value,
ComparisonOperator op)
|
|
static SubsumedCondition |
subsumed(HGHandle h)
|
|
static SubsumesCondition |
subsumes(HGHandle h)
|
|
static TargetCondition |
target(HGHandle h)
|
|
static Mapping<HGHandle,HGHandle> |
targetAt(HyperGraph graph,
int targetPosition)
|
|
static AtomTypeCondition |
type(java.lang.Class<?> c)
|
|
static AtomTypeCondition |
type(HGHandle h)
|
|
static TypePlusCondition |
typePlus(java.lang.Class<?> c)
|
|
static TypePlusCondition |
typePlus(HGHandle h)
|
|
static AtomValueCondition |
value(java.lang.Object value,
ComparisonOperator op)
|
|
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public HGQuery.hg()
| Method Detail |
|---|
public static HGHandle addUnique(HyperGraph graph,
java.lang.Object instance,
HGQueryCondition condition)
public static HGHandle addUnique(HyperGraph graph,
java.lang.Object instance,
HGHandle typeHandle,
HGQueryCondition condition)
public static HGHandle addUnique(HyperGraph graph,
java.lang.Object instance,
java.lang.Class javaClass,
HGQueryCondition condition)
public static AtomTypeCondition type(HGHandle h)
public static AtomTypeCondition type(java.lang.Class<?> c)
public static TypePlusCondition typePlus(HGHandle h)
public static TypePlusCondition typePlus(java.lang.Class<?> c)
public static SubsumesCondition subsumes(HGHandle h)
public static SubsumedCondition subsumed(HGHandle h)
public static And and(HGQueryCondition... clauses)
public static Or or(HGQueryCondition... clauses)
public static Not not(HGAtomPredicate c)
public static TargetCondition target(HGHandle h)
public static IncidentCondition incident(HGHandle h)
public static LinkCondition link(HGHandle... h)
public static OrderedLinkCondition orderedLink(HGHandle... h)
public static ArityCondition arity(int i)
public static AtomValueCondition value(java.lang.Object value,
ComparisonOperator op)
public static AtomValueCondition eq(java.lang.Object x)
public static AtomValueCondition lt(java.lang.Object x)
public static AtomValueCondition gt(java.lang.Object x)
public static AtomValueCondition lte(java.lang.Object x)
public static AtomValueCondition gte(java.lang.Object x)
public static AtomPartCondition part(java.lang.String path,
java.lang.Object value,
ComparisonOperator op)
public static AtomPartCondition eq(java.lang.String path,
java.lang.Object x)
public static AtomPartCondition lt(java.lang.String path,
java.lang.Object x)
public static AtomPartCondition gt(java.lang.String path,
java.lang.Object x)
public static AtomPartCondition lte(java.lang.String path,
java.lang.Object x)
public static AtomPartCondition gte(java.lang.String path,
java.lang.Object x)
public static HGQueryCondition apply(Mapping<?,?> m,
HGQueryCondition c)
public static Mapping<HGLink,HGHandle> linkProjection(int targetPosition)
public static Mapping<HGHandle,java.lang.Object> deref(HyperGraph graph)
public static Mapping<HGHandle,HGHandle> targetAt(HyperGraph graph,
int targetPosition)
public static HGQueryCondition all()
public static BFSCondition bfs(HGHandle start)
public static BFSCondition bfs(HGHandle start,
HGAtomPredicate lp,
HGAtomPredicate sp)
public static BFSCondition bfs(HGHandle start,
HGAtomPredicate lp,
HGAtomPredicate sp,
boolean returnPreceeding,
boolean returnSucceeding)
public static DFSCondition dfs(HGHandle start)
public static DFSCondition dfs(HGHandle start,
HGAtomPredicate lp,
HGAtomPredicate sp)
public static DFSCondition dfs(HGHandle start,
HGAtomPredicate lp,
HGAtomPredicate sp,
boolean returnPreceeding,
boolean returnSucceeding)
public static HGHandle anyHandle()
public static long count(HyperGraph graph,
HGQueryCondition cond)
Count the number of atoms that match the query condition parameter. Retrieving
the count might require performing the actual query traversing the result set.
In cases where the condition is simple and the count is available directly from
an index, it is returned right away. Otherwise, the operation may be expensive
when the result set matching cond is large or it takes time
to obtain it.
graph - The HyperGraph against which the counting is performed.cond - The condition specifying the result set.
public static long count(HGQuery<?> query)
Count the result set from executing the given query. The query is executed and the result set scanned completely.
query -
public static <T> T getOne(HyperGraph graph,
HGQueryCondition condition)
Run a query based on the passed in condition. If the result set is not
empty, get and return the atom instance of the first element. Otherwise,
return null.
graph - The HyperGraph database to query.condition - The query condition.
public static <T> T findOne(HyperGraph graph,
HGQueryCondition condition)
Run a query based on the passed in condition. If the result set is not
empty, return the first HGHandle element. Otherwise,
return null.
graph - condition -
public static <T> java.util.List<T> findAll(HyperGraph graph,
HGQueryCondition condition)
Run a query based on the specified condition and put all HGHandles
from the result set into a java.util.List.
graph - condition -
public static <T> java.util.List<T> getAll(HyperGraph graph,
HGQueryCondition condition)
Run a query based on the specified condition and put all atom instances
from the result set into a java.util.List.
graph - condition -
public static <T> java.util.List<T> findAll(HGQuery<T> query)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||