if (!first.equals(HConstants.EMPTY_BYTE_ARRAY)) { throw new IllegalArgumentException("First region of table should have empty start key. Instead has: " + Bytes.toStringBinary(first.get()));
().get())); if (!first.equals(HConstants.EMPTY_BYTE_ARRAY)) { throw new IllegalArgumentException( "First region of table should have empty start key. Instead has: "
@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); }
public boolean isEmptyGuidePost() { return guidePosts.equals(EMPTY_GUIDEPOST_KEY) && guidePostsCount == 0 && byteCounts.length == 1 && gpTimestamps.length == 1; }
/** * 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) {
@Override public boolean equals(Object obj) { if (this == obj) return true; if (!super.equals(obj)) return false; if (getClass() != obj.getClass()) return false; ClientKeyValue other = (ClientKeyValue) obj; if (family == null) { if (other.family != null) return false; } else if (!family.equals(other.family)) return false; if (qualifier == null) { if (other.qualifier != null) return false; } else if (!qualifier.equals(other.qualifier)) return false; if (row == null) { if (other.row != null) return false; } else if (!row.equals(other.row)) return false; if (ts != other.ts) return false; if (type != other.type) return false; if (value == null) { if (other.value != null) return false; } else if (!value.equals(other.value)) return false; return true; }
if (!first.getRowkey().equals(HConstants.EMPTY_BYTE_ARRAY)) { throw new IllegalArgumentException( "First region of table should have empty start key. Instead has: "
public boolean isEmptyGuidePost() { return guidePosts.equals(EMPTY_GUIDEPOST_KEY) && guidePostsCount == 0 && byteCounts.length == 1 && gpTimestamps.length == 1; }
public boolean isEmptyGuidePost() { return guidePosts.equals(EMPTY_GUIDEPOST_KEY) && guidePostsCount == 0 && byteCounts.length == 1 && gpTimestamps.length == 1; }
if (currentRow == null || !row.equals(currentRow)) { currentRow = row; incrementRow = true;
@Override public Tuple next() throws SQLException { Tuple result = resultIterator.next(); if (result == null) { return null; } if (currentKey.get() == UNITIALIZED_KEY_BUFFER) { getGroupingKey(result, currentKey); } Aggregator[] rowAggregators = aggregators.getAggregators(); aggregators.reset(rowAggregators); while (true) { aggregators.aggregate(rowAggregators, result); Tuple nextResult = resultIterator.peek(); if (nextResult == null || !currentKey.equals(getGroupingKey(nextResult, nextKey))) { break; } result = resultIterator.next(); } byte[] value = aggregators.toBytes(rowAggregators); Tuple tuple = wrapKeyValueAsResult(PhoenixKeyValueUtil.newKeyValue(currentKey, SINGLE_COLUMN_FAMILY, SINGLE_COLUMN, AGG_TIMESTAMP, value, 0, value.length)); currentKey.set(nextKey.get(), nextKey.getOffset(), nextKey.getLength()); return tuple; }
if (!first.getRowkey().equals(HConstants.EMPTY_BYTE_ARRAY)) { throw new IllegalArgumentException( "First region of table should have empty start key. Instead has: "
if (!first.getRowkey().equals(HConstants.EMPTY_BYTE_ARRAY)) { throw new IllegalArgumentException( "First region of table should have empty start key. Instead has: "
@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 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) {
@Override public Tuple next() throws SQLException { Tuple result = resultIterator.next(); if (result == null) { return null; } if (currentKey.get() == UNITIALIZED_KEY_BUFFER) { getGroupingKey(result, currentKey); } Aggregator[] rowAggregators = aggregators.getAggregators(); aggregators.reset(rowAggregators); while (true) { aggregators.aggregate(rowAggregators, result); Tuple nextResult = resultIterator.peek(); if (nextResult == null || !currentKey.equals(getGroupingKey(nextResult, nextKey))) { break; } result = resultIterator.next(); } byte[] value = aggregators.toBytes(rowAggregators); Tuple tuple = wrapKeyValueAsResult(PhoenixKeyValueUtil.newKeyValue(currentKey, SINGLE_COLUMN_FAMILY, SINGLE_COLUMN, AGG_TIMESTAMP, value, 0, value.length)); currentKey.set(nextKey.get(), nextKey.getOffset(), nextKey.getLength()); return tuple; }
@Override public Tuple next() throws SQLException { Tuple result = resultIterator.next(); if (result == null) { return null; } if (currentKey.get() == UNITIALIZED_KEY_BUFFER) { getGroupingKey(result, currentKey); } Aggregator[] rowAggregators = aggregators.getAggregators(); aggregators.reset(rowAggregators); while (true) { aggregators.aggregate(rowAggregators, result); Tuple nextResult = resultIterator.peek(); if (nextResult == null || !currentKey.equals(getGroupingKey(nextResult, nextKey))) { break; } result = resultIterator.next(); } byte[] value = aggregators.toBytes(rowAggregators); Tuple tuple = wrapKeyValueAsResult(PhoenixKeyValueUtil.newKeyValue(currentKey, SINGLE_COLUMN_FAMILY, SINGLE_COLUMN, AGG_TIMESTAMP, value, 0, value.length)); currentKey.set(nextKey.get(), nextKey.getOffset(), nextKey.getLength()); return tuple; }
if (targetHash.equals(currentSourceHash)) { context.getCounter(Counter.HASHES_MATCHED).increment(1); } else {