Java Code Examples for org.apache.accumulo.core.data.Range#getStartKey()
The following examples show how to use
org.apache.accumulo.core.data.Range#getStartKey() .
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: CompositeSeeker.java From datawave with Apache License 2.0 | 6 votes |
@Override public Key nextSeekKey(List<String> fields, Key currentKey, Range currentRange, String separator) { Key startKey = currentRange.getStartKey(); Key endKey = currentRange.getEndKey(); List<String> values = Arrays.asList(currentKey.getRow().toString().split(separator)); List<String> startValues = Arrays.asList(startKey.getRow().toString().split(separator)); List<String> endValues = Arrays.asList(endKey.getRow().toString().split(separator)); String nextLowerBound = nextLowerBound(fields, values, separator, startValues, currentRange.isStartKeyInclusive(), endValues, currentRange.isEndKeyInclusive()); Key newStartKey = new Key(new Text(nextLowerBound), startKey.getColumnFamily(), startKey.getColumnQualifier(), startKey.getColumnVisibility(), 0L); // return a new seek key only if it falls within the current range if (currentRange.contains(newStartKey)) return newStartKey; return startKey; }
Example 2
Source File: FirstNEntriesInRowIterator.java From accumulo-recipes with Apache License 2.0 | 6 votes |
@Override public void seek(Range range, Collection<ByteSequence> columnFamilies, boolean inclusive) throws IOException { // save parameters for future internal seeks latestRange = range; latestColumnFamilies = columnFamilies; latestInclusive = inclusive; lastRowFound = null; Key startKey = range.getStartKey(); Range seekRange = new Range(startKey == null ? null : new Key(startKey.getRow()), true, range.getEndKey(), range.isEndKeyInclusive()); getSource().seek(seekRange, columnFamilies, inclusive); finished = false; if (getSource().hasTop()) { lastRowFound = getSource().getTopKey().getRow(); if (hasSeeked && range.beforeStartKey(getSource().getTopKey())) skipRow(); } hasSeeked = true; prepKeys(); }
Example 3
Source File: DatawaveFieldIndexCachingIteratorJexl.java From datawave with Apache License 2.0 | 6 votes |
/** * Does the last range seeked contain the passed in range * * @param r * @return true if there is a last seeked range and it contains the passed in range */ protected boolean lastRangeSeekedContains(Range r) { boolean subRange = false; if (this.lastRangeSeeked != null) { Key beginOfThisRange = r.getStartKey(); Key endOfThisRange = r.getEndKey(); subRange = true; if (beginOfThisRange == null && this.lastRangeSeeked.getStartKey() != null) { subRange = false; } else if (!Objects.equal(beginOfThisRange, this.lastRangeSeeked.getStartKey()) && !this.lastRangeSeeked.contains(beginOfThisRange)) { subRange = false; } else if (endOfThisRange == null && this.lastRangeSeeked.getEndKey() != null) { subRange = false; } else if (!Objects.equal(endOfThisRange, this.lastRangeSeeked.getEndKey()) && !this.lastRangeSeeked.contains(endOfThisRange)) { subRange = false; } } return subRange; }
Example 4
Source File: AndingIterator.java From rya with Apache License 2.0 | 6 votes |
@Override public void seek(final Range range, final Collection<ByteSequence> seekColumnFamilies, final boolean inclusive) throws IOException { overallRange = new Range(range); currentPartition = new Text(); currentDocID.set(emptyByteArray); // seek each of the sources to the right column family within the row given by key for (int i = 0; i < sourcesCount; i++) { Key sourceKey; if (range.getStartKey() != null) { if (range.getStartKey().getColumnQualifier() != null) { sourceKey = buildKey(getPartition(range.getStartKey()), sources[i].term, range.getStartKey().getColumnQualifier()); } else { sourceKey = buildKey(getPartition(range.getStartKey()), sources[i].term); } // Seek only to the term for this source as a column family sources[i].iter.seek(new Range(sourceKey, true, null, false), sources[i].seekColfams, true); } else { // Seek only to the term for this source as a column family sources[i].iter.seek(range, sources[i].seekColfams, true); } } advanceToIntersection(); }
Example 5
Source File: AccumuloClient.java From presto with Apache License 2.0 | 6 votes |
private Collection<Range> splitByTabletBoundaries(String tableName, Collection<Range> ranges) throws org.apache.accumulo.core.client.TableNotFoundException, AccumuloException, AccumuloSecurityException { ImmutableSet.Builder<Range> rangeBuilder = ImmutableSet.builder(); for (Range range : ranges) { // if start and end key are equivalent, no need to split the range if (range.getStartKey() != null && range.getEndKey() != null && range.getStartKey().equals(range.getEndKey())) { rangeBuilder.add(range); } else { // Call out to Accumulo to split the range on tablets rangeBuilder.addAll(connector.tableOperations().splitRangeByTablets(tableName, range, Integer.MAX_VALUE)); } } return rangeBuilder.build(); }
Example 6
Source File: AggregationIterator.java From geowave with Apache License 2.0 | 6 votes |
protected static void findStart( final Iterator<Range> rangeIt, final Collection<Range> internalRanges, final Range seekRange) { // find the first range whose end key is after this range's start key // and clip its start to this range start key, and start on that while (rangeIt.hasNext()) { final Range internalRange = rangeIt.next(); if ((internalRange.getEndKey() == null) || (internalRange.getEndKey().compareTo(seekRange.getStartKey()) > 0)) { if ((internalRange.getStartKey() != null) && (internalRange.getStartKey().compareTo(seekRange.getStartKey()) > 0)) { internalRanges.add(internalRange); return; } else { internalRanges.add(new Range(seekRange.getStartKey(), internalRange.getEndKey())); return; } } } }
Example 7
Source File: StatsLinksEdgeCombiner.java From datawave with Apache License 2.0 | 6 votes |
@Override public void seek(final Range range, final Collection<ByteSequence> columnFamilies, final boolean inclusive) throws IOException { // do not want to seek to the middle of a value that should be combined... final Range seekRange = IteratorUtil.maximizeStartKeyTimeStamp(range); super.seek(seekRange, columnFamilies, inclusive); findTop(); if (range.getStartKey() != null) { while (hasTop() && getTopKey().equals(range.getStartKey(), PartialKey.ROW_COLFAM_COLQUAL_COLVIS) && (getTopKey().getTimestamp() > range.getStartKey().getTimestamp())) { // the value has a more recent time stamp, so pass it up next(); } while (hasTop() && range.beforeStartKey(getTopKey())) { next(); } } }
Example 8
Source File: FirstEntryInPrefixedRowIterator.java From accumulo-recipes with Apache License 2.0 | 6 votes |
@Override public void seek(Range range, Collection<ByteSequence> columnFamilies, boolean inclusive) throws IOException { // save parameters for future internal seeks latestRange = range; latestColumnFamilies = columnFamilies; latestInclusive = inclusive; lastRowFound = null; Key startKey = range.getStartKey(); Range seekRange = new Range(startKey == null ? null : new Key(startKey.getRow(), startKey.getColumnFamily()), true, range.getEndKey(), range.isEndKeyInclusive()); super.seek(seekRange, columnFamilies, inclusive); finished = false; if (getSource().hasTop()) { lastRowFound = getSource().getTopKey().getRow(); if (range.beforeStartKey(getSource().getTopKey())) consume(); } }
Example 9
Source File: CreateUidsIterator.java From datawave with Apache License 2.0 | 5 votes |
/** * Method that ensures if we have to skip the current key, we do so with the contract provided by the create UID iterator. * * @param range */ protected Range skipKey(Range range) { Key startKey = range.getStartKey(); Key newKey = new Key(startKey.getRow(), startKey.getColumnFamily(), new Text(startKey.getColumnQualifier() + "\u0000\uffff")); return new Range(newKey, true, range.getEndKey(), range.isEndKeyInclusive()); }
Example 10
Source File: AccumuloGraphLogger.java From vertexium with Apache License 2.0 | 5 votes |
private void logStartIterator(String table, Range range, SortedSet<Column> fetchedColumns) { String fetchedColumnsString = fetchedColumnsToString(fetchedColumns); if (range == null || (range.getStartKey() == null && range.getEndKey() == null)) { queryLogger.trace("begin accumulo iterator %s: (%s): all items", table, fetchedColumnsString); } else { queryLogger.trace("begin accumulo iterator %s: (%s): %s - %s", table, fetchedColumnsString, keyToString(range.getStartKey()), keyToString(range.getEndKey())); } }
Example 11
Source File: QueryIterator.java From datawave with Apache License 2.0 | 5 votes |
/** * Determines if a range is document specific according to the following criteria * * <pre> * 1. Cannot have a null start or end key * 2. Cannot span multiple rows * 3. ColumnFamily must contain a null byte separator * </pre> * * @param r * - {@link Range} to be evaluated * @return - true if this is a document specific range, false if not. */ public static boolean isDocumentSpecificRange(Range r) { Preconditions.checkNotNull(r); // Also @see datawave.query.index.lookup.TupleToRange // We have already made the assertion that the client is sending us // an inclusive start key due to the inability to ascertain the // difference between and event-specific range and a continueMultiScan. // // As such, it is acceptable for us to make the same assertion on the // inclusivity of the start key. // Cannot have a null start or end key if (r.isInfiniteStartKey() || r.isInfiniteStopKey()) { return false; } // Cannot span multiple rows. Key startKey = r.getStartKey(); Key endKey = r.getEndKey(); if (!startKey.getRowData().equals(endKey.getRowData())) { return false; } // Column Family must contain a null byte separator. Text startCF = startKey.getColumnFamily(); Text endCF = endKey.getColumnFamily(); if (startCF.find(Constants.NULL) == -1 || endCF.find(Constants.NULL) == -1) { return false; } return true; }
Example 12
Source File: RecordIteratorTest.java From datawave with Apache License 2.0 | 5 votes |
@Test public void testProgressDiffRows() throws IOException, InterruptedException { TabletSplitSplit splits = new TabletSplitSplit(3); FileRangeSplit r1 = new FileRangeSplit(new Range(new Key("A123", "cf3123", "cq3"), new Key("A1239999", "cf3123", "cq3")), null, 0, 0, null); FileRangeSplit r2 = new FileRangeSplit(new Range(new Key("B12", "cf212", "cq2"), new Key("B129999", "cf212", "cq2")), null, 0, 0, null); FileRangeSplit r3 = new FileRangeSplit(new Range(new Key("C1", "cf11", "cq1"), new Key("C19999", "cf11", "cq1")), null, 0, 0, null); splits.add(r1); splits.add(r2); splits.add(r3); final SortedMap<Key,Value> keys = new TreeMap<>(); Value EMPTY_VALUE = new Value(); for (int s = 0; s < 3; s++) { Range range = ((FileRangeSplit) (splits.get(s))).getRange(); keys.put(range.getStartKey(), EMPTY_VALUE); keys.put(range.getStartKey(), EMPTY_VALUE); // now add a set of keys in between Key startKey = range.getStartKey(); for (int i = 0; i < 9999; i++) { Key key = new Key(startKey.getRow().toString() + i, startKey.getColumnFamily().toString(), startKey.getColumnQualifier().toString(), startKey.getColumnVisibilityParsed(), startKey.getTimestamp()); keys.put(key, EMPTY_VALUE); } } RecordIterator iterator = new RecordIterator(splits, new Configuration()) { @Override protected SortedKeyValueIterator<Key,Value> buildTopIterators(SortedKeyValueIterator<Key,Value> topIter, Configuration conf) throws ClassNotFoundException, InstantiationException, IllegalAccessException, IOException { return new SortedMapIterator(keys); } }; testIterator(iterator); }
Example 13
Source File: AccumuloQueryRuleset.java From rya with Apache License 2.0 | 5 votes |
private static boolean rangeContainsRange(final Range r1, final Range r2) { // 1. If r1.start is infinite, r1 contains r2.start if (!r1.isInfiniteStartKey()) { // 2. Otherwise, if r2.start is infinite, r1 can't contain r2 if (r2.isInfiniteStartKey()) { return false; } final Key start2 = r2.getStartKey(); // 3. If r2 is inclusive, r1 needs to contain r2's start key. if (r2.isStartKeyInclusive()) { if (!r1.contains(start2)) { return false; } } // 4. Otherwise, the only failure is if r2's start key comes first (they can be equal) else if (start2.compareTo(r1.getStartKey()) < 0) { return false; } } // Similar logic for end points if (!r1.isInfiniteStopKey()) { if (r2.isInfiniteStopKey()) { return false; } final Key end2 = r2.getEndKey(); if (r2.isEndKeyInclusive()) { if (!r1.contains(end2)) { return false; } } else if (end2.compareTo(r1.getEndKey()) > 0) { return false; } } return true; }
Example 14
Source File: GetStartKey.java From datawave with Apache License 2.0 | 4 votes |
@Override public Key apply(Range input) { return input.getStartKey(); }
Example 15
Source File: GetStartKeyForRoot.java From datawave with Apache License 2.0 | 4 votes |
@Override public Key apply(Range input) { Key k = input.getStartKey(); return TLD.buildParentKey(k.getRow(), TLD.parseRootPointerFromId(k.getColumnFamilyData()), k.getColumnQualifierData(), k.getColumnVisibility(), k.getTimestamp()); }
Example 16
Source File: AndIterator.java From accumulo-recipes with Apache License 2.0 | 4 votes |
private void doSeek(Range range) throws IOException { overallRange = new Range(range); if (range.getEndKey() != null && range.getEndKey().getRow() != null) { this.parentEndRow = range.getEndKey().getRow(); } // seek each of the sources to the right column family within the row given by key for (int i = 0; i < sourcesCount; i++) { Key sourceKey; Text dataLocation = (sources[i].dataLocation == null) ? nullText : sources[i].dataLocation; if (range.getStartKey() != null) { // Build a key with the DocID if one is given if (range.getStartKey().getColumnFamily() != null) { sourceKey = buildKey(getPartition(range.getStartKey()), dataLocation, (sources[i].term == null) ? nullText : new Text(sources[i].term + NULL_BYTE + range.getStartKey().getColumnFamily())); } // Build a key with just the term. else { sourceKey = buildKey(getPartition(range.getStartKey()), dataLocation, (sources[i].term == null) ? nullText : sources[i].term); } if (!range.isStartKeyInclusive()) sourceKey = sourceKey.followingKey(PartialKey.ROW_COLFAM_COLQUAL); sources[i].iter.seek(new Range(sourceKey, true, null, false), sources[i].seekColumnFamilies, SEEK_INCLUSIVE); } else { sources[i].iter.seek(range, sources[i].seekColumnFamilies, SEEK_INCLUSIVE); } } advanceToIntersection(); if (hasTop()) { if (overallRange != null && !overallRange.contains(topKey)) { topKey = null; if (log.isDebugEnabled()) { log.debug("doSeek, topKey is outside of overall range: " + overallRange); } } } }
Example 17
Source File: DocumentIndexIntersectingIterator.java From rya with Apache License 2.0 | 4 votes |
@Override public void seek(Range range, Collection<ByteSequence> seekColumnFamilies, boolean inclusive) throws IOException { overallRange = new Range(range); currentRow = new Text(); currentTermCond.set(emptyByteArray); termCondSet = false; // log.info("Calling seek with range " + range); // seek each of the sources to the right column family within the row // given by key Key sourceKey; if (rangeCqValid(range)) { String[] cqInfo = cqParser(range.getStartKey().getColumnQualifier()); int id = Integer.parseInt(cqInfo[1]); if (id >= 0) { for (int i = 0; i < sourcesCount; i++) { if (i == id) { sourceKey = buildKey(getRow(range.getStartKey()), sources[i].term, new Text(cqInfo[0])); sources[i].seek(new Range(sourceKey, true, null, false)); sources[i].next(); if(!hasContext && sources[i].hasTop()) { ctxt = getTermCond(sources[i].top).toString().split("\u0000")[0]; } } else { sourceKey = buildKey(getRow(range.getStartKey()), sources[i].term); sources[i].seek(new Range(sourceKey, true, null, false)); } } } else { for (int i = 0; i < sourcesCount; i++) { sourceKey = buildKey(getRow(range.getStartKey()), sources[i].term, range.getStartKey() .getColumnQualifier()); sources[i].seek(new Range(sourceKey, true, null, false)); } } } else { // log.info("Range is invalid."); for (int i = 0; i < sourcesCount; i++) { if (range.getStartKey() != null) { sourceKey = buildKey(getRow(range.getStartKey()), sources[i].term); // Seek only to the term for this source as a column family sources[i].seek(new Range(sourceKey, true, null, false)); } else { // Seek only to the term for this source as a column family sources[i].seek(range); } } } advanceToIntersection(); }
Example 18
Source File: AccumuloSplitsProvider.java From geowave with Apache License 2.0 | 4 votes |
public static GeoWaveRowRange fromAccumuloRange(final Range range, final int partitionKeyLength) { if (partitionKeyLength <= 0) { return new GeoWaveRowRange( null, range.getStartKey() == null ? null : range.getStartKey().getRowData().getBackingArray(), range.getEndKey() == null ? null : range.getEndKey().getRowData().getBackingArray(), range.isStartKeyInclusive(), range.isEndKeyInclusive()); } else { byte[] partitionKey; boolean partitionKeyDiffers = false; if ((range.getStartKey() == null) && (range.getEndKey() == null)) { return null; } else if (range.getStartKey() != null) { partitionKey = ArrayUtils.subarray( range.getStartKey().getRowData().getBackingArray(), 0, partitionKeyLength); if (range.getEndKey() != null) { partitionKeyDiffers = !Arrays.equals( partitionKey, ArrayUtils.subarray( range.getEndKey().getRowData().getBackingArray(), 0, partitionKeyLength)); } } else { partitionKey = ArrayUtils.subarray( range.getEndKey().getRowData().getBackingArray(), 0, partitionKeyLength); } return new GeoWaveRowRange( partitionKey, range.getStartKey() == null ? null : ArrayUtils.subarray( range.getStartKey().getRowData().getBackingArray(), partitionKeyLength, range.getStartKey().getRowData().getBackingArray().length), partitionKeyDiffers ? null : range.getEndKey() == null ? null : ArrayUtils.subarray( range.getEndKey().getRowData().getBackingArray(), partitionKeyLength, range.getEndKey().getRowData().getBackingArray().length), range.isStartKeyInclusive(), partitionKeyDiffers ? true : range.isEndKeyInclusive()); } }
Example 19
Source File: ShardUidMappingIterator.java From datawave with Apache License 2.0 | 4 votes |
/** * Seek to a range and setup the next top key and value */ @Override public void seek(Range range, Collection<ByteSequence> columnFamilies, boolean inclusive) throws IOException { if (this.source == null) { return; } // remap the range etc. if needed to encompass all of the keys that will map into this range SeekParams params = mapSeek(range, columnFamilies, inclusive); // seek the source this.source.seek(params.range, params.columnFamilies, params.inclusive); // if the mapped range is contained by the current mapped range // and the start key has the same baseUid, // and we have not already passed by the start key // then simply seek within the current cache boolean cacheSeeked = false; if (cacheBaseUidKey != null && ((cacheTopKey != null) || !cache.isEmpty()) && (lastSeekParams != null) && (range.getStartKey() != null)) { if (cacheTopKey == null) { findCacheTop(); } if (range.beforeStartKey(cacheTopKey) && getBaseUidKey(range.getStartKey()).equals(cacheBaseUidKey) && lastSeekParams.contains(params)) { cacheSeek(range); cacheSeeked = true; } } // else clear the cache and reload if (!cacheSeeked) { cache.clear(); // recache for this base uid findTop(); if (super.topKey != null) { cacheKeys(getBaseUidKey(super.topKey)); } // and get the first item off of the cache in the range specified cacheSeek(range); } // and remember what we did lastSeekParams = params; }
Example 20
Source File: DocumentIndexIntersectingIterator.java From rya with Apache License 2.0 | 4 votes |
private boolean rangeCqValid(Range range) { return (range.getStartKey() != null) && (range.getStartKey().getColumnQualifier() != null); }