Java 类org.apache.hadoop.hbase.thrift2.generated.TIncrement 实例源码

项目:ditb    文件:ThriftUtilities.java   
public static Increment incrementFromThrift(TIncrement in) throws IOException {
  Increment out = new Increment(in.getRow());
  for (TColumnIncrement column : in.getColumns()) {
    out.addColumn(column.getFamily(), column.getQualifier(), column.getAmount());
  }

  if (in.isSetAttributes()) {
    addAttributes(out,in.getAttributes());
  }

  if (in.isSetDurability()) {
    out.setDurability(durabilityFromThrift(in.getDurability()));
  }

  if(in.getCellVisibility() != null) {
    out.setCellVisibility(new CellVisibility(in.getCellVisibility().getExpression()));
  }

  return out;
}
项目:ditb    文件:TestThriftHBaseServiceHandler.java   
@Test
public void testIncrement() throws Exception {
  ThriftHBaseServiceHandler handler = createHandler();
  byte[] rowName = "testIncrement".getBytes();
  ByteBuffer table = wrap(tableAname);

  List<TColumnValue> columnValues = new ArrayList<TColumnValue>();
  columnValues.add(new TColumnValue(wrap(familyAname), wrap(qualifierAname),
    wrap(Bytes.toBytes(1L))));
  TPut put = new TPut(wrap(rowName), columnValues);
  put.setColumnValues(columnValues);
  handler.put(table, put);

  List<TColumnIncrement> incrementColumns = new ArrayList<TColumnIncrement>();
  incrementColumns.add(new TColumnIncrement(wrap(familyAname), wrap(qualifierAname)));
  TIncrement increment = new TIncrement(wrap(rowName), incrementColumns);
  handler.increment(table, increment);

  TGet get = new TGet(wrap(rowName));
  TResult result = handler.get(table, get);

  assertArrayEquals(rowName, result.getRow());
  assertEquals(1, result.getColumnValuesSize());
  TColumnValue columnValue = result.getColumnValues().get(0);
  assertArrayEquals(Bytes.toBytes(2L), columnValue.getValue());
}
项目:LCIndex-HBase-0.94.16    文件:TestThriftHBaseServiceHandler.java   
@Test
public void testIncrement() throws Exception {
  ThriftHBaseServiceHandler handler = createHandler();
  byte[] rowName = "testIncrement".getBytes();
  ByteBuffer table = wrap(tableAname);

  List<TColumnValue> columnValues = new ArrayList<TColumnValue>();
  columnValues.add(new TColumnValue(wrap(familyAname), wrap(qualifierAname),
    wrap(Bytes.toBytes(1L))));
  TPut put = new TPut(wrap(rowName), columnValues);
  put.setColumnValues(columnValues);
  handler.put(table, put);

  List<TColumnIncrement> incrementColumns = new ArrayList<TColumnIncrement>();
  incrementColumns.add(new TColumnIncrement(wrap(familyAname), wrap(qualifierAname)));
  TIncrement increment = new TIncrement(wrap(rowName), incrementColumns);
  handler.increment(table, increment);

  TGet get = new TGet(wrap(rowName));
  TResult result = handler.get(table, get);

  assertArrayEquals(rowName, result.getRow());
  assertEquals(1, result.getColumnValuesSize());
  TColumnValue columnValue = result.getColumnValues().get(0);
  assertArrayEquals(Bytes.toBytes(2L), columnValue.getValue());
}
项目:HIndex    文件:ThriftUtilities.java   
public static Increment incrementFromThrift(TIncrement in) throws IOException {
  Increment out = new Increment(in.getRow());
  for (TColumnIncrement column : in.getColumns()) {
    out.addColumn(column.getFamily(), column.getQualifier(), column.getAmount());
  }

  if (in.isSetAttributes()) {
    addAttributes(out,in.getAttributes());
  }

  if (in.isSetDurability()) {
    out.setDurability(durabilityFromThrift(in.getDurability()));
  }

  if(in.getCellVisibility() != null) {
    out.setCellVisibility(new CellVisibility(in.getCellVisibility().getExpression()));
  }

  return out;
}
项目:HIndex    文件:TestThriftHBaseServiceHandler.java   
@Test
public void testIncrement() throws Exception {
  ThriftHBaseServiceHandler handler = createHandler();
  byte[] rowName = "testIncrement".getBytes();
  ByteBuffer table = wrap(tableAname);

  List<TColumnValue> columnValues = new ArrayList<TColumnValue>();
  columnValues.add(new TColumnValue(wrap(familyAname), wrap(qualifierAname),
    wrap(Bytes.toBytes(1L))));
  TPut put = new TPut(wrap(rowName), columnValues);
  put.setColumnValues(columnValues);
  handler.put(table, put);

  List<TColumnIncrement> incrementColumns = new ArrayList<TColumnIncrement>();
  incrementColumns.add(new TColumnIncrement(wrap(familyAname), wrap(qualifierAname)));
  TIncrement increment = new TIncrement(wrap(rowName), incrementColumns);
  handler.increment(table, increment);

  TGet get = new TGet(wrap(rowName));
  TResult result = handler.get(table, get);

  assertArrayEquals(rowName, result.getRow());
  assertEquals(1, result.getColumnValuesSize());
  TColumnValue columnValue = result.getColumnValues().get(0);
  assertArrayEquals(Bytes.toBytes(2L), columnValue.getValue());
}
项目:IRIndex    文件:TestThriftHBaseServiceHandler.java   
@Test
public void testIncrement() throws Exception {
  ThriftHBaseServiceHandler handler = createHandler();
  byte[] rowName = "testIncrement".getBytes();
  ByteBuffer table = wrap(tableAname);

  List<TColumnValue> columnValues = new ArrayList<TColumnValue>();
  columnValues.add(new TColumnValue(wrap(familyAname), wrap(qualifierAname),
    wrap(Bytes.toBytes(1L))));
  TPut put = new TPut(wrap(rowName), columnValues);
  put.setColumnValues(columnValues);
  handler.put(table, put);

  List<TColumnIncrement> incrementColumns = new ArrayList<TColumnIncrement>();
  incrementColumns.add(new TColumnIncrement(wrap(familyAname), wrap(qualifierAname)));
  TIncrement increment = new TIncrement(wrap(rowName), incrementColumns);
  handler.increment(table, increment);

  TGet get = new TGet(wrap(rowName));
  TResult result = handler.get(table, get);

  assertArrayEquals(rowName, result.getRow());
  assertEquals(1, result.getColumnValuesSize());
  TColumnValue columnValue = result.getColumnValues().get(0);
  assertArrayEquals(Bytes.toBytes(2L), columnValue.getValue());
}
项目:hbase    文件:ThriftUtilities.java   
public static Increment incrementFromThrift(TIncrement in) throws IOException {
  Increment out = new Increment(in.getRow());
  for (TColumnIncrement column : in.getColumns()) {
    out.addColumn(column.getFamily(), column.getQualifier(), column.getAmount());
  }

  if (in.isSetAttributes()) {
    addAttributes(out,in.getAttributes());
  }

  if (in.isSetDurability()) {
    out.setDurability(durabilityFromThrift(in.getDurability()));
  }

  if(in.getCellVisibility() != null) {
    out.setCellVisibility(new CellVisibility(in.getCellVisibility().getExpression()));
  }

  return out;
}
项目:hbase    文件:TestThriftHBaseServiceHandlerWithReadOnly.java   
@Test
public void testIncrementWithReadOnly() throws Exception {
  ThriftHBaseServiceHandler handler = createHandler();
  byte[] rowName = Bytes.toBytes("testIncrement");
  ByteBuffer table = wrap(tableAname);

  List<TColumnIncrement> incrementColumns = new ArrayList<>(1);
  incrementColumns.add(new TColumnIncrement(wrap(familyAname), wrap(qualifierAname)));
  TIncrement increment = new TIncrement(wrap(rowName), incrementColumns);

  boolean exceptionCaught = false;
  try {
    handler.increment(table, increment);
  } catch (TIOError e) {
    exceptionCaught = true;
    assertTrue(e.getCause() instanceof DoNotRetryIOException);
    assertEquals("Thrift Server is in Read-only mode.", e.getMessage());
  } finally {
    assertTrue(exceptionCaught);
  }
}
项目:hbase    文件:TestThriftHBaseServiceHandler.java   
@Test
public void testIncrement() throws Exception {
  ThriftHBaseServiceHandler handler = createHandler();
  byte[] rowName = Bytes.toBytes("testIncrement");
  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);
  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);
  handler.increment(table, increment);

  TGet get = new TGet(wrap(rowName));
  TResult result = handler.get(table, get);

  assertArrayEquals(rowName, result.getRow());
  assertEquals(1, result.getColumnValuesSize());
  TColumnValue columnValue = result.getColumnValues().get(0);
  assertArrayEquals(Bytes.toBytes(2L), columnValue.getValue());
}
项目:PyroDB    文件:ThriftUtilities.java   
public static Increment incrementFromThrift(TIncrement in) throws IOException {
  Increment out = new Increment(in.getRow());
  for (TColumnIncrement column : in.getColumns()) {
    out.addColumn(column.getFamily(), column.getQualifier(), column.getAmount());
  }

  if (in.isSetAttributes()) {
    addAttributes(out,in.getAttributes());
  }

  if (in.isSetDurability()) {
    out.setDurability(durabilityFromThrift(in.getDurability()));
  }

  if(in.getCellVisibility() != null) {
    out.setCellVisibility(new CellVisibility(in.getCellVisibility().getExpression()));
  }

  return out;
}
项目:PyroDB    文件:TestThriftHBaseServiceHandler.java   
@Test
public void testIncrement() throws Exception {
  ThriftHBaseServiceHandler handler = createHandler();
  byte[] rowName = "testIncrement".getBytes();
  ByteBuffer table = wrap(tableAname);

  List<TColumnValue> columnValues = new ArrayList<TColumnValue>();
  columnValues.add(new TColumnValue(wrap(familyAname), wrap(qualifierAname),
    wrap(Bytes.toBytes(1L))));
  TPut put = new TPut(wrap(rowName), columnValues);
  put.setColumnValues(columnValues);
  handler.put(table, put);

  List<TColumnIncrement> incrementColumns = new ArrayList<TColumnIncrement>();
  incrementColumns.add(new TColumnIncrement(wrap(familyAname), wrap(qualifierAname)));
  TIncrement increment = new TIncrement(wrap(rowName), incrementColumns);
  handler.increment(table, increment);

  TGet get = new TGet(wrap(rowName));
  TResult result = handler.get(table, get);

  assertArrayEquals(rowName, result.getRow());
  assertEquals(1, result.getColumnValuesSize());
  TColumnValue columnValue = result.getColumnValues().get(0);
  assertArrayEquals(Bytes.toBytes(2L), columnValue.getValue());
}
项目:HBase-Research    文件:TestThriftHBaseServiceHandler.java   
@Test
public void testIncrement() throws Exception {
  ThriftHBaseServiceHandler handler = createHandler();
  byte[] rowName = "testIncrement".getBytes();
  ByteBuffer table = ByteBuffer.wrap(tableAname);

  List<TColumnValue> columnValues = new ArrayList<TColumnValue>();
  columnValues.add(new TColumnValue(ByteBuffer.wrap(familyAname), ByteBuffer.wrap(qualifierAname), ByteBuffer
      .wrap(Bytes.toBytes(1L))));
  TPut put = new TPut(ByteBuffer.wrap(rowName), columnValues);
  put.setColumnValues(columnValues);
  handler.put(table, put);

  List<TColumnIncrement> incrementColumns = new ArrayList<TColumnIncrement>();
  incrementColumns.add(new TColumnIncrement(ByteBuffer.wrap(familyAname), ByteBuffer.wrap(qualifierAname)));
  TIncrement increment = new TIncrement(ByteBuffer.wrap(rowName), incrementColumns);
  handler.increment(table, increment);

  TGet get = new TGet(ByteBuffer.wrap(rowName));
  TResult result = handler.get(table, get);

  assertArrayEquals(rowName, result.getRow());
  assertEquals(1, result.getColumnValuesSize());
  TColumnValue columnValue = result.getColumnValues().get(0);
  assertArrayEquals(Bytes.toBytes(2L), columnValue.getValue());
}
项目:hbase-0.94.8-qod    文件:TestThriftHBaseServiceHandler.java   
@Test
public void testIncrement() throws Exception {
  ThriftHBaseServiceHandler handler = createHandler();
  byte[] rowName = "testIncrement".getBytes();
  ByteBuffer table = ByteBuffer.wrap(tableAname);

  List<TColumnValue> columnValues = new ArrayList<TColumnValue>();
  columnValues.add(new TColumnValue(ByteBuffer.wrap(familyAname), ByteBuffer.wrap(qualifierAname), ByteBuffer
      .wrap(Bytes.toBytes(1L))));
  TPut put = new TPut(ByteBuffer.wrap(rowName), columnValues);
  put.setColumnValues(columnValues);
  handler.put(table, put);

  List<TColumnIncrement> incrementColumns = new ArrayList<TColumnIncrement>();
  incrementColumns.add(new TColumnIncrement(ByteBuffer.wrap(familyAname), ByteBuffer.wrap(qualifierAname)));
  TIncrement increment = new TIncrement(ByteBuffer.wrap(rowName), incrementColumns);
  handler.increment(table, increment);

  TGet get = new TGet(ByteBuffer.wrap(rowName));
  TResult result = handler.get(table, get);

  assertArrayEquals(rowName, result.getRow());
  assertEquals(1, result.getColumnValuesSize());
  TColumnValue columnValue = result.getColumnValues().get(0);
  assertArrayEquals(Bytes.toBytes(2L), columnValue.getValue());
}
项目:hbase-0.94.8-qod    文件:TestThriftHBaseServiceHandler.java   
@Test
public void testIncrement() throws Exception {
  ThriftHBaseServiceHandler handler = createHandler();
  byte[] rowName = "testIncrement".getBytes();
  ByteBuffer table = ByteBuffer.wrap(tableAname);

  List<TColumnValue> columnValues = new ArrayList<TColumnValue>();
  columnValues.add(new TColumnValue(ByteBuffer.wrap(familyAname), ByteBuffer.wrap(qualifierAname), ByteBuffer
      .wrap(Bytes.toBytes(1L))));
  TPut put = new TPut(ByteBuffer.wrap(rowName), columnValues);
  put.setColumnValues(columnValues);
  handler.put(table, put);

  List<TColumnIncrement> incrementColumns = new ArrayList<TColumnIncrement>();
  incrementColumns.add(new TColumnIncrement(ByteBuffer.wrap(familyAname), ByteBuffer.wrap(qualifierAname)));
  TIncrement increment = new TIncrement(ByteBuffer.wrap(rowName), incrementColumns);
  handler.increment(table, increment);

  TGet get = new TGet(ByteBuffer.wrap(rowName));
  TResult result = handler.get(table, get);

  assertArrayEquals(rowName, result.getRow());
  assertEquals(1, result.getColumnValuesSize());
  TColumnValue columnValue = result.getColumnValues().get(0);
  assertArrayEquals(Bytes.toBytes(2L), columnValue.getValue());
}
项目:DominoHBase    文件:TestThriftHBaseServiceHandler.java   
@Test
public void testIncrement() throws Exception {
  ThriftHBaseServiceHandler handler = createHandler();
  byte[] rowName = "testIncrement".getBytes();
  ByteBuffer table = ByteBuffer.wrap(tableAname);

  List<TColumnValue> columnValues = new ArrayList<TColumnValue>();
  columnValues.add(new TColumnValue(ByteBuffer.wrap(familyAname), ByteBuffer.wrap(qualifierAname), ByteBuffer
      .wrap(Bytes.toBytes(1L))));
  TPut put = new TPut(ByteBuffer.wrap(rowName), columnValues);
  put.setColumnValues(columnValues);
  handler.put(table, put);

  List<TColumnIncrement> incrementColumns = new ArrayList<TColumnIncrement>();
  incrementColumns.add(new TColumnIncrement(ByteBuffer.wrap(familyAname), ByteBuffer.wrap(qualifierAname)));
  TIncrement increment = new TIncrement(ByteBuffer.wrap(rowName), incrementColumns);
  handler.increment(table, increment);

  TGet get = new TGet(ByteBuffer.wrap(rowName));
  TResult result = handler.get(table, get);

  assertArrayEquals(rowName, result.getRow());
  assertEquals(1, result.getColumnValuesSize());
  TColumnValue columnValue = result.getColumnValues().get(0);
  assertArrayEquals(Bytes.toBytes(2L), columnValue.getValue());
}
项目:hindex    文件:TestThriftHBaseServiceHandler.java   
@Test
public void testIncrement() throws Exception {
  ThriftHBaseServiceHandler handler = createHandler();
  byte[] rowName = "testIncrement".getBytes();
  ByteBuffer table = ByteBuffer.wrap(tableAname);

  List<TColumnValue> columnValues = new ArrayList<TColumnValue>();
  columnValues.add(new TColumnValue(ByteBuffer.wrap(familyAname), ByteBuffer.wrap(qualifierAname), ByteBuffer
      .wrap(Bytes.toBytes(1L))));
  TPut put = new TPut(ByteBuffer.wrap(rowName), columnValues);
  put.setColumnValues(columnValues);
  handler.put(table, put);

  List<TColumnIncrement> incrementColumns = new ArrayList<TColumnIncrement>();
  incrementColumns.add(new TColumnIncrement(ByteBuffer.wrap(familyAname), ByteBuffer.wrap(qualifierAname)));
  TIncrement increment = new TIncrement(ByteBuffer.wrap(rowName), incrementColumns);
  handler.increment(table, increment);

  TGet get = new TGet(ByteBuffer.wrap(rowName));
  TResult result = handler.get(table, get);

  assertArrayEquals(rowName, result.getRow());
  assertEquals(1, result.getColumnValuesSize());
  TColumnValue columnValue = result.getColumnValues().get(0);
  assertArrayEquals(Bytes.toBytes(2L), columnValue.getValue());
}
项目:ditb    文件:TestThriftHBaseServiceHandlerWithLabels.java   
@Test
public void testIncrementWithTags() throws Exception {
  ThriftHBaseServiceHandler handler = createHandler();
  byte[] rowName = "testIncrementWithTags".getBytes();
  ByteBuffer table = wrap(tableAname);

  List<TColumnValue> columnValues = new ArrayList<TColumnValue>();
  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<TColumnIncrement>();
  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<String>();
  labels.add(SECRET);
  tauth.setLabels(labels);
  get.setAuthorizations(tauth);
  TResult result = handler.get(table, get);

  assertArrayEquals(rowName, result.getRow());
  assertEquals(1, result.getColumnValuesSize());
  TColumnValue columnValue = result.getColumnValues().get(0);
  assertArrayEquals(Bytes.toBytes(2L), columnValue.getValue());
}
项目:ditb    文件:TestThriftHBaseServiceHandlerWithLabels.java   
@Test
public void testIncrementWithTagsWithNotMatchLabels() throws Exception {
  ThriftHBaseServiceHandler handler = createHandler();
  byte[] rowName = "testIncrementWithTagsWithNotMatchLabels".getBytes();
  ByteBuffer table = wrap(tableAname);

  List<TColumnValue> columnValues = new ArrayList<TColumnValue>();
  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<TColumnIncrement>();
  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<String>();
  labels.add(PUBLIC);
  tauth.setLabels(labels);
  get.setAuthorizations(tauth);
  TResult result = handler.get(table, get);
  assertNull(result.getRow());
}
项目:HIndex    文件:TestThriftHBaseServiceHandlerWithLabels.java   
@Test
public void testIncrementWithTags() throws Exception {
  ThriftHBaseServiceHandler handler = createHandler();
  byte[] rowName = "testIncrementWithTags".getBytes();
  ByteBuffer table = wrap(tableAname);

  List<TColumnValue> columnValues = new ArrayList<TColumnValue>();
  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<TColumnIncrement>();
  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<String>();
  labels.add(SECRET);
  tauth.setLabels(labels);
  get.setAuthorizations(tauth);
  TResult result = handler.get(table, get);

  assertArrayEquals(rowName, result.getRow());
  assertEquals(1, result.getColumnValuesSize());
  TColumnValue columnValue = result.getColumnValues().get(0);
  assertArrayEquals(Bytes.toBytes(2L), columnValue.getValue());
}
项目:HIndex    文件:TestThriftHBaseServiceHandlerWithLabels.java   
@Test
public void testIncrementWithTagsWithNotMatchLabels() throws Exception {
  ThriftHBaseServiceHandler handler = createHandler();
  byte[] rowName = "testIncrementWithTagsWithNotMatchLabels".getBytes();
  ByteBuffer table = wrap(tableAname);

  List<TColumnValue> columnValues = new ArrayList<TColumnValue>();
  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<TColumnIncrement>();
  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<String>();
  labels.add(PUBLIC);
  tauth.setLabels(labels);
  get.setAuthorizations(tauth);
  TResult result = handler.get(table, get);
  assertNull(result.getRow());
}
项目:hbase    文件:TestThriftHBaseServiceHandlerWithLabels.java   
@Test
public void testIncrementWithTags() throws Exception {
  ThriftHBaseServiceHandler handler = createHandler();
  byte[] rowName = Bytes.toBytes("testIncrementWithTags");
  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(SECRET);
  tauth.setLabels(labels);
  get.setAuthorizations(tauth);
  TResult result = handler.get(table, get);

  assertArrayEquals(rowName, result.getRow());
  assertEquals(1, result.getColumnValuesSize());
  TColumnValue columnValue = result.getColumnValues().get(0);
  assertArrayEquals(Bytes.toBytes(2L), columnValue.getValue());
}
项目:hbase    文件:TestThriftHBaseServiceHandlerWithLabels.java   
@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());
}
项目:PyroDB    文件:TestThriftHBaseServiceHandlerWithLabels.java   
@Test
public void testIncrementWithTags() throws Exception {
  ThriftHBaseServiceHandler handler = createHandler();
  byte[] rowName = "testIncrementWithTags".getBytes();
  ByteBuffer table = wrap(tableAname);

  List<TColumnValue> columnValues = new ArrayList<TColumnValue>();
  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<TColumnIncrement>();
  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<String>();
  labels.add(SECRET);
  tauth.setLabels(labels);
  get.setAuthorizations(tauth);
  TResult result = handler.get(table, get);

  assertArrayEquals(rowName, result.getRow());
  assertEquals(1, result.getColumnValuesSize());
  TColumnValue columnValue = result.getColumnValues().get(0);
  assertArrayEquals(Bytes.toBytes(2L), columnValue.getValue());
}
项目:PyroDB    文件:TestThriftHBaseServiceHandlerWithLabels.java   
@Test
public void testIncrementWithTagsWithNotMatchLabels() throws Exception {
  ThriftHBaseServiceHandler handler = createHandler();
  byte[] rowName = "testIncrementWithTagsWithNotMatchLabels".getBytes();
  ByteBuffer table = wrap(tableAname);

  List<TColumnValue> columnValues = new ArrayList<TColumnValue>();
  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<TColumnIncrement>();
  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<String>();
  labels.add(PUBLIC);
  tauth.setLabels(labels);
  get.setAuthorizations(tauth);
  TResult result = handler.get(table, get);
  assertNull(result.getRow());
}
项目:ditb    文件:TestThriftHBaseServiceHandler.java   
/**
 * Create TPut, TDelete , TIncrement objects, set durability then call ThriftUtility
 * functions to get Put , Delete and Increment respectively. Use getDurability to make sure
 * the returned objects have the appropriate durability setting.
 *
 * @throws Exception
 */
