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


Java TScan类代码示例

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


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

示例1: getScannerResults

import org.apache.hadoop.hbase.thrift2.generated.TScan; //导入依赖的package包/类
@Override
public List<TResult> getScannerResults(ByteBuffer table, TScan scan, int numRows)
    throws TIOError, TException {
  Table htable = getTable(table);
  List<TResult> results = null;
  ResultScanner scanner = null;
  try {
    scanner = htable.getScanner(scanFromThrift(scan));
    results = resultsFromHBase(scanner.next(numRows));
  } catch (IOException e) {
    throw getTIOError(e);
  } finally {
    if (scanner != null) {
      scanner.close();
    }
    closeTable(htable);
  }
  return results;
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:20,代码来源:ThriftHBaseServiceHandler.java

示例2: getScannerResults

import org.apache.hadoop.hbase.thrift2.generated.TScan; //导入依赖的package包/类
@Override
public List<TResult> getScannerResults(ByteBuffer table, TScan scan, int numRows)
    throws TIOError, TException {
  HTableInterface htable = getTable(table);
  List<TResult> results = null;
  ResultScanner scanner = null;
  try {
    scanner = htable.getScanner(scanFromThrift(scan));
    results = resultsFromHBase(scanner.next(numRows));
  } catch (IOException e) {
    throw getTIOError(e);
  } finally {
    if (scanner != null) {
      scanner.close();
    }
    closeTable(htable);
  }
  return results;
}
 
开发者ID:fengchen8086,项目名称:LCIndex-HBase-0.94.16,代码行数:20,代码来源:ThriftHBaseServiceHandler.java

示例3: testScanWithReadOnly

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

  TScan scan = new TScan();
  boolean exceptionCaught = false;
  try {
    int scanId = handler.openScanner(table, scan);
    handler.getScannerRows(scanId, 10);
    handler.closeScanner(scanId);
  } catch (TIOError e) {
    exceptionCaught = true;
  } finally {
    assertFalse(exceptionCaught);
  }
}
 
开发者ID:apache,项目名称:hbase,代码行数:18,代码来源:TestThriftHBaseServiceHandlerWithReadOnly.java

示例4: openScanner

import org.apache.hadoop.hbase.thrift2.generated.TScan; //导入依赖的package包/类
@Override
public int openScanner(ByteBuffer table, TScan scan) throws TIOError, TException {
  Table htable = getTable(table);
  ResultScanner resultScanner = null;
  try {
    resultScanner = htable.getScanner(scanFromThrift(scan));
  } catch (IOException e) {
    throw getTIOError(e);
  } finally {
    closeTable(htable);
  }
  return addScanner(resultScanner);
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:14,代码来源:ThriftHBaseServiceHandler.java

示例5: openScanner

import org.apache.hadoop.hbase.thrift2.generated.TScan; //导入依赖的package包/类
@Override
public int openScanner(ByteBuffer table, TScan scan) throws TIOError, TException {
  HTableInterface htable = getTable(table);
  ResultScanner resultScanner = null;
  try {
    resultScanner = htable.getScanner(scanFromThrift(scan));
  } catch (IOException e) {
    throw getTIOError(e);
  } finally {
    closeTable(htable);
  }
  return addScanner(resultScanner);
}
 
开发者ID:fengchen8086,项目名称:LCIndex-HBase-0.94.16,代码行数:14,代码来源:ThriftHBaseServiceHandler.java

示例6: openScanner

import org.apache.hadoop.hbase.thrift2.generated.TScan; //导入依赖的package包/类
@Override
public int openScanner(ByteBuffer table, TScan scan) throws TIOError, TException {
  HTableInterface htable = getTable(table.array());
  ResultScanner resultScanner = null;
  try {
    resultScanner = htable.getScanner(scanFromThrift(scan));
  } catch (IOException e) {
    throw getTIOError(e);
  } finally {
    closeTable(htable);
  }
  return addScanner(resultScanner);
}
 
开发者ID:zwqjsj0404,项目名称:HBase-Research,代码行数:14,代码来源:ThriftHBaseServiceHandler.java

示例7: scanFromThrift

import org.apache.hadoop.hbase.thrift2.generated.TScan; //导入依赖的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

示例8: testScanWithVisibilityLabels

import org.apache.hadoop.hbase.thrift2.generated.TScan; //导入依赖的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

示例9: testGetScannerResultsWithAuthorizations

import org.apache.hadoop.hbase.thrift2.generated.TScan; //导入依赖的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

示例10: testScan

import org.apache.hadoop.hbase.thrift2.generated.TScan; //导入依赖的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

示例11: testReverseScan

import org.apache.hadoop.hbase.thrift2.generated.TScan; //导入依赖的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

示例12: testScanWithFilter

import org.apache.hadoop.hbase.thrift2.generated.TScan; //导入依赖的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

示例13: testGetScannerResults

import org.apache.hadoop.hbase.thrift2.generated.TScan; //导入依赖的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

示例14: scanFromThrift

import org.apache.hadoop.hbase.thrift2.generated.TScan; //导入依赖的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()));
  }

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

示例15: testGetScannerResults

import org.apache.hadoop.hbase.thrift2.generated.TScan; //导入依赖的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:tenggyut,项目名称:HIndex,代码行数:57,代码来源:TestThriftHBaseServiceHandler.java


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