本文整理汇总了Java中org.apache.hadoop.hbase.rest.model.CellSetModel.getRows方法的典型用法代码示例。如果您正苦于以下问题:Java CellSetModel.getRows方法的具体用法?Java CellSetModel.getRows怎么用?Java CellSetModel.getRows使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.hadoop.hbase.rest.model.CellSetModel
的用法示例。
在下文中一共展示了CellSetModel.getRows方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: buildResultFromModel
import org.apache.hadoop.hbase.rest.model.CellSetModel; //导入方法依赖的package包/类
protected Result[] buildResultFromModel(final CellSetModel model) {
List<Result> results = new ArrayList<Result>();
for (RowModel row: model.getRows()) {
List<Cell> kvs = new ArrayList<Cell>();
for (CellModel cell: row.getCells()) {
byte[][] split = KeyValue.parseColumn(cell.getColumn());
byte[] column = split[0];
byte[] qualifier = null;
if (split.length == 1) {
qualifier = HConstants.EMPTY_BYTE_ARRAY;
} else if (split.length == 2) {
qualifier = split[1];
} else {
throw new IllegalArgumentException("Invalid familyAndQualifier provided.");
}
kvs.add(new KeyValue(row.getKey(), column, qualifier,
cell.getTimestamp(), cell.getValue()));
}
results.add(Result.create(kvs));
}
return results.toArray(new Result[results.size()]);
}
示例2: buildResultFromModel
import org.apache.hadoop.hbase.rest.model.CellSetModel; //导入方法依赖的package包/类
protected Result[] buildResultFromModel(final CellSetModel model) {
List<Result> results = new ArrayList<>();
for (RowModel row: model.getRows()) {
List<Cell> kvs = new ArrayList<>(row.getCells().size());
for (CellModel cell: row.getCells()) {
byte[][] split = CellUtil.parseColumn(cell.getColumn());
byte[] column = split[0];
byte[] qualifier = null;
if (split.length == 1) {
qualifier = HConstants.EMPTY_BYTE_ARRAY;
} else if (split.length == 2) {
qualifier = split[1];
} else {
throw new IllegalArgumentException("Invalid familyAndQualifier provided.");
}
kvs.add(new KeyValue(row.getKey(), column, qualifier,
cell.getTimestamp(), cell.getValue()));
}
results.add(Result.create(kvs));
}
return results.toArray(new Result[results.size()]);
}
示例3: verifyScan
import org.apache.hadoop.hbase.rest.model.CellSetModel; //导入方法依赖的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);
}
示例4: buildResultFromModel
import org.apache.hadoop.hbase.rest.model.CellSetModel; //导入方法依赖的package包/类
protected Result[] buildResultFromModel(final CellSetModel model) {
List<Result> results = new ArrayList<Result>();
for (RowModel row: model.getRows()) {
List<KeyValue> kvs = new ArrayList<KeyValue>();
for (CellModel cell: row.getCells()) {
byte[][] split = KeyValue.parseColumn(cell.getColumn());
byte[] column = split[0];
byte[] qualifier = split.length > 1 ? split[1] : null;
kvs.add(new KeyValue(row.getKey(), column, qualifier,
cell.getTimestamp(), cell.getValue()));
}
results.add(new Result(kvs));
}
return results.toArray(new Result[results.size()]);
}
示例5: verifyScan
import org.apache.hadoop.hbase.rest.model.CellSetModel; //导入方法依赖的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);
}
示例6: verifyScan
import org.apache.hadoop.hbase.rest.model.CellSetModel; //导入方法依赖的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());
}
示例7: checkRowsNotNull
import org.apache.hadoop.hbase.rest.model.CellSetModel; //导入方法依赖的package包/类
private void checkRowsNotNull(CellSetModel model) {
for (RowModel row: model.getRows()) {
assertTrue(row.getKey() != null);
assertTrue(row.getCells().size() > 0);
}
}