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


Java RowModel类代码示例

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


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

示例1: buildResultFromModel

import org.apache.hadoop.hbase.rest.model.RowModel; //导入依赖的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()]);
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:23,代码来源:RemoteHTable.java

示例2: setUpBeforeClass

import org.apache.hadoop.hbase.rest.model.RowModel; //导入依赖的package包/类
@BeforeClass
public static void setUpBeforeClass() throws Exception {
  conf = TEST_UTIL.getConfiguration();
  TEST_UTIL.startMiniCluster();
  REST_TEST_UTIL.startServletContainer(conf);
  client = new Client(new Cluster().add("localhost",
    REST_TEST_UTIL.getServletPort()));
  context = JAXBContext.newInstance(
    CellModel.class,
    CellSetModel.class,
    RowModel.class,
    ScannerModel.class);
  marshaller = context.createMarshaller();
  unmarshaller = context.createUnmarshaller();
  Admin admin = TEST_UTIL.getHBaseAdmin();
  if (admin.tableExists(TABLE)) {
    return;
  }
  HTableDescriptor htd = new HTableDescriptor(TABLE);
  htd.addFamily(new HColumnDescriptor(CFA));
  htd.addFamily(new HColumnDescriptor(CFB));
  admin.createTable(htd);
  expectedRows1 = insertData(TEST_UTIL.getConfiguration(), TABLE, COLUMN_1, 1.0);
  expectedRows2 = insertData(TEST_UTIL.getConfiguration(), TABLE, COLUMN_2, 0.5);
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:26,代码来源:TestScannerResource.java

示例3: setUpBeforeClass

import org.apache.hadoop.hbase.rest.model.RowModel; //导入依赖的package包/类
@BeforeClass
public static void setUpBeforeClass() throws Exception {
  conf = TEST_UTIL.getConfiguration();
  TEST_UTIL.startMiniCluster();
  REST_TEST_UTIL.startServletContainer(conf);
  context = JAXBContext.newInstance(
          CellModel.class,
          CellSetModel.class,
          RowModel.class);
  marshaller = context.createMarshaller();
  unmarshaller = context.createUnmarshaller();
  client = new Client(new Cluster().add("localhost", REST_TEST_UTIL.getServletPort()));
  Admin admin = TEST_UTIL.getHBaseAdmin();
  if (admin.tableExists(TABLE)) {
    return;
  }
  HTableDescriptor htd = new HTableDescriptor(TABLE);
  htd.addFamily(new HColumnDescriptor(CFA));
  htd.addFamily(new HColumnDescriptor(CFB));
  admin.createTable(htd);
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:22,代码来源:TestMultiRowResource.java

示例4: testInvalidCheckParam

import org.apache.hadoop.hbase.rest.model.RowModel; //导入依赖的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);
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:17,代码来源:TestGetAndPutResource.java

示例5: testInvalidColumnPut

import org.apache.hadoop.hbase.rest.model.RowModel; //导入依赖的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);
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:18,代码来源:TestGetAndPutResource.java

示例6: setUpBeforeClass

import org.apache.hadoop.hbase.rest.model.RowModel; //导入依赖的package包/类
@BeforeClass
public static void setUpBeforeClass() throws Exception {
  conf = TEST_UTIL.getConfiguration();
  TEST_UTIL.startMiniCluster(3);
  REST_TEST_UTIL.startServletContainer(conf);
  context = JAXBContext.newInstance(
      CellModel.class,
      CellSetModel.class,
      RowModel.class);
  xmlMarshaller = context.createMarshaller();
  xmlUnmarshaller = context.createUnmarshaller();
  jsonMapper = new JacksonProvider()
  .locateMapper(CellSetModel.class, MediaType.APPLICATION_JSON_TYPE);
  client = new Client(new Cluster().add("localhost",
    REST_TEST_UTIL.getServletPort()));
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:17,代码来源:RowResourceBase.java

示例7: checkAndPutValuePB

import org.apache.hadoop.hbase.rest.model.RowModel; //导入依赖的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;
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:25,代码来源:RowResourceBase.java

示例8: checkAndPutValueXML

import org.apache.hadoop.hbase.rest.model.RowModel; //导入依赖的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;
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:26,代码来源:RowResourceBase.java

示例9: checkAndDeleteXML

import org.apache.hadoop.hbase.rest.model.RowModel; //导入依赖的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;
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:23,代码来源:RowResourceBase.java

示例10: checkAndDeleteJson

import org.apache.hadoop.hbase.rest.model.RowModel; //导入依赖的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;
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:22,代码来源:RowResourceBase.java

示例11: checkAndDeleteValuePB

import org.apache.hadoop.hbase.rest.model.RowModel; //导入依赖的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;
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:21,代码来源:RowResourceBase.java

示例12: setUpBeforeClass

import org.apache.hadoop.hbase.rest.model.RowModel; //导入依赖的package包/类
@BeforeClass
public static void setUpBeforeClass() throws Exception {
  conf = TEST_UTIL.getConfiguration();
  TEST_UTIL.startMiniCluster();
  REST_TEST_UTIL.startServletContainer(conf);
  client = new Client(new Cluster().add("localhost",
    REST_TEST_UTIL.getServletPort()));
  context = JAXBContext.newInstance(
    CellModel.class,
    CellSetModel.class,
    RowModel.class,
    ScannerModel.class);
  marshaller = context.createMarshaller();
  unmarshaller = context.createUnmarshaller();
  HBaseAdmin admin = TEST_UTIL.getHBaseAdmin();
  if (admin.tableExists(TABLE)) {
    return;
  }
  HTableDescriptor htd = new HTableDescriptor(TABLE);
  htd.addFamily(new HColumnDescriptor(CFA));
  htd.addFamily(new HColumnDescriptor(CFB));
  admin.createTable(htd);
  expectedRows1 = insertData(TABLE, COLUMN_1, 1.0);
  expectedRows2 = insertData(TABLE, COLUMN_2, 0.5);
}
 
开发者ID:fengchen8086,项目名称:LCIndex-HBase-0.94.16,代码行数:26,代码来源:TestScannerResource.java

示例13: setUpBeforeClass

import org.apache.hadoop.hbase.rest.model.RowModel; //导入依赖的package包/类
@BeforeClass
public static void setUpBeforeClass() throws Exception {
  conf = TEST_UTIL.getConfiguration();
  TEST_UTIL.startMiniCluster();
  REST_TEST_UTIL.startServletContainer(conf);
  context = JAXBContext.newInstance(
          CellModel.class,
          CellSetModel.class,
          RowModel.class);
  marshaller = context.createMarshaller();
  unmarshaller = context.createUnmarshaller();
  client = new Client(new Cluster().add("localhost", REST_TEST_UTIL.getServletPort()));
  HBaseAdmin admin = TEST_UTIL.getHBaseAdmin();
  if (admin.tableExists(TABLE)) {
    return;
  }
  HTableDescriptor htd = new HTableDescriptor(TABLE);
  htd.addFamily(new HColumnDescriptor(CFA));
  htd.addFamily(new HColumnDescriptor(CFB));
  admin.createTable(htd);
}
 
开发者ID:fengchen8086,项目名称:LCIndex-HBase-0.94.16,代码行数:22,代码来源:TestMultiRowResource.java

示例14: setUpBeforeClass

import org.apache.hadoop.hbase.rest.model.RowModel; //导入依赖的package包/类
@BeforeClass
public static void setUpBeforeClass() throws Exception {
  conf = TEST_UTIL.getConfiguration();
  TEST_UTIL.startMiniCluster(3);
  REST_TEST_UTIL.startServletContainer(conf);
  context = JAXBContext.newInstance(
      CellModel.class,
      CellSetModel.class,
      RowModel.class);
  marshaller = context.createMarshaller();
  unmarshaller = context.createUnmarshaller();
  client = new Client(new Cluster().add("localhost", 
    REST_TEST_UTIL.getServletPort()));
  HBaseAdmin admin = TEST_UTIL.getHBaseAdmin();
  if (admin.tableExists(TABLE)) {
    return;
  }
  HTableDescriptor htd = new HTableDescriptor(TABLE);
  htd.addFamily(new HColumnDescriptor(CFA));
  htd.addFamily(new HColumnDescriptor(CFB));
  admin.createTable(htd);
}
 
开发者ID:fengchen8086,项目名称:LCIndex-HBase-0.94.16,代码行数:23,代码来源:TestRowResource.java

示例15: checkAndPutValueXML

import org.apache.hadoop.hbase.rest.model.RowModel; //导入依赖的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;
}
 
开发者ID:fengchen8086,项目名称:LCIndex-HBase-0.94.16,代码行数:18,代码来源:TestRowResource.java


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