@Test
public void testDurability() throws Exception {
  byte[] rowName = "testDurability".getBytes();
  List<TColumnValue> columnValues = new ArrayList<TColumnValue>();
  columnValues.add(new TColumnValue(wrap(familyAname), wrap(qualifierAname), wrap(valueAname)));

  List<TColumnIncrement> incrementColumns = new ArrayList<TColumnIncrement>();
  incrementColumns.add(new TColumnIncrement(wrap(familyAname), wrap(qualifierAname)));

  TDelete tDelete = new TDelete(wrap(rowName));
  tDelete.setDurability(TDurability.SKIP_WAL);
  Delete delete = deleteFromThrift(tDelete);
  assertEquals(delete.getDurability(), Durability.SKIP_WAL);

  tDelete.setDurability(TDurability.ASYNC_WAL);
  delete = deleteFromThrift(tDelete);
  assertEquals(delete.getDurability(), Durability.ASYNC_WAL);

  tDelete.setDurability(TDurability.SYNC_WAL);
  delete = deleteFromThrift(tDelete);
  assertEquals(delete.getDurability(), Durability.SYNC_WAL);

  tDelete.setDurability(TDurability.FSYNC_WAL);
  delete = deleteFromThrift(tDelete);
  assertEquals(delete.getDurability(), Durability.FSYNC_WAL);

  TPut tPut = new TPut(wrap(rowName), columnValues);
  tPut.setDurability(TDurability.SKIP_WAL);
  Put put = putFromThrift(tPut);
  assertEquals(put.getDurability(), Durability.SKIP_WAL);

  tPut.setDurability(TDurability.ASYNC_WAL);
  put = putFromThrift(tPut);
  assertEquals(put.getDurability(), Durability.ASYNC_WAL);

  tPut.setDurability(TDurability.SYNC_WAL);
  put = putFromThrift(tPut);
  assertEquals(put.getDurability(), Durability.SYNC_WAL);

  tPut.setDurability(TDurability.FSYNC_WAL);
  put = putFromThrift(tPut);
  assertEquals(put.getDurability(), Durability.FSYNC_WAL);

  TIncrement tIncrement = new TIncrement(wrap(rowName), incrementColumns);

  tIncrement.setDurability(TDurability.SKIP_WAL);
  Increment increment = incrementFromThrift(tIncrement);
  assertEquals(increment.getDurability(), Durability.SKIP_WAL);

  tIncrement.setDurability(TDurability.ASYNC_WAL);
  increment = incrementFromThrift(tIncrement);
  assertEquals(increment.getDurability(), Durability.ASYNC_WAL);

  tIncrement.setDurability(TDurability.SYNC_WAL);
  increment = incrementFromThrift(tIncrement);
  assertEquals(increment.getDurability(), Durability.SYNC_WAL);

  tIncrement.setDurability(TDurability.FSYNC_WAL);
  increment = incrementFromThrift(tIncrement);
  assertEquals(increment.getDurability(), Durability.FSYNC_WAL);
}
项目:HIndex    文件:TestThriftHBaseServiceHandler.java   
/**
 * Create TPut, TDelete , TIncrement objects, set durability then call ThriftUtility
 * functions to get Put , Delete and Increment respectively. Use getDurability to make sure
 * the returned objects have the appropriate durability setting.
 *
 * @throws Exception
 */
