Java Code Examples for org.apache.accumulo.core.client.IteratorSetting#addOption()

The following examples show how to use org.apache.accumulo.core.client.IteratorSetting#addOption() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: FacetedQueryPlanner.java    From datawave with Apache License 2.0 6 votes vote down vote up
@Override
public IteratorSetting getQueryIterator(MetadataHelper metadataHelper, ShardQueryConfiguration config, Query settings, String queryString,
                Boolean isFullTable) throws DatawaveQueryException {
    if (isFullTable) {
        QueryException qe = new QueryException(DatawaveErrorCode.FULL_TABLE_SCAN_DISALLOWED);
        throw new FullTableScansDisallowedException(qe);
    }
    
    IteratorSetting cfg = super.getQueryIterator(metadataHelper, config, settings, queryString, isFullTable);
    if (!usePrecomputedFacets)
        cfg.setIteratorClass(DynamicFacetIterator.class.getName());
    else {
        config.setShardTableName("FacetsNating");
        cfg.setIteratorClass(FacetedTableIterator.class.getName());
    }
    
    cfg.addOption(DynamicFacetIterator.FACETED_SEARCH_TYPE, facetedConfig.getType().toString());
    cfg.addOption(DynamicFacetIterator.FACETED_MINIMUM, Integer.toString(facetedConfig.getMinimumFacetCount()));
    cfg.addOption(DynamicFacetIterator.FACETED_SEARCH_FIELDS, Joiner.on(",").join(facetedConfig.getFacetedFields()));
    
    if (log.isTraceEnabled())
        log.trace("Configuration is " + facetedConfig);
    
    return cfg;
}
 
Example 2
Source File: RateIterator.java    From timely with Apache License 2.0 5 votes vote down vote up
public static void setRateOptions(IteratorSetting is, QueryRequest.RateOption options) {
    if (options != null && options.isCounter()) {
        LOG.trace("Setting rate counter options cm:{}, rv:{}", options.getCounterMax(), options.getResetValue());
        is.addOption(COUNTER_MAX, Long.toString(options.getCounterMax()));
        is.addOption(RATE_RESET_VALUE, Long.toString(options.getResetValue()));
    }
}
 
Example 3
Source File: ShardIndexQueryTableStaticMethods.java    From datawave with Apache License 2.0 5 votes vote down vote up
public static final IteratorSetting configureGlobalIndexDateRangeFilter(ShardQueryConfiguration config, LongRange dateRange) {
    // Setup the GlobalIndexDateRangeFilter
    if (log.isTraceEnabled()) {
        log.trace("Configuring GlobalIndexDateRangeFilter with " + dateRange);
    }
    IteratorSetting cfg = new IteratorSetting(config.getBaseIteratorPriority() + 21, "dateFilter", GlobalIndexDateRangeFilter.class);
    cfg.addOption(Constants.START_DATE, Long.toString(dateRange.getMinimumLong()));
    cfg.addOption(Constants.END_DATE, Long.toString(dateRange.getMaximumLong()));
    return cfg;
}
 
Example 4
Source File: BaseQfdInputFormat.java    From accumulo-recipes with Apache License 2.0 5 votes vote down vote up
protected static void configureScanner(Job job, Set<String> types, Node query, NodeToJexl nodeToJexl, GlobalIndexVisitor globalInexVisitor,
    TypeRegistry<String> typeRegistry, Class<? extends OptimizedQueryIterator> optimizedQueryIteratorClass)
      throws AccumuloSecurityException, AccumuloException, TableNotFoundException {

    QueryPlanner logicalPlan = new QueryPlanner(query, globalInexVisitor, typeRegistry);
    String jexl = nodeToJexl.transform(types, logicalPlan.getOptimizedQuery());
    String originalJexl = nodeToJexl.transform(types, query);

    log.debug("Original Jexl: "+ originalJexl);
    log.debug("Optimized Jexl: "+ jexl);

    Collection<Range> ranges = new ArrayList<Range>();
    if(jexl.equals("()") || jexl.equals("") || logicalPlan.getShards().size() == 0) {
        ranges.add(new Range(END_BYTE));
    } else {
        for (String shard : logicalPlan.getShards())
            ranges.add(new Range(shard));

        IteratorSetting setting = new IteratorSetting(16, optimizedQueryIteratorClass);
        setting.addOption(BooleanLogicIterator.QUERY_OPTION, originalJexl);
        setting.addOption(BooleanLogicIterator.FIELD_INDEX_QUERY, jexl);

        addIterator(job, setting);
    }

    setRanges(job, ranges);


    final String[] selectFields = job.getConfiguration().getStrings(SELECT_FIELDS);

    if (selectFields != null && selectFields.length > 0) {
        IteratorSetting iteratorSetting = new IteratorSetting(16, SelectFieldsExtractor.class);
        SelectFieldsExtractor.setSelectFields(iteratorSetting, new HashSet<String>(asList(selectFields)));
    }
}
 
