HBASE-19031 Align exist method in Table and AsyncTable interfaces

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.

Signed-off-by: Chia-Ping Tsai <chia7712@gmail.com>
This commit is contained in:
Peter Somogyi 2017-10-25 20:10:11 -07:00 committed by Chia-Ping Tsai
parent e5e2bde87b
commit 482d6bd3a4
4 changed files with 22 additions and 21 deletions

View File

@ -945,11 +945,8 @@ public class HTable implements Table {
return r.getExists(); return r.getExists();
} }
/**
* {@inheritDoc}
*/
@Override @Override
public boolean[] existsAll(final List<Get> gets) throws IOException { public boolean[] exists(List<Get> gets) throws IOException {
if (gets.isEmpty()) return new boolean[]{}; if (gets.isEmpty()) return new boolean[]{};
if (gets.size() == 1) return new boolean[]{exists(gets.get(0))}; if (gets.size() == 1) return new boolean[]{exists(gets.get(0))};

View File

@ -110,7 +110,25 @@ public interface Table extends Closeable {
* @return Array of boolean. True if the specified Get matches one or more keys, false if not. * @return Array of boolean. True if the specified Get matches one or more keys, false if not.
* @throws IOException e * @throws IOException e
*/ */
boolean[] existsAll(List<Get> gets) throws IOException; boolean[] exists(List<Get> 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 since 2.0 version and will be removed in 3.0 version.
* use {@link #exists(List)}
*/
@Deprecated
default boolean[] existsAll(List<Get> gets) throws IOException {
return exists(gets);
}
/** /**
* Method that does a batch call on Deletes, Gets, Puts, Increments, Appends, RowMutations. * Method that does a batch call on Deletes, Gets, Puts, Increments, Appends, RowMutations.

View File

@ -367,12 +367,8 @@ public class RemoteHTable implements Table {
return (result != null && !(result.isEmpty())); 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 @Override
public boolean[] existsAll(List<Get> gets) throws IOException { public boolean[] exists(List<Get> gets) throws IOException {
LOG.warn("exists(List<Get>) is really list of get() calls, just use get()"); LOG.warn("exists(List<Get>) is really list of get() calls, just use get()");
boolean[] results = new boolean[gets.size()]; boolean[] results = new boolean[gets.size()];
for (int i = 0; i < results.length; i++) { for (int i = 0; i < results.length; i++) {
@ -381,16 +377,6 @@ public class RemoteHTable implements Table {
return results; return results;
} }
@Deprecated
public Boolean[] exists(List<Get> 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 @Override
public void put(Put put) throws IOException { public void put(Put put) throws IOException {
CellSetModel model = buildModelFromPut(put); CellSetModel model = buildModelFromPut(put);

View File

@ -100,7 +100,7 @@ public class RegionAsTable implements Table {
} }
@Override @Override
public boolean[] existsAll(List<Get> gets) throws IOException { public boolean[] exists(List<Get> gets) throws IOException {
boolean [] results = new boolean[gets.size()]; boolean [] results = new boolean[gets.size()];
int index = 0; int index = 0;
for (Get get: gets) { for (Get get: gets) {