private synchronized void buildIndex(int indexEntries, CachedBlockRead cacheBlock, IndexEntry indexEntry) throws IOException { cacheBlock.seek(0); RelativeKey rk = new RelativeKey(); Value val = new Value(); int interval = indexEntry.getNumEntries() / indexEntries; if (interval <= 32) return; // multiple threads could try to create the index with different sizes, do not replace a large // index with a smaller one if (this.blockIndex != null && this.blockIndex.length > indexEntries - 1) return; int count = 0; ArrayList<BlockIndexEntry> index = new ArrayList<>(indexEntries - 1); while (count < (indexEntry.getNumEntries() - interval + 1)) { Key myPrevKey = rk.getKey(); int pos = cacheBlock.getPosition(); rk.readFields(cacheBlock); val.readFields(cacheBlock); if (count > 0 && count % interval == 0) { index.add(new BlockIndexEntry(pos, indexEntry.getNumEntries() - count, myPrevKey)); } count++; } this.blockIndex = index.toArray(new BlockIndexEntry[index.size()]); cacheBlock.seek(0); }
val.readFields(in);
private void _next() throws IOException { if (!hasTop) throw new IllegalStateException(); if (entriesLeft == 0) { currBlock.close(); if (metricsGatherer != null) metricsGatherer.startBlock(); if (iiter.hasNext()) { IndexEntry indexEntry = iiter.next(); entriesLeft = indexEntry.getNumEntries(); currBlock = getDataBlock(indexEntry); checkRange = range.afterEndKey(indexEntry.getKey()); if (!checkRange) hasTop = true; } else { rk = null; val = null; hasTop = false; return; } } prevKey = rk.getKey(); rk.readFields(currBlock); val.readFields(currBlock); if (metricsGatherer != null) metricsGatherer.addMetric(rk.getKey(), val); entriesLeft--; if (checkRange) hasTop = !range.afterEndKey(rk.getKey()); }
/** * Deserialize the group, key, and value */ @Override public void readFields(final DataInput in) throws IOException { group.readFields(in); key.readFields(in); value.readFields(in); }
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { this.key = new Key(); key.readFields(in); Value val = new Value(); val.readFields(in); this.value = val.get(); }
private synchronized void buildIndex(int indexEntries, ABlockReader cacheBlock, IndexEntry indexEntry) throws IOException { cacheBlock.seek(0); RelativeKey rk = new RelativeKey(); Value val = new Value(); int interval = indexEntry.getNumEntries() / indexEntries; if (interval <= 32) return; // multiple threads could try to create the index with different sizes, do not replace a large // index with a smaller one if (this.blockIndex != null && this.blockIndex.length > indexEntries - 1) return; int count = 0; ArrayList<BlockIndexEntry> index = new ArrayList<>(indexEntries - 1); while (count < (indexEntry.getNumEntries() - interval + 1)) { Key myPrevKey = rk.getKey(); int pos = cacheBlock.getPosition(); rk.readFields(cacheBlock); val.readFields(cacheBlock); if (count > 0 && count % interval == 0) { index.add(new BlockIndexEntry(pos, indexEntry.getNumEntries() - count, myPrevKey)); } count++; } this.blockIndex = index.toArray(new BlockIndexEntry[index.size()]); cacheBlock.seek(0); }
private void _next() throws IOException { if (!hasTop) throw new IllegalStateException(); if (entriesLeft == 0) { currBlock.close(); if (metricsGatherer != null) metricsGatherer.startBlock(); if (iiter.hasNext()) { IndexEntry indexEntry = iiter.next(); entriesLeft = indexEntry.getNumEntries(); currBlock = getDataBlock(indexEntry); checkRange = range.afterEndKey(indexEntry.getKey()); if (!checkRange) hasTop = true; } else { rk = null; val = null; hasTop = false; return; } } prevKey = rk.getKey(); rk.readFields(currBlock); val.readFields(currBlock); if (metricsGatherer != null) metricsGatherer.addMetric(rk.getKey(), val); entriesLeft--; if (checkRange) hasTop = !range.afterEndKey(rk.getKey()); }
val = new Value(); val.readFields(currBlock); valbs = new MutableByteSequence(val.get(), 0, val.getSize());
val = new Value(); val.readFields(currBlock); valbs = new MutableByteSequence(val.get(), 0, val.getSize());