Example 5
Source File: FirstEntryInColumnIterator.java    From accumulo-recipes with Apache License 2.0 4 votes vote down vote up
/**
 * convenience method to set the option to optimize the frequency of scans vs. seeks
 */
public static void setNumScansBeforeSeek(IteratorSetting cfg, int num) {
    cfg.addOption(NUM_SCANS_STRING_NAME, Integer.toString(num));
}
 
Example 6
Source File: HistoricalEventsIterator.java    From vertexium with Apache License 2.0 4 votes vote down vote up
public static void setElementType(IteratorSetting settings, ElementType elementType) {
    settings.addOption("elementType", elementType.name());
}
 
Example 7
Source File: DiscoveryIteratorTest.java    From datawave with Apache License 2.0 4 votes vote down vote up
@Test
public void testReverseIndex() throws Throwable {
    Connector con = new InMemoryInstance("DiscoveryIteratorTest").getConnector("root", new PasswordToken(""));
    con.tableOperations().create("reverseIndex");
    writeSample(con.createBatchWriter("reverseIndex", new BatchWriterConfig().setMaxLatency(0, TimeUnit.SECONDS).setMaxMemory(0).setMaxWriteThreads(1)),
                    true);
    Scanner s = con.createScanner("reverseIndex", new Authorizations("FOO"));
    IteratorSetting setting = new IteratorSetting(50, DiscoveryIterator.class);
    setting.addOption(DiscoveryLogic.REVERSE_INDEX, "true");
    s.addScanIterator(setting);
    s.setRange(new Range());
    
    Iterator<Map.Entry<Key,Value>> itr = s.iterator();
    assertTrue(itr.hasNext());
    Map.Entry<Key,Value> e = itr.next();
    assertFalse(itr.hasNext());
    
    Key key = e.getKey();
    assertEquals("mret", key.getRow().toString());
    assertEquals("field", key.getColumnFamily().toString());
    // see DiscoveryIterator for why this has a max unsigned char tacked on the end
    assertEquals("20130101\uffff", key.getColumnQualifier().toString());
    
    Value value = e.getValue();
    assertTrue(value.getSize() > 0);
    
    DataInputBuffer in = new DataInputBuffer();
    in.reset(value.get(), value.getSize());
    ArrayWritable valWrapper = new ArrayWritable(DiscoveredThing.class);
    valWrapper.readFields(in);
    Writable[] values = valWrapper.get();
    assertEquals(3, values.length);
    Set<String> types = Sets.newHashSet("t1", "t2", "t3");
    for (int i = 0; i < 3; ++i) {
        DiscoveredThing thing = (DiscoveredThing) values[i];
        assertEquals("term", thing.getTerm());
        assertEquals("field", thing.getField());
        assertTrue(types.remove(thing.getType()));
        assertEquals("20130101", thing.getDate());
        assertEquals("FOO", thing.getColumnVisibility());
        assertEquals(240L, thing.getCount());
    }
    
}
 
Example 8
Source File: MatchingKeySkippingIterator.java    From datawave with Apache License 2.0 4 votes vote down vote up
/**
 * convenience method to set the option to optimize the frequency of scans vs. seeks
 */
