@Override protected void cleanup(Context context) throws IOException, InterruptedException { hasher.finishBatch(); context.write(hasher.getBatchStartKey(), hasher.getBatchHash()); } }
@Override protected void map(ImmutableBytesWritable key, Result value, Context context) throws IOException, InterruptedException { if (currentRow == null || !currentRow.equals(key)) { currentRow = new ImmutableBytesWritable(key); // not immutable if (hasher.getBatchSize() >= targetBatchSize) { hasher.finishBatch(); context.write(hasher.getBatchStartKey(), hasher.getBatchHash()); hasher.startBatch(currentRow); } } hasher.hashResult(value); }
/** * Finish the currently open hash batch. * Compare the target hash to the given source hash. * If they do not match, then sync the covered key range. */ private void finishBatchAndCompareHashes(Context context) throws IOException, InterruptedException { targetHasher.finishBatch(); context.getCounter(Counter.BATCHES).increment(1); if (targetHasher.getBatchSize() == 0) { context.getCounter(Counter.EMPTY_BATCHES).increment(1); } ImmutableBytesWritable targetHash = targetHasher.getBatchHash(); if (targetHash.equals(currentSourceHash)) { context.getCounter(Counter.HASHES_MATCHED).increment(1); } else { context.getCounter(Counter.HASHES_NOT_MATCHED).increment(1); ImmutableBytesWritable stopRow = nextSourceKey == null ? new ImmutableBytesWritable(sourceTableHash.stopRow) : nextSourceKey; if (LOG.isDebugEnabled()) { LOG.debug("Hash mismatch. Key range: " + toHex(targetHasher.getBatchStartKey()) + " to " + toHex(stopRow) + " sourceHash: " + toHex(currentSourceHash) + " targetHash: " + toHex(targetHash)); } syncRange(context, targetHasher.getBatchStartKey(), stopRow); } } private static String toHex(ImmutableBytesWritable bytes) {
/** * Finish the currently open hash batch. * Compare the target hash to the given source hash. * If they do not match, then sync the covered key range. */ private void finishBatchAndCompareHashes(Context context) throws IOException, InterruptedException { targetHasher.finishBatch(); context.getCounter(Counter.BATCHES).increment(1); if (targetHasher.getBatchSize() == 0) { context.getCounter(Counter.EMPTY_BATCHES).increment(1); } ImmutableBytesWritable targetHash = targetHasher.getBatchHash(); if (targetHash.equals(currentSourceHash)) { context.getCounter(Counter.HASHES_MATCHED).increment(1); } else { context.getCounter(Counter.HASHES_NOT_MATCHED).increment(1); ImmutableBytesWritable stopRow = nextSourceKey == null ? new ImmutableBytesWritable(sourceTableHash.stopRow) : nextSourceKey; if (LOG.isDebugEnabled()) { LOG.debug("Hash mismatch. Key range: " + toHex(targetHasher.getBatchStartKey()) + " to " + toHex(stopRow) + " sourceHash: " + toHex(currentSourceHash) + " targetHash: " + toHex(targetHash)); } syncRange(context, targetHasher.getBatchStartKey(), stopRow); } } private static String toHex(ImmutableBytesWritable bytes) {
/** * Finish the currently open hash batch. * Compare the target hash to the given source hash. * If they do not match, then sync the covered key range. */ private void finishBatchAndCompareHashes(Context context) throws IOException, InterruptedException { targetHasher.finishBatch(); context.getCounter(Counter.BATCHES).increment(1); if (targetHasher.getBatchSize() == 0) { context.getCounter(Counter.EMPTY_BATCHES).increment(1); } ImmutableBytesWritable targetHash = targetHasher.getBatchHash(); if (targetHash.equals(currentSourceHash)) { context.getCounter(Counter.HASHES_MATCHED).increment(1); } else { context.getCounter(Counter.HASHES_NOT_MATCHED).increment(1); ImmutableBytesWritable stopRow = nextSourceKey == null ? new ImmutableBytesWritable(sourceTableHash.stopRow) : nextSourceKey; if (LOG.isDebugEnabled()) { LOG.debug("Hash mismatch. Key range: " + toHex(targetHasher.getBatchStartKey()) + " to " + toHex(stopRow) + " sourceHash: " + toHex(currentSourceHash) + " targetHash: " + toHex(targetHash)); } syncRange(context, targetHasher.getBatchStartKey(), stopRow); } } private static String toHex(ImmutableBytesWritable bytes) {
LOG.debug("Hash mismatch. Key range: " + toHex(targetHasher.getBatchStartKey()) + " to " + toHex(stopRow) + " sourceHash: " + toHex(currentSourceHash) syncRange(context, targetHasher.getBatchStartKey(), stopRow);
@Override protected void map(ImmutableBytesWritable key, Result value, Context context) throws IOException, InterruptedException { if (currentRow == null || !currentRow.equals(key)) { currentRow = new ImmutableBytesWritable(key); // not immutable if (hasher.getBatchSize() >= targetBatchSize) { hasher.finishBatch(); context.write(hasher.getBatchStartKey(), hasher.getBatchHash()); hasher.startBatch(currentRow); } } hasher.hashResult(value); }
@Override protected void map(ImmutableBytesWritable key, Result value, Context context) throws IOException, InterruptedException { if (currentRow == null || !currentRow.equals(key)) { currentRow = new ImmutableBytesWritable(key); // not immutable if (hasher.getBatchSize() >= targetBatchSize) { hasher.finishBatch(); context.write(hasher.getBatchStartKey(), hasher.getBatchHash()); hasher.startBatch(currentRow); } } hasher.hashResult(value); }
@Override protected void cleanup(Context context) throws IOException, InterruptedException { hasher.finishBatch(); context.write(hasher.getBatchStartKey(), hasher.getBatchHash()); } }
@Override protected void map(ImmutableBytesWritable key, Result value, Context context) throws IOException, InterruptedException { if (currentRow == null || !currentRow.equals(key)) { currentRow = new ImmutableBytesWritable(key); // not immutable if (hasher.getBatchSize() >= targetBatchSize) { hasher.finishBatch(); context.write(hasher.getBatchStartKey(), hasher.getBatchHash()); hasher.startBatch(currentRow); } } hasher.hashResult(value); }
@Override protected void cleanup(Context context) throws IOException, InterruptedException { hasher.finishBatch(); context.write(hasher.getBatchStartKey(), hasher.getBatchHash()); } }
@Override protected void cleanup(Context context) throws IOException, InterruptedException { hasher.finishBatch(); context.write(hasher.getBatchStartKey(), hasher.getBatchHash()); } }