@Test
public void testDurability() throws Exception {
  byte[] rowName = "testDurability".getBytes();
  List<TColumnValue> columnValues = new ArrayList<TColumnValue>();
  columnValues.add(new TColumnValue(wrap(familyAname), wrap(qualifierAname), wrap(valueAname)));

  List<TColumnIncrement> incrementColumns = new ArrayList<TColumnIncrement>();
  incrementColumns.add(new TColumnIncrement(wrap(familyAname), wrap(qualifierAname)));

  TDelete tDelete = new TDelete(wrap(rowName));
  tDelete.setDurability(TDurability.SKIP_WAL);
  Delete delete = deleteFromThrift(tDelete);
  assertEquals(delete.getDurability(), Durability.SKIP_WAL);

  tDelete.setDurability(TDurability.ASYNC_WAL);
  delete = deleteFromThrift(tDelete);
  assertEquals(delete.getDurability(), Durability.ASYNC_WAL);

  tDelete.setDurability(TDurability.SYNC_WAL);
  delete = deleteFromThrift(tDelete);
  assertEquals(delete.getDurability(), Durability.SYNC_WAL);

  tDelete.setDurability(TDurability.FSYNC_WAL);
  delete = deleteFromThrift(tDelete);
  assertEquals(delete.getDurability(), Durability.FSYNC_WAL);

  TPut tPut = new TPut(wrap(rowName), columnValues);
  tPut.setDurability(TDurability.SKIP_WAL);
  Put put = putFromThrift(tPut);
  assertEquals(put.getDurability(), Durability.SKIP_WAL);

  tPut.setDurability(TDurability.ASYNC_WAL);
  put = putFromThrift(tPut);
  assertEquals(put.getDurability(), Durability.ASYNC_WAL);

  tPut.setDurability(TDurability.SYNC_WAL);
  put = putFromThrift(tPut);
  assertEquals(put.getDurability(), Durability.SYNC_WAL);

  tPut.setDurability(TDurability.FSYNC_WAL);
  put = putFromThrift(tPut);
  assertEquals(put.getDurability(), Durability.FSYNC_WAL);

  TIncrement tIncrement = new TIncrement(wrap(rowName), incrementColumns);

  tIncrement.setDurability(TDurability.SKIP_WAL);
  Increment increment = incrementFromThrift(tIncrement);
  assertEquals(increment.getDurability(), Durability.SKIP_WAL);

  tIncrement.setDurability(TDurability.ASYNC_WAL);
  increment = incrementFromThrift(tIncrement);
  assertEquals(increment.getDurability(), Durability.ASYNC_WAL);

  tIncrement.setDurability(TDurability.SYNC_WAL);
  increment = incrementFromThrift(tIncrement);
  assertEquals(increment.getDurability(), Durability.SYNC_WAL);

  tIncrement.setDurability(TDurability.FSYNC_WAL);
  increment = incrementFromThrift(tIncrement);
  assertEquals(increment.getDurability(), Durability.FSYNC_WAL);
}
项目:hbase    文件:TestThriftHBaseServiceHandler.java   
/**
 * Create TPut, TDelete , TIncrement objects, set durability then call ThriftUtility
 * functions to get Put , Delete and Increment respectively. Use getDurability to make sure
 * the returned objects have the appropriate durability setting.
 */
