Author: stack
Date: Tue Sep 7 22:20:40 2010
New Revision: 993548
URL: http://svn.apache.org/viewvc?rev=993548&view=rev
Log:
HBASE-2962 Add missing methods to HTableInterface (and HTable)
Modified:
hbase/trunk/CHANGES.txt
hbase/trunk/src/main/java/org/apache/hadoop/hbase/client/HTable.java
hbase/trunk/src/main/java/org/apache/hadoop/hbase/client/HTableInterface.java
hbase/trunk/src/main/java/org/apache/hadoop/hbase/rest/client/RemoteHTable.java
Modified: hbase/trunk/CHANGES.txt
URL:
http://svn.apache.org/viewvc/hbase/trunk/CHANGES.txt?rev=993548&r1=993547&r2=993548&view=diff
==============================================================================
--- hbase/trunk/CHANGES.txt (original)
+++ hbase/trunk/CHANGES.txt Tue Sep 7 22:20:40 2010
@@ -884,6 +884,8 @@ Release 0.21.0 - Unreleased
HBASE-1676 load balancing on a large cluster doesn't work very well
HBASE-2953 Edit of hbase-default.xml removing stale configs.
HBASE-2857 HBaseAdmin.tableExists() should not require a full meta scan
+ HBASE-2962 Add missing methods to HTableInterface (and HTable)
+ (Lars Francke via Stack)
NEW FEATURES
HBASE-1961 HBase EC2 scripts
Modified: hbase/trunk/src/main/java/org/apache/hadoop/hbase/client/HTable.java
URL:
http://svn.apache.org/viewvc/hbase/trunk/src/main/java/org/apache/hadoop/hbase/client/HTable.java?rev=993548&r1=993547&r2=993548&view=diff
==============================================================================
--- hbase/trunk/src/main/java/org/apache/hadoop/hbase/client/HTable.java
(original)
+++ hbase/trunk/src/main/java/org/apache/hadoop/hbase/client/HTable.java Tue
Sep 7 22:20:40 2010
@@ -268,6 +268,7 @@ public class HTable implements HTableInt
return connection.getRegionLocation(tableName, row, false);
}
+ @Override
public byte [] getTableName() {
return this.tableName;
}
@@ -305,6 +306,7 @@ public class HTable implements HTableInt
this.scannerCaching = scannerCaching;
}
+ @Override
public HTableDescriptor getTableDescriptor() throws IOException {
return new UnmodifyableHTableDescriptor(
this.connection.getHTableDescriptor(this.tableName));
@@ -492,6 +494,7 @@ public class HTable implements HTableInt
return allRegions;
}
+ @Override
public Result getRowOrBefore(final byte[] row, final byte[] family)
throws IOException {
return connection.getRegionServerWithRetries(
@@ -503,18 +506,21 @@ public class HTable implements HTableInt
});
}
+ @Override
public ResultScanner getScanner(final Scan scan) throws IOException {
ClientScanner s = new ClientScanner(scan);
s.initialize();
return s;
}
+ @Override
public ResultScanner getScanner(byte [] family) throws IOException {
Scan scan = new Scan();
scan.addFamily(family);
return getScanner(scan);
}
+ @Override
public ResultScanner getScanner(byte [] family, byte [] qualifier)
throws IOException {
Scan scan = new Scan();
@@ -532,6 +538,10 @@ public class HTable implements HTableInt
);
}
+ public Result[] get(List<Get> gets) throws IOException {
+ return batch((List) gets);
+ }
+
/**
* Method that does a batch call on Deletes, Gets and Puts.
*
@@ -541,6 +551,7 @@ public class HTable implements HTableInt
* the call for that action failed, even after retries
* @throws IOException
*/
+ @Override
public synchronized void batch(final List<Row> actions, final Result[]
results) throws IOException {
connection.processBatch(actions, tableName, pool, results);
}
@@ -553,6 +564,7 @@ public class HTable implements HTableInt
* the call for that action failed, even after retries
* @throws IOException
*/
+ @Override
public synchronized Result[] batch(final List<Row> actions) throws
IOException {
Result[] results = new Result[actions.size()];
connection.processBatch(actions, tableName, pool, results);
@@ -566,6 +578,7 @@ public class HTable implements HTableInt
* @throws IOException if a remote or network exception occurs.
* @since 0.20.0
*/
+ @Override
public void delete(final Delete delete)
throws IOException {
connection.getRegionServerWithRetries(
@@ -587,6 +600,7 @@ public class HTable implements HTableInt
* that have not be successfully applied.
* @since 0.20.1
*/
+ @Override
public void delete(final List<Delete> deletes)
throws IOException {
Result[] results = new Result[deletes.size()];
@@ -603,10 +617,12 @@ public class HTable implements HTableInt
}
}
+ @Override
public void put(final Put put) throws IOException {
doPut(Arrays.asList(put));
}
+ @Override
public void put(final List<Put> puts) throws IOException {
doPut(puts);
}
@@ -622,12 +638,14 @@ public class HTable implements HTableInt
}
}
+ @Override
public long incrementColumnValue(final byte [] row, final byte [] family,
final byte [] qualifier, final long amount)
throws IOException {
return incrementColumnValue(row, family, qualifier, amount, true);
}
+ @Override
public long incrementColumnValue(final byte [] row, final byte [] family,
final byte [] qualifier, final long amount, final boolean writeToWAL)
throws IOException {
@@ -665,6 +683,7 @@ public class HTable implements HTableInt
* @throws IOException
* @return true if the new put was execute, false otherwise
*/
+ @Override
public boolean checkAndPut(final byte [] row,
final byte [] family, final byte [] qualifier, final byte [] value,
final Put put)
@@ -692,6 +711,7 @@ public class HTable implements HTableInt
* @throws IOException
* @return true if the new delete was executed, false otherwise
*/
+ @Override
public boolean checkAndDelete(final byte [] row,
final byte [] family, final byte [] qualifier, final byte [] value,
final Delete delete)
@@ -719,6 +739,7 @@ public class HTable implements HTableInt
* @return true if the specified Get matches one or more keys, false if not
* @throws IOException
*/
+ @Override
public boolean exists(final Get get) throws IOException {
return connection.getRegionServerWithRetries(
new ServerCallable<Boolean>(connection, tableName, get.getRow()) {
@@ -738,6 +759,7 @@ public class HTable implements HTableInt
* {...@link #isAutoFlush()} is {...@code true}.
* @throws IOException if a remote or network exception occurs.
*/
+ @Override
public void flushCommits() throws IOException {
try {
connection.processBatchOfPuts(writeBuffer, tableName, pool);
@@ -750,10 +772,7 @@ public class HTable implements HTableInt
}
}
- /**
- * Close down this HTable instance.
- * Calls {...@link #flushCommits()}.
- */
+ @Override
public void close() throws IOException{
flushCommits();
}
@@ -774,6 +793,7 @@ public class HTable implements HTableInt
}
}
+ @Override
public RowLock lockRow(final byte [] row)
throws IOException {
return connection.getRegionServerWithRetries(
@@ -787,6 +807,7 @@ public class HTable implements HTableInt
);
}
+ @Override
public void unlockRow(final RowLock rl)
throws IOException {
connection.getRegionServerWithRetries(
@@ -800,6 +821,7 @@ public class HTable implements HTableInt
);
}
+ @Override
public boolean isAutoFlush() {
return autoFlush;
}
Modified:
hbase/trunk/src/main/java/org/apache/hadoop/hbase/client/HTableInterface.java
URL:
http://svn.apache.org/viewvc/hbase/trunk/src/main/java/org/apache/hadoop/hbase/client/HTableInterface.java?rev=993548&r1=993547&r2=993548&view=diff
==============================================================================
---
hbase/trunk/src/main/java/org/apache/hadoop/hbase/client/HTableInterface.java
(original)
+++
hbase/trunk/src/main/java/org/apache/hadoop/hbase/client/HTableInterface.java
Tue Sep 7 22:20:40 2010
@@ -21,6 +21,7 @@ package org.apache.hadoop.hbase.client;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hbase.HTableDescriptor;
+import org.apache.hadoop.hbase.KeyValue;
import java.io.IOException;
import java.util.List;
@@ -70,6 +71,29 @@ public interface HTableInterface {
boolean exists(Get get) throws IOException;
/**
+ * Method that does a batch call on Deletes, Gets and Puts.
+ *
+ * @param actions list of Get, Put, Delete objects
+ * @param results Empty Result[], same size as actions. Provides access to
partial
+ * results, in case an exception is thrown. A null in the
result array means that
+ * the call for that action failed, even after retries
+ * @throws IOException
+ * @since 0.90.0
+ */
+ void batch(final List<Row> actions, final Result[] results) throws
IOException;
+
+ /**
+ * Method that does a batch call on Deletes, Gets and Puts.
+ *
+ * @param actions list of Get, Put, Delete objects
+ * @return the results from the actions. A null in the return array means
that
+ * the call for that action failed, even after retries
+ * @throws IOException
+ * @since 0.90.0
+ */
+ Result[] batch(final List<Row> actions) throws IOException;
+
+ /**
* Extracts certain cells from a given row.
* @param get The object that specifies what data to fetch and from which
row.
* @return The data coming from the specified row, if it exists. If the row
@@ -81,6 +105,22 @@ public interface HTableInterface {
Result get(Get get) throws IOException;
/**
+ * Extracts certain cells from the given rows, in batch.
+ *
+ * @param gets The objects that specify what data to fetch and from which
rows.
+ *
+ * @return The data coming from the specified rows, if it exists. If the row
+ * specified doesn't exist, the {...@link Result} instance returned
won't
+ * contain any {...@link KeyValue}, as indicated by {...@link
Result#isEmpty()}.
+ * A null in the return array means that the get operation for that
+ * Get failed, even after retries.
+ * @throws IOException if a remote or network exception occurs.
+ *
+ * @since 0.90.0
+ */
+ Result[] get(List<Get> gets) throws IOException;
+
+ /**
* Return the row that matches <i>row</i> exactly,
* or the one that immediately precedes it.
*
Modified:
hbase/trunk/src/main/java/org/apache/hadoop/hbase/rest/client/RemoteHTable.java
URL:
http://svn.apache.org/viewvc/hbase/trunk/src/main/java/org/apache/hadoop/hbase/rest/client/RemoteHTable.java?rev=993548&r1=993547&r2=993548&view=diff
==============================================================================
---
hbase/trunk/src/main/java/org/apache/hadoop/hbase/rest/client/RemoteHTable.java
(original)
+++
hbase/trunk/src/main/java/org/apache/hadoop/hbase/rest/client/RemoteHTable.java
Tue Sep 7 22:20:40 2010
@@ -43,6 +43,7 @@ import org.apache.hadoop.hbase.client.De
import org.apache.hadoop.hbase.client.Get;
import org.apache.hadoop.hbase.client.HTableInterface;
import org.apache.hadoop.hbase.client.Put;
+import org.apache.hadoop.hbase.client.Row;
import org.apache.hadoop.hbase.client.Result;
import org.apache.hadoop.hbase.client.ResultScanner;
import org.apache.hadoop.hbase.client.RowLock;
@@ -598,4 +599,19 @@ public class RemoteHTable implements HTa
throw new IOException("incrementColumnValue not supported");
}
+ @Override
+ public void batch(List<Row> actions, Result[] results) throws IOException {
+ throw new IOException("batch not supported");
+ }
+
+ @Override
+ public Result[] batch(List<Row> actions) throws IOException {
+ throw new IOException("batch not supported");
+ }
+
+ @Override
+ public Result[] get(List<Get> gets) throws IOException {
+ throw new IOException("get(List<Get>) not supported");
+ }
+
}