CRUNCH-546 Remove calls to CellUtil.cloneXXX Remove (relatively expensive) calls to CellUtil.cloneXXX where possible, instead using alternate versions of Bytes.compareTo and Bytes.equals.
Project: http://git-wip-us.apache.org/repos/asf/crunch/repo Commit: http://git-wip-us.apache.org/repos/asf/crunch/commit/de1553e7 Tree: http://git-wip-us.apache.org/repos/asf/crunch/tree/de1553e7 Diff: http://git-wip-us.apache.org/repos/asf/crunch/diff/de1553e7 Branch: refs/heads/master Commit: de1553e73c646f3747c71a5b345d15c33a32f230 Parents: b2e6d16 Author: Gabriel Reid <[email protected]> Authored: Sun Jul 19 16:41:39 2015 +0200 Committer: Gabriel Reid <[email protected]> Committed: Mon Jul 20 15:12:43 2015 +0200 ---------------------------------------------------------------------- .../apache/crunch/io/hbase/HFileInputFormat.java | 5 ++++- .../java/org/apache/crunch/io/hbase/HFileUtils.java | 16 +++++++++++----- 2 files changed, 15 insertions(+), 6 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/crunch/blob/de1553e7/crunch-hbase/src/main/java/org/apache/crunch/io/hbase/HFileInputFormat.java ---------------------------------------------------------------------- diff --git a/crunch-hbase/src/main/java/org/apache/crunch/io/hbase/HFileInputFormat.java b/crunch-hbase/src/main/java/org/apache/crunch/io/hbase/HFileInputFormat.java index 1d8e106..7381ddd 100644 --- a/crunch-hbase/src/main/java/org/apache/crunch/io/hbase/HFileInputFormat.java +++ b/crunch-hbase/src/main/java/org/apache/crunch/io/hbase/HFileInputFormat.java @@ -144,7 +144,10 @@ public class HFileInputFormat extends FileInputFormat<NullWritable, KeyValue> { return false; } value = KeyValue.cloneAndAddTags(scanner.getKeyValue(), ImmutableList.<Tag>of()); - if (stopRow != null && Bytes.compareTo(CellUtil.cloneRow(value), stopRow) >= 0) { + if (stopRow != null && + Bytes.compareTo( + value.getRowArray(), value.getRowOffset(), value.getRowLength(), + stopRow, 0, stopRow.length) >= 0) { if(LOG.isInfoEnabled()) { LOG.info("Reached stop row {}", Bytes.toStringBinary(stopRow)); } http://git-wip-us.apache.org/repos/asf/crunch/blob/de1553e7/crunch-hbase/src/main/java/org/apache/crunch/io/hbase/HFileUtils.java ---------------------------------------------------------------------- diff --git a/crunch-hbase/src/main/java/org/apache/crunch/io/hbase/HFileUtils.java b/crunch-hbase/src/main/java/org/apache/crunch/io/hbase/HFileUtils.java index d18b65b..31684d2 100644 --- a/crunch-hbase/src/main/java/org/apache/crunch/io/hbase/HFileUtils.java +++ b/crunch-hbase/src/main/java/org/apache/crunch/io/hbase/HFileUtils.java @@ -126,7 +126,9 @@ public final class HFileUtils { @Override public boolean accept(C input) { - return Bytes.equals(CellUtil.cloneFamily(input), family); + return Bytes.equals( + input.getFamilyArray(), input.getFamilyOffset(), input.getFamilyLength(), + family, 0, family.length); } @Override @@ -145,7 +147,9 @@ public final class HFileUtils { @Override public boolean accept(C input) { - return Bytes.compareTo(CellUtil.cloneRow(input), startRow) >= 0; + return Bytes.compareTo( + input.getRowArray(), input.getRowOffset(), input.getRowLength(), + startRow, 0, startRow.length) >= 0; } } @@ -159,7 +163,9 @@ public final class HFileUtils { @Override public boolean accept(C input) { - return Bytes.compareTo(CellUtil.cloneRow(input), stopRow) < 0; + return Bytes.compareTo( + input.getRowArray(), input.getRowOffset(), input.getRowLength(), + stopRow, 0, stopRow.length) < 0; } } @@ -223,8 +229,8 @@ public final class HFileUtils { @Override public boolean accept(C input) { - ByteBuffer f = ByteBuffer.wrap(CellUtil.cloneFamily(input)); - ByteBuffer q = ByteBuffer.wrap(CellUtil.cloneQualifier(input)); + ByteBuffer f = ByteBuffer.wrap(input.getFamilyArray(), input.getFamilyOffset(), input.getFamilyLength()); + ByteBuffer q = ByteBuffer.wrap(input.getQualifierArray(), input.getQualifierOffset(), input.getQualifierLength()); return familySet.contains(f) || qualifierSet.contains(Pair.of(f, q)); } }
