Search in sources :

Example 6 with ScannerChunk

use of datawave.query.tables.async.ScannerChunk in project datawave by NationalSecurityAgency.

the class VisitorFunctionTest method rangeOverTermThresholdTest.

@Test
public void rangeOverTermThresholdTest() throws IOException, TableNotFoundException, URISyntaxException {
    setupExpects();
    config.setCleanupShardsAndDaysQueryHints(false);
    config.setBypassExecutabilityCheck(true);
    config.setSerializeQueryIterator(false);
    Query mockQuery = createMock(Query.class);
    config.setQuery(mockQuery);
    EasyMock.expect(mockQuery.getId()).andReturn(new UUID(0, 0)).anyTimes();
    EasyMock.expect(mockQuery.duplicate("testQuery1")).andReturn(mockQuery).anyTimes();
    // set thresholds
    config.setMaxTermThreshold(1);
    config.setMaxDepthThreshold(10);
    config.setMaxOrExpansionFstThreshold(100);
    config.setMaxOrExpansionThreshold(20);
    config.setMaxOrRangeThreshold(2);
    config.setMaxRangesPerRangeIvarator(50);
    config.setMaxOrRangeThreshold(2);
    SessionOptions options = new SessionOptions();
    IteratorSetting iteratorSetting = new IteratorSetting(10, "itr", QueryIterator.class);
    String query = "((_Bounded_ = true) && (FIELD1 > 'a' && FIELD1 < 'y')) || ((_Bounded_ = true) && (FIELD1 > 'c' && FIELD1 < 'z'))";
    iteratorSetting.addOption(QueryOptions.QUERY, query);
    options.addScanIterator(iteratorSetting);
    ScannerChunk chunk = new ScannerChunk(options, Collections.singleton(new Range("20210101_0", "20210101_0")));
    replayAll();
    function = new VisitorFunction(config, helper);
    ScannerChunk updatedChunk = function.apply(chunk);
    verifyAll();
    Assert.assertNotEquals(chunk, updatedChunk);
    String updatedQuery = updatedChunk.getOptions().getIterators().iterator().next().getOptions().get(QueryOptions.QUERY);
    Assert.assertNotEquals(query, updatedQuery);
    Assert.assertTrue(updatedQuery, updatedQuery.contains("_List_"));
    Assert.assertTrue(updatedQuery, updatedQuery.contains("field = 'FIELD1'"));
    Assert.assertTrue(updatedQuery, updatedQuery.contains("ranges\":[[\"(a\",\"z)\"]"));
}
Also used : Query(datawave.webservice.query.Query) IteratorSetting(org.apache.accumulo.core.client.IteratorSetting) SessionOptions(datawave.query.tables.SessionOptions) ScannerChunk(datawave.query.tables.async.ScannerChunk) UUID(java.util.UUID) Range(org.apache.accumulo.core.data.Range) Test(org.junit.Test)

Example 7 with ScannerChunk

use of datawave.query.tables.async.ScannerChunk in project datawave by NationalSecurityAgency.

the class VisitorFunctionTest method underTermThresholdTest.

@Test
public void underTermThresholdTest() throws IOException, TableNotFoundException, URISyntaxException {
    setupExpects();
    // test specific expects
    config.setCleanupShardsAndDaysQueryHints(false);
    config.setBypassExecutabilityCheck(true);
    config.setSerializeQueryIterator(false);
    Query mockQuery = createMock(Query.class);
    config.setQuery(mockQuery);
    EasyMock.expect(mockQuery.getId()).andReturn(new UUID(0, 0)).anyTimes();
    // set thresholds
    config.setMaxTermThreshold(2);
    config.setMaxDepthThreshold(2);
    SessionOptions options = new SessionOptions();
    IteratorSetting iteratorSetting = new IteratorSetting(10, "itr", QueryIterator.class);
    iteratorSetting.addOption(QueryOptions.QUERY, "FIELD1 == 'a'");
    options.addScanIterator(iteratorSetting);
    ScannerChunk chunk = new ScannerChunk(options, Collections.singleton(new Range("20210101_0", "20210101_0")));
    replayAll();
    function = new VisitorFunction(config, helper);
    function.apply(chunk);
    verifyAll();
}
Also used : Query(datawave.webservice.query.Query) IteratorSetting(org.apache.accumulo.core.client.IteratorSetting) SessionOptions(datawave.query.tables.SessionOptions) ScannerChunk(datawave.query.tables.async.ScannerChunk) UUID(java.util.UUID) Range(org.apache.accumulo.core.data.Range) Test(org.junit.Test)

Example 8 with ScannerChunk

use of datawave.query.tables.async.ScannerChunk in project datawave by NationalSecurityAgency.

the class VisitorFunctionTest method overTermThresholdCantReduceTest.