public static void setNumScansBeforeSeek(IteratorSetting cfg, int num) {
    cfg.addOption(NUM_SCANS_STRING_NAME, Integer.toString(num));
}
 
Example 9
Source File: QueryInformationIterator.java    From datawave with Apache License 2.0 4 votes vote down vote up
public static void setErrorReporting(IteratorSetting cfg) {
    cfg.addOption(REPORT_ERRORS_OPT, REPORT_ERRORS_OPT);
}
 
Example 10
Source File: PrewriteIterator.java    From fluo with Apache License 2.0 4 votes vote down vote up
public static void setSnaptime(IteratorSetting cfg, long time) {
  if (time < 0 || (ColumnConstants.PREFIX_MASK & time) != 0) {
    throw new IllegalArgumentException();
  }
  cfg.addOption(TIMESTAMP_OPT, time + "");
}
 
Example 11
Source File: SnapshotIterator.java    From fluo with Apache License 2.0 4 votes vote down vote up
public static void setReturnReadLockPresent(IteratorSetting cfg, boolean rrlp) {
  cfg.addOption(RETURN_READLOCK_PRESENT_OPT, rrlp + "");
}
 
Example 12
Source File: EdgeRefFilter.java    From vertexium with Apache License 2.0 4 votes vote down vote up
public static void setVertexIds(IteratorSetting settings, Set<String> vertexIdsSet) {
    settings.addOption(SETTING_VERTEX_IDS, SetOfStringsEncoder.encodeToString(vertexIdsSet));
}
 
Example 13
Source File: TimeSeriesGroupingIteratorTest.java    From timely with Apache License 2.0 4 votes vote down vote up
@Test
public void testManySparseTimeSeries() throws Exception {
    table.clear();
    long ts = System.currentTimeMillis();
    List<Tag> tags1 = new ArrayList<>();
    tags1.add(new Tag("host", "r01n01"));
    List<Tag> tags2 = new ArrayList<>();
    tags2.add(new Tag("host", "r01n02"));
    List<Tag> tags3 = new ArrayList<>();
    tags3.add(new Tag("host", "r01n03"));
    for (int i = 0; i < 100; i++) {
        ts += 1000;
        Metric m = new Metric("sys.cpu.user", ts, i * 1.0D, tags1);
        byte[] row = MetricAdapter.encodeRowKey(m);
        Key k = new Key(row, tags1.get(0).join().getBytes(StandardCharsets.UTF_8),
                MetricAdapter.encodeColQual(ts, ""), new byte[0], ts);
        Value v = new Value(MetricAdapter.encodeValue(m.getValue().getMeasure()));
        table.put(k, v);
        // jitter the time on the second time series
        Metric m2 = new Metric("sys.cpu.user", ts + 50, i * 2.0D, tags2);
        byte[] row2 = MetricAdapter.encodeRowKey(m2);
        Key k2 = new Key(row2, tags2.get(0).join().getBytes(StandardCharsets.UTF_8),
                MetricAdapter.encodeColQual(ts, ""), new byte[0], ts + 50);
        Value v2 = new Value(MetricAdapter.encodeValue(m2.getValue().getMeasure()));
        table.put(k2, v2);
        Metric m3 = new Metric("sys.cpu.user", ts, i * 3.0D, tags3);
        byte[] row3 = MetricAdapter.encodeRowKey(m3);
        Key k3 = new Key(row3, tags3.get(0).join().getBytes(StandardCharsets.UTF_8),
                MetricAdapter.encodeColQual(ts, ""), new byte[0], ts);
        Value v3 = new Value(MetricAdapter.encodeValue(m3.getValue().getMeasure()));
        table.put(k3, v3);
    }

    SortedMapIterator source = new SortedMapIterator(table);
    TimeSeriesGroupingIterator iter = new TimeSeriesGroupingIterator();
    IteratorSetting settings = new IteratorSetting(100, TimeSeriesGroupingIterator.class);
    settings.addOption(TimeSeriesGroupingIterator.FILTER, "0.20,0.20,0.20,0.20,0.20");
    iter.init(source, settings.getOptions(), SCAN_IE);
    iter.seek(new Range(), EMPTY_COL_FAMS, true);

    LinkedList<Double> first = new LinkedList<>();
    first.add(0D);
    first.add(1D);
    first.add(2D);
    first.add(3D);
    first.add(4D);
    LinkedList<Double> second = new LinkedList<>();
    second.add(0D);
    second.add(2D);
    second.add(4D);
    second.add(6D);
    second.add(8D);
    LinkedList<Double> third = new LinkedList<>();
    third.add(0D);
    third.add(3D);
    third.add(6D);
    third.add(9D);
    third.add(12D);

    // this section changed when the key structure changed so that identical
    // colFam values sorted consecutively within an given time period
    for (int i = 4; i < 100; i++) {
        checkNextResult(iter, first);
        shiftAndAdd(first, 1);
    }
    for (int i = 4; i < 100; i++) {
        System.out.println(i);
        checkNextResult(iter, second);
        shiftAndAdd(second, 2);
    }
    for (int i = 4; i < 100; i++) {
        checkNextResult(iter, third);
        shiftAndAdd(third, 3);
    }
    assertFalse(iter.hasTop());
}
 
