/** * Gets a Boolean value indicating if the given value is in one of the Ranges in the given collection * * @param text Text object to check against the Range collection * @param ranges Ranges to look into * @return True if the text object is in one of the ranges, false otherwise */ private static boolean inRange(Text text, Collection<Range> ranges) { Key kCq = new Key(text); return ranges.stream().anyMatch(r -> !r.beforeStartKey(kCq) && !r.afterEndKey(kCq)); } }
@Override public Key build() { return new Key(this.row, this.rowOffset, this.rowLength, this.family, this.familyOffset, this.familyLength, this.qualifier, this.qualifierOffset, this.qualifierLength, this.visibility, this.visibilityOffset, this.visibilityLength, this.timestamp, this.deleted, false); } }
protected void deserializeData(AccumuloRowSerializer serializer, byte[] data) { Mutation m = new Mutation("row"); m.put(b("a"), b("a"), data); Key key = new Key(b("row"), b("a"), b("b"), b(), 0, false); Value value = new Value(data); serializer.setMapping(COLUMN_NAME, "a", "b"); serializer.deserialize(new SimpleImmutableEntry<>(key, value)); }
private void setFirstKey(Key key) { if (firstKey != null) throw new IllegalStateException(); this.firstKey = new Key(key); }
@Override protected Key buildKey(Text partition, Text term) { Text colq = new Text(term); return new Key(partition, indexColf, colq); }
@Override protected Key newValue() throws IOException { Key key = new Key(); key.readFields(dis); return key; } }
SampleEntry(Key key, Value val) { this.key = new Key(key); this.val = new Value(val); } }
@Override protected Key buildKey(Text partition, Text term, Text docID) { Text colq = new Text(term); colq.append(nullByte, 0, 1); colq.append(docID.getBytes(), 0, docID.getLength()); colq.append(nullByte, 0, 1); return new Key(partition, indexColf, colq); }
public SequenceFileIterator(SequenceFile.Reader reader, boolean readValue) throws IOException { this.reader = reader; this.readValue = readValue; top_key = new Key(); if (readValue) top_value = new Value(); next(); }
private void addKeyValue(Key k, Value v) { if (dropEmptyColFams && k.getColumnFamilyData().equals(EMPTY)) { return; } keys.add(new Key(k)); values.add(new Value(v)); }
/** * Constructs an iterator over Values whose Keys are versions of the current topKey of the * source SortedKeyValueIterator. * * @param source * The {@code SortedKeyValueIterator<Key,Value>} from which to read data. */ public ValueIterator(SortedKeyValueIterator<Key,Value> source) { this.source = source; topKey = new Key(source.getTopKey()); hasNext = _hasNext(); }
/** * Creates a range that covers an exact row and column family. * * @param row * row row to cover * @param cf * column family to cover */ public static Range exact(Text row, Text cf) { Key startKey = new Key(row, cf); return new Range(startKey, true, startKey.followingKey(PartialKey.ROW_COLFAM), false); }
private static Scanner getTabletLogScanner(ServerContext context, KeyExtent extent) { Table.ID tableId = MetadataTable.ID; if (extent.isMeta()) tableId = RootTable.ID; Scanner scanner = new ScannerImpl(context, tableId, Authorizations.EMPTY); scanner.fetchColumnFamily(LogColumnFamily.NAME); Text start = extent.getMetadataEntry(); Key endKey = new Key(start, LogColumnFamily.NAME); endKey = endKey.followingKey(PartialKey.ROW_COLFAM); scanner.setRange(new Range(new Key(start), endKey)); return scanner; }
private void addUnfinishedRange(LookupResult lookupResult, Range range, Key key, boolean inclusiveStartKey) { if (range.getEndKey() == null || key.compareTo(range.getEndKey()) < 0) { Range nlur = new Range(new Key(key), inclusiveStartKey, range.getEndKey(), range.isEndKeyInclusive()); lookupResult.unfinishedRanges.add(nlur); } }
@Override public Entry<Key,Value> next() { try { Entry<Key,Value> result = new KeyValue(new Key(inner.getTopKey()), new Value(inner.getTopValue()).get()); inner.next(); return result; } catch (IOException ex) { throw new NoSuchElementException(); } }
TreeMap<Key,Value> consume(SortedKeyValueIterator<Key,Value> skvi) throws IOException { TreeMap<Key,Value> data = new TreeMap<>(); while (skvi.hasTop()) { // Make sure to copy the K-V data.put(new Key(skvi.getTopKey()), new Value(skvi.getTopValue())); skvi.next(); } return data; }
@Override protected FileSKVIterator openReader(FileOptions options) throws IOException { FileSKVIterator iter = new RangeIterator(new MapFileIterator(options.getTableConfiguration(), options.getFileSystem(), options.getFilename(), options.getConfiguration())); if (options.isSeekToBeginning()) { iter.seek(new Range(new Key(), null), new ArrayList<>(), false); } return iter; }
private void consumeRow(ByteSequence row) throws IOException { // try reading a few and if still not to next row, then seek int count = 0; while (source.hasTop() && source.getTopKey().getRowData().equals(row)) { source.next(); count++; if (count >= 10) { Key nextRowStart = new Key(new Text(row.toArray())).followingKey(PartialKey.ROW); reseek(nextRowStart); count = 0; } } }