Package org.apache.jackrabbit.core.query
Interface QueryHandler
-
- All Known Implementing Classes:
AbstractQueryHandler,SearchIndex
public interface QueryHandlerDefines an interface for the actual node indexing and query execution. The goal is to allow different implementations based on the persistent manager in use. Some persistent model might allow to execute a query in an optimized manner, e.g. database persistence.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description voidaddNode(NodeState node)Adds aNodeto the search index.voidclose()Closes thisQueryHandlerand frees resources attached to this handler.ExecutableQuerycreateExecutableQuery(SessionContext sessionContext, String statement, String language)Creates a new query by specifying the query statement itself and the language in which the query is stated.voiddeleteNode(NodeId id)Deletes the Node withidfrom the search index.QueryHandlerContextgetContext()Returns the query handler context that passed ininit(FileSystem, QueryHandlerContext).StringgetQueryClass()Iterable<NodeId>getWeaklyReferringNodes(NodeId id)Returns the ids of the nodes that refer to the node withidby weak references.voidinit(FileSystem fs, QueryHandlerContext context)Initializes this query handler.voidupdateNodes(Iterator<NodeId> remove, Iterator<NodeState> add)Updates the index in an atomic operation.
-
-
-
Method Detail
-
init
void init(FileSystem fs, QueryHandlerContext context) throws IOException
Initializes this query handler. This method is called after theQueryHandleris instantiated.If a file system has been configured (i.e. the fs argument is not
null), then the query handler is expected to close the given file system when theclose()method is called.- Parameters:
fs- the configured search index file system, ornullcontext- the context for this query handler.- Throws:
IOException- if an error occurs during initialization.
-
getContext
QueryHandlerContext getContext()
Returns the query handler context that passed ininit(FileSystem, QueryHandlerContext).- Returns:
- the query handler context.
-
addNode
void addNode(NodeState node) throws RepositoryException, IOException
Adds aNodeto the search index.- Parameters:
node- the NodeState to add.- Throws:
RepositoryException- if an error occurs while indexing the node.IOException- if an error occurs while adding the node to the index.
-
deleteNode
void deleteNode(NodeId id) throws IOException
Deletes the Node withidfrom the search index.- Parameters:
id- theidof the node to delete.- Throws:
IOException- if an error occurs while deleting the node.
-
updateNodes
void updateNodes(Iterator<NodeId> remove, Iterator<NodeState> add) throws RepositoryException, IOException
Updates the index in an atomic operation. Some nodes may be removed and added again in the same updateNodes() call, which is equivalent to an node update.- Parameters:
remove- Iterator ofNodeIdsof nodes to deleteadd- Iterator ofNodeStateinstance to add to the index.- Throws:
RepositoryException- if an error occurs while indexing a node.IOException- if an error occurs while updating the index.
-
close
void close() throws IOExceptionCloses thisQueryHandlerand frees resources attached to this handler.- Throws:
IOException
-
createExecutableQuery
ExecutableQuery createExecutableQuery(SessionContext sessionContext, String statement, String language) throws InvalidQueryException
Creates a new query by specifying the query statement itself and the language in which the query is stated. If the query statement is syntactically invalid, given the language specified, an InvalidQueryException is thrown.languagemust specify a query language string from among those returned by QueryManager.getSupportedQueryLanguages(); if it is not then anInvalidQueryExceptionis thrown.- Parameters:
sessionContext- component context of the current sessionstatement- the query statement.language- the syntax of the query statement.- Returns:
- A
Queryobject. - Throws:
InvalidQueryException- if statement is invalid or language is unsupported.
-
getQueryClass
String getQueryClass()
- Returns:
- the name of the query class to use.
-
getWeaklyReferringNodes
Iterable<NodeId> getWeaklyReferringNodes(NodeId id) throws RepositoryException, IOException
Returns the ids of the nodes that refer to the node withidby weak references.- Parameters:
id- the id of the target node.- Returns:
- the ids of the referring nodes.
- Throws:
RepositoryException- if an error occurs.IOException- if an error occurs while reading from the index.
-
-