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


Java ScannerModel.fromScan方法代码示例

本文整理汇总了Java中org.apache.hadoop.hbase.rest.model.ScannerModel.fromScan方法的典型用法代码示例。如果您正苦于以下问题:Java ScannerModel.fromScan方法的具体用法?Java ScannerModel.fromScan怎么用?Java ScannerModel.fromScan使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.hadoop.hbase.rest.model.ScannerModel的用法示例。


在下文中一共展示了ScannerModel.fromScan方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: verifyScan

import org.apache.hadoop.hbase.rest.model.ScannerModel; //导入方法依赖的package包/类
private static void verifyScan(Scan s, long expectedRows, long expectedKeys) 
    throws Exception {
  ScannerModel model = ScannerModel.fromScan(s);
  model.setBatch(Integer.MAX_VALUE); // fetch it all at once
  StringWriter writer = new StringWriter();
  marshaller.marshal(model, writer);
  LOG.debug(writer.toString());
  byte[] body = Bytes.toBytes(writer.toString());
  Response response = client.put("/" + TABLE + "/scanner",
    Constants.MIMETYPE_XML, body);
  assertEquals(response.getCode(), 201);
  String scannerURI = response.getLocation();
  assertNotNull(scannerURI);

  // get a cell set
  response = client.get(scannerURI, Constants.MIMETYPE_XML);
  assertEquals(response.getCode(), 200);
  assertEquals(Constants.MIMETYPE_XML, response.getHeader("content-type"));
  CellSetModel cells = (CellSetModel)
    unmarshaller.unmarshal(new ByteArrayInputStream(response.getBody()));

  int rows = cells.getRows().size();
  assertTrue("Scanned too many rows! Only expected " + expectedRows + 
      " total but scanned " + rows, expectedRows == rows);
  for (RowModel row: cells.getRows()) {
    int count = row.getCells().size();
    assertEquals("Expected " + expectedKeys + " keys per row but " +
      "returned " + count, expectedKeys, count);
  }

  // delete the scanner
  response = client.delete(scannerURI);
  assertEquals(response.getCode(), 200);
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:35,代码来源:TestScannersWithFilters.java

示例2: verifyScan

import org.apache.hadoop.hbase.rest.model.ScannerModel; //导入方法依赖的package包/类
private static void verifyScan(Scan s, long expectedRows, long expectedKeys) 
    throws Exception {
  ScannerModel model = ScannerModel.fromScan(s);
  model.setBatch(Integer.MAX_VALUE); // fetch it all at once
  StringWriter writer = new StringWriter();
  marshaller.marshal(model, writer);
  LOG.debug(writer.toString());
  byte[] body = Bytes.toBytes(writer.toString());
  Response response = client.put("/" + TABLE + "/scanner", 
    Constants.MIMETYPE_XML, body);
  assertEquals(response.getCode(), 201);
  String scannerURI = response.getLocation();
  assertNotNull(scannerURI);

  // get a cell set
  response = client.get(scannerURI, Constants.MIMETYPE_XML);
  assertEquals(response.getCode(), 200);
  assertEquals(Constants.MIMETYPE_XML, response.getHeader("content-type"));
  CellSetModel cells = (CellSetModel)
    unmarshaller.unmarshal(new ByteArrayInputStream(response.getBody()));

  int rows = cells.getRows().size();
  assertTrue("Scanned too many rows! Only expected " + expectedRows + 
      " total but scanned " + rows, expectedRows == rows);
  for (RowModel row: cells.getRows()) {
    int count = row.getCells().size();
    assertEquals("Expected " + expectedKeys + " keys per row but " +
      "returned " + count, expectedKeys, count);
  }

  // delete the scanner
  response = client.delete(scannerURI);
  assertEquals(response.getCode(), 200);
}
 
开发者ID:fengchen8086,项目名称:LCIndex-HBase-0.94.16,代码行数:35,代码来源:TestScannersWithFilters.java

示例3: verifyScan

import org.apache.hadoop.hbase.rest.model.ScannerModel; //导入方法依赖的package包/类
private static void verifyScan(Scan s, long expectedRows, long expectedKeys)
    throws Exception {
  ScannerModel model = ScannerModel.fromScan(s);
  model.setBatch(Integer.MAX_VALUE); // fetch it all at once
  StringWriter writer = new StringWriter();
  marshaller.marshal(model, writer);
  LOG.debug(writer.toString());
  byte[] body = Bytes.toBytes(writer.toString());
  Response response = client.put("/" + TABLE + "/scanner",
    Constants.MIMETYPE_XML, body);
  assertEquals(201, response.getCode());
  String scannerURI = response.getLocation();
  assertNotNull(scannerURI);

  // get a cell set
  response = client.get(scannerURI, Constants.MIMETYPE_XML);
  assertEquals(200, response.getCode());
  assertEquals(Constants.MIMETYPE_XML, response.getHeader("content-type"));
  CellSetModel cells = (CellSetModel)
    unmarshaller.unmarshal(new ByteArrayInputStream(response.getBody()));

  int rows = cells.getRows().size();
  assertTrue("Scanned too many rows! Only expected " + expectedRows +
      " total but scanned " + rows, expectedRows == rows);
  for (RowModel row: cells.getRows()) {
    int count = row.getCells().size();
    assertEquals("Expected " + expectedKeys + " keys per row but " +
      "returned " + count, expectedKeys, count);
  }

  // delete the scanner
  response = client.delete(scannerURI);
  assertEquals(200, response.getCode());
}
 
开发者ID:apache,项目名称:hbase,代码行数:35,代码来源:TestScannersWithFilters.java

示例4: verifyScanFull

import org.apache.hadoop.hbase.rest.model.ScannerModel; //导入方法依赖的package包/类
private static void verifyScanFull(Scan s, KeyValue [] kvs) 
    throws Exception {
  ScannerModel model = ScannerModel.fromScan(s);
  model.setBatch(Integer.MAX_VALUE); // fetch it all at once
  StringWriter writer = new StringWriter();
  marshaller.marshal(model, writer);
  LOG.debug(writer.toString());
  byte[] body = Bytes.toBytes(writer.toString());
  Response response = client.put("/" + TABLE + "/scanner",
    Constants.MIMETYPE_XML, body);
  assertEquals(response.getCode(), 201);
  String scannerURI = response.getLocation();
  assertNotNull(scannerURI);

  // get a cell set
  response = client.get(scannerURI, Constants.MIMETYPE_XML);
  assertEquals(response.getCode(), 200);
  assertEquals(Constants.MIMETYPE_XML, response.getHeader("content-type"));
  CellSetModel cellSet = (CellSetModel)
    unmarshaller.unmarshal(new ByteArrayInputStream(response.getBody()));

  // delete the scanner
  response = client.delete(scannerURI);
  assertEquals(response.getCode(), 200);

  int row = 0;
  int idx = 0;
  Iterator<RowModel> i = cellSet.getRows().iterator();
  for (boolean done = true; done; row++) {
    done = i.hasNext();
    if (!done) break;
    RowModel rowModel = i.next();
    List<CellModel> cells = rowModel.getCells();
    if (cells.isEmpty()) break;
    assertTrue("Scanned too many keys! Only expected " + kvs.length + 
      " total but already scanned " + (cells.size() + idx), 
      kvs.length >= idx + cells.size());
    for (CellModel cell: cells) {
      assertTrue("Row mismatch", 
          Bytes.equals(rowModel.getKey(), kvs[idx].getRow()));
      byte[][] split = KeyValue.parseColumn(cell.getColumn());
      assertTrue("Family mismatch", 
          Bytes.equals(split[0], kvs[idx].getFamily()));
      assertTrue("Qualifier mismatch", 
          Bytes.equals(split[1], kvs[idx].getQualifier()));
      assertTrue("Value mismatch", 
          Bytes.equals(cell.getValue(), kvs[idx].getValue()));
      idx++;
    }
  }
  assertEquals("Expected " + kvs.length + " total keys but scanned " + idx,
    kvs.length, idx);
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:54,代码来源:TestScannersWithFilters.java

示例5: verifyScanNoEarlyOut

import org.apache.hadoop.hbase.rest.model.ScannerModel; //导入方法依赖的package包/类
private static void verifyScanNoEarlyOut(Scan s, long expectedRows,
    long expectedKeys) throws Exception {
  ScannerModel model = ScannerModel.fromScan(s);
  model.setBatch(Integer.MAX_VALUE); // fetch it all at once
  StringWriter writer = new StringWriter();
  marshaller.marshal(model, writer);
  LOG.debug(writer.toString());
  byte[] body = Bytes.toBytes(writer.toString());
  Response response = client.put("/" + TABLE + "/scanner", 
    Constants.MIMETYPE_XML, body);
  assertEquals(response.getCode(), 201);
  String scannerURI = response.getLocation();
  assertNotNull(scannerURI);

  // get a cell set
  response = client.get(scannerURI, Constants.MIMETYPE_XML);
  assertEquals(response.getCode(), 200);
  assertEquals(Constants.MIMETYPE_XML, response.getHeader("content-type"));
  CellSetModel cellSet = (CellSetModel)
    unmarshaller.unmarshal(new ByteArrayInputStream(response.getBody()));

  // delete the scanner
  response = client.delete(scannerURI);
  assertEquals(response.getCode(), 200);

  Iterator<RowModel> i = cellSet.getRows().iterator();
  int j = 0;
  for (boolean done = true; done; j++) {
    done = i.hasNext();
    if (!done) break;
    RowModel rowModel = i.next();
    List<CellModel> cells = rowModel.getCells();
    if (cells.isEmpty()) break;
    assertTrue("Scanned too many rows! Only expected " + expectedRows + 
      " total but already scanned " + (j+1), expectedRows > j);
    assertEquals("Expected " + expectedKeys + " keys per row but " +
      "returned " + cells.size(), expectedKeys, cells.size());
  }
  assertEquals("Expected " + expectedRows + " rows but scanned " + j +
    " rows", expectedRows, j);
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:42,代码来源:TestScannersWithFilters.java

示例6: verifyScanFull

import org.apache.hadoop.hbase.rest.model.ScannerModel; //导入方法依赖的package包/类
private static void verifyScanFull(Scan s, KeyValue [] kvs) 
    throws Exception {
  ScannerModel model = ScannerModel.fromScan(s);
  model.setBatch(Integer.MAX_VALUE); // fetch it all at once
  StringWriter writer = new StringWriter();
  marshaller.marshal(model, writer);
  LOG.debug(writer.toString());
  byte[] body = Bytes.toBytes(writer.toString());
  Response response = client.put("/" + TABLE + "/scanner", 
    Constants.MIMETYPE_XML, body);
  assertEquals(response.getCode(), 201);
  String scannerURI = response.getLocation();
  assertNotNull(scannerURI);

  // get a cell set
  response = client.get(scannerURI, Constants.MIMETYPE_XML);
  assertEquals(response.getCode(), 200);
  assertEquals(Constants.MIMETYPE_XML, response.getHeader("content-type"));
  CellSetModel cellSet = (CellSetModel)
    unmarshaller.unmarshal(new ByteArrayInputStream(response.getBody()));

  // delete the scanner
  response = client.delete(scannerURI);
  assertEquals(response.getCode(), 200);

  int row = 0;
  int idx = 0;
  Iterator<RowModel> i = cellSet.getRows().iterator();
  for (boolean done = true; done; row++) {
    done = i.hasNext();
    if (!done) break;
    RowModel rowModel = i.next();
    List<CellModel> cells = rowModel.getCells();
    if (cells.isEmpty()) break;
    assertTrue("Scanned too many keys! Only expected " + kvs.length + 
      " total but already scanned " + (cells.size() + idx), 
      kvs.length >= idx + cells.size());
    for (CellModel cell: cells) {
      assertTrue("Row mismatch", 
          Bytes.equals(rowModel.getKey(), kvs[idx].getRow()));
      byte[][] split = KeyValue.parseColumn(cell.getColumn());
      assertTrue("Family mismatch", 
          Bytes.equals(split[0], kvs[idx].getFamily()));
      assertTrue("Qualifier mismatch", 
          Bytes.equals(split[1], kvs[idx].getQualifier()));
      assertTrue("Value mismatch", 
          Bytes.equals(cell.getValue(), kvs[idx].getValue()));
      idx++;
    }
  }
  assertEquals("Expected " + kvs.length + " total keys but scanned " + idx,
    kvs.length, idx);
}
 
开发者ID:fengchen8086,项目名称:LCIndex-HBase-0.94.16,代码行数:54,代码来源:TestScannersWithFilters.java

示例7: verifyScanFull

import org.apache.hadoop.hbase.rest.model.ScannerModel; //导入方法依赖的package包/类
private static void verifyScanFull(Scan s, KeyValue [] kvs)
    throws Exception {
  ScannerModel model = ScannerModel.fromScan(s);
  model.setBatch(Integer.MAX_VALUE); // fetch it all at once
  StringWriter writer = new StringWriter();
  marshaller.marshal(model, writer);
  LOG.debug(writer.toString());
  byte[] body = Bytes.toBytes(writer.toString());
  Response response = client.put("/" + TABLE + "/scanner",
    Constants.MIMETYPE_XML, body);
  assertEquals(201, response.getCode());
  String scannerURI = response.getLocation();
  assertNotNull(scannerURI);

  // get a cell set
  response = client.get(scannerURI, Constants.MIMETYPE_XML);
  assertEquals(200, response.getCode());
  assertEquals(Constants.MIMETYPE_XML, response.getHeader("content-type"));
  CellSetModel cellSet = (CellSetModel)
    unmarshaller.unmarshal(new ByteArrayInputStream(response.getBody()));

  // delete the scanner
  response = client.delete(scannerURI);
  assertEquals(200, response.getCode());

  int row = 0;
  int idx = 0;
  Iterator<RowModel> i = cellSet.getRows().iterator();
  for (boolean done = true; done; row++) {
    done = i.hasNext();
    if (!done) break;
    RowModel rowModel = i.next();
    List<CellModel> cells = rowModel.getCells();
    if (cells.isEmpty()) break;
    assertTrue("Scanned too many keys! Only expected " + kvs.length +
      " total but already scanned " + (cells.size() + idx),
      kvs.length >= idx + cells.size());
    for (CellModel cell: cells) {
      assertTrue("Row mismatch",
          Bytes.equals(rowModel.getKey(), CellUtil.cloneRow(kvs[idx])));
      byte[][] split = CellUtil.parseColumn(cell.getColumn());
      assertTrue("Family mismatch",
          Bytes.equals(split[0], CellUtil.cloneFamily(kvs[idx])));
      assertTrue("Qualifier mismatch",
          Bytes.equals(split[1], CellUtil.cloneQualifier(kvs[idx])));
      assertTrue("Value mismatch",
          Bytes.equals(cell.getValue(), CellUtil.cloneValue(kvs[idx])));
      idx++;
    }
  }
  assertEquals("Expected " + kvs.length + " total keys but scanned " + idx,
    kvs.length, idx);
}
 
开发者ID:apache,项目名称:hbase,代码行数:54,代码来源:TestScannersWithFilters.java

示例8: verifyScanNoEarlyOut

import org.apache.hadoop.hbase.rest.model.ScannerModel; //导入方法依赖的package包/类
private static void verifyScanNoEarlyOut(Scan s, long expectedRows,
    long expectedKeys) throws Exception {
  ScannerModel model = ScannerModel.fromScan(s);
  model.setBatch(Integer.MAX_VALUE); // fetch it all at once
  StringWriter writer = new StringWriter();
  marshaller.marshal(model, writer);
  LOG.debug(writer.toString());
  byte[] body = Bytes.toBytes(writer.toString());
  Response response = client.put("/" + TABLE + "/scanner",
    Constants.MIMETYPE_XML, body);
  assertEquals(201, response.getCode());
  String scannerURI = response.getLocation();
  assertNotNull(scannerURI);

  // get a cell set
  response = client.get(scannerURI, Constants.MIMETYPE_XML);
  assertEquals(200, response.getCode());
  assertEquals(Constants.MIMETYPE_XML, response.getHeader("content-type"));
  CellSetModel cellSet = (CellSetModel)
    unmarshaller.unmarshal(new ByteArrayInputStream(response.getBody()));

  // delete the scanner
  response = client.delete(scannerURI);
  assertEquals(200, response.getCode());

  Iterator<RowModel> i = cellSet.getRows().iterator();
  int j = 0;
  for (boolean done = true; done; j++) {
    done = i.hasNext();
    if (!done) break;
    RowModel rowModel = i.next();
    List<CellModel> cells = rowModel.getCells();
    if (cells.isEmpty()) break;
    assertTrue("Scanned too many rows! Only expected " + expectedRows +
      " total but already scanned " + (j+1), expectedRows > j);
    assertEquals("Expected " + expectedKeys + " keys per row but " +
      "returned " + cells.size(), expectedKeys, cells.size());
  }
  assertEquals("Expected " + expectedRows + " rows but scanned " + j +
    " rows", expectedRows, j);
}
 
开发者ID:apache,项目名称:hbase,代码行数:42,代码来源:TestScannersWithFilters.java


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