org.apache.hadoop.hbase.client.Put.cellScanner()方法的使用及代码示例

x33g5p2x  于2022-01-26 转载在 其他  
字(6.0k)|赞(0)|评价(0)|浏览(161)

本文整理了Java中org.apache.hadoop.hbase.client.Put.cellScanner()方法的一些代码示例,展示了Put.cellScanner()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Put.cellScanner()方法的具体详情如下:
包路径:org.apache.hadoop.hbase.client.Put
类名称:Put
方法名:cellScanner

Put.cellScanner介绍

暂无

代码示例

代码示例来源:origin: apache/hive

@Override
 public void write(final DataOutput out)
 throws IOException {
  ProtobufUtil.toMutationNoData(MutationType.PUT, put).writeDelimitedTo(DataOutputOutputStream.from(out));
  out.writeInt(put.size());
  CellScanner scanner = put.cellScanner();
  while(scanner.advance()) {
   KeyValue kv = KeyValueUtil.ensureKeyValue(scanner.current());
   KeyValue.write(kv, out);
  }
 }
}

代码示例来源:origin: apache/hbase

@Test
public void testPutIteration() throws IOException {
 Put p = new Put(ROW);
 for (int i = 0; i < COUNT; i++) {
  byte [] bytes = Bytes.toBytes(i);
  p.addColumn(bytes, bytes, TIMESTAMP, bytes);
 }
 int index = 0;
 for (CellScanner cellScanner = p.cellScanner(); cellScanner.advance();) {
  Cell cell = cellScanner.current();
  byte [] bytes = Bytes.toBytes(index++);
  cell.equals(new KeyValue(ROW, bytes, bytes, TIMESTAMP, bytes));
 }
 assertEquals(COUNT, index);
}

代码示例来源:origin: apache/hbase

@Test (expected = ConcurrentModificationException.class)
public void testPutConcurrentModificationOnIteration() throws IOException {
 Put p = new Put(ROW);
 for (int i = 0; i < COUNT; i++) {
  byte [] bytes = Bytes.toBytes(i);
  p.addColumn(bytes, bytes, TIMESTAMP, bytes);
 }
 int index = 0;
 int trigger = 3;
 for (CellScanner cellScanner = p.cellScanner(); cellScanner.advance();) {
  Cell cell = cellScanner.current();
  byte [] bytes = Bytes.toBytes(index++);
  // When we hit the trigger, try inserting a new KV; should trigger exception
  if (trigger == 3) p.addColumn(bytes, bytes, TIMESTAMP, bytes);
  cell.equals(new KeyValue(ROW, bytes, bytes, TIMESTAMP, bytes));
 }
 assertEquals(COUNT, index);
}

代码示例来源:origin: apache/hbase

TableName.META_TABLE_NAME, System.currentTimeMillis(), mvcc, scopes);
WALEdit edit = new WALEdit();
CellScanner CellScanner = put.cellScanner();
assertTrue(CellScanner.advance());
edit.add(CellScanner.current());

代码示例来源:origin: apache/hbase

CellScanner cs = p.cellScanner();
while (cs.advance()) {
 edits.add(cs.current());

代码示例来源:origin: larsgeorge/hbase-book

public static void main(String[] args) throws Exception {
  // vv CellScannerExample
  Put put = new Put(Bytes.toBytes("testrow"));
  put.addColumn(Bytes.toBytes("fam-1"), Bytes.toBytes("qual-1"),
   Bytes.toBytes("val-1"));
  put.addColumn(Bytes.toBytes("fam-1"), Bytes.toBytes("qual-2"),
   Bytes.toBytes("val-2"));
  put.addColumn(Bytes.toBytes("fam-2"), Bytes.toBytes("qual-3"),
   Bytes.toBytes("val-3"));

  CellScanner scanner = put.cellScanner();
  while (scanner.advance()) {
   Cell cell = scanner.current();
   System.out.println("Cell: " + cell);
  }
  // ^^ CellScannerExample
 }
}

代码示例来源:origin: larsgeorge/hbase-book

@Override
public void postGetOp(ObserverContext<RegionCoprocessorEnvironment> e,
 Get get, List<Cell> results) throws IOException {
 Put put = new Put(get.getRow());
 put.addColumn(get.getRow(), FIXED_COLUMN, Bytes.toBytes(counter.get()));
 CellScanner scanner = put.cellScanner();
 scanner.advance();
 Cell cell = scanner.current();
 LOG.debug("Adding fake cell: " + cell);
 results.add(cell);
}