@Test
public void testDurability() throws Exception {
  byte[] rowName = Bytes.toBytes("testDurability");
  List<TColumnValue> columnValues = new ArrayList<>(1);
  columnValues.add(new TColumnValue(wrap(familyAname), wrap(qualifierAname), wrap(valueAname)));

  List<TColumnIncrement> incrementColumns = new ArrayList<>(1);
  incrementColumns.add(new TColumnIncrement(wrap(familyAname), wrap(qualifierAname)));

  TDelete tDelete = new TDelete(wrap(rowName));
  tDelete.setDurability(TDurability.SKIP_WAL);
  Delete delete = deleteFromThrift(tDelete);
  assertEquals(Durability.SKIP_WAL, delete.getDurability());

  tDelete.setDurability(TDurability.ASYNC_WAL);
  delete = deleteFromThrift(tDelete);
  assertEquals(Durability.ASYNC_WAL, delete.getDurability());

  tDelete.setDurability(TDurability.SYNC_WAL);
  delete = deleteFromThrift(tDelete);
  assertEquals(Durability.SYNC_WAL, delete.getDurability());

  tDelete.setDurability(TDurability.FSYNC_WAL);
  delete = deleteFromThrift(tDelete);
  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());

  TIncrement tIncrement = new TIncrement(wrap(rowName), incrementColumns);

  tIncrement.setDurability(TDurability.SKIP_WAL);
  Increment increment = incrementFromThrift(tIncrement);
  assertEquals(Durability.SKIP_WAL, increment.getDurability());

  tIncrement.setDurability(TDurability.ASYNC_WAL);
  increment = incrementFromThrift(tIncrement);
  assertEquals(Durability.ASYNC_WAL, increment.getDurability());

  tIncrement.setDurability(TDurability.SYNC_WAL);
  increment = incrementFromThrift(tIncrement);
  assertEquals(Durability.SYNC_WAL, increment.getDurability());

  tIncrement.setDurability(TDurability.FSYNC_WAL);
  increment = incrementFromThrift(tIncrement);
  assertEquals(Durability.FSYNC_WAL, increment.getDurability());
}
项目:PyroDB    文件:TestThriftHBaseServiceHandler.java   
/**
 * Create TPut, TDelete , TIncrement objects, set durability then call ThriftUtility
 * functions to get Put , Delete and Increment respectively. Use getDurability to make sure
 * the returned objects have the appropriate durability setting.
 *
 * @throws Exception
 */
