Java Code Examples for org.apache.hadoop.hbase.client.Append#addColumn()
The following examples show how to use
org.apache.hadoop.hbase.client.Append#addColumn() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ThriftUtilities.java From hbase with Apache License 2.0 | 6 votes |
public static Append appendFromThrift(TAppend append) throws IOException { Append out = new Append(append.getRow()); for (TColumnValue column : append.getColumns()) { out.addColumn(column.getFamily(), column.getQualifier(), column.getValue()); } if (append.isSetAttributes()) { addAttributes(out, append.getAttributes()); } if (append.isSetDurability()) { out.setDurability(durabilityFromThrift(append.getDurability())); } if(append.getCellVisibility() != null) { out.setCellVisibility(new CellVisibility(append.getCellVisibility().getExpression())); } if (append.isSetReturnResults()) { out.setReturnResults(append.isReturnResults()); } return out; }
Example 2
Source File: ThriftUtilities.java From hbase with Apache License 2.0 | 6 votes |
/** * From a {@link TAppend} create an {@link Append}. * @param tappend the Thrift version of an append. * @return an increment that the {@link TAppend} represented. */ public static Append appendFromThrift(TAppend tappend) { Append append = new Append(tappend.getRow()); List<ByteBuffer> columns = tappend.getColumns(); List<ByteBuffer> values = tappend.getValues(); if (columns.size() != values.size()) { throw new IllegalArgumentException( "Sizes of columns and values in tappend object are not matching"); } int length = columns.size(); for (int i = 0; i < length; i++) { byte[][] famAndQf = CellUtil.parseColumn(getBytes(columns.get(i))); append.addColumn(famAndQf[0], famAndQf[1], getBytes(values.get(i))); } return append; }
Example 3
Source File: TestAccessController.java From hbase with Apache License 2.0 | 6 votes |
@Test public void testAppend() throws Exception { AccessTestAction appendAction = new AccessTestAction() { @Override public Object run() throws Exception { byte[] row = TEST_ROW; byte[] qualifier = TEST_QUALIFIER; Put put = new Put(row); put.addColumn(TEST_FAMILY, qualifier, Bytes.toBytes(1)); Append append = new Append(row); append.addColumn(TEST_FAMILY, qualifier, Bytes.toBytes(2)); try(Connection conn = ConnectionFactory.createConnection(conf); Table t = conn.getTable(TEST_TABLE)) { t.put(put); t.append(append); } return null; } }; verifyAllowed(appendAction, SUPERUSER, USER_ADMIN, USER_OWNER, USER_CREATE, USER_RW, USER_GROUP_WRITE); verifyDenied(appendAction, USER_RO, USER_NONE, USER_GROUP_CREATE, USER_GROUP_READ, USER_GROUP_ADMIN); }
Example 4
Source File: TestRegionObserverInterface.java From hbase with Apache License 2.0 | 6 votes |
@Test public void testAppendHook() throws IOException { final TableName tableName = TableName.valueOf(TEST_TABLE.getNameAsString() + "." + name.getMethodName()); Table table = util.createTable(tableName, new byte[][] { A, B, C }); try { Append app = new Append(Bytes.toBytes(0)); app.addColumn(A, A, A); verifyMethodResult(SimpleRegionObserver.class, new String[] { "hadPreAppend", "hadPostAppend", "hadPreAppendAfterRowLock" }, tableName, new Boolean[] { false, false, false }); table.append(app); verifyMethodResult(SimpleRegionObserver.class, new String[] { "hadPreAppend", "hadPostAppend", "hadPreAppendAfterRowLock" }, tableName, new Boolean[] { true, true, true }); } finally { util.deleteTable(tableName); table.close(); } }
Example 5
Source File: TestSpaceQuotaBasicFunctioning.java From hbase with Apache License 2.0 | 5 votes |
@Test public void testNoInsertsWithAppend() throws Exception { Append a = new Append(Bytes.toBytes("to_reject")); a.addColumn(Bytes.toBytes(SpaceQuotaHelperForTests.F1), Bytes.toBytes("to"), Bytes.toBytes("reject")); helper.writeUntilViolationAndVerifyViolation(SpaceViolationPolicy.NO_INSERTS, a); }
Example 6
Source File: TestSpaceQuotaBasicFunctioning.java From hbase with Apache License 2.0 | 5 votes |
@Test public void testNoWritesWithAppend() throws Exception { Append a = new Append(Bytes.toBytes("to_reject")); a.addColumn(Bytes.toBytes(SpaceQuotaHelperForTests.F1), Bytes.toBytes("to"), Bytes.toBytes("reject")); helper.writeUntilViolationAndVerifyViolation(SpaceViolationPolicy.NO_WRITES, a); }
Example 7
Source File: TestRegionObserverInterface.java From hbase with Apache License 2.0 | 5 votes |
private void testPreWALAppendHook(Table table, TableName tableName) throws IOException { int expectedCalls = 0; String [] methodArray = new String[1]; methodArray[0] = "getCtPreWALAppend"; Object[] resultArray = new Object[1]; Put p = new Put(ROW); p.addColumn(A, A, A); table.put(p); resultArray[0] = ++expectedCalls; verifyMethodResult(SimpleRegionObserver.class, methodArray, tableName, resultArray); Append a = new Append(ROW); a.addColumn(B, B, B); table.append(a); resultArray[0] = ++expectedCalls; verifyMethodResult(SimpleRegionObserver.class, methodArray, tableName, resultArray); Increment i = new Increment(ROW); i.addColumn(C, C, 1); table.increment(i); resultArray[0] = ++expectedCalls; verifyMethodResult(SimpleRegionObserver.class, methodArray, tableName, resultArray); Delete d = new Delete(ROW); table.delete(d); resultArray[0] = ++expectedCalls; verifyMethodResult(SimpleRegionObserver.class, methodArray, tableName, resultArray); }
Example 8
Source File: TestRegionServerMetrics.java From hbase with Apache License 2.0 | 5 votes |
@Test public void testAppend() throws Exception { doNPuts(1, false); for(int count = 0; count< 73; count++) { Append append = new Append(row); append.addColumn(cf, qualifier, Bytes.toBytes(",Test")); table.append(append); } metricsRegionServer.getRegionServerWrapper().forceRecompute(); assertCounter("appendNumOps", 73); }
Example 9
Source File: PerformanceEvaluation.java From hbase with Apache License 2.0 | 5 votes |
@Override boolean testRow(final int i) throws IOException { byte [] bytes = format(i); Append append = new Append(bytes); // unlike checkAndXXX tests, which make most sense to do on a single value, // if multiple families are specified for an append test we assume it is // meant to raise the work factor for (int family = 0; family < opts.families; family++) { byte[] familyName = Bytes.toBytes(FAMILY_NAME_BASE + family); append.addColumn(familyName, getQualifier(), bytes); } updateValueSize(this.table.append(append)); return true; }
Example 10
Source File: TestPassCustomCellViaRegionObserver.java From hbase with Apache License 2.0 | 4 votes |
@Test public void testMutation() throws Exception { Put put = new Put(ROW); put.addColumn(FAMILY, QUALIFIER, VALUE); table.put(put); byte[] value = VALUE; assertResult(table.get(new Get(ROW)), value, value); assertObserverHasExecuted(); Increment inc = new Increment(ROW); inc.addColumn(FAMILY, QUALIFIER, 10L); table.increment(inc); // QUALIFIER -> 10 (put) + 10 (increment) // QUALIFIER_FROM_CP -> 10 (from cp's put) + 10 (from cp's increment) value = Bytes.toBytes(20L); assertResult(table.get(new Get(ROW)), value, value); assertObserverHasExecuted(); Append append = new Append(ROW); append.addColumn(FAMILY, QUALIFIER, APPEND_VALUE); table.append(append); // 10L + "MB" value = ByteBuffer.wrap(new byte[value.length + APPEND_VALUE.length]) .put(value) .put(APPEND_VALUE) .array(); assertResult(table.get(new Get(ROW)), value, value); assertObserverHasExecuted(); Delete delete = new Delete(ROW); delete.addColumns(FAMILY, QUALIFIER); table.delete(delete); assertTrue(Arrays.asList(table.get(new Get(ROW)).rawCells()).toString(), table.get(new Get(ROW)).isEmpty()); assertObserverHasExecuted(); assertTrue(table.checkAndMutate(ROW, FAMILY).qualifier(QUALIFIER).ifNotExists().thenPut(put)); assertObserverHasExecuted(); assertTrue( table.checkAndMutate(ROW, FAMILY).qualifier(QUALIFIER).ifEquals(VALUE).thenDelete(delete)); assertObserverHasExecuted(); assertTrue(table.get(new Get(ROW)).isEmpty()); }