@Test(expected = DatawaveFatalQueryException.class)
public void overTermThresholdCantReduceTest() throws IOException, TableNotFoundException, URISyntaxException {
    setupExpects();
    config.setCleanupShardsAndDaysQueryHints(false);
    config.setBypassExecutabilityCheck(true);
    config.setSerializeQueryIterator(false);
    Query mockQuery = createMock(Query.class);
    config.setQuery(mockQuery);
    EasyMock.expect(mockQuery.getId()).andReturn(new UUID(0, 0)).anyTimes();
    EasyMock.expect(mockQuery.getQueryName()).andReturn("testQuery1").anyTimes();
    EasyMock.expect(mockQuery.duplicate("testQuery1")).andReturn(mockQuery).anyTimes();
    // set thresholds
    config.setMaxTermThreshold(1);
    config.setMaxDepthThreshold(10);
    config.setMaxOrExpansionFstThreshold(100);
    config.setMaxOrExpansionThreshold(20);
    config.setMaxOrRangeThreshold(2);
    config.setMaxRangesPerRangeIvarator(50);
    config.setMaxOrRangeThreshold(2);
    SessionOptions options = new SessionOptions();
    IteratorSetting iteratorSetting = new IteratorSetting(10, "itr", QueryIterator.class);
    String query = "FIELD2 == 'a' || FIELD1 == 'b'";
    iteratorSetting.addOption(QueryOptions.QUERY, query);
    options.addScanIterator(iteratorSetting);
    ScannerChunk chunk = new ScannerChunk(options, Collections.singleton(new Range("20210101_0", "20210101_0")));
    replayAll();
    function = new VisitorFunction(config, helper);
    ScannerChunk updatedChunk = function.apply(chunk);
    verifyAll();
    Assert.assertNotEquals(chunk, updatedChunk);
    String updatedQuery = updatedChunk.getOptions().getIterators().iterator().next().getOptions().get(QueryOptions.QUERY);
    Assert.assertNotEquals(query, updatedQuery);
    Assert.assertTrue(updatedQuery, updatedQuery.contains("_List_"));
    Assert.assertTrue(updatedQuery, updatedQuery.contains("field = 'FIELD1'"));
    Assert.assertTrue(updatedQuery, updatedQuery.contains("values\":[\"a\",\"b\"]"));
}
Also used : Query(datawave.webservice.query.Query) IteratorSetting(org.apache.accumulo.core.client.IteratorSetting) SessionOptions(datawave.query.tables.SessionOptions) ScannerChunk(datawave.query.tables.async.ScannerChunk) UUID(java.util.UUID) Range(org.apache.accumulo.core.data.Range) Test(org.junit.Test)

Example 9 with ScannerChunk

use of datawave.query.tables.async.ScannerChunk in project datawave by NationalSecurityAgency.

the class BatchScannerSession method submitTasks.

/**
 */
protected void submitTasks() {
    List<ScannerChunk> newChunks;
    newChunks = Lists.newArrayList(currentBatch);
    currentBatch.clear();
    Collections.shuffle(newChunks);
    for (ScannerChunk chunk : newChunks) {
        AtomicInteger numChunks = serverMap.get(chunk.getLastKnownLocation());
        if (numChunks == null) {
            numChunks = new AtomicInteger(1);
            serverMap.put(chunk.getLastKnownLocation(), numChunks);
        } else
            numChunks.incrementAndGet();
        Scan scan = null;
        if (speculativeScanning && delegatedResourceInitializer == RfileResource.class) {
            if (log.isTraceEnabled()) {
                log.trace("Using speculative execution");
            }
            scan = new SpeculativeScan(localTableName, localAuths, chunk, delegatorReference, delegatedResourceInitializer, resultQueue, listenerService);
            ((SpeculativeScan) scan).addScan(new Scan(localTableName, localAuths, new ScannerChunk(chunk), delegatorReference, BatchResource.class, ((SpeculativeScan) scan).getQueue(), listenerService));
            ((SpeculativeScan) scan).addScan(new Scan(localTableName, localAuths, new ScannerChunk(chunk), delegatorReference, delegatedResourceInitializer, ((SpeculativeScan) scan).getQueue(), listenerService));
        } else {
            scan = new Scan(localTableName, localAuths, chunk, delegatorReference, delegatedResourceInitializer, resultQueue, listenerService);
        }
        if (backoffEnabled) {
            scan.setSessionArbiter(this);
        }
        scan.setVisitors(visitorFunctions);
        scan.setTimeout(scanLimitTimeout);
        if (log.isTraceEnabled()) {
            log.trace("Adding scanner " + chunk);
        }
        submitScan(scan, true);
    }
}
Also used : RfileResource(datawave.mr.bulk.RfileResource) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) SpeculativeScan(datawave.query.tables.async.SpeculativeScan) ScannerChunk(datawave.query.tables.async.ScannerChunk) Scan(datawave.query.tables.async.Scan) SpeculativeScan(datawave.query.tables.async.SpeculativeScan)

Aggregations

ScannerChunk (datawave.query.tables.async.ScannerChunk)9 SessionOptions (datawave.query.tables.SessionOptions)7 IteratorSetting (org.apache.accumulo.core.client.IteratorSetting)7 Query (datawave.webservice.query.Query)5 UUID (java.util.UUID)5 Range (org.apache.accumulo.core.data.Range)5 Test (org.junit.Test)5 RfileResource (datawave.mr.bulk.RfileResource)2 Scan (datawave.query.tables.async.Scan)2 SpeculativeScan (datawave.query.tables.async.SpeculativeScan)2 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)2 ParseException (org.apache.commons.jexl2.parser.ParseException)2 DatawaveFatalQueryException (datawave.query.exceptions.DatawaveFatalQueryException)1 InvalidQueryException (datawave.query.exceptions.InvalidQueryException)1 STATE (datawave.query.jexl.visitors.ExecutableDeterminationVisitor.STATE)1 QueryPlan (datawave.query.planner.QueryPlan)1 BadRequestQueryException (datawave.webservice.query.exception.BadRequestQueryException)1 PreConditionFailedQueryException (datawave.webservice.query.exception.PreConditionFailedQueryException)1 IOException (java.io.IOException)1 Nullable (javax.annotation.Nullable)1