Java Code Examples for org.apache.accumulo.core.data.Range#contains()
The following examples show how to use
org.apache.accumulo.core.data.Range#contains() .
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: RangeBindingSetEntries.java From rya with Apache License 2.0 | 6 votes |
public Collection<BindingSet> containsKey(Key key) { Set<BindingSet> bsSet = new HashSet<>(); for (Range range : ranges.keySet()) { // Check to see if the Key falls within Range and has same ColumnFamily // as beginning and ending key of Range. // The additional ColumnFamily check by the method // validateContext(...) is necessary because range.contains(key) // returns true if only the Row is within the Range but the ColumnFamily // doesn't fall within the Range ColumnFamily bounds. if (range.contains(key) && validateContext(key.getColumnFamily(), range.getStartKey().getColumnFamily(), range.getEndKey().getColumnFamily())) { bsSet.addAll(ranges.get(range)); } } return bsSet; }
Example 3
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 4
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); } } } }