@Test public void testExists() throws TIOError, TException { ThriftHBaseServiceHandler handler = createHandler(); byte[] rowName = Bytes.toBytes("testExists"); ByteBuffer table = wrap(tableAname); TGet get = new TGet(wrap(rowName)); assertFalse(handler.exists(table, get)); List<TColumnValue> columnValues = new ArrayList<>(2); columnValues.add(new TColumnValue(wrap(familyAname), wrap(qualifierAname), wrap(valueAname))); columnValues.add(new TColumnValue(wrap(familyBname), wrap(qualifierBname), wrap(valueBname))); TPut put = new TPut(wrap(rowName), columnValues); put.setColumnValues(columnValues); handler.put(table, put); assertTrue(handler.exists(table, get)); }
case ROW: if (value == null) { unsetRow(); } else { if (value instanceof byte[]) { setRow((byte[])value); } else { setRow((java.nio.ByteBuffer)value); unsetColumnValues(); } else { setColumnValues((java.util.List<TColumnValue>)value); unsetTimestamp(); } else { setTimestamp((java.lang.Long)value); unsetAttributes(); } else { setAttributes((java.util.Map<java.nio.ByteBuffer,java.nio.ByteBuffer>)value); unsetDurability(); } else { setDurability((TDurability)value); unsetCellVisibility(); } else { setCellVisibility((TCellVisibility)value);
@Override public boolean equals(java.lang.Object that) { if (that == null) return false; if (that instanceof TPut) return this.equals((TPut)that); return false; }
@org.apache.thrift.annotation.Nullable public java.lang.Object getFieldValue(_Fields field) { switch (field) { case ROW: return getRow(); case COLUMN_VALUES: return getColumnValues(); case TIMESTAMP: return getTimestamp(); case ATTRIBUTES: return getAttributes(); case DURABILITY: return getDurability(); case CELL_VISIBILITY: return getCellVisibility(); } throw new java.lang.IllegalStateException(); }
@Test public void testGetsWithLabels() throws Exception { ThriftHBaseServiceHandler handler = createHandler(); byte[] rowName = Bytes.toBytes("testPutGet"); ByteBuffer table = wrap(tableAname); List<TColumnValue> columnValues = new ArrayList<>(2); columnValues.add(new TColumnValue(wrap(familyAname), wrap(qualifierAname), wrap(valueAname))); columnValues.add(new TColumnValue(wrap(familyBname), wrap(qualifierBname), wrap(valueBname))); TPut put = new TPut(wrap(rowName), columnValues); put.setColumnValues(columnValues); put.setCellVisibility(new TCellVisibility().setExpression("(" + SECRET + "|" + CONFIDENTIAL + ")" + "&" + "!" + TOPSECRET)); handler.put(table, put); TGet get = new TGet(wrap(rowName)); TAuthorization tauth = new TAuthorization(); List<String> labels = new ArrayList<>(2); labels.add(SECRET); labels.add(PRIVATE); tauth.setLabels(labels); get.setAuthorizations(tauth); TResult result = handler.get(table, get); assertArrayEquals(rowName, result.getRow()); List<TColumnValue> returnedColumnValues = result.getColumnValues(); assertTColumnValuesEqual(columnValues, returnedColumnValues); }
Put out; if (in.isSetTimestamp()) { out = new Put(in.getRow(), in.getTimestamp()); } else { out = new Put(in.getRow()); if (in.isSetDurability()) { out.setDurability(durabilityFromThrift(in.getDurability())); for (TColumnValue columnValue : in.getColumnValues()) { try { if (columnValue.isSetTimestamp()) { if (in.isSetAttributes()) { addAttributes(out,in.getAttributes()); if (in.getCellVisibility() != null) { out.setCellVisibility(new CellVisibility(in.getCellVisibility().getExpression()));
public static TPut putFromHBase(Put in) { TPut out = new TPut(); out.setRow(in.getRow()); if (in.getTimestamp() != HConstants.LATEST_TIMESTAMP) { out.setTimestamp(in.getTimestamp()); out.setDurability(durabilityFromHBase(in.getDurability())); columnValue.setTags(CellUtil.cloneTags(cell)); out.addToColumnValues(columnValue); out.putToAttributes(ByteBuffer.wrap(Bytes.toBytes(attribute.getKey())), ByteBuffer.wrap(attribute.getValue())); TCellVisibility tCellVisibility = new TCellVisibility(); tCellVisibility.setExpression(cellVisibility.getExpression()); out.setCellVisibility(tCellVisibility);
TPut put = new TPut(wrap(rowName), columnValues); put.setColumnValues(columnValues); put.setAttributes(attributes);
case ROW: if (value == null) { unsetRow(); } else { setRow((ByteBuffer)value); unsetColumnValues(); } else { setColumnValues((List<TColumnValue>)value); unsetTimestamp(); } else { setTimestamp((Long)value); unsetWriteToWal(); } else { setWriteToWal((Boolean)value);
columnValues.add(columnValue); for (int i = 0; i < 20; i++) { TPut put = new TPut( wrap(Bytes.toBytes("testGetScannerResults" + pad(i, (byte) 2))), columnValues); if (i == 3) { put.setCellVisibility(new TCellVisibility().setExpression(PUBLIC)); } else { put.setCellVisibility(new TCellVisibility().setExpression("(" + SECRET + "|" + CONFIDENTIAL + ")" + "&" + "!" + TOPSECRET));
TPut put = new TPut(); put.setRow("row1".getBytes()); List<TColumnValue> columnValues = new ArrayList<>(1); columnValues.add(columnValue); put.setColumnValues(columnValues);
public Object getFieldValue(_Fields field) { switch (field) { case ROW: return getRow(); case COLUMN_VALUES: return getColumnValues(); case TIMESTAMP: return Long.valueOf(getTimestamp()); case WRITE_TO_WAL: return Boolean.valueOf(isWriteToWal()); } throw new IllegalStateException(); }
TPut tPut = new TPut(wrap(rowName) , columnValues); tPut.setAttributes(attributes); Put put = putFromThrift(tPut); assertArrayEquals(put.getAttribute("attribute1"), attributeValue);
assertEquals(Durability.FSYNC_WAL, delete.getDurability()); TPut tPut = new TPut(wrap(rowName), columnValues); tPut.setDurability(TDurability.SKIP_WAL); Put put = putFromThrift(tPut); assertEquals(Durability.SKIP_WAL, put.getDurability()); tPut.setDurability(TDurability.ASYNC_WAL); put = putFromThrift(tPut); assertEquals(Durability.ASYNC_WAL, put.getDurability()); tPut.setDurability(TDurability.SYNC_WAL); put = putFromThrift(tPut); assertEquals(Durability.SYNC_WAL, put.getDurability()); tPut.setDurability(TDurability.FSYNC_WAL); put = putFromThrift(tPut); assertEquals(Durability.FSYNC_WAL, put.getDurability());
public TPut deepCopy() { return new TPut(this); }
public byte[] getRow() { setRow(org.apache.thrift.TBaseHelper.rightSize(row)); return row == null ? null : row.array(); }
@Test public void testIncrementWithTagsWithNotMatchLabels() throws Exception { ThriftHBaseServiceHandler handler = createHandler(); byte[] rowName = Bytes.toBytes("testIncrementWithTagsWithNotMatchLabels"); ByteBuffer table = wrap(tableAname); List<TColumnValue> columnValues = new ArrayList<>(1); columnValues.add(new TColumnValue(wrap(familyAname), wrap(qualifierAname), wrap(Bytes.toBytes(1L)))); TPut put = new TPut(wrap(rowName), columnValues); put.setColumnValues(columnValues); put.setCellVisibility(new TCellVisibility().setExpression(PRIVATE)); handler.put(table, put); List<TColumnIncrement> incrementColumns = new ArrayList<>(1); incrementColumns.add(new TColumnIncrement(wrap(familyAname), wrap(qualifierAname))); TIncrement increment = new TIncrement(wrap(rowName), incrementColumns); increment.setCellVisibility(new TCellVisibility().setExpression(SECRET)); handler.increment(table, increment); TGet get = new TGet(wrap(rowName)); TAuthorization tauth = new TAuthorization(); List<String> labels = new ArrayList<>(1); labels.add(PUBLIC); tauth.setLabels(labels); get.setAuthorizations(tauth); TResult result = handler.get(table, get); assertNull(result.getRow()); }
Put out; if (in.isSetTimestamp()) { out = new Put(in.getRow(), in.getTimestamp()); } else { out = new Put(in.getRow()); if (in.isSetDurability()) { out.setDurability(durabilityFromThrift(in.getDurability())); for (TColumnValue columnValue : in.getColumnValues()) { try { if (columnValue.isSetTimestamp()) { if (in.isSetAttributes()) { addAttributes(out,in.getAttributes()); if (in.getCellVisibility() != null) { out.setCellVisibility(new CellVisibility(in.getCellVisibility().getExpression()));
public Object getFieldValue(_Fields field) { switch (field) { case ROW: return getRow(); case COLUMN_VALUES: return getColumnValues(); case TIMESTAMP: return Long.valueOf(getTimestamp()); case ATTRIBUTES: return getAttributes(); case DURABILITY: return getDurability(); case CELL_VISIBILITY: return getCellVisibility(); } throw new IllegalStateException(); }