From 58c8d8ab3b0298067ecdf727187d79b022b494ec Mon Sep 17 00:00:00 2001 From: Peter Somogyi Date: Wed, 25 Oct 2017 20:10:11 -0700 Subject: [PATCH] HBASE-19031 Align exist method in Table and AsyncTable interfacesi Deprecate Table::existsAll method and add Table::exists. RemoteHTable already had a deprecated exists method, remove that and implement the new exists from Table interface. --- .../java/org/apache/hadoop/hbase/client/HTable.java | 14 ++++++++++---- .../java/org/apache/hadoop/hbase/client/Table.java | 19 ++++++++++++++++++- .../apache/hadoop/hbase/rest/client/RemoteHTable.java | 16 +--------------- .../hadoop/hbase/regionserver/RegionAsTable.java | 8 +++++++- 4 files changed, 36 insertions(+), 21 deletions(-) diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/HTable.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/HTable.java index 7da1662c4d..b32e398a11 100644 --- a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/HTable.java +++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/HTable.java @@ -945,11 +945,8 @@ public class HTable implements Table { return r.getExists(); } - /** - * {@inheritDoc} - */ @Override - public boolean[] existsAll(final List gets) throws IOException { + public boolean[] exists(List gets) throws IOException { if (gets.isEmpty()) return new boolean[]{}; if (gets.size() == 1) return new boolean[]{exists(gets.get(0))}; @@ -978,6 +975,15 @@ public class HTable implements Table { return results; } + /** + * {@inheritDoc} + */ + @Override + @Deprecated + public boolean[] existsAll(final List gets) throws IOException { + return exists(gets); + } + /** * Process a mixed batch of Get, Put and Delete actions. All actions for a * RegionServer are forwarded in one RPC call. Queries are executed in parallel. diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/Table.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/Table.java index f3dae4e659..628f0ca1ed 100644 --- a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/Table.java +++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/Table.java @@ -110,7 +110,24 @@ public interface Table extends Closeable { * @return Array of boolean. True if the specified Get matches one or more keys, false if not. * @throws IOException e */ - boolean[] existsAll(List gets) throws IOException; + boolean[] exists(List gets) throws IOException; + + /** + * Test for the existence of columns in the table, as specified by the Gets. + * This will return an array of booleans. Each value will be true if the related Get matches + * one or more keys, false if not. + * This is a server-side call so it prevents any data from being transferred to + * the client. + * + * @param gets the Gets + * @return Array of boolean. True if the specified Get matches one or more keys, false if not. + * @throws IOException e + * @deprecated //TODO fill this + */ + @Deprecated + default boolean[] existsAll(List gets) throws IOException { + return exists(gets); + } /** * Method that does a batch call on Deletes, Gets, Puts, Increments, Appends, RowMutations. diff --git a/hbase-rest/src/main/java/org/apache/hadoop/hbase/rest/client/RemoteHTable.java b/hbase-rest/src/main/java/org/apache/hadoop/hbase/rest/client/RemoteHTable.java index 5051d47fde..1eaaa65b83 100644 --- a/hbase-rest/src/main/java/org/apache/hadoop/hbase/rest/client/RemoteHTable.java +++ b/hbase-rest/src/main/java/org/apache/hadoop/hbase/rest/client/RemoteHTable.java @@ -367,12 +367,8 @@ public class RemoteHTable implements Table { return (result != null && !(result.isEmpty())); } - /** - * exists(List) is really a list of get() calls. Just use get(). - * @param gets list of Get to test for the existence - */ @Override - public boolean[] existsAll(List gets) throws IOException { + public boolean[] exists(List gets) throws IOException { LOG.warn("exists(List) is really list of get() calls, just use get()"); boolean[] results = new boolean[gets.size()]; for (int i = 0; i < results.length; i++) { @@ -381,16 +377,6 @@ public class RemoteHTable implements Table { return results; } - @Deprecated - public Boolean[] exists(List gets) throws IOException { - boolean[] results = existsAll(gets); - Boolean[] objectResults = new Boolean[results.length]; - for (int i = 0; i < results.length; ++i) { - objectResults[i] = results[i]; - } - return objectResults; - } - @Override public void put(Put put) throws IOException { CellSetModel model = buildModelFromPut(put); diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/RegionAsTable.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/RegionAsTable.java index f72060d335..a065b8b15f 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/RegionAsTable.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/RegionAsTable.java @@ -100,7 +100,7 @@ public class RegionAsTable implements Table { } @Override - public boolean[] existsAll(List gets) throws IOException { + public boolean[] exists(List gets) throws IOException { boolean [] results = new boolean[gets.size()]; int index = 0; for (Get get: gets) { @@ -109,6 +109,12 @@ public class RegionAsTable implements Table { return results; } + @Override + @Deprecated + public boolean[] existsAll(List gets) throws IOException { + return exists(gets); + } + @Override public void batch(List actions, Object[] results) throws IOException, InterruptedException { -- 2.14.2