@Override public void register(long raw, long begin, long end) { metaIndex.addEntry(new MetaIndexEntry(name, compressAlgo, new BlockRegion(begin, end - begin, raw))); } }
/** * Compare an entry with a RawComparable object. This is useful when * Entries are stored in a collection, and we want to compare a user * supplied key. */ @Override public int compareTo(RawComparable key) { return reader.compareKeys(keyBuffer, 0, getKeyLength(), key.buffer(), key.offset(), key.size()); }
/** * Get the last key in the TFile. * * @return The last key in the TFile. * @throws IOException */ public RawComparable getLastKey() throws IOException { checkTFileDataIndex(); return tfileIndex.getLastKey(); }
public TFileMeta(DataInput in) throws IOException { version = new Version(in); if (!version.compatibleWith(TFile.API_VERSION)) { throw new RuntimeException("Incompatible TFile fileVersion."); } recordCount = Utils.readVLong(in); strComparator = Utils.readString(in); comparator = makeComparator(strComparator); }
public DataIndex(DataInput in) throws IOException { defaultCompressionAlgorithm = Compression.getCompressionAlgorithmByName(Utils.readString(in)); int n = Utils.readVInt(in); listRegions = new ArrayList<BlockRegion>(n); for (int i = 0; i < n; i++) { BlockRegion region = new BlockRegion(in); listRegions.add(region); } }
public void write(DataOutput out) throws IOException { TFile.API_VERSION.write(out); Utils.writeVLong(out, recordCount); Utils.writeString(out, strComparator); }
/** * Provide a customized comparator for Entries. This is useful if we * have a collection of Entry objects. However, if the Entry objects * come from different TFiles, users must ensure that those TFiles share * the same RawComparator. */ @Override public int compare(Scanner.Entry o1, Scanner.Entry o2) { return comparator.compare(o1.getKeyBuffer(), 0, o1.getKeyLength(), o2 .getKeyBuffer(), 0, o2.getKeyLength()); } };
public void write(DataOutput out) throws IOException { Utils.writeString(out, defaultPrefix + metaName); Utils.writeString(out, compressionAlgorithm.getName()); region.write(out); } }
/** * Get the name of the default compression algorithm. * * @return the name of the default compression algorithm. */ public String getDefaultCompressionName() { return dataIndex.getDefaultCompressionAlgorithm().getName(); }
@Override public void register(long raw, long begin, long end) { dataIndex.addBlockRegion(new BlockRegion(begin, end - begin, raw)); } }
/** * Get the uncompressed size of the block. * * @return uncompressed size of the block. */ public long getRawSize() { return rBlkState.getBlockRegion().getRawSize(); }
/** * Get the first key in the TFile. * * @return The first key in the TFile. * @throws IOException */ public RawComparable getFirstKey() throws IOException { checkTFileDataIndex(); return tfileIndex.getFirstKey(); }
/** * Get the compressed size of the block. * * @return compressed size of the block. */ public long getCompressedSize() { return rBlkState.getBlockRegion().getCompressedSize(); }
/** * Get the starting position of the block in the file. * * @return the starting position of the block in the file. */ public long getStartPos() { return rBlkState.getBlockRegion().getOffset(); } }
private BlockReader createReader(Algorithm compressAlgo, BlockRegion region) throws IOException { RBlockState rbs = new RBlockState(compressAlgo, in, region, conf); return new BlockReader(rbs); }
Location getLocationByRecordNum(long recNum) throws IOException { checkTFileDataIndex(); return tfileIndex.getLocationByRecordNum(recNum); }
long getRecordNumByLocation(Location location) throws IOException { checkTFileDataIndex(); return tfileIndex.getRecordNumByLocation(location); }