Reader(Configuration conf, ImmutableBytesWritable startKey) throws IOException { this.conf = conf; int partitionIndex = Collections.binarySearch(partitions, startKey); if (partitionIndex >= 0) { // if the key is equal to a partition, then go the file after that partition hashFileIndex = partitionIndex+1; } else { // if the key is between partitions, then go to the file between those partitions hashFileIndex = -1-partitionIndex; } openHashFile(); // MapFile's don't make it easy to seek() so that the subsequent next() returns // the desired key/value pair. So we cache it for the first call of next(). hash = new ImmutableBytesWritable(); key = (ImmutableBytesWritable) mapFileReader.getClosest(startKey, hash); if (key == null) { cachedNext = false; hash = null; } else { cachedNext = true; } }
Reader(Configuration conf, ImmutableBytesWritable startKey) throws IOException { this.conf = conf; int partitionIndex = Collections.binarySearch(partitions, startKey); if (partitionIndex >= 0) { // if the key is equal to a partition, then go the file after that partition hashFileIndex = partitionIndex+1; } else { // if the key is between partitions, then go to the file between those partitions hashFileIndex = -1-partitionIndex; } openHashFile(); // MapFile's don't make it easy to seek() so that the subsequent next() returns // the desired key/value pair. So we cache it for the first call of next(). hash = new ImmutableBytesWritable(); key = (ImmutableBytesWritable) mapFileReader.getClosest(startKey, hash); if (key == null) { cachedNext = false; hash = null; } else { cachedNext = true; } }
Reader(Configuration conf, ImmutableBytesWritable startKey) throws IOException { this.conf = conf; int partitionIndex = Collections.binarySearch(partitions, startKey); if (partitionIndex >= 0) { // if the key is equal to a partition, then go the file after that partition hashFileIndex = partitionIndex+1; } else { // if the key is between partitions, then go to the file between those partitions hashFileIndex = -1-partitionIndex; } openHashFile(); // MapFile's don't make it easy to seek() so that the subsequent next() returns // the desired key/value pair. So we cache it for the first call of next(). hash = new ImmutableBytesWritable(); key = (ImmutableBytesWritable) mapFileReader.getClosest(startKey, hash); if (key == null) { cachedNext = false; hash = null; } else { cachedNext = true; } }
/** * Read the next key/hash pair. * Returns true if such a pair exists and false when at the end of the data. */ public boolean next() throws IOException { if (cachedNext) { cachedNext = false; return true; } key = new ImmutableBytesWritable(); hash = new ImmutableBytesWritable(); while (true) { boolean hasNext = mapFileReader.next(key, hash); if (hasNext) { return true; } hashFileIndex++; if (hashFileIndex < TableHash.this.numHashFiles) { mapFileReader.close(); openHashFile(); } else { key = null; hash = null; return false; } } }
/** * Read the next key/hash pair. * Returns true if such a pair exists and false when at the end of the data. */ public boolean next() throws IOException { if (cachedNext) { cachedNext = false; return true; } key = new ImmutableBytesWritable(); hash = new ImmutableBytesWritable(); while (true) { boolean hasNext = mapFileReader.next(key, hash); if (hasNext) { return true; } hashFileIndex++; if (hashFileIndex < TableHash.this.numHashFiles) { mapFileReader.close(); openHashFile(); } else { key = null; hash = null; return false; } } }
Reader(Configuration conf, ImmutableBytesWritable startKey) throws IOException { this.conf = conf; int partitionIndex = Collections.binarySearch(partitions, startKey); if (partitionIndex >= 0) { // if the key is equal to a partition, then go the file after that partition hashFileIndex = partitionIndex+1; } else { // if the key is between partitions, then go to the file between those partitions hashFileIndex = -1-partitionIndex; } openHashFile(); // MapFile's don't make it easy to seek() so that the subsequent next() returns // the desired key/value pair. So we cache it for the first call of next(). hash = new ImmutableBytesWritable(); key = (ImmutableBytesWritable) mapFileReader.getClosest(startKey, hash); if (key == null) { cachedNext = false; hash = null; } else { cachedNext = true; } }
/** * Read the next key/hash pair. * Returns true if such a pair exists and false when at the end of the data. */ public boolean next() throws IOException { if (cachedNext) { cachedNext = false; return true; } key = new ImmutableBytesWritable(); hash = new ImmutableBytesWritable(); while (true) { boolean hasNext = mapFileReader.next(key, hash); if (hasNext) { return true; } hashFileIndex++; if (hashFileIndex < TableHash.this.numHashFiles) { mapFileReader.close(); openHashFile(); } else { key = null; hash = null; return false; } } }
/** * Read the next key/hash pair. * Returns true if such a pair exists and false when at the end of the data. */ public boolean next() throws IOException { if (cachedNext) { cachedNext = false; return true; } key = new ImmutableBytesWritable(); hash = new ImmutableBytesWritable(); while (true) { boolean hasNext = mapFileReader.next(key, hash); if (hasNext) { return true; } hashFileIndex++; if (hashFileIndex < TableHash.this.numHashFiles) { mapFileReader.close(); openHashFile(); } else { key = null; hash = null; return false; } } }