From 5464442ad2e55a2b618f08105a5c51416158b888 Mon Sep 17 00:00:00 2001 From: "shenyunlong.syl" Date: Fri, 27 Jun 2025 10:53:26 +0800 Subject: [PATCH] [Fix] add defensive code for empty family scan/get --- .../java/com/alipay/oceanbase/hbase/OHTable.java | 6 ++++++ .../oceanbase/hbase/util/FeatureSupport.java | 14 ++++++++++++++ 2 files changed, 20 insertions(+) create mode 100644 src/main/java/com/alipay/oceanbase/hbase/util/FeatureSupport.java diff --git a/src/main/java/com/alipay/oceanbase/hbase/OHTable.java b/src/main/java/com/alipay/oceanbase/hbase/OHTable.java index 106058eb..d0463ab5 100644 --- a/src/main/java/com/alipay/oceanbase/hbase/OHTable.java +++ b/src/main/java/com/alipay/oceanbase/hbase/OHTable.java @@ -927,6 +927,9 @@ private void processColumnFilters(NavigableSet columnFilters, @Override public Result get(final Get get) throws IOException { if (get.getFamilyMap().keySet().isEmpty()) { + if (!FeatureSupport.isEmptyFamilySupported()) { + throw new FeatureNotSupportedException("empty family get not supported yet within observer version: " + ObGlobal.obVsnString()); + } // check nothing, use table group; } else { checkFamilyViolation(get.getFamilyMap().keySet(), false); @@ -1012,6 +1015,9 @@ public Result[] get(List gets) throws IOException { @Override public ResultScanner getScanner(final Scan scan) throws IOException { if (scan.getFamilyMap().keySet().isEmpty()) { + if (!FeatureSupport.isEmptyFamilySupported()) { + throw new FeatureNotSupportedException("empty family scan not supported yet within observer version: " + ObGlobal.obVsnString()); + } // check nothing, use table group; } else { checkFamilyViolation(scan.getFamilyMap().keySet(), false); diff --git a/src/main/java/com/alipay/oceanbase/hbase/util/FeatureSupport.java b/src/main/java/com/alipay/oceanbase/hbase/util/FeatureSupport.java new file mode 100644 index 00000000..9054b10e --- /dev/null +++ b/src/main/java/com/alipay/oceanbase/hbase/util/FeatureSupport.java @@ -0,0 +1,14 @@ +package com.alipay.oceanbase.hbase.util; + +import static com.alipay.oceanbase.rpc.ObGlobal.OB_VERSION; +import static com.alipay.oceanbase.rpc.ObGlobal.calcVersion; + + +public class FeatureSupport { + // check empty family get/scan supported + public static boolean isEmptyFamilySupported() { + return (OB_VERSION >= calcVersion(4, 2, 3, 0) + && OB_VERSION < calcVersion(4, 3, 0, 0)) + || (OB_VERSION > calcVersion(4, 3, 4, 0)); + } +}