@Test
public void testDurability() throws Exception {
  byte[] rowName = "testDurability".getBytes();
  List<TColumnValue> columnValues = new ArrayList<TColumnValue>();
  columnValues.add(new TColumnValue(wrap(familyAname), wrap(qualifierAname), wrap(valueAname)));

  List<TColumnIncrement> incrementColumns = new ArrayList<TColumnIncrement>();
  incrementColumns.add(new TColumnIncrement(wrap(familyAname), wrap(qualifierAname)));

  TDelete tDelete = new TDelete(wrap(rowName));
  tDelete.setDurability(TDurability.SKIP_WAL);
  Delete delete = deleteFromThrift(tDelete);
  assertEquals(delete.getDurability(), Durability.SKIP_WAL);

  tDelete.setDurability(TDurability.ASYNC_WAL);
  delete = deleteFromThrift(tDelete);
  assertEquals(delete.getDurability(), Durability.ASYNC_WAL);

  tDelete.setDurability(TDurability.SYNC_WAL);
  delete = deleteFromThrift(tDelete);
  assertEquals(delete.getDurability(), Durability.SYNC_WAL);

  tDelete.setDurability(TDurability.FSYNC_WAL);
  delete = deleteFromThrift(tDelete);
  assertEquals(delete.getDurability(), Durability.FSYNC_WAL);

  TPut tPut = new TPut(wrap(rowName), columnValues);
  tPut.setDurability(TDurability.SKIP_WAL);
  Put put = putFromThrift(tPut);
  assertEquals(put.getDurability(), Durability.SKIP_WAL);

  tPut.setDurability(TDurability.ASYNC_WAL);
  put = putFromThrift(tPut);
  assertEquals(put.getDurability(), Durability.ASYNC_WAL);

  tPut.setDurability(TDurability.SYNC_WAL);
  put = putFromThrift(tPut);
  assertEquals(put.getDurability(), Durability.SYNC_WAL);

  tPut.setDurability(TDurability.FSYNC_WAL);
  put = putFromThrift(tPut);
  assertEquals(put.getDurability(), Durability.FSYNC_WAL);

  TIncrement tIncrement = new TIncrement(wrap(rowName), incrementColumns);

  tIncrement.setDurability(TDurability.SKIP_WAL);
  Increment increment = incrementFromThrift(tIncrement);
  assertEquals(increment.getDurability(), Durability.SKIP_WAL);

  tIncrement.setDurability(TDurability.ASYNC_WAL);
  increment = incrementFromThrift(tIncrement);
  assertEquals(increment.getDurability(), Durability.ASYNC_WAL);

  tIncrement.setDurability(TDurability.SYNC_WAL);
  increment = incrementFromThrift(tIncrement);
  assertEquals(increment.getDurability(), Durability.SYNC_WAL);

  tIncrement.setDurability(TDurability.FSYNC_WAL);
  increment = incrementFromThrift(tIncrement);
  assertEquals(increment.getDurability(), Durability.FSYNC_WAL);
}