Guest User

Untitled

a guest
Aug 19th, 2014
333
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.48 KB | None | 0 0
  1. diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestFromClientSide.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestFromClientSide
  2. index b59db4e..0eb8bc5 100644
  3. --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestFromClientSide.java
  4. +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestFromClientSide.java
  5. @@ -53,6 +53,7 @@ import org.apache.hadoop.hbase.Abortable;
  6. import org.apache.hadoop.hbase.Cell;
  7. import org.apache.hadoop.hbase.CellUtil;
  8. import org.apache.hadoop.hbase.DoNotRetryIOException;
  9. +import org.apache.hadoop.hbase.HBaseConfiguration;
  10. import org.apache.hadoop.hbase.HBaseTestingUtility;
  11. import org.apache.hadoop.hbase.HColumnDescriptor;
  12. import org.apache.hadoop.hbase.HConstants;
  13. @@ -165,6 +166,62 @@ public class TestFromClientSide {
  14. // Nothing to do.
  15. }
  16.  
  17. + @Test
  18. + public void testPutDeleteCell() throws Exception {
  19. + final byte[] TABLENAME = Bytes.toBytes("testHbasePutDeleteCell");
  20. + Configuration configuration = TEST_UTIL.getConfiguration();
  21. + final String rowKey = "12345";
  22. + final byte[] FAMILY = Bytes.toBytes("family");
  23. + HColumnDescriptor hcd = new HColumnDescriptor(FAMILY)
  24. + .setKeepDeletedCells(true).setMaxVersions(3);
  25. +
  26. + HTableDescriptor desc = new HTableDescriptor(TableName.valueOf(TABLENAME));
  27. + desc.addFamily(hcd);
  28. + TEST_UTIL.getHBaseAdmin().createTable(desc);
  29. +
  30. + HTableInterface table = new HTable(configuration, TABLENAME);
  31. + // put one row
  32. + Put put = new Put(Bytes.toBytes(rowKey));
  33. + put.add(FAMILY, Bytes.toBytes("A"), Bytes.toBytes("a"));
  34. + put.add(FAMILY, Bytes.toBytes("B"), Bytes.toBytes("b"));
  35. + put.add(FAMILY, Bytes.toBytes("C"), Bytes.toBytes("c"));
  36. + table.put(put);
  37. + // get row back and assert the values
  38. + Get get = new Get(Bytes.toBytes(rowKey));
  39. + Result result = table.get(get);
  40. + assertEquals("Column A value should be a",
  41. + Bytes.toString(result.getValue(FAMILY, Bytes.toBytes("A"))).equals("a"), true);
  42. + assertEquals("Column B value should be b",
  43. + Bytes.toString(result.getValue(FAMILY, Bytes.toBytes("B"))).equals("b"), true);
  44. + assertEquals("Column C value should be c",
  45. + Bytes.toString(result.getValue(FAMILY, Bytes.toBytes("C"))).equals("c"), true);
  46. +
  47. + // put the same row again with C column deleted
  48. + put = new Put(Bytes.toBytes(rowKey));
  49. + put.add(FAMILY, Bytes.toBytes("A"), Bytes.toBytes("a"));
  50. + put.add(FAMILY, Bytes.toBytes("B"), Bytes.toBytes("b"));
  51. + KeyValue kv = new KeyValue(Bytes.toBytes(rowKey), FAMILY, Bytes.toBytes("C"),
  52. + HConstants.LATEST_TIMESTAMP, KeyValue.Type.DeleteColumn);
  53. + /*
  54. + put.add(kv);
  55. + */
  56. + table.put(put);
  57. + Delete del = new Delete(Bytes.toBytes(rowKey));
  58. + del.deleteColumns(FAMILY, Bytes.toBytes("C"), HConstants.LATEST_TIMESTAMP);
  59. + table.delete(del);
  60. + // get row back and assert the values
  61. + get = new Get(Bytes.toBytes(rowKey));
  62. + result = table.get(get);
  63. + table.close();
  64. +
  65. + assertEquals("Column A value should be a",
  66. + Bytes.toString(result.getValue(FAMILY, Bytes.toBytes("A"))).equals("a"), true);
  67. + assertEquals("Column A value should be b",
  68. + Bytes.toString(result.getValue(FAMILY, Bytes.toBytes("B"))).equals("b"), true);
  69. + byte[] val = result.getValue(FAMILY, Bytes.toBytes("C"));
  70. + assertEquals("Column C should not exists", null, Bytes.toString(val));
  71. + }
  72. +
  73. /**
  74. * Basic client side validation of HBASE-4536
  75. */
Advertisement
Add Comment
Please, Sign In to add comment