HBASE-5736 ThriftServerRunner.HbaseHandler.mutateRow() does not use ByteBuffer correctly (Scott Chen)
git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1310634 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
6d43887b88
commit
915f2cd40d
|
@ -974,11 +974,11 @@ public class ThriftServerRunner implements Runnable {
|
||||||
} else {
|
} else {
|
||||||
if(famAndQf.length == 1) {
|
if(famAndQf.length == 1) {
|
||||||
put.add(famAndQf[0], HConstants.EMPTY_BYTE_ARRAY,
|
put.add(famAndQf[0], HConstants.EMPTY_BYTE_ARRAY,
|
||||||
m.value != null ? m.value.array()
|
m.value != null ? getBytes(m.value)
|
||||||
: HConstants.EMPTY_BYTE_ARRAY);
|
: HConstants.EMPTY_BYTE_ARRAY);
|
||||||
} else {
|
} else {
|
||||||
put.add(famAndQf[0], famAndQf[1],
|
put.add(famAndQf[0], famAndQf[1],
|
||||||
m.value != null ? m.value.array()
|
m.value != null ? getBytes(m.value)
|
||||||
: HConstants.EMPTY_BYTE_ARRAY);
|
: HConstants.EMPTY_BYTE_ARRAY);
|
||||||
}
|
}
|
||||||
put.setWriteToWAL(m.writeToWAL);
|
put.setWriteToWAL(m.writeToWAL);
|
||||||
|
@ -1032,11 +1032,11 @@ public class ThriftServerRunner implements Runnable {
|
||||||
} else {
|
} else {
|
||||||
if(famAndQf.length == 1) {
|
if(famAndQf.length == 1) {
|
||||||
put.add(famAndQf[0], HConstants.EMPTY_BYTE_ARRAY,
|
put.add(famAndQf[0], HConstants.EMPTY_BYTE_ARRAY,
|
||||||
m.value != null ? m.value.array()
|
m.value != null ? getBytes(m.value)
|
||||||
: HConstants.EMPTY_BYTE_ARRAY);
|
: HConstants.EMPTY_BYTE_ARRAY);
|
||||||
} else {
|
} else {
|
||||||
put.add(famAndQf[0], famAndQf[1],
|
put.add(famAndQf[0], famAndQf[1],
|
||||||
m.value != null ? m.value.array()
|
m.value != null ? getBytes(m.value)
|
||||||
: HConstants.EMPTY_BYTE_ARRAY);
|
: HConstants.EMPTY_BYTE_ARRAY);
|
||||||
}
|
}
|
||||||
put.setWriteToWAL(m.writeToWAL);
|
put.setWriteToWAL(m.writeToWAL);
|
||||||
|
@ -1401,8 +1401,8 @@ public class ThriftServerRunner implements Runnable {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
for (Map.Entry<ByteBuffer, ByteBuffer> entry : attributes.entrySet()) {
|
for (Map.Entry<ByteBuffer, ByteBuffer> entry : attributes.entrySet()) {
|
||||||
String name = Bytes.toStringBinary(entry.getKey());
|
String name = Bytes.toStringBinary(getBytes(entry.getKey()));
|
||||||
byte[] value = Bytes.toBytes(entry.getValue());
|
byte[] value = getBytes(entry.getValue());
|
||||||
op.setAttribute(name, value);
|
op.setAttribute(name, value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -209,9 +209,13 @@ public class TestThriftServer {
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public void doTestTableMutations() throws Exception {
|
public void doTestTableMutations() throws Exception {
|
||||||
// Setup
|
|
||||||
ThriftServerRunner.HBaseHandler handler =
|
ThriftServerRunner.HBaseHandler handler =
|
||||||
new ThriftServerRunner.HBaseHandler(UTIL.getConfiguration());
|
new ThriftServerRunner.HBaseHandler(UTIL.getConfiguration());
|
||||||
|
doTestTableMutations(handler);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void doTestTableMutations(Hbase.Iface handler) throws Exception {
|
||||||
|
// Setup
|
||||||
handler.createTable(tableAname, getColumnDescriptors());
|
handler.createTable(tableAname, getColumnDescriptors());
|
||||||
|
|
||||||
// Apply a few Mutations to rowA
|
// Apply a few Mutations to rowA
|
||||||
|
@ -267,7 +271,7 @@ public class TestThriftServer {
|
||||||
handler.mutateRow(tableAname, rowAname, mutations, null);
|
handler.mutateRow(tableAname, rowAname, mutations, null);
|
||||||
TRowResult rowResult3 = handler.getRow(tableAname, rowAname, null).get(0);
|
TRowResult rowResult3 = handler.getRow(tableAname, rowAname, null).get(0);
|
||||||
assertEquals(rowAname, rowResult3.row);
|
assertEquals(rowAname, rowResult3.row);
|
||||||
assertEquals(0, rowResult3.columns.get(columnAname).value.array().length);
|
assertEquals(0, rowResult3.columns.get(columnAname).value.remaining());
|
||||||
|
|
||||||
// Teardown
|
// Teardown
|
||||||
handler.disableTable(tableAname);
|
handler.disableTable(tableAname);
|
||||||
|
@ -540,7 +544,7 @@ public class TestThriftServer {
|
||||||
* (rowB, columnA): place valueC
|
* (rowB, columnA): place valueC
|
||||||
* (rowB, columnB): place valueD
|
* (rowB, columnB): place valueD
|
||||||
*/
|
*/
|
||||||
private List<BatchMutation> getBatchMutations() {
|
private static List<BatchMutation> getBatchMutations() {
|
||||||
List<BatchMutation> batchMutations = new ArrayList<BatchMutation>();
|
List<BatchMutation> batchMutations = new ArrayList<BatchMutation>();
|
||||||
|
|
||||||
// Mutations to rowA. You can't mix delete and put anymore.
|
// Mutations to rowA. You can't mix delete and put anymore.
|
||||||
|
|
|
@ -142,7 +142,7 @@ public class TestThriftServerCmdLine {
|
||||||
cmdLineThread.start();
|
cmdLineThread.start();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(timeout=30 * 1000)
|
@Test(timeout=60 * 1000)
|
||||||
public void testRunThriftServer() throws Exception {
|
public void testRunThriftServer() throws Exception {
|
||||||
List<String> args = new ArrayList<String>();
|
List<String> args = new ArrayList<String>();
|
||||||
if (implType != null) {
|
if (implType != null) {
|
||||||
|
@ -209,6 +209,7 @@ public class TestThriftServerCmdLine {
|
||||||
TestThriftServer.doTestTableCreateDrop(client);
|
TestThriftServer.doTestTableCreateDrop(client);
|
||||||
TestThriftServer.doTestGetRegionInfo(client);
|
TestThriftServer.doTestGetRegionInfo(client);
|
||||||
TestThriftServer.doTestGetTableRegions(client);
|
TestThriftServer.doTestGetTableRegions(client);
|
||||||
|
TestThriftServer.doTestTableMutations(client);
|
||||||
} finally {
|
} finally {
|
||||||
sock.close();
|
sock.close();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue