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


Java TColumn类代码示例

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


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

示例1: deleteFromHBase

import org.apache.hadoop.hbase.thrift2.generated.TColumn; //导入依赖的package包/类
public static TDelete deleteFromHBase(Delete in) {
  TDelete out = new TDelete(ByteBuffer.wrap(in.getRow()));

  List<TColumn> columns = new ArrayList<TColumn>();
  long rowTimestamp = in.getTimeStamp();
  if (rowTimestamp != HConstants.LATEST_TIMESTAMP) {
    out.setTimestamp(rowTimestamp);
  }

  // Map<family, List<KeyValue>>
  for (Map.Entry<byte[], List<org.apache.hadoop.hbase.Cell>> familyEntry:
      in.getFamilyCellMap().entrySet()) {
    TColumn column = new TColumn(ByteBuffer.wrap(familyEntry.getKey()));
    for (org.apache.hadoop.hbase.Cell cell: familyEntry.getValue()) {
      byte[] family = CellUtil.cloneFamily(cell);
      byte[] qualifier = CellUtil.cloneQualifier(cell);
      long timestamp = cell.getTimestamp();
      if (family != null) {
        column.setFamily(family);
      }
      if (qualifier != null) {
        column.setQualifier(qualifier);
      }
      if (timestamp != HConstants.LATEST_TIMESTAMP) {
        column.setTimestamp(timestamp);
      }
    }
    columns.add(column);
  }
  out.setColumns(columns);

  return out;
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:34,代码来源:ThriftUtilities.java

示例2: testDelete

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

  List<TColumnValue> columnValues = new ArrayList<TColumnValue>();
  TColumnValue columnValueA = new TColumnValue(wrap(familyAname), wrap(qualifierAname),
    wrap(valueAname));
  TColumnValue columnValueB = new TColumnValue(wrap(familyBname), wrap(qualifierBname),
    wrap(valueBname));
  columnValues.add(columnValueA);
  columnValues.add(columnValueB);
  TPut put = new TPut(wrap(rowName), columnValues);

  put.setColumnValues(columnValues);

  handler.put(table, put);

  TDelete delete = new TDelete(wrap(rowName));
  List<TColumn> deleteColumns = new ArrayList<TColumn>();
  TColumn deleteColumn = new TColumn(wrap(familyAname));
  deleteColumn.setQualifier(qualifierAname);
  deleteColumns.add(deleteColumn);
  delete.setColumns(deleteColumns);

  handler.deleteSingle(table, delete);

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

示例3: deleteFromHBase

import org.apache.hadoop.hbase.thrift2.generated.TColumn; //导入依赖的package包/类
public static TDelete deleteFromHBase(Delete in) {
  TDelete out = new TDelete(ByteBuffer.wrap(in.getRow()));

  List<TColumn> columns = new ArrayList<TColumn>();
  long rowTimestamp = in.getTimeStamp();
  if (rowTimestamp != HConstants.LATEST_TIMESTAMP) {
    out.setTimestamp(rowTimestamp);
  }

  // Map<family, List<KeyValue>>
  for (Map.Entry<byte[], List<org.apache.hadoop.hbase.Cell>> familyEntry:
      in.getFamilyCellMap().entrySet()) {
    TColumn column = new TColumn(ByteBuffer.wrap(familyEntry.getKey()));
    for (org.apache.hadoop.hbase.Cell cell: familyEntry.getValue()) {
      KeyValue kv = KeyValueUtil.ensureKeyValue(cell);
      byte[] family = kv.getFamily();
      byte[] qualifier = kv.getQualifier();
      long timestamp = kv.getTimestamp();
      if (family != null) {
        column.setFamily(family);
      }
      if (qualifier != null) {
        column.setQualifier(qualifier);
      }
      if (timestamp != HConstants.LATEST_TIMESTAMP) {
        column.setTimestamp(kv.getTimestamp());
      }
    }
    columns.add(column);
  }
  out.setColumns(columns);

  return out;
}
 
开发者ID:tenggyut,项目名称:HIndex,代码行数:35,代码来源:ThriftUtilities.java

示例4: deleteFromHBase

import org.apache.hadoop.hbase.thrift2.generated.TColumn; //导入依赖的package包/类
public static TDelete deleteFromHBase(Delete in) {
  TDelete out = new TDelete(ByteBuffer.wrap(in.getRow()));

  List<TColumn> columns = new ArrayList<>(in.getFamilyCellMap().entrySet().size());
  long rowTimestamp = in.getTimeStamp();
  if (rowTimestamp != HConstants.LATEST_TIMESTAMP) {
    out.setTimestamp(rowTimestamp);
  }

  // Map<family, List<KeyValue>>
  for (Map.Entry<byte[], List<org.apache.hadoop.hbase.Cell>> familyEntry:
      in.getFamilyCellMap().entrySet()) {
    TColumn column = new TColumn(ByteBuffer.wrap(familyEntry.getKey()));
    for (org.apache.hadoop.hbase.Cell cell: familyEntry.getValue()) {
      byte[] family = CellUtil.cloneFamily(cell);
      byte[] qualifier = CellUtil.cloneQualifier(cell);
      long timestamp = cell.getTimestamp();
      if (family != null) {
        column.setFamily(family);
      }
      if (qualifier != null) {
        column.setQualifier(qualifier);
      }
      if (timestamp != HConstants.LATEST_TIMESTAMP) {
        column.setTimestamp(timestamp);
      }
    }
    columns.add(column);
  }
  out.setColumns(columns);

  return out;
}
 
开发者ID:apache,项目名称:hbase,代码行数:34,代码来源:ThriftUtilities.java

示例5: testDelete

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

  List<TColumnValue> columnValues = new ArrayList<>(2);
  TColumnValue columnValueA = new TColumnValue(wrap(familyAname), wrap(qualifierAname),
    wrap(valueAname));
  TColumnValue columnValueB = new TColumnValue(wrap(familyBname), wrap(qualifierBname),
    wrap(valueBname));
  columnValues.add(columnValueA);
  columnValues.add(columnValueB);
  TPut put = new TPut(wrap(rowName), columnValues);

  put.setColumnValues(columnValues);

  handler.put(table, put);

  TDelete delete = new TDelete(wrap(rowName));
  List<TColumn> deleteColumns = new ArrayList<>(1);
  TColumn deleteColumn = new TColumn(wrap(familyAname));
  deleteColumn.setQualifier(qualifierAname);
  deleteColumns.add(deleteColumn);
  delete.setColumns(deleteColumns);

  handler.deleteSingle(table, delete);

  TGet get = new TGet(wrap(rowName));
  TResult result = handler.get(table, get);
  assertArrayEquals(rowName, result.getRow());
  List<TColumnValue> returnedColumnValues = result.getColumnValues();
  List<TColumnValue> expectedColumnValues = new ArrayList<>(1);
  expectedColumnValues.add(columnValueB);
  assertTColumnValuesEqual(expectedColumnValues, returnedColumnValues);
}
 
