Java Code Examples for org.apache.accumulo.core.data.Range#beforeStartKey()

The following examples show how to use org.apache.accumulo.core.data.Range#beforeStartKey() . 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: StatsLinksEdgeCombiner.java    From datawave with Apache License 2.0 6 votes vote down vote up
@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 2
Source File: ShardUidMappingIterator.java    From datawave with Apache License 2.0 6 votes vote down vote up
/**
 * Seek within the cache to a specified range
 * 
 * @param range
 * @return true if we have a new top key and value
 */
protected boolean cacheSeek(Range range) {
    if (cacheTopKey == null) {
        findCacheTop();
    }
    while (cacheTopKey != null && range.beforeStartKey(cacheTopKey)) {
        findCacheTop();
    }
    // if we passed the end of the range, the put the last cache key back
    if (cacheTopKey != null && range.afterEndKey(cacheTopKey)) {
        cacheAdd(cacheTopKey, cacheTopValue);
        cacheTopKey = null;
        cacheTopValue = null;
    }
    return (cacheTopKey != null);
}
 
Example 3
Source File: MatchingKeySkippingIterator.java    From datawave with Apache License 2.0 6 votes vote down vote up
@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;
    lastKeyFound = null;
    
    Key startKey = range.getStartKey();
    Range seekRange = new Range(startKey == null ? null : new Key(startKey.getRow()), true, range.getEndKey(), range.isEndKeyInclusive());
    super.seek(seekRange, columnFamilies, inclusive);
    finished = false;
    
    if (getSource().hasTop()) {
        lastKeyFound = getSource().getTopKey();
        if (range.beforeStartKey(getSource().getTopKey()))
            consume();
    }
}
 
Example 4
Source File: DocumentIndexIntersectingIterator.java    From rya with Apache License 2.0 6 votes vote down vote up
public void seek(Range r) throws IOException {

            if (seeked) {
 
                if (next != null && !r.beforeStartKey(next)) {
                    if (next.getColumnFamily().equals(term)) {
                        this.updateTop();
                    }
                } else if (iter.hasTop()) {
                    iter.seek(r, seekColfams, true);
                    this.updateTopNext();
                } else {
                    top = null;
                    next = null;
                
                }
            } else {

                iter.seek(r, seekColfams, true);
                this.updateTopNext();
                seeked = true;
            }

        }
 
Example 5
Source File: AbstractEvaluatingIterator.java    From accumulo-recipes with Apache License 2.0 6 votes vote down vote up
public void seek(Range range, Collection<ByteSequence> columnFamilies, boolean inclusive) throws IOException {
    // do not want to seek to the middle of a value that should be
    // aggregated...

    seekRange = maximizeStartKeyTimeStamp(range);

    iterator.seek(seekRange, columnFamilies, inclusive);
    findTop();

    if (range.getStartKey() != null) {
        while (hasTop() && getTopKey().equals(range.getStartKey(), this.comparator) && getTopKey().getTimestamp() > range.getStartKey().getTimestamp()) {
            // the value has a more recent time stamp, so
            // pass it up
            // log.debug("skipping "+getTopKey());
            next();
        }

        while (hasTop() && range.beforeStartKey(getTopKey())) {
            next();
        }
    }

}
 
Example 6
Source File: FirstNEntriesInRowIterator.java    From accumulo-recipes with Apache License 2.0 6 votes vote down vote up
@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 7
Source File: FirstEntryInPrefixedRowIterator.java    From accumulo-recipes with Apache License 2.0 6 votes vote down vote up
@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 8
Source File: PropogatingIterator.java    From datawave with Apache License 2.0 5 votes vote down vote up
@Override
public void seek(Range range, Collection<ByteSequence> columnFamilies, boolean inclusive) throws IOException {
    if (aggrKey != null) {
        aggrKey = null;
        aggrValue = null;
    }
    
    Range seekRange = range;
    // if there isn't an aggregator configured for the start key, timestamp modification isn't necessary
    if (range.getStartKey() != null && getAggregator(range.getStartKey()) != null) {
        // do not want to seek to the middle of a value that should be
        // aggregated...
        seekRange = IteratorUtil.maximizeStartKeyTimeStamp(range);
    }
    
    iterator.seek(seekRange, columnFamilies, inclusive);
    
    findTop();
    
    // (only if the range was modified) it's necessary to skip keys until the start key is found
    if (seekRange != range) {
        while (hasTop() && getTopKey().equals(range.getStartKey(), PartialKey.ROW_COLFAM_COLQUAL_COLVIS)
                        && getTopKey().getTimestamp() > range.getStartKey().getTimestamp()) {
            next();
        }
        
        while (hasTop() && range.beforeStartKey(getTopKey())) {
            
            next();
        }
    }
    
}
 
Example 9
Source File: NotificationIterator.java    From fluo with Apache License 2.0 5 votes vote down vote up
@Override
public void seek(Range range, Collection<ByteSequence> columnFamilies, boolean inclusive)
    throws IOException {
  lastKeySet = false;

  seekRange = IteratorUtil.maximizeStartKeyTimeStamp(range);
  this.colFams = new HashSet<>(columnFamilies);
  this.inclusive = inclusive;
  super.seek(seekRange, columnFamilies, inclusive);

  while (hasTop() && range.beforeStartKey(getTopKey())) {
    next();
  }
}
 
Example 10
Source File: ShardUidMappingIterator.java    From datawave with Apache License 2.0 4 votes vote down vote up
/**
 * 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;
}