use of datawave.webservice.query.QueryImpl in project datawave by NationalSecurityAgency.
the class ExceededOrThresholdMarkerJexlNodeTest method getResultsIterator.
private Iterator getResultsIterator(String queryString, ShardQueryLogic logic) throws Exception {
MultivaluedMap<String, String> params = new MultivaluedMapImpl<>();
params.putSingle(QUERY_LOGIC_NAME, "EventQuery");
params.putSingle(QUERY_STRING, queryString);
params.putSingle(QUERY_NAME, "geoQuery");
params.putSingle(QUERY_PERSISTENCE, "PERSISTENT");
params.putSingle(QUERY_AUTHORIZATIONS, AUTHS);
params.putSingle(QUERY_EXPIRATION, "20200101 000000.000");
params.putSingle(QUERY_BEGIN, BEGIN_DATE);
params.putSingle(QUERY_END, END_DATE);
QueryParameters queryParams = new QueryParametersImpl();
queryParams.validate(params);
Set<Authorizations> auths = new HashSet<>();
auths.add(new Authorizations(AUTHS));
Query query = new QueryImpl();
query.initialize(USER, Arrays.asList(USER_DN), null, queryParams, null);
ShardQueryConfiguration config = ShardQueryConfiguration.create(logic, query);
logic.initialize(config, instance.getConnector("root", PASSWORD), query, auths);
logic.setupQuery(config);
return logic.getTransformIterator(query);
}
use of datawave.webservice.query.QueryImpl in project datawave by NationalSecurityAgency.
the class AbstractFunctionalQuery method getPlan.
/**
* Used by test cases that verify the plan
*
* @param queryStr
* query string for evaluation
* @param expandFields
* whether to use the index for anyfield expansion
* @param expandValues
* whether to use the index for regex/range expansion
* @return query configuration
* @throws Exception
* error condition from query initialization
*/
protected String getPlan(final String queryStr, boolean expandFields, boolean expandValues) throws Exception {
Date[] startEndDate = this.dataManager.getShardStartEndDate();
if (log.isDebugEnabled()) {
log.debug(" query[" + queryStr + "] start(" + YMD_DateFormat.format(startEndDate[0]) + ") end(" + YMD_DateFormat.format(startEndDate[1]) + ")");
}
QueryImpl q = new QueryImpl();
q.setBeginDate(startEndDate[0]);
q.setEndDate(startEndDate[1]);
q.setQuery(queryStr);
q.setId(UUID.randomUUID());
q.setPagesize(Integer.MAX_VALUE);
q.setQueryAuthorizations(auths.toString());
return this.logic.getPlan(connector, q, this.authSet, expandFields, expandValues);
}
use of datawave.webservice.query.QueryImpl in project datawave by NationalSecurityAgency.
the class AbstractFunctionalQuery method runCountTest.
/**
* Executes test cases that use {@link CountingShardQueryLogic}.
*
* @param query
* query for evaluation
* @throws Exception
* error condition during execution of query
*/
protected void runCountTest(String query) throws Exception {
Date[] startEndDate = this.dataManager.getShardStartEndDate();
if (log.isDebugEnabled()) {
log.debug(" count query[" + query + "] start(" + YMD_DateFormat.format(startEndDate[0]) + ") end(" + YMD_DateFormat.format(startEndDate[1]) + ")");
}
QueryImpl q = new QueryImpl();
q.setBeginDate(startEndDate[0]);
q.setEndDate(startEndDate[1]);
q.setQuery(query);
q.setId(UUID.randomUUID());
q.setPagesize(Integer.MAX_VALUE);
q.setQueryAuthorizations(auths.toString());
RunningQuery runner = new RunningQuery(connector, AccumuloConnectionFactory.Priority.NORMAL, this.countLogic, q, "", principal, new QueryMetricFactoryImpl());
TransformIterator it = runner.getTransformIterator();
ShardQueryCountTableTransformer ctt = (ShardQueryCountTableTransformer) it.getTransformer();
EventQueryResponseBase resp = (EventQueryResponseBase) ctt.createResponse(runner.next());
Collection<String> expect = getExpectedKeyResponse(query);
List<EventBase> events = resp.getEvents();
Assert.assertEquals(1, events.size());
EventBase<?, ?> event = events.get(0);
List<?> fields = event.getFields();
Assert.assertEquals(1, fields.size());
FieldBase<?> count = (FieldBase) fields.get(0);
String val = count.getValueString();
if (log.isDebugEnabled()) {
log.debug("expected count(" + expect.size() + ") actual count(" + val + ")");
}
Assert.assertEquals("" + expect.size(), val);
}
use of datawave.webservice.query.QueryImpl in project datawave by NationalSecurityAgency.
the class AbstractFunctionalQuery method setupConfig.
/**
* Used by test cases that verify the configuration.
*
* @param queryStr
* query string for evaluation
* @return query configuration
* @throws Exception
* error condition from query initialization
*/
protected GenericQueryConfiguration setupConfig(final String queryStr) throws Exception {
Date[] startEndDate = this.dataManager.getShardStartEndDate();
if (log.isDebugEnabled()) {
log.debug(" query[" + queryStr + "] start(" + YMD_DateFormat.format(startEndDate[0]) + ") end(" + YMD_DateFormat.format(startEndDate[1]) + ")");
}
QueryImpl q = new QueryImpl();
q.setBeginDate(startEndDate[0]);
q.setEndDate(startEndDate[1]);
q.setQuery(queryStr);
q.setId(UUID.randomUUID());
q.setPagesize(Integer.MAX_VALUE);
q.setQueryAuthorizations(auths.toString());
return this.logic.initialize(connector, q, this.authSet);
}
use of datawave.webservice.query.QueryImpl in project datawave by NationalSecurityAgency.
the class DefaultEdgeEventQueryLogicTest method testEdgesWithComplexPreconditions.
@Test
public void testEdgesWithComplexPreconditions() throws Exception {
Query query = new QueryImpl();
query.setQuery("SOURCE == '$609_1_R' AND SINK == '$604_1_R' AND TYPE == 'TEST11' AND RELATION == 'REL42-REL42'");
String transformed = logic.getEventQuery(query);
assertEquals("($609_1_R == '$609_1_R' AND $604_1_R == '$604_1_R' AND F05_3_R == 'enrichValue' AND ($609_3 == '2384' && $600_7 == '2'))", transformed);
}
Aggregations