开发者ID:apache,项目名称:hbase,代码行数:37,代码来源:TestThriftHBaseServiceHandler.java

示例6: testDelete

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

  List<TColumnValue> columnValues = new ArrayList<TColumnValue>();
  TColumnValue columnValueA = new TColumnValue(ByteBuffer.wrap(familyAname), ByteBuffer.wrap(qualifierAname),
      ByteBuffer.wrap(valueAname));
  TColumnValue columnValueB = new TColumnValue(ByteBuffer.wrap(familyBname), ByteBuffer.wrap(qualifierBname),
      ByteBuffer.wrap(valueBname));
  columnValues.add(columnValueA);
  columnValues.add(columnValueB);
  TPut put = new TPut(ByteBuffer.wrap(rowName), columnValues);

  put.setColumnValues(columnValues);

  handler.put(table, put);

  TDelete delete = new TDelete(ByteBuffer.wrap(rowName));
  List<TColumn> deleteColumns = new ArrayList<TColumn>();
  TColumn deleteColumn = new TColumn(ByteBuffer.wrap(familyAname));
  deleteColumn.setQualifier(qualifierAname);
  deleteColumns.add(deleteColumn);
  delete.setColumns(deleteColumns);

  handler.deleteSingle(table, delete);

  TGet get = new TGet(ByteBuffer.wrap(rowName));
  TResult result = handler.get(table, get);
  assertArrayEquals(rowName, result.getRow());
  List<TColumnValue> returnedColumnValues = result.getColumnValues();
  List<TColumnValue> expectedColumnValues = new ArrayList<TColumnValue>();
  expectedColumnValues.add(columnValueB);
  assertTColumnValuesEqual(expectedColumnValues, returnedColumnValues);
}
 
开发者ID:zwqjsj0404,项目名称:HBase-Research,代码行数:37,代码来源:TestThriftHBaseServiceHandler.java

示例7: getFromThrift

import org.apache.hadoop.hbase.thrift2.generated.TColumn; //导入依赖的package包/类
/**
 * Creates a {@link Get} (HBase) from a {@link TGet} (Thrift).
 *
 * This ignores any timestamps set on {@link TColumn} objects.
 *
 * @param in the <code>TGet</code> to convert
 *
 * @return <code>Get</code> object
 *
 * @throws IOException if an invalid time range or max version parameter is given
 */
public static Get getFromThrift(TGet in) throws IOException {
  Get out = new Get(in.getRow());

  // Timestamp overwrites time range if both are set
  if (in.isSetTimestamp()) {
    out.setTimeStamp(in.getTimestamp());
  } else if (in.isSetTimeRange()) {
    out.setTimeRange(in.getTimeRange().getMinStamp(), in.getTimeRange().getMaxStamp());
  }

  if (in.isSetMaxVersions()) {
    out.setMaxVersions(in.getMaxVersions());
  }

  if (in.isSetFilterString()) {
    ParseFilter parseFilter = new ParseFilter();
    out.setFilter(parseFilter.parseFilterString(in.getFilterString()));
  }

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

  if (in.isSetAuthorizations()) {
    out.setAuthorizations(new Authorizations(in.getAuthorizations().getLabels()));
  }
  
  if (!in.isSetColumns()) {
    return out;
  }

  for (TColumn column : in.getColumns()) {
    if (column.isSetQualifier()) {
      out.addColumn(column.getFamily(), column.getQualifier());
    } else {
      out.addFamily(column.getFamily());
    }
  }

  return out;
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:53,代码来源:ThriftUtilities.java

示例8: scanFromThrift

import org.apache.hadoop.hbase.thrift2.generated.TColumn; //导入依赖的package包/类
public static Scan scanFromThrift(TScan in) throws IOException {
  Scan out = new Scan();

  if (in.isSetStartRow())
    out.setStartRow(in.getStartRow());
  if (in.isSetStopRow())
    out.setStopRow(in.getStopRow());
  if (in.isSetCaching())
    out.setCaching(in.getCaching());
  if (in.isSetMaxVersions()) {
    out.setMaxVersions(in.getMaxVersions());
  }

  if (in.isSetColumns()) {
    for (TColumn column : in.getColumns()) {
      if (column.isSetQualifier()) {
        out.addColumn(column.getFamily(), column.getQualifier());
      } else {
        out.addFamily(column.getFamily());
      }
    }
  }

  TTimeRange timeRange = in.getTimeRange();
  if (timeRange != null &&
      timeRange.isSetMinStamp() && timeRange.isSetMaxStamp()) {
    out.setTimeRange(timeRange.getMinStamp(), timeRange.getMaxStamp());
  }

  if (in.isSetBatchSize()) {
    out.setBatch(in.getBatchSize());
  }

  if (in.isSetFilterString()) {
    ParseFilter parseFilter = new ParseFilter();
    out.setFilter(parseFilter.parseFilterString(in.getFilterString()));
  }

  if (in.isSetAttributes()) {
    addAttributes(out,in.getAttributes());
  }
  
  if (in.isSetAuthorizations()) {
    out.setAuthorizations(new Authorizations(in.getAuthorizations().getLabels()));
  }

  if (in.isSetReversed()) {
    out.setReversed(in.isReversed());
  }

  return out;
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:53,代码来源:ThriftUtilities.java

示例9: testScanWithVisibilityLabels

import org.apache.hadoop.hbase.thrift2.generated.TColumn; //导入依赖的package包/类
@Test
public void testScanWithVisibilityLabels() throws Exception {
  ThriftHBaseServiceHandler handler = createHandler();
  ByteBuffer table = wrap(tableAname);

  // insert data
  TColumnValue columnValue = new TColumnValue(wrap(familyAname),
      wrap(qualifierAname), wrap(valueAname));
  List<TColumnValue> columnValues = new ArrayList<TColumnValue>();
  columnValues.add(columnValue);
  for (int i = 0; i < 10; i++) {
    TPut put = new TPut(wrap(("testScan" + i).getBytes()), columnValues);
    if (i == 5) {
      put.setCellVisibility(new TCellVisibility().setExpression(PUBLIC));
    } else {
      put.setCellVisibility(new TCellVisibility().setExpression("(" + SECRET
          + "|" + CONFIDENTIAL + ")" + "&" + "!" + TOPSECRET));
    }
    handler.put(table, put);
  }

  // create scan instance
  TScan scan = new TScan();
  List<TColumn> columns = new ArrayList<TColumn>();
  TColumn column = new TColumn();
  column.setFamily(familyAname);
  column.setQualifier(qualifierAname);
  columns.add(column);
  scan.setColumns(columns);
  scan.setStartRow("testScan".getBytes());
  scan.setStopRow("testScan\uffff".getBytes());

  TAuthorization tauth = new TAuthorization();
  List<String> labels = new ArrayList<String>();
  labels.add(SECRET);
  labels.add(PRIVATE);
  tauth.setLabels(labels);
  scan.setAuthorizations(tauth);
  // get scanner and rows
  int scanId = handler.openScanner(table, scan);
  List<TResult> results = handler.getScannerRows(scanId, 10);
  assertEquals(9, results.size());
  Assert.assertFalse(Bytes.equals(results.get(5).getRow(),
      ("testScan" + 5).getBytes()));
  for (int i = 0; i < 9; i++) {
    if (i < 5) {
      assertArrayEquals(("testScan" + i).getBytes(), results.get(i).getRow());
    } else if (i == 5) {
      continue;
    } else {
      assertArrayEquals(("testScan" + (i + 1)).getBytes(), results.get(i)
          .getRow());
    }
  }

  // check that we are at the end of the scan
  results = handler.getScannerRows(scanId, 9);
  assertEquals(0, results.size());

  // close scanner and check that it was indeed closed
  handler.closeScanner(scanId);
  try {
    handler.getScannerRows(scanId, 9);
    fail("Scanner id should be invalid");
  } catch (TIllegalArgument e) {
  }
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:68,代码来源:TestThriftHBaseServiceHandlerWithLabels.java

示例10: testGetScannerResultsWithAuthorizations

import org.apache.hadoop.hbase.thrift2.generated.TColumn; //导入依赖的package包/类
@Test
public void testGetScannerResultsWithAuthorizations() throws Exception {
  ThriftHBaseServiceHandler handler = createHandler();
  ByteBuffer table = wrap(tableAname);

  // insert data
  TColumnValue columnValue = new TColumnValue(wrap(familyAname),
      wrap(qualifierAname), wrap(valueAname));
  List<TColumnValue> columnValues = new ArrayList<TColumnValue>();
  columnValues.add(columnValue);
  for (int i = 0; i < 20; i++) {
    TPut put = new TPut(
        wrap(("testGetScannerResults" + pad(i, (byte) 2)).getBytes()),
        columnValues);
    if (i == 3) {
      put.setCellVisibility(new TCellVisibility().setExpression(PUBLIC));
    } else {
      put.setCellVisibility(new TCellVisibility().setExpression("(" + SECRET
          + "|" + CONFIDENTIAL + ")" + "&" + "!" + TOPSECRET));
    }
    handler.put(table, put);
  }

  // create scan instance
  TScan scan = new TScan();
  List<TColumn> columns = new ArrayList<TColumn>();
  TColumn column = new TColumn();
  column.setFamily(familyAname);
  column.setQualifier(qualifierAname);
  columns.add(column);
  scan.setColumns(columns);
  scan.setStartRow("testGetScannerResults".getBytes());

  // get 5 rows and check the returned results
  scan.setStopRow("testGetScannerResults05".getBytes());
  TAuthorization tauth = new TAuthorization();
  List<String> labels = new ArrayList<String>();
  labels.add(SECRET);
  labels.add(PRIVATE);
  tauth.setLabels(labels);
  scan.setAuthorizations(tauth);
  List<TResult> results = handler.getScannerResults(table, scan, 5);
  assertEquals(4, results.size());
  for (int i = 0; i < 4; i++) {
    if (i < 3) {
      assertArrayEquals(
          ("testGetScannerResults" + pad(i, (byte) 2)).getBytes(),
          results.get(i).getRow());
    } else if (i == 3) {
      continue;
    } else {
      assertArrayEquals(
          ("testGetScannerResults" + pad(i + 1, (byte) 2)).getBytes(), results
              .get(i).getRow());
    }
  }
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:58,代码来源:TestThriftHBaseServiceHandlerWithLabels.java

示例11: testScan

import org.apache.hadoop.hbase.thrift2.generated.TColumn; //导入依赖的package包/类
@Test
public void testScan() throws Exception {
  ThriftHBaseServiceHandler handler = createHandler();
  ByteBuffer table = wrap(tableAname);

  // insert data
  TColumnValue columnValue = new TColumnValue(wrap(familyAname), wrap(qualifierAname),
    wrap(valueAname));
  List<TColumnValue> columnValues = new ArrayList<TColumnValue>();
  columnValues.add(columnValue);
  for (int i = 0; i < 10; i++) {
    TPut put = new TPut(wrap(("testScan" + i).getBytes()), columnValues);
    handler.put(table, put);
  }

  // create scan instance
  TScan scan = new TScan();
  List<TColumn> columns = new ArrayList<TColumn>();
  TColumn column = new TColumn();
  column.setFamily(familyAname);
  column.setQualifier(qualifierAname);
  columns.add(column);
  scan.setColumns(columns);
  scan.setStartRow("testScan".getBytes());
  scan.setStopRow("testScan\uffff".getBytes());

  // get scanner and rows
  int scanId = handler.openScanner(table, scan);
  List<TResult> results = handler.getScannerRows(scanId, 10);
  assertEquals(10, results.size());
  for (int i = 0; i < 10; i++) {
    // check if the rows are returned and in order
    assertArrayEquals(("testScan" + i).getBytes(), results.get(i).getRow());
  }

  // check that we are at the end of the scan
  results = handler.getScannerRows(scanId, 10);
  assertEquals(0, results.size());

  // close scanner and check that it was indeed closed
  handler.closeScanner(scanId);
  try {
    handler.getScannerRows(scanId, 10);
    fail("Scanner id should be invalid");
  } catch (TIllegalArgument e) {
  }
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:48,代码来源:TestThriftHBaseServiceHandler.java

示例12: testReverseScan

import org.apache.hadoop.hbase.thrift2.generated.TColumn; //导入依赖的package包/类
@Test
public void testReverseScan() throws Exception {
  ThriftHBaseServiceHandler handler = createHandler();
  ByteBuffer table = wrap(tableAname);

  // insert data
  TColumnValue columnValue = new TColumnValue(wrap(familyAname), wrap(qualifierAname),
    wrap(valueAname));
  List<TColumnValue> columnValues = new ArrayList<TColumnValue>();
  columnValues.add(columnValue);
  for (int i = 0; i < 10; i++) {
    TPut put = new TPut(wrap(("testReverseScan" + i).getBytes()), columnValues);
    handler.put(table, put);
  }

  // create reverse scan instance
  TScan scan = new TScan();
  scan.setReversed(true);
  List<TColumn> columns = new ArrayList<TColumn>();
  TColumn column = new TColumn();
  column.setFamily(familyAname);
  column.setQualifier(qualifierAname);
  columns.add(column);
  scan.setColumns(columns);
  scan.setStartRow("testReverseScan\uffff".getBytes());
  scan.setStopRow("testReverseScan".getBytes());

  // get scanner and rows
  int scanId = handler.openScanner(table, scan);
  List<TResult> results = handler.getScannerRows(scanId, 10);
  assertEquals(10, results.size());
  for (int i = 0; i < 10; i++) {
    // check if the rows are returned and in order
    assertArrayEquals(("testReverseScan" + (9 - i)).getBytes(), results.get(i).getRow());
  }

  // check that we are at the end of the scan
  results = handler.getScannerRows(scanId, 10);
  assertEquals(0, results.size());

  // close scanner and check that it was indeed closed
  handler.closeScanner(scanId);
  try {
    handler.getScannerRows(scanId, 10);
    fail("Scanner id should be invalid");
  } catch (TIllegalArgument e) {
  }
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:49,代码来源:TestThriftHBaseServiceHandler.java

示例13: testScanWithFilter

import org.apache.hadoop.hbase.thrift2.generated.TColumn; //导入依赖的package包/类
@Test
public void testScanWithFilter() throws Exception {
  ThriftHBaseServiceHandler handler = createHandler();
  ByteBuffer table = wrap(tableAname);

  // insert data
  TColumnValue columnValue = new TColumnValue(wrap(familyAname), wrap(qualifierAname),
    wrap(valueAname));
  List<TColumnValue> columnValues = new ArrayList<TColumnValue>();
  columnValues.add(columnValue);
  for (int i = 0; i < 10; i++) {
    TPut put = new TPut(wrap(("testScanWithFilter" + i).getBytes()), columnValues);
    handler.put(table, put);
  }

  // create scan instance with filter
  TScan scan = new TScan();
  List<TColumn> columns = new ArrayList<TColumn>();
  TColumn column = new TColumn();
  column.setFamily(familyAname);
  column.setQualifier(qualifierAname);
  columns.add(column);
  scan.setColumns(columns);
  scan.setStartRow("testScanWithFilter".getBytes());
  scan.setStopRow("testScanWithFilter\uffff".getBytes());
  // only get the key part
  scan.setFilterString(wrap(("KeyOnlyFilter()").getBytes()));

  // get scanner and rows
  int scanId = handler.openScanner(table, scan);
  List<TResult> results = handler.getScannerRows(scanId, 10);
  assertEquals(10, results.size());
  for (int i = 0; i < 10; i++) {
    // check if the rows are returned and in order
    assertArrayEquals(("testScanWithFilter" + i).getBytes(), results.get(i).getRow());
    // check that the value is indeed stripped by the filter
    assertEquals(0, results.get(i).getColumnValues().get(0).getValue().length);
  }

  // check that we are at the end of the scan
  results = handler.getScannerRows(scanId, 10);
  assertEquals(0, results.size());

  // close scanner and check that it was indeed closed
  handler.closeScanner(scanId);
  try {
    handler.getScannerRows(scanId, 10);
    fail("Scanner id should be invalid");
  } catch (TIllegalArgument e) {
  }
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:52,代码来源:TestThriftHBaseServiceHandler.java

示例14: testMutateRow

import org.apache.hadoop.hbase.thrift2.generated.TColumn; //导入依赖的package包/类
/**
 * Put valueA to a row, make sure put has happened, then create a mutation object to put valueB
 * and delete ValueA, then check that the row value is only valueB.
 *
 * @throws Exception
 */
@Test
public void testMutateRow() throws Exception {
  ThriftHBaseServiceHandler handler = createHandler();
  byte[] rowName = "testMutateRow".getBytes();
  ByteBuffer table = wrap(tableAname);

  List<TColumnValue> columnValuesA = new ArrayList<TColumnValue>();
  TColumnValue columnValueA = new TColumnValue(wrap(familyAname), wrap(qualifierAname),
      wrap(valueAname));
  columnValuesA.add(columnValueA);
  TPut putA = new TPut(wrap(rowName), columnValuesA);
  putA.setColumnValues(columnValuesA);

  handler.put(table,putA);

  TGet get = new TGet(wrap(rowName));
  TResult result = handler.get(table, get);
  assertArrayEquals(rowName, result.getRow());
  List<TColumnValue> returnedColumnValues = result.getColumnValues();

  List<TColumnValue> expectedColumnValues = new ArrayList<TColumnValue>();
  expectedColumnValues.add(columnValueA);
  assertTColumnValuesEqual(expectedColumnValues, returnedColumnValues);

  List<TColumnValue> columnValuesB = new ArrayList<TColumnValue>();
  TColumnValue columnValueB = new TColumnValue(wrap(familyAname), wrap(qualifierBname),
      wrap(valueBname));
  columnValuesB.add(columnValueB);
  TPut putB = new TPut(wrap(rowName), columnValuesB);
  putB.setColumnValues(columnValuesB);

  TDelete delete = new TDelete(wrap(rowName));
  List<TColumn> deleteColumns = new ArrayList<TColumn>();
  TColumn deleteColumn = new TColumn(wrap(familyAname));
  deleteColumn.setQualifier(qualifierAname);
  deleteColumns.add(deleteColumn);
  delete.setColumns(deleteColumns);

  List<TMutation> mutations = new ArrayList<TMutation>();
  TMutation mutationA = TMutation.put(putB);
  mutations.add(mutationA);

  TMutation mutationB = TMutation.deleteSingle(delete);
  mutations.add(mutationB);

  TRowMutations tRowMutations = new TRowMutations(wrap(rowName),mutations);
  handler.mutateRow(table,tRowMutations);

  result = handler.get(table, get);
  assertArrayEquals(rowName, result.getRow());
  returnedColumnValues = result.getColumnValues();

  expectedColumnValues = new ArrayList<TColumnValue>();
  expectedColumnValues.add(columnValueB);
  assertTColumnValuesEqual(expectedColumnValues, returnedColumnValues);
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:63,代码来源:TestThriftHBaseServiceHandler.java

示例15: testGetScannerResults

import org.apache.hadoop.hbase.thrift2.generated.TColumn; //导入依赖的package包/类
@Test
public void testGetScannerResults() throws Exception {
  ThriftHBaseServiceHandler handler = createHandler();
  ByteBuffer table = wrap(tableAname);

  // insert data
  TColumnValue columnValue =
      new TColumnValue(wrap(familyAname), wrap(qualifierAname), wrap(valueAname));
  List<TColumnValue> columnValues = new ArrayList<TColumnValue>();
  columnValues.add(columnValue);
  for (int i = 0; i < 20; i++) {
    TPut put =
        new TPut(wrap(("testGetScannerResults" + pad(i, (byte) 2)).getBytes()), columnValues);
    handler.put(table, put);
  }

  // create scan instance
  TScan scan = new TScan();
  List<TColumn> columns = new ArrayList<TColumn>();
  TColumn column = new TColumn();
  column.setFamily(familyAname);
  column.setQualifier(qualifierAname);
  columns.add(column);
  scan.setColumns(columns);
  scan.setStartRow("testGetScannerResults".getBytes());

  // get 5 rows and check the returned results
  scan.setStopRow("testGetScannerResults05".getBytes());
  List<TResult> results = handler.getScannerResults(table, scan, 5);
  assertEquals(5, results.size());
  for (int i = 0; i < 5; i++) {
    // check if the rows are returned and in order
    assertArrayEquals(("testGetScannerResults" + pad(i, (byte) 2)).getBytes(), results.get(i)
        .getRow());
  }

  // get 10 rows and check the returned results
  scan.setStopRow("testGetScannerResults10".getBytes());
  results = handler.getScannerResults(table, scan, 10);
  assertEquals(10, results.size());
  for (int i = 0; i < 10; i++) {
    // check if the rows are returned and in order
    assertArrayEquals(("testGetScannerResults" + pad(i, (byte) 2)).getBytes(), results.get(i)
        .getRow());
  }

  // get 20 rows and check the returned results
  scan.setStopRow("testGetScannerResults20".getBytes());
  results = handler.getScannerResults(table, scan, 20);
  assertEquals(20, results.size());
  for (int i = 0; i < 20; i++) {
    // check if the rows are returned and in order
    assertArrayEquals(("testGetScannerResults" + pad(i, (byte) 2)).getBytes(), results.get(i)
        .getRow());
  }
}
 
开发者ID:fengchen8086,项目名称:LCIndex-HBase-0.94.16,代码行数:57,代码来源:TestThriftHBaseServiceHandler.java


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