org.apache.accumulo.core.client.IteratorSetting Java Examples
The following examples show how to use
org.apache.accumulo.core.client.IteratorSetting.
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: ShardQueryLogic.java From datawave with Apache License 2.0 | 6 votes |
public static BatchScanner createBatchScanner(ShardQueryConfiguration config, ScannerFactory scannerFactory, QueryData qd) throws TableNotFoundException { final BatchScanner bs = scannerFactory.newScanner(config.getShardTableName(), config.getAuthorizations(), config.getNumQueryThreads(), config.getQuery()); if (log.isTraceEnabled()) { log.trace("Running with " + config.getAuthorizations() + " and " + config.getNumQueryThreads() + " threads: " + qd); } bs.setRanges(qd.getRanges()); for (IteratorSetting cfg : qd.getSettings()) { bs.addScanIterator(cfg); } return bs; }
Example #2
Source File: TestTransaction.java From fluo with Apache License 2.0 | 6 votes |
public static long getNotificationTS(Environment env, String row, Column col) { try (Scanner scanner = env.getAccumuloClient().createScanner(env.getTable(), env.getAuthorizations())) { IteratorSetting iterCfg = new IteratorSetting(11, NotificationIterator.class); scanner.addScanIterator(iterCfg); Text cv = ByteUtil.toText(col.getVisibility()); scanner.setRange(SpanUtil.toRange(Span.prefix(row))); scanner.fetchColumn(ByteUtil.toText(ColumnConstants.NOTIFY_CF), new Text(NotificationUtil.encodeCol(col))); for (Entry<Key, org.apache.accumulo.core.data.Value> entry : scanner) { if (entry.getKey().getColumnVisibility().equals(cv)) { return Notification.from(entry.getKey()).getTimestamp(); } } throw new RuntimeException("No notification found"); } catch (TableNotFoundException e) { throw new RuntimeException(e); } }
Example #3
Source File: AccumuloRyaUtils.java From rya with Apache License 2.0 | 6 votes |
/** * Prints the table with the specified config and additional settings. * @param tableName the name of the table to print. * @param config the {@link AccumuloRdfConfiguration}. * @param shouldAddCommonIterators {@code true} to add the common iterators to the table scanner. * {@code false} otherwise. * @param settings the additional {@link IteratorSetting}s to add besides the common ones. * @throws IOException */ public static void printTable(final String tableName, final AccumuloRdfConfiguration config, final boolean shouldAddCommonIterators, final IteratorSetting... settings) throws IOException { final Scanner scanner = AccumuloRyaUtils.getScanner(tableName, config, shouldAddCommonIterators); for (final IteratorSetting setting : settings) { scanner.addScanIterator(setting); } final Iterator<Entry<Key, Value>> iterator = scanner.iterator(); final String instance = config.get(MRUtils.AC_INSTANCE_PROP); log.info("=================="); log.info("TABLE: " + tableName + " INSTANCE: " + instance); log.info("------------------"); while (iterator.hasNext()) { final Entry<Key, Value> entry = iterator.next(); final Key key = entry.getKey(); final Value value = entry.getValue(); final String keyString = getFormattedKeyString(key); log.info(keyString + " - " + value); } log.info("=================="); }
Example #4
Source File: AccumuloFeatureStore.java From accumulo-recipes with Apache License 2.0 | 6 votes |
@Override public Iterable<String> groups(String prefix, Auths auths) { checkNotNull(prefix); checkNotNull(auths); try { BatchScanner scanner = connector.createBatchScanner(tableName + INDEX_SUFFIX, auths.getAuths(), config.getMaxQueryThreads()); scanner.setRanges(singleton(Range.prefix(prefix))); IteratorSetting setting = new IteratorSetting(25, GroupIndexIterator.class); scanner.addScanIterator(setting); return transform(wrap(scanner), groupIndexTransform); } catch (TableNotFoundException e) { throw new RuntimeException(e); } }
Example #5
Source File: RowTimestampFilter.java From vertexium with Apache License 2.0 | 6 votes |
public static void setTimestamps(IteratorSetting iteratorSetting, Map<Text, Timestamp> timestamps) { StringBuilder value = new StringBuilder(); boolean first = true; for (Map.Entry<Text, Timestamp> entry : timestamps.entrySet()) { if (!first) { value.append(";"); } Timestamp ts = entry.getValue(); value.append(OptionsUtils.bytesToHex(entry.getKey().getBytes())); value.append(":"); value.append(OptionsUtils.longToString(ts.startTimestamp)); value.append(":"); value.append(OptionsUtils.booleanToString(ts.startInclusive)); value.append(":"); value.append(OptionsUtils.longToString(ts.endTimestamp)); value.append(":"); value.append(OptionsUtils.booleanToString(ts.endInclusive)); first = false; } iteratorSetting.addOption(TIMESTAMPS, value.toString()); }
Example #6
Source File: StatsJob.java From datawave with Apache License 2.0 | 6 votes |
@Override protected void configureInputFormat(Job job, AccumuloHelper cbHelper, Configuration conf) throws Exception { BulkInputFormat.setZooKeeperInstance(conf, cbHelper.getInstanceName(), cbHelper.getZooKeepers()); // add the versioning iterator IteratorSetting cfg = new IteratorSetting(100, VersioningIterator.class); BulkInputFormat.addIterator(conf, cfg); // get authorizations Connector conn = cbHelper.getConnector(); SecurityOperations secOps = conn.securityOperations(); Authorizations auths = secOps.getUserAuthorizations(cbHelper.getUsername()); BulkInputFormat.setInputInfo(job, cbHelper.getUsername(), cbHelper.getPassword(), this.inputTableName, auths); final Set<Range> scanShards = calculateRanges(conf); BulkInputFormat.setRanges(job, scanShards); super.configureInputFormat(job, cbHelper, conf); }
Example #7
Source File: AccumuloRyaUtils.java From rya with Apache License 2.0 | 6 votes |
/** * Prints the table with the specified config and additional settings. * @param tableName the name of the table to print. * @param config the {@link AccumuloRdfConfiguration}. * @param shouldAddCommonIterators {@code true} to add the common iterators to the table scanner. * {@code false} otherwise. * @param settings the additional {@link IteratorSetting}s to add besides the common ones. * @throws IOException */ public static void printTable(final String tableName, final AccumuloRdfConfiguration config, final boolean shouldAddCommonIterators, final IteratorSetting... settings) throws IOException { final Scanner scanner = AccumuloRyaUtils.getScanner(tableName, config, shouldAddCommonIterators); for (final IteratorSetting setting : settings) { scanner.addScanIterator(setting); } final Iterator<Entry<Key, Value>> iterator = scanner.iterator(); final String instance = config.get(MRUtils.AC_INSTANCE_PROP); log.info("=================="); log.info("TABLE: " + tableName + " INSTANCE: " + instance); log.info("------------------"); while (iterator.hasNext()) { final Entry<Key, Value> entry = iterator.next(); final Key key = entry.getKey(); final Value value = entry.getValue(); final String keyString = getFormattedKeyString(key); log.info(keyString + " - " + value); } log.info("=================="); }
Example #8
Source File: MetricsTableConfigHelperTest.java From datawave with Apache License 2.0 | 6 votes |
@Test public void shouldConfigureAggregators() throws Exception { String table = MetricsConfiguration.getTable(conf); configHelper.configure(tops); IteratorSetting is = tops.getIteratorSetting(table, "sum", IteratorScope.scan); assertEquals(SummingCombiner.class.getName(), is.getIteratorClass()); assertEquals(TestKeyValueCountMetricsReceiver.ITER_PRIORITY, is.getPriority()); Map<String,String> options = is.getOptions(); String type = options.get("type"); String columns = options.get("columns"); assertEquals(Metric.KV_PER_TABLE.toString(), columns); assertEquals("STRING", type); }
Example #9
Source File: AccumuloRdfConfiguration.java From rya with Apache License 2.0 | 6 votes |
public void setAdditionalIterators(final IteratorSetting... additionalIterators){ //TODO do we need to worry about cleaning up this.set(ITERATOR_SETTINGS_SIZE, Integer.toString(additionalIterators.length)); int i = 0; for(final IteratorSetting iterator : additionalIterators) { this.set(String.format(ITERATOR_SETTINGS_NAME, i), iterator.getName()); this.set(String.format(ITERATOR_SETTINGS_CLASS, i), iterator.getIteratorClass()); this.set(String.format(ITERATOR_SETTINGS_PRIORITY, i), Integer.toString(iterator.getPriority())); final Map<String, String> options = iterator.getOptions(); this.set(String.format(ITERATOR_SETTINGS_OPTIONS_SIZE, i), Integer.toString(options.size())); final Iterator<Entry<String, String>> it = options.entrySet().iterator(); int j = 0; while(it.hasNext()) { final Entry<String, String> item = it.next(); this.set(String.format(ITERATOR_SETTINGS_OPTIONS_KEY, i, j), item.getKey()); this.set(String.format(ITERATOR_SETTINGS_OPTIONS_VALUE, i, j), item.getValue()); j++; } i++; } }
Example #10
Source File: DefaultQueryPlanner.java From datawave with Apache License 2.0 | 6 votes |
private void configureIterator(ShardQueryConfiguration config, IteratorSetting cfg, String newQueryString, boolean isFullTable) throws DatawaveQueryException { // Load enrichers, filters, unevaluatedExpressions, and projection // fields setCommonIteratorOptions(config, cfg); addOption(cfg, QueryOptions.LIMIT_FIELDS, config.getLimitFieldsAsString(), true); addOption(cfg, QueryOptions.GROUP_FIELDS, config.getGroupFieldsAsString(), true); addOption(cfg, QueryOptions.GROUP_FIELDS_BATCH_SIZE, config.getGroupFieldsBatchSizeAsString(), true); addOption(cfg, QueryOptions.UNIQUE_FIELDS, config.getUniqueFieldsAsString(), true); addOption(cfg, QueryOptions.HIT_LIST, Boolean.toString(config.isHitList()), false); addOption(cfg, QueryOptions.TYPE_METADATA_IN_HDFS, Boolean.toString(config.isTypeMetadataInHdfs()), true); addOption(cfg, QueryOptions.TERM_FREQUENCY_FIELDS, Joiner.on(',').join(config.getQueryTermFrequencyFields()), false); addOption(cfg, QueryOptions.TERM_FREQUENCIES_REQUIRED, Boolean.toString(config.isTermFrequenciesRequired()), true); addOption(cfg, QueryOptions.QUERY, newQueryString, false); addOption(cfg, QueryOptions.QUERY_ID, config.getQuery().getId().toString(), false); addOption(cfg, QueryOptions.FULL_TABLE_SCAN_ONLY, Boolean.toString(isFullTable), false); addOption(cfg, QueryOptions.TRACK_SIZES, Boolean.toString(config.isTrackSizes()), true); // Set the start and end dates configureTypeMappings(config, cfg, metadataHelper, compressMappings); }
Example #11
Source File: AccumuloOperations.java From geowave with Apache License 2.0 | 6 votes |
protected <T> void addIndexFilterToIterator( final ReaderParams<T> params, final ScannerBase scanner) { final List<MultiDimensionalCoordinateRangesArray> coords = params.getCoordinateRanges(); if ((coords != null) && !coords.isEmpty()) { final IteratorSetting iteratorSetting = new IteratorSetting( NumericIndexStrategyFilterIterator.IDX_FILTER_ITERATOR_PRIORITY, NumericIndexStrategyFilterIterator.IDX_FILTER_ITERATOR_NAME, NumericIndexStrategyFilterIterator.class); iteratorSetting.addOption( NumericIndexStrategyFilterIterator.INDEX_STRATEGY_KEY, ByteArrayUtils.byteArrayToString( PersistenceUtils.toBinary(params.getIndex().getIndexStrategy()))); iteratorSetting.addOption( NumericIndexStrategyFilterIterator.COORDINATE_RANGE_KEY, ByteArrayUtils.byteArrayToString( new ArrayOfArrays( coords.toArray(new MultiDimensionalCoordinateRangesArray[] {})).toBinary())); scanner.addScanIterator(iteratorSetting); } }
Example #12
Source File: FieldIndexCountingIteratorPerVisibility.java From datawave with Apache License 2.0 | 6 votes |
/** * Get an IteratorSetting given a hadoop configuration * * @param conf * @return the iterator setting */ public static IteratorSetting getIteratorSetting(Configuration conf) { Map<String,String> summaryIteratorSettings = new HashMap<>(); putIfNotNull(summaryIteratorSettings, FieldIndexCountingIteratorPerVisibility.START_TIME, conf.get(FieldIndexCountingIteratorPerVisibility.START_TIME, null)); putIfNotNull(summaryIteratorSettings, FieldIndexCountingIteratorPerVisibility.STOP_TIME, conf.get(FieldIndexCountingIteratorPerVisibility.STOP_TIME, null)); putIfNotNull(summaryIteratorSettings, FieldIndexCountingIteratorPerVisibility.START_TIME_INCL, conf.get(FieldIndexCountingIteratorPerVisibility.START_TIME_INCL, null)); putIfNotNull(summaryIteratorSettings, FieldIndexCountingIteratorPerVisibility.STOP_TIME_INCL, conf.get(FieldIndexCountingIteratorPerVisibility.STOP_TIME_INCL, null)); putIfNotNull(summaryIteratorSettings, FieldIndexCountingIteratorPerVisibility.FIELD_NAMES, conf.get(FieldIndexCountingIteratorPerVisibility.FIELD_NAMES, null)); putIfNotNull(summaryIteratorSettings, FieldIndexCountingIteratorPerVisibility.FIELD_VALUES, conf.get(FieldIndexCountingIteratorPerVisibility.FIELD_VALUES, null)); putIfNotNull(summaryIteratorSettings, FieldIndexCountingIteratorPerVisibility.DATA_TYPES, conf.get(FieldIndexCountingIteratorPerVisibility.DATA_TYPES, null)); putIfNotNull(summaryIteratorSettings, FieldIndexCountingIteratorPerVisibility.UNIQ_BY_DATA_TYPE, conf.get(FieldIndexCountingIteratorPerVisibility.UNIQ_BY_DATA_TYPE, null)); putIfNotNull(summaryIteratorSettings, FieldIndexCountingIteratorPerVisibility.UNIQ_BY_VISIBILITY, conf.get(FieldIndexCountingIteratorPerVisibility.UNIQ_BY_VISIBILITY, null)); return new IteratorSetting(IteratorSettingHelper.BASE_ITERATOR_PRIORITY + 40, "FieldIndexCountingIterator", FieldIndexCountingIteratorPerVisibility.class.getName(), summaryIteratorSettings); }
Example #13
Source File: AccumuloEventStore.java From accumulo-recipes with Apache License 2.0 | 6 votes |
@Override public CloseableIterable<Event> query(Date start, Date end, Set<String> types, Node node, Set<String> selectFields, Auths auths) { checkNotNull(start); checkNotNull(end); checkNotNull(types); checkNotNull(node); checkNotNull(auths); BatchScanner indexScanner = helper.buildIndexScanner(auths.getAuths()); GlobalIndexVisitor globalIndexVisitor = new EventGlobalIndexVisitor(start, end, types, indexScanner, shardBuilder); BatchScanner scanner = helper.buildShardScanner(auths.getAuths()); IteratorSetting timeFilter = new IteratorSetting(5, EventTimeLimitingFilter.class); EventTimeLimitingFilter.setCurrentTime(timeFilter, end.getTime()); EventTimeLimitingFilter.setTTL(timeFilter, end.getTime() - start.getTime()); scanner.addScanIterator(timeFilter); CloseableIterable<Event> events = helper.query(scanner, globalIndexVisitor, types, node, helper.buildQueryXform(), selectFields, auths); indexScanner.close(); return events; }
Example #14
Source File: NotificationHashFilter.java From fluo with Apache License 2.0 | 6 votes |
public static void setModulusParams(IteratorSetting iterCfg, int divisor, int remainder) { if (remainder < 0) { throw new IllegalArgumentException("remainder < 0 : " + remainder); } if (divisor <= 0) { throw new IllegalArgumentException("divisor <= 0 : " + divisor); } if (remainder >= divisor) { throw new IllegalArgumentException("remainder >= divisor : " + remainder + "," + divisor); } iterCfg.addOption(DIVISOR_OPT, divisor + ""); iterCfg.addOption(REMAINDER_OPT, remainder + ""); }
Example #15
Source File: QueryDataTest.java From datawave with Apache License 2.0 | 5 votes |
@Test public void testCorrectReuse() { List<QueryData> queries = Lists.newArrayList(); QueryData query1 = new QueryData(); query1.setQuery("FOO == 'bar'"); query1.setSettings(Lists.newArrayList(new IteratorSetting(20, "iter1", "iter1.class"))); query1.setRanges(Collections.singleton(Range.prefix("1"))); queries.add(query1); queries.add(new QueryData(query1, Collections.singleton(Range.prefix("2")))); queries.add(new QueryData(query1, Collections.singleton(Range.prefix("3")))); Integer count = 1; List<IteratorSetting> prevSettings = null; String prevQuery = null; for (QueryData qd : queries) { if (null == prevSettings) { prevSettings = qd.getSettings(); } else { Assert.assertEquals(prevSettings, qd.getSettings()); } if (null == prevQuery) { prevQuery = qd.getQuery(); } else { Assert.assertEquals(prevQuery, qd.getQuery()); } Assert.assertEquals(1, qd.getRanges().size()); Range r = qd.getRanges().iterator().next(); Assert.assertEquals(count.toString(), r.getStartKey().getRow().toString()); count++; } }
Example #16
Source File: AccumuloOperations.java From geowave with Apache License 2.0 | 5 votes |
protected <T> void addConstraintsScanIteratorSettings( final RecordReaderParams params, final ScannerBase scanner, final DataStoreOptions options) { addFieldSubsettingToIterator(params, scanner); if (params.isMixedVisibility()) { // we have to at least use a whole row iterator final IteratorSetting iteratorSettings = new IteratorSetting( QueryFilterIterator.QUERY_ITERATOR_PRIORITY, QueryFilterIterator.QUERY_ITERATOR_NAME, WholeRowIterator.class); scanner.addScanIterator(iteratorSettings); } }
Example #17
Source File: RowHash.java From accumulo-examples with Apache License 2.0 | 5 votes |
public static void main(String[] args) throws Exception { Opts opts = new Opts(); opts.parseArgs(RowHash.class.getName(), args); Job job = Job.getInstance(opts.getHadoopConfig()); job.setJobName(RowHash.class.getName()); job.setJarByClass(RowHash.class); job.setInputFormatClass(AccumuloInputFormat.class); InputFormatBuilder.InputFormatOptions<Job> inputOpts = AccumuloInputFormat.configure() .clientProperties(opts.getClientProperties()).table(opts.tableName); String col = opts.column; int idx = col.indexOf(":"); Text cf = new Text(idx < 0 ? col : col.substring(0, idx)); Text cq = idx < 0 ? null : new Text(col.substring(idx + 1)); if (cf.getLength() > 0) { inputOpts.fetchColumns(Collections.singleton(new IteratorSetting.Column(cf, cq))); } inputOpts.store(job); job.setMapperClass(HashDataMapper.class); job.setMapOutputKeyClass(Text.class); job.setMapOutputValueClass(Mutation.class); job.setNumReduceTasks(0); job.setOutputFormatClass(AccumuloOutputFormat.class); AccumuloOutputFormat.configure().clientProperties(opts.getClientProperties()) .defaultTable(opts.tableName).store(job); System.exit(job.waitForCompletion(true) ? 0 : 1); }
Example #18
Source File: DiscoveryIteratorTest.java From datawave with Apache License 2.0 | 5 votes |
@Test public void testHappyPath() throws Throwable { Connector con = new InMemoryInstance("DiscoveryIteratorTest").getConnector("root", new PasswordToken("")); con.tableOperations().create("index"); writeSample(con.createBatchWriter("index", new BatchWriterConfig().setMaxLatency(0, TimeUnit.SECONDS).setMaxMemory(0).setMaxWriteThreads(1))); Scanner s = con.createScanner("index", new Authorizations("FOO")); s.addScanIterator(new IteratorSetting(50, DiscoveryIterator.class)); 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("term", 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 #19
Source File: DefaultQueryPlanner.java From datawave with Apache License 2.0 | 5 votes |
protected IteratorSetting getQueryIterator(MetadataHelper metadataHelper, ShardQueryConfiguration config, Query settings, String queryString, Boolean isFullTable) throws DatawaveQueryException { if (null == settingFuture) settingFuture = loadQueryIterator(metadataHelper, config, settings, queryString, isFullTable); if (settingFuture.isDone()) try { return settingFuture.get(); } catch (InterruptedException | ExecutionException e) { throw new RuntimeException(e.getCause()); } else return null; }
Example #20
Source File: CopyTool.java From rya with Apache License 2.0 | 5 votes |
/** * Set up job to use AccumuloMultiTableInput format, using the tables/ranges given by a ruleset. * @param job The Job to configure * @param rules The ruleset mapping a query to the appropriate tables and ranges */ protected void setupMultiTableInputFormat(final Job job, final AccumuloQueryRuleset rules) throws AccumuloSecurityException { AbstractInputFormat.setConnectorInfo(job, userName, new PasswordToken(pwd)); AbstractInputFormat.setScanAuthorizations(job, authorizations); if (!mock) { AbstractInputFormat.setZooKeeperInstance(job, new ClientConfiguration().withInstance(instance).withZkHosts(zk)); } else { AbstractInputFormat.setMockInstance(job, instance); } final Map<String, InputTableConfig> configs = rules.getInputConfigs(); // Add any relevant iterator settings final List<IteratorSetting> additionalSettings = new LinkedList<>(AccumuloRyaUtils.COMMON_REG_EX_FILTER_SETTINGS); if (ttl != null) { final IteratorSetting ttlSetting = new IteratorSetting(1, "fi", AgeOffFilter.class); AgeOffFilter.setTTL(ttlSetting, Long.valueOf(ttl)); additionalSettings.add(ttlSetting); } if (startTime != null) { final IteratorSetting startTimeSetting = getStartTimeSetting(startTime); additionalSettings.add(startTimeSetting); } for (final Map.Entry<String, InputTableConfig> entry : configs.entrySet()) { final List<IteratorSetting> iterators = entry.getValue().getIterators(); iterators.addAll(additionalSettings); entry.getValue().setIterators(iterators); } // Set the input format AccumuloMultiTableInputFormat.setInputTableConfigs(job, configs); job.setInputFormatClass(AccumuloMultiTableInputFormat.class); }
Example #21
Source File: ContinuousQuery.java From accumulo-examples with Apache License 2.0 | 5 votes |
public static void main(String[] args) throws Exception { Opts opts = new Opts(); opts.parseArgs(ContinuousQuery.class.getName(), args); try (AccumuloClient client = Accumulo.newClient().from(opts.getClientPropsPath()).build()) { ArrayList<Text[]> randTerms = findRandomTerms( client.createScanner(opts.doc2Term, Authorizations.EMPTY), opts.numTerms); Random rand = new Random(); try (BatchScanner bs = client.createBatchScanner(opts.tableName, Authorizations.EMPTY, 5)) { for (long i = 0; i < opts.iterations; i += 1) { Text[] columns = randTerms.get(rand.nextInt(randTerms.size())); bs.clearScanIterators(); bs.clearColumns(); IteratorSetting ii = new IteratorSetting(20, "ii", IntersectingIterator.class); IntersectingIterator.setColumnFamilies(ii, columns); bs.addScanIterator(ii); bs.setRanges(Collections.singleton(new Range())); long t1 = System.currentTimeMillis(); int count = Iterators.size(bs.iterator()); long t2 = System.currentTimeMillis(); System.out.printf(" %s %,d %6.3f%n", Arrays.asList(columns), count, (t2 - t1) / 1000.0); } } } }
Example #22
Source File: DefaultQueryPlanner.java From datawave with Apache License 2.0 | 5 votes |
public static void addOption(IteratorSetting cfg, String option, String value, boolean allowBlankValue) { if (StringUtils.isNotBlank(option) && (allowBlankValue || StringUtils.isNotBlank(value))) { // If blank value, then we need to change it to something else or it // will fail in InputFormatBase when run // through the MapReduce api. if (StringUtils.isBlank(value) && allowBlankValue) { value = " "; } cfg.addOption(option, value); } }
Example #23
Source File: CopyTool.java From rya with Apache License 2.0 | 5 votes |
/** * Creates an {@link IteratorSetting} with a time stamp filter that starts with the specified data. * @param time the start time of the filter. * @return the {@link IteratorSetting}. */ public static IteratorSetting getStartTimeSetting(final long time) { final IteratorSetting setting = new IteratorSetting(1, "startTimeIterator", TimestampFilter.class); TimestampFilter.setStart(setting, time, true); TimestampFilter.setEnd(setting, Long.MAX_VALUE, true); return setting; }
Example #24
Source File: ShardIndexQueryTableStaticMethods.java From datawave with Apache License 2.0 | 5 votes |
public static ScannerSession configureLimitedDiscovery(ShardQueryConfiguration config, ScannerFactory scannerFactory, String tableName, Collection<Range> ranges, Collection<String> literals, Collection<String> patterns, boolean reverseIndex, boolean limitToUniqueTerms) throws Exception { // if we have no ranges, then nothing to scan if (ranges.isEmpty()) { return null; } ScannerSession bs = scannerFactory.newLimitedScanner(AnyFieldScanner.class, tableName, config.getAuthorizations(), config.getQuery()); bs.setRanges(ranges); SessionOptions options = new SessionOptions(); options.addScanIterator(configureDateRangeIterator(config)); IteratorSetting setting = configureGlobalIndexDataTypeFilter(config, config.getDatatypeFilter()); if (setting != null) { options.addScanIterator(setting); } setting = configureGlobalIndexTermMatchingIterator(config, literals, patterns, reverseIndex, limitToUniqueTerms); if (setting != null) { options.addScanIterator(setting); } bs.setOptions(options); return bs; }
Example #25
Source File: EntryIterator.java From accumulo-recipes with Apache License 2.0 | 5 votes |
public static void setTypeRegistry(IteratorSetting setting, TypeRegistry<String> registry) { checkNotNull(registry); try { setting.addOption(TYPE_REGISTRY, new String(Serializables.toBase64(registry))); } catch (Exception e) { throw new RuntimeException(e); } }
Example #26
Source File: FirstEntryInPrefixedRowTest.java From accumulo-recipes with Apache License 2.0 | 5 votes |
private Scanner buildScanner() throws TableNotFoundException { IteratorSetting setting = new IteratorSetting(5, TestFirstEntryInPrefixedRowIterator.class); Scanner scanner = connector.createScanner("test", new Authorizations()); scanner.addScanIterator(setting); return scanner; }
Example #27
Source File: BoundingBoxFilter.java From accumulo-recipes with Apache License 2.0 | 5 votes |
public static void setBoundingBox(IteratorSetting config, Rectangle2D.Double box) { Map<String, String> props = new HashMap<String, String>(); props.put("x", Double.toString(box.getX())); props.put("y", Double.toString(box.getY())); props.put("width", Double.toString(box.getWidth())); props.put("height", Double.toString(box.getHeight())); config.addOptions(props); }
Example #28
Source File: AccumuloRyaUtils.java From rya with Apache License 2.0 | 5 votes |
/** * Creates a {@link RegExFilter} setting to ignore the version row in a table. * @return the {@link RegExFilter} {@link IteratorSetting}. */ public static IteratorSetting getVersionRegExFilterSetting() { final IteratorSetting regex = new IteratorSetting(30, "version_regex", RegExFilter.class); RegExFilter.setRegexs(regex, "(.*)urn:(.*)#version[\u0000|\u0001](.*)", null, null, null, false); Filter.setNegate(regex, true); return regex; }
Example #29
Source File: Persister.java From datawave with Apache License 2.0 | 5 votes |
private void tableCheck(Connector c) throws AccumuloException, AccumuloSecurityException, TableExistsException { if (!c.tableOperations().exists(TABLE_NAME)) { c.tableOperations().create(TABLE_NAME); try { IteratorSetting iteratorCfg = new IteratorSetting(19, "ageoff", QueriesTableAgeOffIterator.class); c.tableOperations().attachIterator(TABLE_NAME, iteratorCfg, EnumSet.allOf(IteratorScope.class)); } catch (TableNotFoundException e) { throw new AccumuloException("We just created " + TABLE_NAME + " so this shouldn't have happened!", e); } } }
Example #30
Source File: QueryScannerHelper.java From datawave with Apache License 2.0 | 5 votes |
public static IteratorSetting getQueryInfoIterator(Query query, boolean reportErrors, String querystring) { QueryInformation info = new QueryInformation(query, querystring); IteratorSetting cfg = new IteratorSetting(Integer.MAX_VALUE, QueryInformationIterator.class, info.toMap()); if (reportErrors) QueryInformationIterator.setErrorReporting(cfg); return cfg; }