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; } } }
/** * 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; } }
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; } }
/** * Attempt to read the next source key/hash pair. * If there are no more, set nextSourceKey to null */ private void findNextKeyHashPair() throws IOException { boolean hasNext = sourceHashReader.next(); if (hasNext) { nextSourceKey = sourceHashReader.getCurrentKey(); } else { // no more keys - last hash goes to the end nextSourceKey = null; } }
/** * Open a TableHash.Reader starting at the first hash at or after the given key. * @throws IOException */ public Reader newReader(Configuration conf, ImmutableBytesWritable startKey) throws IOException { return new Reader(conf, startKey); }
/** * Attempt to read the next source key/hash pair. * If there are no more, set nextSourceKey to null */ private void findNextKeyHashPair() throws IOException { boolean hasNext = sourceHashReader.next(); if (hasNext) { nextSourceKey = sourceHashReader.getCurrentKey(); } else { // no more keys - last hash goes to the end nextSourceKey = null; } }
/** * If there is an open hash batch, complete it and sync if there are diffs. * Start a new batch, and seek to read the */ private void moveToNextBatch(Context context) throws IOException, InterruptedException { if (targetHasher.isBatchStarted()) { finishBatchAndCompareHashes(context); } targetHasher.startBatch(nextSourceKey); currentSourceHash = sourceHashReader.getCurrentHash(); findNextKeyHashPair(); }
/** * If there is an open hash batch, complete it and sync if there are diffs. * Start a new batch, and seek to read the */ private void moveToNextBatch(Context context) throws IOException, InterruptedException { if (targetHasher.isBatchStarted()) { finishBatchAndCompareHashes(context); } targetHasher.startBatch(nextSourceKey); currentSourceHash = sourceHashReader.getCurrentHash(); findNextKeyHashPair(); }
/** * Open a TableHash.Reader starting at the first hash at or after the given key. * @throws IOException */ public Reader newReader(Configuration conf, ImmutableBytesWritable startKey) throws IOException { return new Reader(conf, startKey); }
/** * Open a TableHash.Reader starting at the first hash at or after the given key. * @throws IOException */ public Reader newReader(Configuration conf, ImmutableBytesWritable startKey) throws IOException { return new Reader(conf, startKey); }
/** * Attempt to read the next source key/hash pair. * If there are no more, set nextSourceKey to null */ private void findNextKeyHashPair() throws IOException { boolean hasNext = sourceHashReader.next(); if (hasNext) { nextSourceKey = sourceHashReader.getCurrentKey(); } else { // no more keys - last hash goes to the end nextSourceKey = null; } }
/** * If there is an open hash batch, complete it and sync if there are diffs. * Start a new batch, and seek to read the */ private void moveToNextBatch(Context context) throws IOException, InterruptedException { if (targetHasher.isBatchStarted()) { finishBatchAndCompareHashes(context); } targetHasher.startBatch(nextSourceKey); currentSourceHash = sourceHashReader.getCurrentHash(); findNextKeyHashPair(); }
/** * 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; } } }
/** * Open a TableHash.Reader starting at the first hash at or after the given key. * @throws IOException */ public Reader newReader(Configuration conf, ImmutableBytesWritable startKey) throws IOException { return new Reader(conf, startKey); }
/** * Attempt to read the next source key/hash pair. * If there are no more, set nextSourceKey to null */ private void findNextKeyHashPair() throws IOException { boolean hasNext = sourceHashReader.next(); if (hasNext) { nextSourceKey = sourceHashReader.getCurrentKey(); } else { // no more keys - last hash goes to the end nextSourceKey = null; } }
/** * If there is an open hash batch, complete it and sync if there are diffs. * Start a new batch, and seek to read the */ private void moveToNextBatch(Context context) throws IOException, InterruptedException { if (targetHasher.isBatchStarted()) { finishBatchAndCompareHashes(context); } targetHasher.startBatch(nextSourceKey); currentSourceHash = sourceHashReader.getCurrentHash(); findNextKeyHashPair(); }