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


Java ExampleProtos类代码示例

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


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

示例1: getRowCount

import org.apache.hadoop.hbase.coprocessor.example.generated.ExampleProtos; //导入依赖的package包/类
/**
 * Returns a count of the rows in the region where this coprocessor is loaded.
 */
@Override
public void getRowCount(RpcController controller, ExampleProtos.CountRequest request,
                        RpcCallback<ExampleProtos.CountResponse> done) {
  Scan scan = new Scan();
  scan.setFilter(new FirstKeyOnlyFilter());
  ExampleProtos.CountResponse response = null;
  InternalScanner scanner = null;
  try {
    scanner = env.getRegion().getScanner(scan);
    List<Cell> results = new ArrayList<Cell>();
    boolean hasMore = false;
    byte[] lastRow = null;
    long count = 0;
    do {
      hasMore = scanner.next(results);
      for (Cell kv : results) {
        byte[] currentRow = CellUtil.cloneRow(kv);
        if (lastRow == null || !Bytes.equals(lastRow, currentRow)) {
          lastRow = currentRow;
          count++;
        }
      }
      results.clear();
    } while (hasMore);

    response = ExampleProtos.CountResponse.newBuilder()
        .setCount(count).build();
  } catch (IOException ioe) {
    ResponseConverter.setControllerException(controller, ioe);
  } finally {
    if (scanner != null) {
      try {
        scanner.close();
      } catch (IOException ignored) {}
    }
  }
  done.run(response);
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:42,代码来源:RowCountEndpoint.java

示例2: getKeyValueCount

import org.apache.hadoop.hbase.coprocessor.example.generated.ExampleProtos; //导入依赖的package包/类
/**
 * Returns a count of all KeyValues in the region where this coprocessor is loaded.
 */
@Override
public void getKeyValueCount(RpcController controller, ExampleProtos.CountRequest request,
                             RpcCallback<ExampleProtos.CountResponse> done) {
  ExampleProtos.CountResponse response = null;
  InternalScanner scanner = null;
  try {
    scanner = env.getRegion().getScanner(new Scan());
    List<Cell> results = new ArrayList<Cell>();
    boolean hasMore = false;
    long count = 0;
    do {
      hasMore = scanner.next(results);
      for (Cell kv : results) {
        count++;
      }
      results.clear();
    } while (hasMore);

    response = ExampleProtos.CountResponse.newBuilder()
        .setCount(count).build();
  } catch (IOException ioe) {
    ResponseConverter.setControllerException(controller, ioe);
  } finally {
    if (scanner != null) {
      try {
        scanner.close();
      } catch (IOException ignored) {}
    }
  }
  done.run(response);
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:35,代码来源:RowCountEndpoint.java

示例3: testEndpoint

import org.apache.hadoop.hbase.coprocessor.example.generated.ExampleProtos; //导入依赖的package包/类
public void testEndpoint() throws Throwable {
  Table table = new HTable(CONF, TEST_TABLE);

  // insert some test rows
  for (int i=0; i<5; i++) {
    byte[] iBytes = Bytes.toBytes(i);
    Put p = new Put(iBytes);
    p.add(TEST_FAMILY, TEST_COLUMN, iBytes);
    table.put(p);
  }

  final ExampleProtos.CountRequest request = ExampleProtos.CountRequest.getDefaultInstance();
  Map<byte[],Long> results = table.coprocessorService(ExampleProtos.RowCountService.class,
      null, null,
      new Batch.Call<ExampleProtos.RowCountService,Long>() {
        public Long call(ExampleProtos.RowCountService counter) throws IOException {
          ServerRpcController controller = new ServerRpcController();
          BlockingRpcCallback<ExampleProtos.CountResponse> rpcCallback =
              new BlockingRpcCallback<ExampleProtos.CountResponse>();
          counter.getRowCount(controller, request, rpcCallback);
          ExampleProtos.CountResponse response = rpcCallback.get();
          if (controller.failedOnException()) {
            throw controller.getFailedOn();
          }
          return (response != null && response.hasCount()) ? response.getCount() : 0;
        }
      });
  // should be one region with results
  assertEquals(1, results.size());
  Iterator<Long> iter = results.values().iterator();
  Long val = iter.next();
  assertNotNull(val);
  assertEquals(5l, val.longValue());
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:35,代码来源:TestRowCountEndpoint.java

示例4: testEndpoint

import org.apache.hadoop.hbase.coprocessor.example.generated.ExampleProtos; //导入依赖的package包/类
public void testEndpoint() throws Throwable {
  HTable table = new HTable(CONF, TEST_TABLE);

  // insert some test rows
  for (int i=0; i<5; i++) {
    byte[] iBytes = Bytes.toBytes(i);
    Put p = new Put(iBytes);
    p.add(TEST_FAMILY, TEST_COLUMN, iBytes);
    table.put(p);
  }

  final ExampleProtos.CountRequest request = ExampleProtos.CountRequest.getDefaultInstance();
  Map<byte[],Long> results = table.coprocessorService(ExampleProtos.RowCountService.class,
      null, null,
      new Batch.Call<ExampleProtos.RowCountService,Long>() {
        public Long call(ExampleProtos.RowCountService counter) throws IOException {
          ServerRpcController controller = new ServerRpcController();
          BlockingRpcCallback<ExampleProtos.CountResponse> rpcCallback =
              new BlockingRpcCallback<ExampleProtos.CountResponse>();
          counter.getRowCount(controller, request, rpcCallback);
          ExampleProtos.CountResponse response = rpcCallback.get();
          if (controller.failedOnException()) {
            throw controller.getFailedOn();
          }
          return (response != null && response.hasCount()) ? response.getCount() : 0;
        }
      });
  // should be one region with results
  assertEquals(1, results.size());
  Iterator<Long> iter = results.values().iterator();
  Long val = iter.next();
  assertNotNull(val);
  assertEquals(5l, val.longValue());
}
 
开发者ID:tenggyut,项目名称:HIndex,代码行数:35,代码来源:TestRowCountEndpoint.java

示例5: getRowCount

import org.apache.hadoop.hbase.coprocessor.example.generated.ExampleProtos; //导入依赖的package包/类
/**
 * Returns a count of the rows in the region where this coprocessor is loaded.
 */
@Override
public void getRowCount(RpcController controller, ExampleProtos.CountRequest request,
                        RpcCallback<ExampleProtos.CountResponse> done) {
  Scan scan = new Scan();
  scan.setFilter(new FirstKeyOnlyFilter());
  ExampleProtos.CountResponse response = null;
  InternalScanner scanner = null;
  try {
    scanner = env.getRegion().getScanner(scan);
    List<Cell> results = new ArrayList<>();
    boolean hasMore = false;
    byte[] lastRow = null;
    long count = 0;
    do {
      hasMore = scanner.next(results);
      for (Cell kv : results) {
        byte[] currentRow = CellUtil.cloneRow(kv);
        if (lastRow == null || !Bytes.equals(lastRow, currentRow)) {
          lastRow = currentRow;
          count++;
        }
      }
      results.clear();
    } while (hasMore);

    response = ExampleProtos.CountResponse.newBuilder()
        .setCount(count).build();
  } catch (IOException ioe) {
    CoprocessorRpcUtils.setControllerException(controller, ioe);
  } finally {
    if (scanner != null) {
      try {
        scanner.close();
      } catch (IOException ignored) {}
    }
  }
  done.run(response);
}
 
开发者ID:apache,项目名称:hbase,代码行数:42,代码来源:RowCountEndpoint.java

示例6: getKeyValueCount

import org.apache.hadoop.hbase.coprocessor.example.generated.ExampleProtos; //导入依赖的package包/类
/**
 * Returns a count of all KeyValues in the region where this coprocessor is loaded.
 */
@Override
public void getKeyValueCount(RpcController controller, ExampleProtos.CountRequest request,
                             RpcCallback<ExampleProtos.CountResponse> done) {
  ExampleProtos.CountResponse response = null;
  InternalScanner scanner = null;
  try {
    scanner = env.getRegion().getScanner(new Scan());
    List<Cell> results = new ArrayList<>();
    boolean hasMore = false;
    long count = 0;
    do {
      hasMore = scanner.next(results);
      for (Cell kv : results) {
        count++;
      }
      results.clear();
    } while (hasMore);

    response = ExampleProtos.CountResponse.newBuilder()
        .setCount(count).build();
  } catch (IOException ioe) {
    CoprocessorRpcUtils.setControllerException(controller, ioe);
  } finally {
    if (scanner != null) {
      try {
        scanner.close();
      } catch (IOException ignored) {}
    }
  }
  done.run(response);
}
 
开发者ID:apache,项目名称:hbase,代码行数:35,代码来源:RowCountEndpoint.java

示例7: getRowCount

import org.apache.hadoop.hbase.coprocessor.example.generated.ExampleProtos; //导入依赖的package包/类
/**
 * Returns a count of the rows in the region where this coprocessor is loaded.
 */
@Override
public void getRowCount(RpcController controller, ExampleProtos.CountRequest request,
                        RpcCallback<ExampleProtos.CountResponse> done) {
  Scan scan = new Scan();
  scan.setFilter(new FirstKeyOnlyFilter());
  ExampleProtos.CountResponse response = null;
  InternalScanner scanner = null;
  try {
    scanner = env.getRegion().getScanner(scan);
    List<KeyValue> results = new ArrayList<KeyValue>();
    boolean hasMore = false;
    byte[] lastRow = null;
    long count = 0;
    do {
      hasMore = scanner.next(results);
      for (KeyValue kv : results) {
        byte[] currentRow = kv.getRow();
        if (lastRow == null || !Bytes.equals(lastRow, currentRow)) {
          lastRow = currentRow;
          count++;
        }
      }
      results.clear();
    } while (hasMore);

    response = ExampleProtos.CountResponse.newBuilder()
        .setCount(count).build();
  } catch (IOException ioe) {
    ResponseConverter.setControllerException(controller, ioe);
  } finally {
    if (scanner != null) {
      try {
        scanner.close();
      } catch (IOException ignored) {}
    }
  }
  done.run(response);
}
 
开发者ID:daidong,项目名称:DominoHBase,代码行数:42,代码来源:RowCountEndpoint.java

示例8: getKeyValueCount

import org.apache.hadoop.hbase.coprocessor.example.generated.ExampleProtos; //导入依赖的package包/类
/**
 * Returns a count of all KeyValues in the region where this coprocessor is loaded.
 */
@Override
public void getKeyValueCount(RpcController controller, ExampleProtos.CountRequest request,
                             RpcCallback<ExampleProtos.CountResponse> done) {
  ExampleProtos.CountResponse response = null;
  InternalScanner scanner = null;
  try {
    scanner = env.getRegion().getScanner(new Scan());
    List<KeyValue> results = new ArrayList<KeyValue>();
    boolean hasMore = false;
    long count = 0;
    do {
      hasMore = scanner.next(results);
      for (KeyValue kv : results) {
        count++;
      }
      results.clear();
    } while (hasMore);

    response = ExampleProtos.CountResponse.newBuilder()
        .setCount(count).build();
  } catch (IOException ioe) {
    ResponseConverter.setControllerException(controller, ioe);
  } finally {
    if (scanner != null) {
      try {
        scanner.close();
      } catch (IOException ignored) {}
    }
  }
  done.run(response);
}
 
开发者ID:daidong,项目名称:DominoHBase,代码行数:35,代码来源:RowCountEndpoint.java

示例9: testEndpoint

import org.apache.hadoop.hbase.coprocessor.example.generated.ExampleProtos; //导入依赖的package包/类
@Test
public void testEndpoint() throws Throwable {
  HTable table = new HTable(CONF, TEST_TABLE);

  // insert some test rows
  for (int i=0; i<5; i++) {
    byte[] iBytes = Bytes.toBytes(i);
    Put p = new Put(iBytes);
    p.add(TEST_FAMILY, TEST_COLUMN, iBytes);
    table.put(p);
  }

  final ExampleProtos.CountRequest request = ExampleProtos.CountRequest.getDefaultInstance();
  Map<byte[],Long> results = table.coprocessorService(ExampleProtos.RowCountService.class,
      null, null,
      new Batch.Call<ExampleProtos.RowCountService,Long>() {
        public Long call(ExampleProtos.RowCountService counter) throws IOException {
          ServerRpcController controller = new ServerRpcController();
          BlockingRpcCallback<ExampleProtos.CountResponse> rpcCallback =
              new BlockingRpcCallback<ExampleProtos.CountResponse>();
          counter.getRowCount(controller, request, rpcCallback);
          ExampleProtos.CountResponse response = rpcCallback.get();
          if (controller.failedOnException()) {
            throw controller.getFailedOn();
          }
          return (response != null && response.hasCount()) ? response.getCount() : 0;
        }
      });
  // should be one region with results
  assertEquals(1, results.size());
  Iterator<Long> iter = results.values().iterator();
  Long val = iter.next();
  assertNotNull(val);
  assertEquals(5l, val.longValue());
}
 
开发者ID:daidong,项目名称:DominoHBase,代码行数:36,代码来源:TestRowCountEndpoint.java


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