|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.accumulo.examples.wikisearch.logic.AbstractQueryLogic
public abstract class AbstractQueryLogic
Overview
Query implementation that works with the JEXL grammar. This uses the metadata, global index, and partitioned table to return results based on the query. Example queries: Single Term Query 'foo' - looks in global index for foo, and if any entries are found, then the query is rewritten to be field1 == 'foo' or field2 == 'foo', etc. This is then passed down the optimized query path which uses the intersecting iterators on the partitioned table. Boolean expression field == 'foo' - For fielded queries, those that contain a field, an operator, and a literal (string or number), the query is parsed and the set of eventFields in the query that are indexed is determined by querying the metadata table. Depending on the conjunctions in the query (or, and, not) and the eventFields that are indexed, the query may be sent down the optimized path or the full scan path. We are not supporting all of the operators that JEXL supports at this time. We are supporting the following operators: ==, !=, >, ≥, <, ≤, =~, and !~ Custom functions can be created and registered with the Jexl engine. The functions can be used in the queries in conjunction with other supported operators. A sample function has been created, called between, and is bound to the 'f' namespace. An example using this function is : "f:between(LATITUDE,60.0, 70.0)"Constraints on Query Structure
Queries that are sent to this class need to be formatted such that there is a space on either side of the operator. We are rewriting the query in some cases and the current implementation is expecting a space on either side of the operator. If an error occurs in the evaluation we are skipping the event.Notes on Optimization
Queries that meet any of the following criteria will perform a full scan of the events in the partitioned table: 1. An 'or' conjunction exists in the query but not all of the terms are indexed. 2. No indexed terms exist in the query 3. An unsupported operator exists in the query
Nested Class Summary | |
---|---|
static class |
AbstractQueryLogic.IndexRanges
Object that is used to hold ranges found in the index. |
static class |
AbstractQueryLogic.UnionIndexRanges
Object that computes the ranges by unioning all of the ranges for all of the terms together. |
Field Summary | |
---|---|
static String |
DATATYPE_FILTER_SET
Set of datatypes to limit the query to. |
protected static org.apache.log4j.Logger |
log
|
Constructor Summary | |
---|---|
AbstractQueryLogic()
|
Method Summary | |
---|---|
Document |
createDocument(Key key,
Value value)
|
protected Map<String,com.google.common.collect.Multimap<String,Class<? extends Normalizer>>> |
findIndexedTerms(Connector c,
Authorizations auths,
Set<String> queryLiterals,
Set<String> datatypes)
Queries metadata table to determine which terms are indexed. |
protected abstract Collection<Range> |
getFullScanRange(Date begin,
Date end,
com.google.common.collect.Multimap<String,QueryParser.QueryTerm> terms)
|
String |
getIndexTableName()
|
String |
getMetadataTableName()
|
int |
getQueryThreads()
|
String |
getReadAheadQueueSize()
|
String |
getReadAheadTimeOut()
|
String |
getResultsKey(Map.Entry<Key,Value> key)
|
String |
getReverseIndexTableName()
|
String |
getTableName()
|
protected abstract RangeCalculator |
getTermIndexInformation(Connector c,
Authorizations auths,
com.google.common.collect.Multimap<String,Normalizer> indexedTerms,
com.google.common.collect.Multimap<String,QueryParser.QueryTerm> terms,
String indexTableName,
String reverseIndexTableName,
String queryString,
int queryThreads,
Set<String> datatypes)
Performs a lookup in the global index / reverse index and returns a RangeCalculator |
protected abstract AbstractQueryLogic.IndexRanges |
getTermIndexInformation(Connector c,
Authorizations auths,
String value,
Set<String> datatypes)
Performs a lookup in the global index for a single non-fielded term. |
List<String> |
getUnevaluatedFields()
|
boolean |
isUseReadAheadIterator()
|
Results |
runQuery(Connector connector,
List<String> authorizations,
String query,
Date beginDate,
Date endDate,
Set<String> types)
|
void |
setIndexTableName(String indexTableName)
|
void |
setMetadataTableName(String metadataTableName)
|
void |
setQueryThreads(int queryThreads)
|
void |
setReadAheadQueueSize(String readAheadQueueSize)
|
void |
setReadAheadTimeOut(String readAheadTimeOut)
|
void |
setReverseIndexTableName(String reverseIndexTableName)
|
void |
setTableName(String tableName)
|
void |
setUnevaluatedFields(List<String> unevaluatedFields)
|
void |
setUnevaluatedFields(String unevaluatedFieldList)
|
void |
setUseReadAheadIterator(boolean useReadAheadIterator)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected static org.apache.log4j.Logger log
public static final String DATATYPE_FILTER_SET
Constructor Detail |
---|
public AbstractQueryLogic()
Method Detail |
---|
protected Map<String,com.google.common.collect.Multimap<String,Class<? extends Normalizer>>> findIndexedTerms(Connector c, Authorizations auths, Set<String> queryLiterals, Set<String> datatypes) throws TableNotFoundException, InstantiationException, IllegalAccessException
c
- auths
- queryLiterals
- datatypes
- - optional list of types
TableNotFoundException
IllegalAccessException
InstantiationException
protected abstract AbstractQueryLogic.IndexRanges getTermIndexInformation(Connector c, Authorizations auths, String value, Set<String> datatypes) throws TableNotFoundException
c
- auths
- value
- datatypes
- - optional list of types
TableNotFoundException
protected abstract RangeCalculator getTermIndexInformation(Connector c, Authorizations auths, com.google.common.collect.Multimap<String,Normalizer> indexedTerms, com.google.common.collect.Multimap<String,QueryParser.QueryTerm> terms, String indexTableName, String reverseIndexTableName, String queryString, int queryThreads, Set<String> datatypes) throws TableNotFoundException, org.apache.commons.jexl2.parser.ParseException
c
- Accumulo connectionauths
- authset for queriesindexedTerms
- multimap of indexed field name and Normalizers usedterms
- multimap of field name and QueryTerm objectindexTableName
- reverseIndexTableName
- queryString
- original query stringqueryThreads
- datatypes
- - optional list of types
TableNotFoundException
org.apache.commons.jexl2.parser.ParseException
protected abstract Collection<Range> getFullScanRange(Date begin, Date end, com.google.common.collect.Multimap<String,QueryParser.QueryTerm> terms)
public String getMetadataTableName()
public String getIndexTableName()
public String getTableName()
public void setMetadataTableName(String metadataTableName)
public void setIndexTableName(String indexTableName)
public void setTableName(String tableName)
public int getQueryThreads()
public void setQueryThreads(int queryThreads)
public String getReadAheadQueueSize()
public String getReadAheadTimeOut()
public boolean isUseReadAheadIterator()
public void setReadAheadQueueSize(String readAheadQueueSize)
public void setReadAheadTimeOut(String readAheadTimeOut)
public void setUseReadAheadIterator(boolean useReadAheadIterator)
public String getReverseIndexTableName()
public void setReverseIndexTableName(String reverseIndexTableName)
public List<String> getUnevaluatedFields()
public void setUnevaluatedFields(List<String> unevaluatedFields)
public void setUnevaluatedFields(String unevaluatedFieldList)
public Document createDocument(Key key, Value value)
public String getResultsKey(Map.Entry<Key,Value> key)
public Results runQuery(Connector connector, List<String> authorizations, String query, Date beginDate, Date endDate, Set<String> types)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |