当前位置: 首页>>代码示例>>Java>>正文


Java TPut类代码示例

本文整理汇总了Java中org.apache.hadoop.hbase.thrift2.generated.TPut的典型用法代码示例。如果您正苦于以下问题:Java TPut类的具体用法?Java TPut怎么用?Java TPut使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


TPut类属于org.apache.hadoop.hbase.thrift2.generated包,在下文中一共展示了TPut类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testExists

import org.apache.hadoop.hbase.thrift2.generated.TPut; //导入依赖的package包/类
@Test
public void testExists() throws TIOError, TException {
  ThriftHBaseServiceHandler handler = createHandler();
  byte[] rowName = "testExists".getBytes();
  ByteBuffer table = wrap(tableAname);

  TGet get = new TGet(wrap(rowName));
  assertFalse(handler.exists(table, get));

  List<TColumnValue> columnValues = new ArrayList<TColumnValue>();
  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));
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:20,代码来源:TestThriftHBaseServiceHandler.java

示例2: testPutGet

import org.apache.hadoop.hbase.thrift2.generated.TPut; //导入依赖的package包/类
@Test
public void testPutGet() throws Exception {
  ThriftHBaseServiceHandler handler = createHandler();
  byte[] rowName = "testPutGet".getBytes();
  ByteBuffer table = wrap(tableAname);

  List<TColumnValue> columnValues = new ArrayList<TColumnValue>();
  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);

  TGet get = new TGet(wrap(rowName));

  TResult result = handler.get(table, get);
  assertArrayEquals(rowName, result.getRow());
  List<TColumnValue> returnedColumnValues = result.getColumnValues();
  assertTColumnValuesEqual(columnValues, returnedColumnValues);
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:23,代码来源:TestThriftHBaseServiceHandler.java

示例3: testIncrement

import org.apache.hadoop.hbase.thrift2.generated.TPut; //导入依赖的package包/类
@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());
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:27,代码来源:TestThriftHBaseServiceHandler.java

示例4: testAppend

import org.apache.hadoop.hbase.thrift2.generated.TPut; //导入依赖的package包/类
@Test
public void testAppend() throws Exception {
  ThriftHBaseServiceHandler handler = createHandler();
  byte[] rowName = "testAppend".getBytes();
  ByteBuffer table = wrap(tableAname);
  byte[] v1 = Bytes.toBytes("42");
  byte[] v2 = Bytes.toBytes("23");
  List<TColumnValue> columnValues = new ArrayList<TColumnValue>();
  columnValues.add(new TColumnValue(wrap(familyAname), wrap(qualifierAname), wrap(v1)));
  TPut put = new TPut(wrap(rowName), columnValues);
  put.setColumnValues(columnValues);
  handler.put(table, put);

  List<TColumnValue> appendColumns = new ArrayList<TColumnValue>();
  appendColumns.add(new TColumnValue(wrap(familyAname), wrap(qualifierAname), wrap(v2)));
  TAppend append = new TAppend(wrap(rowName), appendColumns);
  handler.append(table, append);

  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.add(v1, v2), columnValue.getValue());
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:27,代码来源:TestThriftHBaseServiceHandler.java

示例5: testMetrics

import org.apache.hadoop.hbase.thrift2.generated.TPut; //导入依赖的package包/类
@Test
public void testMetrics() throws Exception {
  Configuration conf = UTIL.getConfiguration();
  ThriftMetrics metrics = getMetrics(conf);
  ThriftHBaseServiceHandler hbaseHandler = createHandler();
  THBaseService.Iface handler =
      ThriftHBaseServiceHandler.newInstance(hbaseHandler, metrics);
  byte[] rowName = "testMetrics".getBytes();
  ByteBuffer table = wrap(tableAname);

  TGet get = new TGet(wrap(rowName));
  assertFalse(handler.exists(table, get));

  List<TColumnValue> columnValues = new ArrayList<TColumnValue>();
  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));
  metricsHelper.assertCounter("put_num_ops", 1, metrics.getSource());
  metricsHelper.assertCounter( "exists_num_ops", 2, metrics.getSource());
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:26,代码来源:TestThriftHBaseServiceHandler.java

示例6: testMetrics

import org.apache.hadoop.hbase.thrift2.generated.TPut; //导入依赖的package包/类
@Test
public void testMetrics() throws Exception {
  Configuration conf = UTIL.getConfiguration();
  ThriftMetrics metrics = getMetrics(conf);
  THBaseService.Iface handler =
      ThriftHBaseServiceHandler.newInstance(conf, metrics);
  byte[] rowName = "testMetrics".getBytes();
  ByteBuffer table = wrap(tableAname);

  TGet get = new TGet(wrap(rowName));
  assertFalse(handler.exists(table, get));

  List<TColumnValue> columnValues = new ArrayList<TColumnValue>();
  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));
  logMetrics(metrics);
  verifyMetrics(metrics, "put_num_ops", 1);
  verifyMetrics(metrics, "exists_num_ops", 2);
}
 
开发者ID:fengchen8086,项目名称:LCIndex-HBase-0.94.16,代码行数:26,代码来源:TestThriftHBaseServiceHandler.java

示例7: testMetrics

import org.apache.hadoop.hbase.thrift2.generated.TPut; //导入依赖的package包/类
@Test
public void testMetrics() throws Exception {
  Configuration conf = UTIL.getConfiguration();
  ThriftMetrics metrics = getMetrics(conf);
  THBaseService.Iface handler =
      ThriftHBaseServiceHandler.newInstance(conf, metrics);
  byte[] rowName = "testMetrics".getBytes();
  ByteBuffer table = wrap(tableAname);

  TGet get = new TGet(wrap(rowName));
  assertFalse(handler.exists(table, get));

  List<TColumnValue> columnValues = new ArrayList<TColumnValue>();
  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));
  metricsHelper.assertCounter("put_num_ops", 1, metrics.getSource());
  metricsHelper.assertCounter( "exists_num_ops", 2, metrics.getSource());
}
 
开发者ID:tenggyut,项目名称:HIndex,代码行数:25,代码来源:TestThriftHBaseServiceHandler.java

示例8: checkAndPut

import org.apache.hadoop.hbase.thrift2.generated.TPut; //导入依赖的package包/类
@Override
public boolean checkAndPut(ByteBuffer table, ByteBuffer row, ByteBuffer family,
    ByteBuffer qualifier, ByteBuffer value, TPut put) throws TIOError, TException {
  checkReadOnlyMode();
  Table htable = getTable(table);
  try {
    Table.CheckAndMutateBuilder builder = htable.checkAndMutate(byteBufferToByteArray(row),
        byteBufferToByteArray(family)).qualifier(byteBufferToByteArray(qualifier));
    if (value == null) {
      return builder.ifNotExists().thenPut(putFromThrift(put));
    } else {
      return builder.ifEquals(byteBufferToByteArray(value)).thenPut(putFromThrift(put));
    }
  } catch (IOException e) {
    throw getTIOError(e);
  } finally {
    closeTable(htable);
  }
}
 
开发者ID:apache,项目名称:hbase,代码行数:20,代码来源:ThriftHBaseServiceHandler.java

示例9: testPutWithReadOnly

import org.apache.hadoop.hbase.thrift2.generated.TPut; //导入依赖的package包/类
@Test
public void testPutWithReadOnly() throws Exception {
  ThriftHBaseServiceHandler handler = createHandler();
  ByteBuffer table = wrap(tableAname);
  byte[] rowName = Bytes.toBytes("testPut");

  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);

  boolean exceptionCaught = false;
  try {
    handler.put(table, put);
  } catch (TIOError e) {
    exceptionCaught = true;
    assertTrue(e.getCause() instanceof DoNotRetryIOException);
    assertEquals("Thrift Server is in Read-only mode.", e.getMessage());
  } finally {
    assertTrue(exceptionCaught);
  }
}
 
开发者ID:apache,项目名称:hbase,代码行数:23,代码来源:TestThriftHBaseServiceHandlerWithReadOnly.java

示例10: testPutMultipleWithReadOnly

import org.apache.hadoop.hbase.thrift2.generated.TPut; //导入依赖的package包/类
@Test
public void testPutMultipleWithReadOnly() throws Exception {
  ThriftHBaseServiceHandler handler = createHandler();
  ByteBuffer table = wrap(tableAname);
  byte[] rowName1 = Bytes.toBytes("testPutMultiple1");
  byte[] rowName2 = Bytes.toBytes("testPutMultiple2");

  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)));
  List<TPut> puts = new ArrayList<>(2);
  puts.add(new TPut(wrap(rowName1), columnValues));
  puts.add(new TPut(wrap(rowName2), columnValues));

  boolean exceptionCaught = false;
  try {
    handler.putMultiple(table, puts);
  } catch (TIOError e) {
    exceptionCaught = true;
    assertTrue(e.getCause() instanceof DoNotRetryIOException);
    assertEquals("Thrift Server is in Read-only mode.", e.getMessage());
  } finally {
    assertTrue(exceptionCaught);
  }
}
 
开发者ID:apache,项目名称:hbase,代码行数:26,代码来源:TestThriftHBaseServiceHandlerWithReadOnly.java

示例11: testExists

import org.apache.hadoop.hbase.thrift2.generated.TPut; //导入依赖的package包/类
@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));
}
 
开发者ID:apache,项目名称:hbase,代码行数:20,代码来源:TestThriftHBaseServiceHandler.java

示例12: testPutGet

import org.apache.hadoop.hbase.thrift2.generated.TPut; //导入依赖的package包/类
@Test
public void testPutGet() 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);

  handler.put(table, put);

  TGet get = new TGet(wrap(rowName));

  TResult result = handler.get(table, get);
  assertArrayEquals(rowName, result.getRow());
  List<TColumnValue> returnedColumnValues = result.getColumnValues();
  assertTColumnValuesEqual(columnValues, returnedColumnValues);
}
 
开发者ID:apache,项目名称:hbase,代码行数:23,代码来源:TestThriftHBaseServiceHandler.java

示例13: testIncrement

import org.apache.hadoop.hbase.thrift2.generated.TPut; //导入依赖的package包/类
@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());
}
 
开发者ID:apache,项目名称:hbase,代码行数:27,代码来源:TestThriftHBaseServiceHandler.java

示例14: testAppend

import org.apache.hadoop.hbase.thrift2.generated.TPut; //导入依赖的package包/类
@Test
public void testAppend() throws Exception {
  ThriftHBaseServiceHandler handler = createHandler();
  byte[] rowName = Bytes.toBytes("testAppend");
  ByteBuffer table = wrap(tableAname);
  byte[] v1 = Bytes.toBytes("42");
  byte[] v2 = Bytes.toBytes("23");
  List<TColumnValue> columnValues = new ArrayList<>(1);
  columnValues.add(new TColumnValue(wrap(familyAname), wrap(qualifierAname), wrap(v1)));
  TPut put = new TPut(wrap(rowName), columnValues);
  put.setColumnValues(columnValues);
  handler.put(table, put);

  List<TColumnValue> appendColumns = new ArrayList<>(1);
  appendColumns.add(new TColumnValue(wrap(familyAname), wrap(qualifierAname), wrap(v2)));
  TAppend append = new TAppend(wrap(rowName), appendColumns);
  handler.append(table, append);

  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.add(v1, v2), columnValue.getValue());
}
 
开发者ID:apache,项目名称:hbase,代码行数:27,代码来源:TestThriftHBaseServiceHandler.java

示例15: testMetrics

import org.apache.hadoop.hbase.thrift2.generated.TPut; //导入依赖的package包/类
@Test
public void testMetrics() throws Exception {
  Configuration conf = UTIL.getConfiguration();
  ThriftMetrics metrics = getMetrics(conf);
  ThriftHBaseServiceHandler hbaseHandler = createHandler();
  THBaseService.Iface handler =
      ThriftHBaseServiceHandler.newInstance(hbaseHandler, metrics);
  byte[] rowName = Bytes.toBytes("testMetrics");
  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));
  metricsHelper.assertCounter("put_num_ops", 1, metrics.getSource());
  metricsHelper.assertCounter("exists_num_ops", 2, metrics.getSource());
}
 
开发者ID:apache,项目名称:hbase,代码行数:26,代码来源:TestThriftHBaseServiceHandler.java


注:本文中的org.apache.hadoop.hbase.thrift2.generated.TPut类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。