代码示例来源:origin: larsgeorge/hbase-book

CellScanner scanner = put.cellScanner();
while (scanner.advance()) {
 Cell cell = scanner.current();

代码示例来源:origin: larsgeorge/hbase-book

@Override
 public void preGetOp(ObserverContext<RegionCoprocessorEnvironment> e,
  Get get, List<Cell> results) throws IOException {
  // ^^ RegionObserverExample
  LOG.debug("Got preGet for row: " + Bytes.toStringBinary(get.getRow()));
  // vv RegionObserverExample
  if (Bytes.equals(get.getRow(), FIXED_ROW)) { // co RegionObserverExample-1-Check Check if the request row key matches a well known one.
   Put put = new Put(get.getRow());
   put.addColumn(FIXED_ROW, FIXED_ROW, // co RegionObserverExample-2-Cell Create cell indirectly using a Put instance.
    Bytes.toBytes(System.currentTimeMillis()));
   CellScanner scanner = put.cellScanner();
   scanner.advance();
   Cell cell = scanner.current(); // co RegionObserverExample-3-Current Get first cell from Put using the CellScanner instance.
   // ^^ RegionObserverExample
   LOG.debug("Had a match, adding fake cell: " + cell);
   // vv RegionObserverExample
   results.add(cell); // co RegionObserverExample-4-Create Create a special KeyValue instance containing just the current time on the server.
  }
 }
}

代码示例来源:origin: com.github.hyukjinkwon/hive-hbase-handler

@Override
 public void write(final DataOutput out)
 throws IOException {
  ProtobufUtil.toMutationNoData(MutationType.PUT, put).writeDelimitedTo(DataOutputOutputStream.from(out));
  out.writeInt(put.size());
  CellScanner scanner = put.cellScanner();
  while(scanner.advance()) {
   KeyValue kv = KeyValueUtil.ensureKeyValue(scanner.current());
   KeyValue.write(kv, out);
  }
 }
}

代码示例来源:origin: org.apache.hbase/hbase-server

@Test
public void testPutIteration() throws IOException {
 Put p = new Put(ROW);
 for (int i = 0; i < COUNT; i++) {
  byte [] bytes = Bytes.toBytes(i);
  p.addColumn(bytes, bytes, TIMESTAMP, bytes);
 }
 int index = 0;
 for (CellScanner cellScanner = p.cellScanner(); cellScanner.advance();) {
  Cell cell = cellScanner.current();
  byte [] bytes = Bytes.toBytes(index++);
  cell.equals(new KeyValue(ROW, bytes, bytes, TIMESTAMP, bytes));
 }
 assertEquals(COUNT, index);
}

代码示例来源:origin: org.apache.hbase/hbase-server

@Test (expected = ConcurrentModificationException.class)
public void testPutConcurrentModificationOnIteration() throws IOException {
 Put p = new Put(ROW);
 for (int i = 0; i < COUNT; i++) {
  byte [] bytes = Bytes.toBytes(i);
  p.addColumn(bytes, bytes, TIMESTAMP, bytes);
 }
 int index = 0;
 int trigger = 3;
 for (CellScanner cellScanner = p.cellScanner(); cellScanner.advance();) {
  Cell cell = cellScanner.current();
  byte [] bytes = Bytes.toBytes(index++);
  // When we hit the trigger, try inserting a new KV; should trigger exception
  if (trigger == 3) p.addColumn(bytes, bytes, TIMESTAMP, bytes);
  cell.equals(new KeyValue(ROW, bytes, bytes, TIMESTAMP, bytes));
 }
 assertEquals(COUNT, index);
}

代码示例来源:origin: org.apache.hbase/hbase-server

TableName.META_TABLE_NAME, System.currentTimeMillis(), mvcc, scopes);
WALEdit edit = new WALEdit();
CellScanner CellScanner = put.cellScanner();
assertTrue(CellScanner.advance());
edit.add(CellScanner.current());

代码示例来源:origin: org.apache.hbase/hbase-server

CellScanner cs = p.cellScanner();
while (cs.advance()) {
 edits.add(cs.current());

相关文章