From ff68641a6a45afcac9cde0664f379db5b0c9ec75 Mon Sep 17 00:00:00 2001 From: YangJiaqi Date: Sun, 19 Mar 2023 18:45:06 +0800 Subject: [PATCH 1/2] Improve query performance with HBase --- .../apache/hugegraph/backend/store/hbase/HbaseSessions.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/hugegraph-hbase/src/main/java/org/apache/hugegraph/backend/store/hbase/HbaseSessions.java b/hugegraph-hbase/src/main/java/org/apache/hugegraph/backend/store/hbase/HbaseSessions.java index 06cbf9ab73..1239e1df9b 100644 --- a/hugegraph-hbase/src/main/java/org/apache/hugegraph/backend/store/hbase/HbaseSessions.java +++ b/hugegraph-hbase/src/main/java/org/apache/hugegraph/backend/store/hbase/HbaseSessions.java @@ -19,6 +19,7 @@ import java.io.IOException; import java.io.InterruptedIOException; +import java.nio.ByteBuffer; import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; @@ -418,7 +419,11 @@ default R scan(String table, Set prefixes) { */ default R scan(String table, byte[] startRow, boolean inclusiveStart, byte[] prefix) { + short value = (short) (((startRow[0] << 8) | (startRow[1] & 0xFF)) +1); + byte[] endRow = ByteBuffer.allocate(2).putShort(value).array(); + Scan scan = new Scan().withStartRow(startRow, inclusiveStart) + .withStopRow(endRow) .setFilter(new PrefixFilter(prefix)); return this.scan(table, scan); } From b5d08eb343f798337b2d414d8e0ecd6513224788 Mon Sep 17 00:00:00 2001 From: YangJiaqi Date: Thu, 30 Mar 2023 16:12:05 +0800 Subject: [PATCH 2/2] fix ci test error --- .../backend/store/hbase/HbaseSessions.java | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/hugegraph-hbase/src/main/java/org/apache/hugegraph/backend/store/hbase/HbaseSessions.java b/hugegraph-hbase/src/main/java/org/apache/hugegraph/backend/store/hbase/HbaseSessions.java index 1239e1df9b..d05e5a7880 100644 --- a/hugegraph-hbase/src/main/java/org/apache/hugegraph/backend/store/hbase/HbaseSessions.java +++ b/hugegraph-hbase/src/main/java/org/apache/hugegraph/backend/store/hbase/HbaseSessions.java @@ -419,12 +419,17 @@ default R scan(String table, Set prefixes) { */ default R scan(String table, byte[] startRow, boolean inclusiveStart, byte[] prefix) { - short value = (short) (((startRow[0] << 8) | (startRow[1] & 0xFF)) +1); - byte[] endRow = ByteBuffer.allocate(2).putShort(value).array(); - - Scan scan = new Scan().withStartRow(startRow, inclusiveStart) - .withStopRow(endRow) - .setFilter(new PrefixFilter(prefix)); + Scan scan = new Scan(); + if (table.equals("g_oe") || table.equals("g_ie")) { + short value = (short) (((startRow[0] << 8) | (startRow[1] & 0xFF)) +1); + byte[] endRow = ByteBuffer.allocate(2).putShort(value).array(); + scan.withStartRow(startRow, inclusiveStart) + .withStopRow(endRow) + .setFilter(new PrefixFilter(prefix)); + } else { + scan.withStartRow(startRow, inclusiveStart) + .setFilter(new PrefixFilter(prefix)); + } return this.scan(table, scan); }