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


Java Tag.asList方法代码示例

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


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

示例1: doAssert

import org.apache.hadoop.hbase.Tag; //导入方法依赖的package包/类
protected static void doAssert(byte[] row, String visTag) throws Exception {
  if (VisibilityReplicationEndPointForTest.lastEntries == null) {
    return; // first call
  }
  Assert.assertEquals(1, VisibilityReplicationEndPointForTest.lastEntries.size());
  List<Cell> cells = VisibilityReplicationEndPointForTest.lastEntries.get(0).getEdit().getCells();
  Assert.assertEquals(4, cells.size());
  boolean tagFound = false;
  for (Cell cell : cells) {
    if ((Bytes.equals(cell.getRowArray(), cell.getRowOffset(), cell.getRowLength(), row, 0,
        row.length))) {
      List<Tag> tags = Tag
          .asList(cell.getTagsArray(), cell.getTagsOffset(), cell.getTagsLength());
      for (Tag tag : tags) {
        if (tag.getType() == TagType.STRING_VIS_TAG_TYPE) {
          assertEquals(visTag, Bytes.toString(tag.getValue()));
          tagFound = true;
          break;
        }
      }
    }
  }
  assertTrue(tagFound);
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:25,代码来源:TestVisibilityLabelsReplication.java

示例2: postScannerNext

import org.apache.hadoop.hbase.Tag; //导入方法依赖的package包/类
@Override
public boolean postScannerNext(ObserverContext<RegionCoprocessorEnvironment> e,
    InternalScanner s, List<Result> results, int limit, boolean hasMore) throws IOException {
  if (checkTagPresence) {
    if (results.size() > 0) {
      // Check tag presence in the 1st cell in 1st Result
      Result result = results.get(0);
      CellScanner cellScanner = result.cellScanner();
      if (cellScanner.advance()) {
        Cell cell = cellScanner.current();
        tags = Tag.asList(cell.getTagsArray(), cell.getTagsOffset(),
            cell.getTagsLength());
      }
    }
  }
  return hasMore;
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:18,代码来源:TestTags.java

示例3: cellToStringMap

import org.apache.hadoop.hbase.Tag; //导入方法依赖的package包/类
private static Map<String, Object> cellToStringMap(Cell c) {
  Map<String, Object> stringMap = new HashMap<String, Object>();
  stringMap.put("qualifier", Bytes.toStringBinary(c.getQualifierArray(), c.getQualifierOffset(),
              c.getQualifierLength()));
  stringMap.put("timestamp", c.getTimestamp());
  stringMap.put("vlen", c.getValueLength());
  List<Tag> tags = Tag.asList(c.getTagsArray(), c.getTagsOffset(), c.getTagsLength());
  if (tags != null) {
    List<String> tagsString = new ArrayList<String>();
    for (Tag t : tags) {
      tagsString.add((t.getType()) + ":" + Bytes.toStringBinary(t.getValue()));
    }
    stringMap.put("tag", tagsString);
  }
  return stringMap;
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:17,代码来源:Mutation.java

示例4: cellToStringMap

import org.apache.hadoop.hbase.Tag; //导入方法依赖的package包/类
private static Map<String, Object> cellToStringMap(Cell c) {
    Map<String, Object> stringMap = new HashMap<String, Object>();
    stringMap.put("qualifier", Bytes.toStringBinary(c.getQualifierArray(), c.getQualifierOffset(),
            c.getQualifierLength()));
    stringMap.put("timestamp", c.getTimestamp());
    stringMap.put("vlen", c.getValueLength());
    List<Tag> tags = Tag.asList(c.getTagsArray(), c.getTagsOffset(), c.getTagsLength());
    if (tags != null) {
        List<String> tagsString = new ArrayList<String>();
        for (Tag t : tags) {
            tagsString.add((t.getType()) + ":" + Bytes.toStringBinary(t.getValue()));
        }
        stringMap.put("tag", tagsString);
    }
    return stringMap;
}
 
开发者ID:grokcoder,项目名称:pbase,代码行数:17,代码来源:Mutation.java

示例5: postScannerNext

import org.apache.hadoop.hbase.Tag; //导入方法依赖的package包/类
@Override
public boolean postScannerNext(ObserverContext<RegionCoprocessorEnvironment> e,
    InternalScanner s, List<Result> results, int limit, boolean hasMore) throws IOException {
  if (checkTagPresence) {
    if (results.size() > 0) {
      // Check tag presence in the 1st cell in 1st Result
      Result result = results.get(0);
      CellScanner cellScanner = result.cellScanner();
      if (cellScanner.advance()) {
        Cell cell = cellScanner.current();
        tags = Tag.asList(cell.getTagsArray(), cell.getTagsOffset(), cell.getTagsLength());
      }
    }
  }
  return hasMore;
}
 
开发者ID:tenggyut,项目名称:HIndex,代码行数:17,代码来源:TestTags.java

示例6: postGetOp

import org.apache.hadoop.hbase.Tag; //导入方法依赖的package包/类
@Override
public void postGetOp(ObserverContext<RegionCoprocessorEnvironment> e, Get get,
    List<Cell> results) throws IOException {
  if (results.size() > 0) {
    // Check tag presence in the 1st cell in 1st Result
    if (!results.isEmpty()) {
      Cell cell = results.get(0);
      tags = Tag.asList(cell.getTagsArray(), cell.getTagsOffset(), cell.getTagsLength());
    }
  }
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:12,代码来源:TestReplicationWithTags.java

示例7: scanKeysValues

import org.apache.hadoop.hbase.Tag; //导入方法依赖的package包/类
private void scanKeysValues(Path file, KeyValueStatsCollector fileStats,
    HFileScanner scanner,  byte[] row) throws IOException {
  Cell pCell = null;
  do {
    Cell cell = scanner.getKeyValue();
    if (row != null && row.length != 0) {
      int result = CellComparator.compareRows(cell.getRowArray(), cell.getRowOffset(),
          cell.getRowLength(), row, 0, row.length);
      if (result > 0) {
        break;
      } else if (result < 0) {
        continue;
      }
    }
    // collect stats
    if (printStats) {
      fileStats.collect(cell);
    }
    // dump key value
    if (printKey) {
      System.out.print("K: " + cell);
      if (printValue) {
        System.out.print(" V: "
            + Bytes.toStringBinary(cell.getValueArray(), cell.getValueOffset(),
                cell.getValueLength()));
        int i = 0;
        List<Tag> tags = Tag.asList(cell.getTagsArray(), cell.getTagsOffset(),
            cell.getTagsLength());
        for (Tag tag : tags) {
          System.out.print(String.format(" T[%d]: %s", i++,
              Bytes.toStringBinary(tag.getBuffer(), tag.getTagOffset(), tag.getTagLength())));
        }
      }
      System.out.println();
    }
    // check if rows are in order
    if (checkRow && pCell != null) {
      if (CellComparator.compareRows(pCell, cell) > 0) {
        System.err.println("WARNING, previous row is greater then"
            + " current row\n\tfilename -> " + file + "\n\tprevious -> "
            + CellUtil.getCellKeyAsString(pCell) + "\n\tcurrent  -> "
            + CellUtil.getCellKeyAsString(cell));
      }
    }
    // check if families are consistent
    if (checkFamily) {
      String fam = Bytes.toString(cell.getFamilyArray(), cell.getFamilyOffset(),
          cell.getFamilyLength());
      if (!file.toString().contains(fam)) {
        System.err.println("WARNING, filename does not match kv family,"
            + "\n\tfilename -> " + file + "\n\tkeyvalue -> "
            + CellUtil.getCellKeyAsString(cell));
      }
      if (pCell != null && CellComparator.compareFamilies(pCell, cell) != 0) {
        System.err.println("WARNING, previous kv has different family"
            + " compared to current key\n\tfilename -> " + file
            + "\n\tprevious -> " + CellUtil.getCellKeyAsString(pCell)
            + "\n\tcurrent  -> " + CellUtil.getCellKeyAsString(cell));
      }
    }
    pCell = cell;
    ++count;
  } while (scanner.next());
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:65,代码来源:HFilePrettyPrinter.java

示例8: testCellWithTag

import org.apache.hadoop.hbase.Tag; //导入方法依赖的package包/类
@Test
public void testCellWithTag() throws IOException {
  ByteArrayOutputStream baos = new ByteArrayOutputStream();
  CountingOutputStream cos = new CountingOutputStream(baos);
  DataOutputStream dos = new DataOutputStream(cos);
  Codec codec = new CellCodecWithTags();
  Codec.Encoder encoder = codec.getEncoder(dos);
  final Cell cell1 = new KeyValue(Bytes.toBytes("r"), Bytes.toBytes("f"), Bytes.toBytes("1"),
      HConstants.LATEST_TIMESTAMP, Bytes.toBytes("1"), new Tag[] {
          new Tag((byte) 1, Bytes.toBytes("teststring1")),
          new Tag((byte) 2, Bytes.toBytes("teststring2")) });
  final Cell cell2 = new KeyValue(Bytes.toBytes("r"), Bytes.toBytes("f"), Bytes.toBytes("2"),
      HConstants.LATEST_TIMESTAMP, Bytes.toBytes("2"), new Tag[] { new Tag((byte) 1,
          Bytes.toBytes("teststring3")), });
  final Cell cell3 = new KeyValue(Bytes.toBytes("r"), Bytes.toBytes("f"), Bytes.toBytes("3"),
      HConstants.LATEST_TIMESTAMP, Bytes.toBytes("3"), new Tag[] {
          new Tag((byte) 2, Bytes.toBytes("teststring4")),
          new Tag((byte) 2, Bytes.toBytes("teststring5")),
          new Tag((byte) 1, Bytes.toBytes("teststring6")) });

  encoder.write(cell1);
  encoder.write(cell2);
  encoder.write(cell3);
  encoder.flush();
  dos.close();
  long offset = cos.getCount();
  CountingInputStream cis = new CountingInputStream(new ByteArrayInputStream(baos.toByteArray()));
  DataInputStream dis = new DataInputStream(cis);
  Codec.Decoder decoder = codec.getDecoder(dis);
  assertTrue(decoder.advance());
  Cell c = decoder.current();
  assertTrue(CellComparator.equals(c, cell1));
  List<Tag> tags = Tag.asList(c.getTagsArray(), c.getTagsOffset(), c.getTagsLength());
  assertEquals(2, tags.size());
  Tag tag = tags.get(0);
  assertEquals(1, tag.getType());
  assertTrue(Bytes.equals(Bytes.toBytes("teststring1"), tag.getValue()));
  tag = tags.get(1);
  assertEquals(2, tag.getType());
  assertTrue(Bytes.equals(Bytes.toBytes("teststring2"), tag.getValue()));
  assertTrue(decoder.advance());
  c = decoder.current();
  assertTrue(CellComparator.equals(c, cell2));
  tags = Tag.asList(c.getTagsArray(), c.getTagsOffset(), c.getTagsLength());
  assertEquals(1, tags.size());
  tag = tags.get(0);
  assertEquals(1, tag.getType());
  assertTrue(Bytes.equals(Bytes.toBytes("teststring3"), tag.getValue()));
  assertTrue(decoder.advance());
  c = decoder.current();
  assertTrue(CellComparator.equals(c, cell3));
  tags = Tag.asList(c.getTagsArray(), c.getTagsOffset(), c.getTagsLength());
  assertEquals(3, tags.size());
  tag = tags.get(0);
  assertEquals(2, tag.getType());
  assertTrue(Bytes.equals(Bytes.toBytes("teststring4"), tag.getValue()));
  tag = tags.get(1);
  assertEquals(2, tag.getType());
  assertTrue(Bytes.equals(Bytes.toBytes("teststring5"), tag.getValue()));
  tag = tags.get(2);
  assertEquals(1, tag.getType());
  assertTrue(Bytes.equals(Bytes.toBytes("teststring6"), tag.getValue()));
  assertFalse(decoder.advance());
  dis.close();
  assertEquals(offset, cis.getCount());
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:67,代码来源:TestCellCodecWithTags.java

示例9: testKeyValueWithTag

import org.apache.hadoop.hbase.Tag; //导入方法依赖的package包/类
@Test
public void testKeyValueWithTag() throws IOException {
  ByteArrayOutputStream baos = new ByteArrayOutputStream();
  CountingOutputStream cos = new CountingOutputStream(baos);
  DataOutputStream dos = new DataOutputStream(cos);
  Codec codec = new KeyValueCodecWithTags();
  Codec.Encoder encoder = codec.getEncoder(dos);
  final KeyValue kv1 = new KeyValue(Bytes.toBytes("r"), Bytes.toBytes("f"), Bytes.toBytes("1"),
      HConstants.LATEST_TIMESTAMP, Bytes.toBytes("1"), new Tag[] {
          new Tag((byte) 1, Bytes.toBytes("teststring1")),
          new Tag((byte) 2, Bytes.toBytes("teststring2")) });
  final KeyValue kv2 = new KeyValue(Bytes.toBytes("r"), Bytes.toBytes("f"), Bytes.toBytes("2"),
      HConstants.LATEST_TIMESTAMP, Bytes.toBytes("2"), new Tag[] { new Tag((byte) 1,
          Bytes.toBytes("teststring3")), });
  final KeyValue kv3 = new KeyValue(Bytes.toBytes("r"), Bytes.toBytes("f"), Bytes.toBytes("3"),
      HConstants.LATEST_TIMESTAMP, Bytes.toBytes("3"), new Tag[] {
          new Tag((byte) 2, Bytes.toBytes("teststring4")),
          new Tag((byte) 2, Bytes.toBytes("teststring5")),
          new Tag((byte) 1, Bytes.toBytes("teststring6")) });

  encoder.write(kv1);
  encoder.write(kv2);
  encoder.write(kv3);
  encoder.flush();
  dos.close();
  long offset = cos.getCount();
  CountingInputStream cis = new CountingInputStream(new ByteArrayInputStream(baos.toByteArray()));
  DataInputStream dis = new DataInputStream(cis);
  Codec.Decoder decoder = codec.getDecoder(dis);
  assertTrue(decoder.advance());
  Cell c = decoder.current();
  assertTrue(CellComparator.equals(c, kv1));
  List<Tag> tags = Tag.asList(c.getTagsArray(), c.getTagsOffset(), c.getTagsLength());
  assertEquals(2, tags.size());
  Tag tag = tags.get(0);
  assertEquals(1, tag.getType());
  assertTrue(Bytes.equals(Bytes.toBytes("teststring1"), tag.getValue()));
  tag = tags.get(1);
  assertEquals(2, tag.getType());
  assertTrue(Bytes.equals(Bytes.toBytes("teststring2"), tag.getValue()));
  assertTrue(decoder.advance());
  c = decoder.current();
  assertTrue(CellComparator.equals(c, kv2));
  tags = Tag.asList(c.getTagsArray(), c.getTagsOffset(), c.getTagsLength());
  assertEquals(1, tags.size());
  tag = tags.get(0);
  assertEquals(1, tag.getType());
  assertTrue(Bytes.equals(Bytes.toBytes("teststring3"), tag.getValue()));
  assertTrue(decoder.advance());
  c = decoder.current();
  assertTrue(CellComparator.equals(c, kv3));
  tags = Tag.asList(c.getTagsArray(), c.getTagsOffset(), c.getTagsLength());
  assertEquals(3, tags.size());
  tag = tags.get(0);
  assertEquals(2, tag.getType());
  assertTrue(Bytes.equals(Bytes.toBytes("teststring4"), tag.getValue()));
  tag = tags.get(1);
  assertEquals(2, tag.getType());
  assertTrue(Bytes.equals(Bytes.toBytes("teststring5"), tag.getValue()));
  tag = tags.get(2);
  assertEquals(1, tag.getType());
  assertTrue(Bytes.equals(Bytes.toBytes("teststring6"), tag.getValue()));
  assertFalse(decoder.advance());
  dis.close();
  assertEquals(offset, cis.getCount());
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:67,代码来源:TestKeyValueCodecWithTags.java


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