Example 14
Source File: RollbackCheckIterator.java    From fluo with Apache License 2.0 4 votes vote down vote up
public static void setLocktime(IteratorSetting cfg, long time) {
  if (time < 0 || (ColumnConstants.PREFIX_MASK & time) != 0) {
    throw new IllegalArgumentException();
  }
  cfg.addOption(TIMESTAMP_OPT, time + "");
}
 
Example 15
Source File: PrewriteIterator.java    From fluo with Apache License 2.0 4 votes vote down vote up
public static void enableAckCheck(IteratorSetting cfg, long timestamp) {
  cfg.addOption(CHECK_ACK_OPT, Boolean.TRUE.toString());
  cfg.addOption(NTFY_TIMESTAMP_OPT, timestamp + "");
}
 
Example 16
Source File: ElementIterator.java    From vertexium with Apache License 2.0 4 votes vote down vote up
public static void setAuthorizations(IteratorSetting iteratorSettings, String[] authorizations) {
    iteratorSettings.addOption("authorizations", String.join("\u001f", authorizations));
}
 
Example 17
Source File: CutoffIntersectingIterator.java    From accumulo-examples with Apache License 2.0 4 votes vote down vote up
public static void setCutoff(IteratorSetting iterCfg, int cutoff) {
  checkArgument(cutoff >= 0);
  iterCfg.addOption("cutoff", cutoff + "");
}
 
Example 18
Source File: FieldIndexCountingIteratorPerVisibility.java    From datawave with Apache License 2.0 2 votes vote down vote up
/**
 * A convenience method for setting the stamp_start timestamp accepted by the timestamp filter.
 * 
 * @param is
 *            the iterator setting object to configure
 * @param start
 *            the stamp_start timestamp
 * @param startInclusive
 *            boolean indicating whether the stamp_start is inclusive
 */
public static void setStart(IteratorSetting is, long start, boolean startInclusive) {
    SimpleDateFormat dateParser = initDateParser();
    is.addOption(START_TIME, dateParser.format(new Date(start)));
    is.addOption(START_TIME_INCL, Boolean.toString(startInclusive));
}
 
Example 19
Source File: StatsCombiner.java    From accumulo-examples with Apache License 2.0 2 votes vote down vote up
/**
 * A convenience method for setting the expected base/radix of the numbers
 *
 * @param iterConfig
 *          Iterator settings to configure
 * @param base
 *          The expected base/radix of the numbers.
 */
public static void setRadix(IteratorSetting iterConfig, int base) {
  iterConfig.addOption(RADIX_OPTION, base + "");
}
 
Example 20
Source File: BucketRollupIterator.java    From accumulo-recipes with Apache License 2.0 2 votes vote down vote up
public static void setBucketSize(IteratorSetting is, BucketSize bucketSize) {

        is.addOption("bucketSize", bucketSize.name());
    }