org.apache.accumulo.core.iterators.SortedKeyValueIterator Java Examples
The following examples show how to use
org.apache.accumulo.core.iterators.SortedKeyValueIterator.
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: DocumentDataIterator.java From datawave with Apache License 2.0 | 6 votes |
public DocumentDataIterator(SortedKeyValueIterator<Key,Value> source, final IteratorEnvironment env, final Map<String,String> options, Range totalRange, Predicate<Key> dataTypeFilter, Equality eq, EventDataQueryFilter evaluationFilter, boolean includeChildCount, boolean includeParent) { this.source = source; this.totalRange = totalRange; try { this.source.seek(totalRange, columnFamilies, inclusive); } catch (IOException e) { throw new RuntimeException("Could not seek in constructor", e); } this.dataTypeFilter = dataTypeFilter; this.evaluationFilter = evaluationFilter; this.documentMapper = new KeyToDocumentData(source, env, options, eq, evaluationFilter, includeChildCount, includeParent); findNextDocument(); }
Example #2
Source File: DocumentIndexIntersectingIterator.java From rya with Apache License 2.0 | 6 votes |
public void addSource(SortedKeyValueIterator<Key,Value> source, IteratorEnvironment env, TextColumn column) { // Check if we have space for the added Source if (sources == null) { sources = new TermSource[1]; } else { // allocate space for node, and copy current tree. // TODO: Should we change this to an ArrayList so that we can just add() ? - ACCUMULO-1309 TermSource[] localSources = new TermSource[sources.length + 1]; int currSource = 0; for (TermSource myTerm : sources) { // TODO: Do I need to call new here? or can I just re-use the term? - ACCUMULO-1309 localSources[currSource] = new TermSource(myTerm); currSource++; } sources = localSources; } sources[sourcesCount] = new TermSource(source.deepCopy(env), column); sourcesCount++; }
Example #3
Source File: SeekingAggregator.java From datawave with Apache License 2.0 | 6 votes |
/** * Advance an iterator until skip(...) returns false. May be a combination of seek() and next() calls * * @param itr * @param pointer * @param currentRange * @param columnFamilies * @param includeColumnFamilies * @throws IOException */ protected void advanceItr(SortedKeyValueIterator<Key,Value> itr, ByteSequence pointer, Range currentRange, Collection<ByteSequence> columnFamilies, boolean includeColumnFamilies) throws IOException { Key current = itr.getTopKey(); Text row = current.getRow(); int nextCount = 0; while (current != null && skip(current, row, pointer)) { if (maxNextCount == -1 || nextCount < maxNextCount) { itr.next(); nextCount++; } else { Key startKey = getSeekStartKey(current, pointer); Range newRange = new Range(startKey, false, currentRange.getEndKey(), currentRange.isEndKeyInclusive()); itr.seek(newRange, columnFamilies, includeColumnFamilies); nextCount = 0; } current = itr.hasTop() ? itr.getTopKey() : null; } }
Example #4
Source File: SourceManagerTest.java From datawave with Apache License 2.0 | 6 votes |
@Test public void assertNexts() throws IOException { SourceManager manager = new SourceManager(counter); manager.setInitialSize(10); Collection<SortedKeyValueIterator<Key,Value>> kvList = Lists.newArrayList(); for (int i = 0; i < 500; i++) { kvList.add(manager.deepCopy(null)); } for (SortedKeyValueIterator<Key,Value> kv : kvList) { kv.seek(new Range(), Collections.emptyList(), false); kv.next(); } assertEquals(500, counter.nextCalls); assertEquals(10, counter.counter); }
Example #5
Source File: AncestorQueryIterator.java From datawave with Apache License 2.0 | 6 votes |
@Override public void init(SortedKeyValueIterator<Key,Value> source, Map<String,String> options, IteratorEnvironment env) throws IOException { if (log.isTraceEnabled()) { log.trace("AncestorQueryIterator init()"); } super.init(source, options, env); // force evaluation of ranges to find missed hits this.mustUseFieldIndex = true; // TODO: Figure out why this is in the TLD logic: // Replace the fieldIndexKeyDataTypeFilter with a chain of "anded" index-filtering predicates. // If no other predicates are configured via the indexfiltering.classes property, the method // simply returns the existing fieldIndexKeyDataTypeFilter value. Otherwise, the returned value // contains an "anded" chain of newly configured predicates following the existing // fieldIndexKeyDataTypeFilter value (assuming it is defined with something other than the default // "ALWAYS_TRUE" KeyIdentity.Function). fieldIndexKeyDataTypeFilter = parseIndexFilteringChain(new SourcedOptions<>(source, env, options)); disableIndexOnlyDocuments = false; }
Example #6
Source File: DownsampleIterator.java From timely with Apache License 2.0 | 6 votes |
@Override public void init(SortedKeyValueIterator<Key, Value> source, Map<String, String> options, IteratorEnvironment env) throws IOException { super.init(source, options, env); start = Long.parseLong(options.get(START)); end = Long.parseLong(options.get(END)); period = Long.parseLong(options.get(PERIOD)); // default = 100 MB long maxDownsampleMemory = -1; if (options.containsKey(MAX_DOWNSAMPLE_MEMORY)) { maxDownsampleMemory = Long.parseLong(options.get(MAX_DOWNSAMPLE_MEMORY)); } memoryEstimator = new DownsampleMemoryEstimator(maxDownsampleMemory, start, period); String aggClassname = options.get(AGGCLASS); Class<?> aggClass; try { aggClass = this.getClass().getClassLoader().loadClass(aggClassname); } catch (ClassNotFoundException e) { throw new RuntimeException(e); } @SuppressWarnings("unchecked") Class<? extends Aggregator> uncheckedAggClass = (Class<? extends Aggregator>) aggClass; factory = new DownsampleFactory(start, end, period, uncheckedAggClass); }
Example #7
Source File: DocumentIndexIntersectingIterator.java From rya with Apache License 2.0 | 6 votes |
@Override public void init(SortedKeyValueIterator<Key,Value> source, Map<String,String> options, IteratorEnvironment env) throws IOException { TextColumn[] terms = decodeColumns(options.get(columnOptionName)); boolean[] prefixes = decodeBooleans(options.get(columnPrefix)); ctxt = decodeContext(options.get(context)); if(ctxt != null) { hasContext = true; } if (terms.length < 2) { throw new IllegalArgumentException("IntersectionIterator requires two or more columns families"); } sources = new TermSource[terms.length]; sources[0] = new TermSource(source, terms[0]); for (int i = 1; i < terms.length; i++) { //log.info("For decoded column " + i + " column family is " + terms[i].getColumnFamily() + " and qualifier is " + terms[i].getColumnQualifier()); sources[i] = new TermSource(source.deepCopy(env), terms[i]); sources[i].isPrefix = prefixes[i]; } sourcesCount = terms.length; }
Example #8
Source File: TermFrequencyAggregatorTest.java From datawave with Apache License 2.0 | 6 votes |
@Test public void apply_testNormal() throws IOException { TreeMap<Key,Value> treeMap = Maps.newTreeMap(); treeMap.put(getTF("123", "FIELD1", "VALUE1", "dataType1", "123.345.456", 10), new Value()); SortedKeyValueIterator<Key,Value> itr = new SortedMapIterator(treeMap); itr.seek(new Range(), null, true); Key result = aggregator.apply(itr); assertFalse(itr.hasTop()); itr.seek(new Range(), null, true); Key result2 = aggregator.apply(itr, new Range(), null, false); assertFalse(itr.hasTop()); assertEquals(result, result2); }
Example #9
Source File: TimeoutIterator.java From datawave with Apache License 2.0 | 6 votes |
@Override public void init(SortedKeyValueIterator<Key,Value> source, Map<String,String> options, IteratorEnvironment env) throws IOException { super.init(source, options, env); final String maxSessionOpt = options.get(MAX_SESSION_TIME); if (null != maxSessionOpt) { try { maxSessionTime = Long.parseLong(maxSessionOpt); } catch (NumberFormatException nfe) { if (log.isTraceEnabled()) { log.trace("Defaulting to Long.MAX_VALUE since maxKeysVisit is an invalid long value"); } } } currentSession = System.currentTimeMillis(); }
Example #10
Source File: CreateUidsIterator.java From datawave with Apache License 2.0 | 6 votes |
@Override public void init(SortedKeyValueIterator<Key,Value> source, Map<String,String> options, IteratorEnvironment env) throws IOException { src = source; if (null != options) { final String collapseOpt = options.get(COLLAPSE_UIDS); if (null != collapseOpt) { try { collapseUids = Boolean.valueOf(collapseOpt); } catch (Exception e) { collapseUids = false; } } final String parseTldUidsOption = options.get(PARSE_TLD_UIDS); if (null != parseTldUidsOption) { parseTldUids = Boolean.parseBoolean(parseTldUidsOption); } } }
Example #11
Source File: RowTimestampFilter.java From vertexium with Apache License 2.0 | 6 votes |
@Override public void init(SortedKeyValueIterator<Key, Value> source, Map<String, String> options, IteratorEnvironment env) throws IOException { if (options == null) { throw new IllegalArgumentException(TIMESTAMPS + " is required"); } super.init(source, options, env); String timestampOptions = options.get(TIMESTAMPS); if (timestampOptions == null) { throw new IllegalArgumentException(TIMESTAMPS + " is required"); } timestamps = new HashMap<>(); for (String timestampOption : timestampOptions.split(";")) { String[] parts = timestampOption.split(":"); if (parts.length != 5) { throw new IllegalArgumentException(TIMESTAMPS + " is invalid. Expected 5 parts found " + parts.length + ": " + timestampOption); } Text rowKey = new Text(OptionsUtils.hexToBytes(parts[0])); Long startTimestamp = OptionsUtils.parseLong(parts[1]); Boolean startInclusive = OptionsUtils.parseBoolean(parts[2]); Long endTimestamp = OptionsUtils.parseLong(parts[3]); Boolean endInclusive = OptionsUtils.parseBoolean(parts[4]); timestamps.put(rowKey, new Timestamp(startTimestamp, startInclusive, endTimestamp, endInclusive)); } }
Example #12
Source File: IteratorBuildingVisitor.java From datawave with Apache License 2.0 | 5 votes |
public IteratorBuildingVisitor setSource(SourceFactory sourceFactory, IteratorEnvironment env) { SortedKeyValueIterator<Key,Value> skvi = sourceFactory.getSourceDeepCopy(); this.source = new SourceManager(skvi); this.env = env; Map<String,String> options = Maps.newHashMap(); try { this.source.init(skvi, options, env); } catch (IOException e) { throw new RuntimeException(e); } return this; }
Example #13
Source File: TermFrequencyAggregatorTest.java From datawave with Apache License 2.0 | 5 votes |
@Test public void apply_buildDocNotKeep() throws IOException { Document doc = new Document(); AttributeFactory attributeFactory = new AttributeFactory(new TypeMetadata()); TreeMap<Key,Value> treeMap = Maps.newTreeMap(); treeMap.put(getTF("123", "FIELD1", "VALUE1", "dataType1", "123.345.456", 10), new Value()); treeMap.put(getTF("123", "NEXT_DOC_FIELD", "VALUE1", "dataType1", "124.345.456", 10), new Value()); SortedKeyValueIterator<Key,Value> itr = new SortedMapIterator(treeMap); itr.seek(new Range(), null, true); Set<String> keepFields = new HashSet<>(); keepFields.add("FIELD2"); EventDataQueryFilter filter = new EventDataQueryFieldFilter(); Set<String> blacklist = new HashSet<>(); blacklist.add("FIELD1"); ((EventDataQueryFieldFilter) filter).initializeBlacklist(blacklist); aggregator = new TermFrequencyAggregator(keepFields, filter, -1); Key result = aggregator.apply(itr, doc, attributeFactory); // test result key assertTrue(result == null); // test that the doc is empty assertTrue(doc.size() == 0); // test that the iterator is in the correct position assertTrue(itr.hasTop()); assertTrue(itr.getTopKey().equals(getTF("123", "NEXT_DOC_FIELD", "VALUE1", "dataType1", "124.345.456", 10))); }
Example #14
Source File: SourceManagerTest.java From datawave with Apache License 2.0 | 5 votes |
@Test public void dataIntegrity_individualTest() throws IOException { SourceManager manager = new SourceManager(dataIterator); manager.setInitialSize(1); // pre-seek both iterators SortedKeyValueIterator<Key,Value> copy1 = manager.deepCopy(null); copy1.seek(new Range(), Collections.emptyList(), false); SortedKeyValueIterator<Key,Value> copy2 = manager.deepCopy(null); copy2.seek(new Range(), Collections.emptyList(), false); // individual next loops int copy1Count = 0; while (copy1.hasTop()) { assertNotEquals("unexpected topKey on iteration=" + copy1Count, null, copy1.getTopKey()); copy1Count++; copy1.next(); } int copy2Count = 0; while (copy2.hasTop()) { assertNotEquals("unexpected topKey on iteration=" + copy2Count, null, copy2.getTopKey()); copy2Count++; copy2.next(); } assertTrue("both copies should have the same number of next calls; copy1=" + copy1Count + " copy2=" + copy2Count, copy1Count == copy2Count); }
Example #15
Source File: FirstNEntriesInRowIterator.java From accumulo-recipes with Apache License 2.0 | 5 votes |
@Override public void init(SortedKeyValueIterator<Key,Value> source, Map<String,String> options, IteratorEnvironment env) throws IOException { String o = options.get(NUM_SCANS_STRING_NAME); String nStr = options.get(NUM_KEYS_STRING_NAME); n = nStr == null ? 25 : Integer.parseInt(nStr); numscans = o == null ? 10 : Integer.parseInt(o); setSource(source.deepCopy(env)); }
Example #16
Source File: QueryIterator.java From datawave with Apache License 2.0 | 5 votes |
protected Iterator<Entry<Key,Document>> mapDocument(SortedKeyValueIterator<Key,Value> deepSourceCopy, Iterator<Entry<Key,Document>> documents, CompositeMetadata compositeMetadata) { // now lets pull the data if we need to if (log.isTraceEnabled()) { log.trace("mapDocument " + fieldIndexSatisfiesQuery); } if (fieldIndexSatisfiesQuery) { final KeyToDocumentData docMapper = new KeyToDocumentData(deepSourceCopy, this.myEnvironment, this.documentOptions, super.equality, getEvaluationFilter(), this.includeHierarchyFields, this.includeHierarchyFields); Iterator<Tuple2<Key,Document>> mappedDocuments = Iterators.transform( documents, new GetDocument(docMapper, new Aggregation(this.getTimeFilter(), typeMetadataWithNonIndexed, compositeMetadata, this .isIncludeGroupingContext(), this.includeRecordId, this.disableIndexOnlyDocuments(), getEvaluationFilter(), isTrackSizes()))); Iterator<Entry<Key,Document>> retDocuments = Iterators.transform(mappedDocuments, new TupleToEntry<>()); // Inject the document permutations if required if (!this.getDocumentPermutations().isEmpty()) { if (gatherTimingDetails()) { retDocuments = Iterators.transform(retDocuments, new EvaluationTrackingFunction<>(QuerySpan.Stage.DocumentPermutation, trackingSpan, new DocumentPermutation.DocumentPermutationAggregation(this.getDocumentPermutations()))); } else { retDocuments = Iterators.transform(retDocuments, new DocumentPermutation.DocumentPermutationAggregation(this.getDocumentPermutations())); } } return retDocuments; } return documents; }
Example #17
Source File: SourceManagerTest.java From datawave with Apache License 2.0 | 5 votes |
@Test public void dataIntegrity_alternatingTest() throws IOException { SourceManager manager = new SourceManager(dataIterator); manager.setInitialSize(1); // pre-seek both iterators SortedKeyValueIterator<Key,Value> copy1 = manager.deepCopy(null); copy1.seek(new Range(), Collections.emptyList(), false); SortedKeyValueIterator<Key,Value> copy2 = manager.deepCopy(null); copy2.seek(new Range(), Collections.emptyList(), false); // re-seek copy1.seek(new Range(), Collections.emptyList(), false); copy2.seek(new Range(), Collections.emptyList(), false); // alternating next loops int alternatingCount = 0; while (copy1.hasTop() && copy2.hasTop()) { assertTrue(copy1.getTopKey().equals(copy2.getTopKey())); alternatingCount++; copy1.next(); copy2.next(); } assertFalse(copy1.hasTop()); assertFalse(copy2.hasTop()); assertEquals(26, alternatingCount); }
Example #18
Source File: MergingVisibilityCombiner.java From geowave with Apache License 2.0 | 5 votes |
@Override public SortedKeyValueIterator<Key, Value> deepCopy(final IteratorEnvironment env) { final SortedKeyValueIterator<Key, Value> retVal = super.deepCopy(env); if (retVal instanceof MergingVisibilityCombiner) { ((MergingVisibilityCombiner) retVal).combiners = combiners; } return retVal; }
Example #19
Source File: SnapshotIterator.java From fluo with Apache License 2.0 | 5 votes |
@Override public void init(SortedKeyValueIterator<Key, Value> source, Map<String, String> options, IteratorEnvironment env) throws IOException { this.source = new TimestampSkippingIterator(source); this.snaptime = Long.parseLong(options.get(TIMESTAMP_OPT)); this.returnReadLockPresent = Boolean.parseBoolean(options.getOrDefault(RETURN_READLOCK_PRESENT_OPT, "false")); // TODO could require client to send version as a sanity check }
Example #20
Source File: HistoricalEventsIterator.java From vertexium with Apache License 2.0 | 5 votes |
@Override public void init(SortedKeyValueIterator<Key, Value> source, Map<String, String> options, IteratorEnvironment env) throws IOException { super.init(source, options, env); fetchHints = new IteratorHistoricalEventsFetchHints( OptionsUtils.parseLongOptional(options.get(SETTING_FETCH_HINTS_PREFIX + "startTime")), OptionsUtils.parseLongOptional(options.get(SETTING_FETCH_HINTS_PREFIX + "endTime")), OptionsUtils.parseSortDirectionOptional(options.get(SETTING_FETCH_HINTS_PREFIX + "sortDirection")), OptionsUtils.parseLongOptional(options.get(SETTING_FETCH_HINTS_PREFIX + "limit")), Boolean.parseBoolean(options.get(SETTING_FETCH_HINTS_PREFIX + "includePreviousPropertyValues")), Boolean.parseBoolean(options.get(SETTING_FETCH_HINTS_PREFIX + "includePropertyValues")) ); elementType = OptionsUtils.parseElementTypeRequired(options.get("elementType")); String after = options.get("after"); this.after = after == null || after.length() == 0 ? null : HistoricalEventId.fromString(after); }
Example #21
Source File: QueryInformationIterator.java From datawave with Apache License 2.0 | 5 votes |
@Override public void init(SortedKeyValueIterator<Key,Value> source, Map<String,String> options, IteratorEnvironment env) throws IOException { this.info = new QueryInformation(options); if (null != options.get(REPORT_ERRORS_OPT)) { reportErrors = true; } try { super.init(source, options, env); } catch (RuntimeException | IOException e) { log.error("Caught exception on init: " + info, e); throw e; } }
Example #22
Source File: TLDTermFrequencyAggregatorTest.java From datawave with Apache License 2.0 | 5 votes |
@Test public void apply_buildDocOnlyKeepToKeep() throws IOException, ParseException { Document doc = new Document(); AttributeFactory attributeFactory = new AttributeFactory(new TypeMetadata()); TreeMap<Key,Value> treeMap = Maps.newTreeMap(); treeMap.put(getTF("123", "FIELD1", "VALUE1", "dataType1", "123.345.456", 10), new Value()); treeMap.put(getTF("123", "FIELD1", "VALUE1", "dataType1", "123.345.456.1", 10), new Value()); treeMap.put(getTF("123", "NEXT_DOC_FIELD", "VALUE1", "dataType1", "124.345.456", 10), new Value()); SortedKeyValueIterator<Key,Value> itr = new SortedMapIterator(treeMap); itr.seek(new Range(), null, true); Set<String> keepFields = new HashSet<>(); keepFields.add("FIELD2"); EventDataQueryFilter filter = new EventDataQueryFieldFilter(JexlASTHelper.parseJexlQuery("FIELD2 == 'VALUE1'"), Collections.emptySet()); aggregator = new TLDTermFrequencyAggregator(keepFields, filter, -1); Key result = aggregator.apply(itr, doc, attributeFactory); // test result key assertTrue(result == null); // test that the doc is empty assertTrue(doc.size() == 0); // test that the iterator is in the correct position assertTrue(itr.hasTop()); assertTrue(itr.getTopKey().equals(getTF("123", "NEXT_DOC_FIELD", "VALUE1", "dataType1", "124.345.456", 10))); }
Example #23
Source File: MetricAgeOffIteratorTest.java From timely with Apache License 2.0 | 5 votes |
@Test public void testSeekPastEndKey() throws Exception { SortedMap<Key, Value> table = new TreeMap<>(); table.put(new Key(MetricAdapter.encodeRowKey("sys.cpu.user", TEST_TIME), new byte[0], new byte[0], new byte[0], TEST_TIME), EMPTY_VALUE); table.put(new Key(MetricAdapter.encodeRowKey("sys.cpu.user", TEST_TIME + 1), new byte[0], new byte[0], new byte[0], TEST_TIME + 1), EMPTY_VALUE); table.put(new Key(MetricAdapter.encodeRowKey("sys.cpu.user", TEST_TIME + 2), new byte[0], new byte[0], new byte[0], TEST_TIME + 2), EMPTY_VALUE); table.put(new Key(MetricAdapter.encodeRowKey("sys.cpu.user", TEST_TIME + 3), new byte[0], new byte[0], new byte[0], TEST_TIME + 3), EMPTY_VALUE); table.put(new Key(MetricAdapter.encodeRowKey("sys.cpu.user", TEST_TIME + 4), new byte[0], new byte[0], new byte[0], TEST_TIME + 4), EMPTY_VALUE); table.put(new Key(MetricAdapter.encodeRowKey("sys.cpu.user", TEST_TIME + 5), new byte[0], new byte[0], new byte[0], TEST_TIME + 5), EMPTY_VALUE); SortedKeyValueIterator<Key, Value> source = new SortedMapIterator(table); MetricAgeOffIterator iter = new MetricAgeOffIterator(); HashMap<String, String> options = new HashMap<>(); options.put(MetricAgeOffIterator.AGE_OFF_PREFIX + "default", Integer.toString(1)); iter.init(source, options, null); iter.seek(new Range(new Key("sys.cpu.user"), true, new Key(MetricAdapter.encodeRowKey("sys.cpu.user", TEST_TIME + 3), new byte[0], new byte[0], new byte[0], TEST_TIME + 3), true), columnFamilies, true); int seen = 0; while (iter.hasTop()) { Key k = iter.getTopKey(); Assert.assertTrue(k.getTimestamp() >= TEST_TIME && k.getTimestamp() <= TEST_TIME + 5); seen++; iter.next(); } Assert.assertEquals(0, seen); }
Example #24
Source File: MetricAgeOffIteratorTest.java From timely with Apache License 2.0 | 5 votes |
@Test public void testDefault() throws Exception { SortedMap<Key, Value> table = new TreeMap<>(); table.put(new Key(MetricAdapter.encodeRowKey("sys.cpu.user", TEST_TIME), new byte[0], new byte[0], new byte[0], TEST_TIME), EMPTY_VALUE); table.put(new Key(MetricAdapter.encodeRowKey("sys.cpu.user", TEST_TIME + 1), new byte[0], new byte[0], new byte[0], TEST_TIME + 1), EMPTY_VALUE); table.put(new Key(MetricAdapter.encodeRowKey("sys.cpu.user", TEST_TIME + 2), new byte[0], new byte[0], new byte[0], TEST_TIME + 2), EMPTY_VALUE); table.put(new Key(MetricAdapter.encodeRowKey("sys.cpu.user", TEST_TIME + 3), new byte[0], new byte[0], new byte[0], TEST_TIME + 3), EMPTY_VALUE); table.put(new Key(MetricAdapter.encodeRowKey("sys.cpu.user", TEST_TIME + 4), new byte[0], new byte[0], new byte[0], TEST_TIME + 4), EMPTY_VALUE); table.put(new Key(MetricAdapter.encodeRowKey("sys.cpu.user", TEST_TIME + 5), new byte[0], new byte[0], new byte[0], TEST_TIME + 5), EMPTY_VALUE); SortedKeyValueIterator<Key, Value> source = new SortedMapIterator(table); MetricAgeOffIterator iter = new MetricAgeOffIterator(); HashMap<String, String> options = new HashMap<>(); options.put(MetricAgeOffIterator.AGE_OFF_PREFIX + "default", Integer.toString(1 * ONE_DAY)); iter.init(source, options, null); iter.seek(new Range(), columnFamilies, true); int seen = 0; while (iter.hasTop()) { Key k = iter.getTopKey(); Assert.assertTrue(k.getTimestamp() >= TEST_TIME && k.getTimestamp() <= TEST_TIME + 5); seen++; iter.next(); } Assert.assertEquals(6, seen); }
Example #25
Source File: SourceThreadTrackingIterator.java From datawave with Apache License 2.0 | 5 votes |
@Override public void init(SortedKeyValueIterator<K,V> source, Map<String,String> options, IteratorEnvironment env) throws IOException { if (!inMethod.compareAndSet(false, true)) { log.error("Concurrently initializing " + source + " on thread " + Thread.currentThread().getId(), new RuntimeException()); } try { if (log.isDebugEnabled()) log.debug("Initializing " + source + " on thread " + Thread.currentThread().getId()); this.source = source; } finally { if (!inMethod.compareAndSet(true, false)) { log.error("Concurrently initializing " + source + " on thread " + Thread.currentThread().getId(), new RuntimeException()); } } }
Example #26
Source File: BulkInputFormat.java From datawave with Apache License 2.0 | 5 votes |
/** * Check whether a configuration is fully configured to be used with an Accumulo {@link org.apache.hadoop.mapreduce.InputFormat}. * * @param conf * the Hadoop configuration object * @throws IOException * if the configuration is improperly configured */ protected static void validateOptions(Configuration conf) throws IOException { if (!conf.getBoolean(INPUT_INFO_HAS_BEEN_SET, false)) throw new IOException("Input info has not been set."); if (!conf.getBoolean(INSTANCE_HAS_BEEN_SET, false)) throw new IOException("Instance info has not been set."); /* * if (conf.get(RACKSTRATEGY) == null) { throw new IOException("Rack strategy must be set."); } */ // validate that we can connect as configured try { Connector c = getInstance(conf).getConnector(getUsername(conf), new PasswordToken(getPassword(conf))); if (!c.securityOperations().authenticateUser(getUsername(conf), new PasswordToken(getPassword(conf)))) throw new IOException("Unable to authenticate user"); if (!c.securityOperations().hasTablePermission(getUsername(conf), getTablename(conf), TablePermission.READ)) throw new IOException("Unable to access table"); if (!usesLocalIterators(conf)) { // validate that any scan-time iterators can be loaded by the the tablet servers for (AccumuloIterator iter : getIterators(conf)) { if (!c.tableOperations().testClassLoad(getTablename(conf), iter.getIteratorClass(), SortedKeyValueIterator.class.getName()) && !c.instanceOperations().testClassLoad(iter.getIteratorClass(), SortedKeyValueIterator.class.getName())) throw new AccumuloException("Servers are unable to load " + iter.getIteratorClass() + " as a " + SortedKeyValueIterator.class.getName()); } } } catch (AccumuloException | AccumuloSecurityException | TableNotFoundException e) { throw new IOException(e); } }
Example #27
Source File: FixedCardinalitySkippingIterator.java From geowave with Apache License 2.0 | 5 votes |
protected FixedCardinalitySkippingIterator( final SortedKeyValueIterator<Key, Value> source, final Integer bitPosition, final Collection<ByteSequence> columnFamilies, final boolean inclusive) { this(source); this.columnFamilies = columnFamilies; this.bitPosition = bitPosition; this.inclusive = inclusive; }
Example #28
Source File: FieldIndexDocumentFilter.java From datawave with Apache License 2.0 | 5 votes |
@Override public void init(SortedKeyValueIterator<Key,Value> source, Map<String,String> options, IteratorEnvironment env) throws IOException { super.init(source, options, env); String suffix = NULL_BYTE + options.get(DATA_TYPE_OPT) + NULL_BYTE + options.get(EVENT_UID_OPT); try { cqSuffix = suffix.getBytes("UTF8"); } catch (UnsupportedEncodingException uee) { throw new RuntimeException("Unable to encode using UTF8?", uee); } }
Example #29
Source File: CsvKeyFilter.java From datawave with Apache License 2.0 | 5 votes |
@Override public void init(SortedKeyValueIterator<Key,Value> source, Map<String,String> options, IteratorEnvironment env) throws IOException { super.init(source, options, env); String csv = options.get(ALLOWED_OPT); if (csv != null && !csv.isEmpty()) { allowed = new HashSet<>(); String[] vals = StringUtils.split(csv, ','); for (String val : vals) { if (log.isTraceEnabled()) { log.trace("Adding value " + val + " to filter."); } allowed.add(new Text(val)); } } else { if (log.isDebugEnabled()) { log.debug("AllowAll is turned on-- returning true for all values."); } allowAll = true; } String part = options.get(KEY_PART_OPT); if (part == null || part.isEmpty()) { this.part = KeyPart.ROW; } else { if ("colq".equalsIgnoreCase(part)) { this.part = KeyPart.COLQ; } else if ("colf".equalsIgnoreCase(part)) { this.part = KeyPart.COLF; } else { this.part = KeyPart.ROW; } } if (log.isDebugEnabled()) { log.debug("Will filter on key part " + this.part); } }
Example #30
Source File: GlobalIndexTermMatchingIterator.java From datawave with Apache License 2.0 | 5 votes |
@Override public void init(SortedKeyValueIterator<Key,Value> source, Map<String,String> options, IteratorEnvironment env) throws IOException { super.init(source, options, env); if (!validateOptions(options)) throw new IOException("Iterator options are not correct"); setSource(source); }