本文整理汇总了Java中org.apache.hadoop.hbase.rest.model.CellSetModel.addRow方法的典型用法代码示例。如果您正苦于以下问题:Java CellSetModel.addRow方法的具体用法?Java CellSetModel.addRow怎么用?Java CellSetModel.addRow使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.hadoop.hbase.rest.model.CellSetModel
的用法示例。
在下文中一共展示了CellSetModel.addRow方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testInvalidCheckParam
import org.apache.hadoop.hbase.rest.model.CellSetModel; //导入方法依赖的package包/类
@Test
public void testInvalidCheckParam() throws IOException, JAXBException {
CellSetModel cellSetModel = new CellSetModel();
RowModel rowModel = new RowModel(ROW_1);
rowModel.addCell(new CellModel(Bytes.toBytes(COLUMN_1),
Bytes.toBytes(VALUE_1)));
cellSetModel.addRow(rowModel);
StringWriter writer = new StringWriter();
xmlMarshaller.marshal(cellSetModel, writer);
final String path = "/" + TABLE + "/" + ROW_1 + "/" + COLUMN_1 + "?check=blah";
Response response = client.put(path, Constants.MIMETYPE_XML,
Bytes.toBytes(writer.toString()));
assertEquals(response.getCode(), 400);
}
示例2: testInvalidColumnPut
import org.apache.hadoop.hbase.rest.model.CellSetModel; //导入方法依赖的package包/类
@Test
public void testInvalidColumnPut() throws IOException, JAXBException {
String dummyColumn = "doesnot:exist";
CellSetModel cellSetModel = new CellSetModel();
RowModel rowModel = new RowModel(ROW_1);
rowModel.addCell(new CellModel(Bytes.toBytes(dummyColumn),
Bytes.toBytes(VALUE_1)));
cellSetModel.addRow(rowModel);
StringWriter writer = new StringWriter();
xmlMarshaller.marshal(cellSetModel, writer);
final String path = "/" + TABLE + "/" + ROW_1 + "/" + dummyColumn;
Response response = client.put(path, Constants.MIMETYPE_XML,
Bytes.toBytes(writer.toString()));
assertEquals(response.getCode(), 404);
}
示例3: checkAndPutValuePB
import org.apache.hadoop.hbase.rest.model.CellSetModel; //导入方法依赖的package包/类
protected static Response checkAndPutValuePB(String url, String table,
String row, String column, String valueToCheck, String valueToPut, HashMap<String,String> otherCells)
throws IOException {
RowModel rowModel = new RowModel(row);
rowModel.addCell(new CellModel(Bytes.toBytes(column),
Bytes.toBytes(valueToPut)));
if(otherCells != null) {
for (Map.Entry<String,String> entry :otherCells.entrySet()) {
rowModel.addCell(new CellModel(Bytes.toBytes(entry.getKey()), Bytes.toBytes(entry.getValue())));
}
}
// This Cell need to be added as last cell.
rowModel.addCell(new CellModel(Bytes.toBytes(column),
Bytes.toBytes(valueToCheck)));
CellSetModel cellSetModel = new CellSetModel();
cellSetModel.addRow(rowModel);
Response response = client.put(url, Constants.MIMETYPE_PROTOBUF,
cellSetModel.createProtobufOutput());
Thread.yield();
return response;
}
示例4: checkAndPutValueXML
import org.apache.hadoop.hbase.rest.model.CellSetModel; //导入方法依赖的package包/类
protected static Response checkAndPutValueXML(String url, String table,
String row, String column, String valueToCheck, String valueToPut, HashMap<String,String> otherCells)
throws IOException, JAXBException {
RowModel rowModel = new RowModel(row);
rowModel.addCell(new CellModel(Bytes.toBytes(column),
Bytes.toBytes(valueToPut)));
if(otherCells != null) {
for (Map.Entry<String,String> entry :otherCells.entrySet()) {
rowModel.addCell(new CellModel(Bytes.toBytes(entry.getKey()), Bytes.toBytes(entry.getValue())));
}
}
// This Cell need to be added as last cell.
rowModel.addCell(new CellModel(Bytes.toBytes(column),
Bytes.toBytes(valueToCheck)));
CellSetModel cellSetModel = new CellSetModel();
cellSetModel.addRow(rowModel);
StringWriter writer = new StringWriter();
xmlMarshaller.marshal(cellSetModel, writer);
Response response = client.put(url, Constants.MIMETYPE_XML,
Bytes.toBytes(writer.toString()));
Thread.yield();
return response;
}
示例5: checkAndDeleteXML
import org.apache.hadoop.hbase.rest.model.CellSetModel; //导入方法依赖的package包/类
protected static Response checkAndDeleteXML(String url, String table,
String row, String column, String valueToCheck, HashMap<String,String> cellsToDelete)
throws IOException, JAXBException {
RowModel rowModel = new RowModel(row);
if(cellsToDelete != null) {
for (Map.Entry<String,String> entry :cellsToDelete.entrySet()) {
rowModel.addCell(new CellModel(Bytes.toBytes(entry.getKey()), Bytes.toBytes(entry.getValue())));
}
}
// Add this at the end
rowModel.addCell(new CellModel(Bytes.toBytes(column),
Bytes.toBytes(valueToCheck)));
CellSetModel cellSetModel = new CellSetModel();
cellSetModel.addRow(rowModel);
StringWriter writer = new StringWriter();
xmlMarshaller.marshal(cellSetModel, writer);
Response response = client.put(url, Constants.MIMETYPE_XML,
Bytes.toBytes(writer.toString()));
Thread.yield();
return response;
}
示例6: checkAndDeleteJson
import org.apache.hadoop.hbase.rest.model.CellSetModel; //导入方法依赖的package包/类
protected static Response checkAndDeleteJson(String url, String table,
String row, String column, String valueToCheck, HashMap<String,String> cellsToDelete)
throws IOException, JAXBException {
RowModel rowModel = new RowModel(row);
if(cellsToDelete != null) {
for (Map.Entry<String,String> entry :cellsToDelete.entrySet()) {
rowModel.addCell(new CellModel(Bytes.toBytes(entry.getKey()), Bytes.toBytes(entry.getValue())));
}
}
// Add this at the end
rowModel.addCell(new CellModel(Bytes.toBytes(column),
Bytes.toBytes(valueToCheck)));
CellSetModel cellSetModel = new CellSetModel();
cellSetModel.addRow(rowModel);
String jsonString = jsonMapper.writeValueAsString(cellSetModel);
Response response = client.put(url, Constants.MIMETYPE_JSON,
Bytes.toBytes(jsonString));
Thread.yield();
return response;
}
示例7: checkAndDeleteValuePB
import org.apache.hadoop.hbase.rest.model.CellSetModel; //导入方法依赖的package包/类
protected static Response checkAndDeleteValuePB(String url, String table,
String row, String column, String valueToCheck, HashMap<String,String> cellsToDelete)
throws IOException {
RowModel rowModel = new RowModel(row);
if(cellsToDelete != null) {
for (Map.Entry<String,String> entry :cellsToDelete.entrySet()) {
rowModel.addCell(new CellModel(Bytes.toBytes(entry.getKey()), Bytes.toBytes(entry.getValue())));
}
}
// Add this at the end
rowModel.addCell(new CellModel(Bytes.toBytes(column), Bytes
.toBytes(valueToCheck)));
CellSetModel cellSetModel = new CellSetModel();
cellSetModel.addRow(rowModel);
Response response = client.put(url, Constants.MIMETYPE_PROTOBUF,
cellSetModel.createProtobufOutput());
Thread.yield();
return response;
}
示例8: checkAndPutValueXML
import org.apache.hadoop.hbase.rest.model.CellSetModel; //导入方法依赖的package包/类
private static Response checkAndPutValueXML(String url, String table,
String row, String column, String valueToCheck, String valueToPut)
throws IOException, JAXBException {
RowModel rowModel = new RowModel(row);
rowModel.addCell(new CellModel(Bytes.toBytes(column),
Bytes.toBytes(valueToPut)));
rowModel.addCell(new CellModel(Bytes.toBytes(column),
Bytes.toBytes(valueToCheck)));
CellSetModel cellSetModel = new CellSetModel();
cellSetModel.addRow(rowModel);
StringWriter writer = new StringWriter();
marshaller.marshal(cellSetModel, writer);
Response response = client.put(url, Constants.MIMETYPE_XML,
Bytes.toBytes(writer.toString()));
Thread.yield();
return response;
}
示例9: testInvalidCheckParam
import org.apache.hadoop.hbase.rest.model.CellSetModel; //导入方法依赖的package包/类
@Test
public void testInvalidCheckParam() throws IOException, JAXBException {
CellSetModel cellSetModel = new CellSetModel();
RowModel rowModel = new RowModel(ROW_1);
rowModel.addCell(new CellModel(Bytes.toBytes(COLUMN_1),
Bytes.toBytes(VALUE_1)));
cellSetModel.addRow(rowModel);
StringWriter writer = new StringWriter();
marshaller.marshal(cellSetModel, writer);
final String path = "/" + TABLE + "/" + ROW_1 + "/" + COLUMN_1 + "?check=blah";
Response response = client.put(path, Constants.MIMETYPE_XML,
Bytes.toBytes(writer.toString()));
assertEquals(response.getCode(), 400);
}
示例10: checkAndPutValueXML
import org.apache.hadoop.hbase.rest.model.CellSetModel; //导入方法依赖的package包/类
protected static Response checkAndPutValueXML(String url, String table,
String row, String column, String valueToCheck, String valueToPut)
throws IOException, JAXBException {
RowModel rowModel = new RowModel(row);
rowModel.addCell(new CellModel(Bytes.toBytes(column),
Bytes.toBytes(valueToPut)));
rowModel.addCell(new CellModel(Bytes.toBytes(column),
Bytes.toBytes(valueToCheck)));
CellSetModel cellSetModel = new CellSetModel();
cellSetModel.addRow(rowModel);
StringWriter writer = new StringWriter();
xmlMarshaller.marshal(cellSetModel, writer);
Response response = client.put(url, Constants.MIMETYPE_XML,
Bytes.toBytes(writer.toString()));
Thread.yield();
return response;
}
示例11: testInvalidColumnPut
import org.apache.hadoop.hbase.rest.model.CellSetModel; //导入方法依赖的package包/类
@Test
public void testInvalidColumnPut() throws IOException, JAXBException {
String dummyColumn = "doesnot:exist";
CellSetModel cellSetModel = new CellSetModel();
RowModel rowModel = new RowModel(ROW_1);
rowModel.addCell(new CellModel(Bytes.toBytes(dummyColumn),
Bytes.toBytes(VALUE_1)));
cellSetModel.addRow(rowModel);
StringWriter writer = new StringWriter();
xmlMarshaller.marshal(cellSetModel, writer);
final String path = "/" + TABLE + "/" + ROW_1 + "/" + dummyColumn;
Response response = client.put(path, Constants.MIMETYPE_XML,
Bytes.toBytes(writer.toString()));
assertEquals(404, response.getCode());
}
示例12: createModelFromResults
import org.apache.hadoop.hbase.rest.model.CellSetModel; //导入方法依赖的package包/类
private CellSetModel createModelFromResults(Result[] results) {
CellSetModel cellSetModel = new CellSetModel();
for (Result rs : results) {
byte[] rowKey = rs.getRow();
RowModel rModel = new RowModel(rowKey);
List<Cell> kvs = rs.listCells();
for (Cell kv : kvs) {
rModel.addCell(new CellModel(CellUtil.cloneFamily(kv), CellUtil.cloneQualifier(kv), kv
.getTimestamp(), CellUtil.cloneValue(kv)));
}
cellSetModel.addRow(rModel);
}
return cellSetModel;
}
示例13: buildModelFromPut
import org.apache.hadoop.hbase.rest.model.CellSetModel; //导入方法依赖的package包/类
protected CellSetModel buildModelFromPut(Put put) {
RowModel row = new RowModel(put.getRow());
long ts = put.getTimeStamp();
for (List<Cell> cells: put.getFamilyCellMap().values()) {
for (Cell cell: cells) {
row.addCell(new CellModel(CellUtil.cloneFamily(cell), CellUtil.cloneQualifier(cell),
ts != HConstants.LATEST_TIMESTAMP ? ts : cell.getTimestamp(),
CellUtil.cloneValue(cell)));
}
}
CellSetModel model = new CellSetModel();
model.addRow(row);
return model;
}
示例14: testLatestCellGetJSON
import org.apache.hadoop.hbase.rest.model.CellSetModel; //导入方法依赖的package包/类
@Test
public void testLatestCellGetJSON() throws IOException, JAXBException {
final String path = "/" + TABLE + "/" + ROW_4 + "/" + COLUMN_1;
CellSetModel cellSetModel = new CellSetModel();
RowModel rowModel = new RowModel(ROW_4);
CellModel cellOne = new CellModel(Bytes.toBytes(COLUMN_1), 1L,
Bytes.toBytes(VALUE_1));
CellModel cellTwo = new CellModel(Bytes.toBytes(COLUMN_1), 2L,
Bytes.toBytes(VALUE_2));
rowModel.addCell(cellOne);
rowModel.addCell(cellTwo);
cellSetModel.addRow(rowModel);
String jsonString = jsonMapper.writeValueAsString(cellSetModel);
Response response = client.put(path, Constants.MIMETYPE_JSON,
Bytes.toBytes(jsonString));
assertEquals(response.getCode(), 200);
Thread.yield();
response = client.get(path, Constants.MIMETYPE_JSON);
assertEquals(response.getCode(), 200);
assertEquals(Constants.MIMETYPE_JSON, response.getHeader("content-type"));
CellSetModel cellSet = jsonMapper.readValue(response.getBody(), CellSetModel.class);
assertTrue(cellSet.getRows().size() == 1);
assertTrue(cellSet.getRows().get(0).getCells().size() == 1);
CellModel cell = cellSet.getRows().get(0).getCells().get(0);
assertEquals(VALUE_2 , Bytes.toString(cell.getValue()));
assertEquals(2L , cell.getTimestamp());
response = deleteRow(TABLE, ROW_4);
assertEquals(response.getCode(), 200);
}
示例15: testMultiColumnGetXML
import org.apache.hadoop.hbase.rest.model.CellSetModel; //导入方法依赖的package包/类
@Test
public void testMultiColumnGetXML() throws Exception {
String path = "/" + TABLE + "/fakerow";
CellSetModel cellSetModel = new CellSetModel();
RowModel rowModel = new RowModel(ROW_1);
rowModel.addCell(new CellModel(Bytes.toBytes(COLUMN_1), Bytes.toBytes(VALUE_1)));
rowModel.addCell(new CellModel(Bytes.toBytes(COLUMN_2), Bytes.toBytes(VALUE_2)));
rowModel.addCell(new CellModel(Bytes.toBytes(COLUMN_3), Bytes.toBytes(VALUE_2)));
cellSetModel.addRow(rowModel);
StringWriter writer = new StringWriter();
xmlMarshaller.marshal(cellSetModel, writer);
Response response = client.put(path, Constants.MIMETYPE_XML, Bytes.toBytes(writer.toString()));
Thread.yield();
// make sure the fake row was not actually created
response = client.get(path, Constants.MIMETYPE_XML);
assertEquals(response.getCode(), 404);
// Try getting all the column values at once.
path = "/" + TABLE + "/" + ROW_1 + "/" + COLUMN_1 + "," + COLUMN_2 + "," + COLUMN_3;
response = client.get(path, Constants.MIMETYPE_XML);
assertEquals(200, response.getCode());
CellSetModel cellSet = (CellSetModel) xmlUnmarshaller.unmarshal(new ByteArrayInputStream(response
.getBody()));
assertTrue(cellSet.getRows().size() == 1);
assertTrue(cellSet.getRows().get(0).getCells().size() == 3);
List<CellModel> cells = cellSet.getRows().get(0).getCells();
assertTrue(containsCellModel(cells, COLUMN_1, VALUE_1));
assertTrue(containsCellModel(cells, COLUMN_2, VALUE_2));
assertTrue(containsCellModel(cells, COLUMN_3, VALUE_2));
response = deleteRow(TABLE, ROW_1);
assertEquals(response.getCode(), 200);
}