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


Java CellUtil.cloneValue方法代码示例

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


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

示例1: list

import org.apache.hadoop.hbase.CellUtil; //导入方法依赖的package包/类
public synchronized NavigableSet<NamespaceDescriptor> list() throws IOException {
  NavigableSet<NamespaceDescriptor> ret =
      Sets.newTreeSet(NamespaceDescriptor.NAMESPACE_DESCRIPTOR_COMPARATOR);
  ResultScanner scanner = getNamespaceTable().getScanner(HTableDescriptor.NAMESPACE_FAMILY_INFO_BYTES);
  try {
    for(Result r : scanner) {
      byte[] val = CellUtil.cloneValue(r.getColumnLatestCell(
        HTableDescriptor.NAMESPACE_FAMILY_INFO_BYTES,
        HTableDescriptor.NAMESPACE_COL_DESC_BYTES));
      ret.add(ProtobufUtil.toNamespaceDescriptor(
          HBaseProtos.NamespaceDescriptor.parseFrom(val)));
    }
  } finally {
    scanner.close();
  }
  return ret;
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:18,代码来源:TableNamespaceManager.java

示例2: stringifyKvs

import org.apache.hadoop.hbase.CellUtil; //导入方法依赖的package包/类
static String stringifyKvs(Collection<Cell> kvs) {
  StringBuilder out = new StringBuilder();
  out.append("[");
  if (kvs != null) {
    for (Cell kv : kvs) {
      byte[] col = CellUtil.cloneQualifier(kv);
      byte[] val = CellUtil.cloneValue(kv);
      if (Bytes.equals(col, COUNTER)) {
        out.append(Bytes.toStringBinary(col) + ":" +
                   Bytes.toInt(val) + " ");
      } else {
        out.append(Bytes.toStringBinary(col) + ":" +
                   Bytes.toStringBinary(val) + " ");
      }
    }
  }
  out.append("]");
  return out.toString();
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:20,代码来源:TestRowProcessorEndpoint.java

示例3: recoverClusteringResult

import org.apache.hadoop.hbase.CellUtil; //导入方法依赖的package包/类
public static Result recoverClusteringResult(Result raw, byte[] family, byte[] qualifier) {
  if (raw == null) return null;
  byte[][] indexColumn = IndexPutParser.parseIndexRowKey(raw.getRow());
  List<KeyValue> list = new ArrayList<>(raw.listCells().size() + 1);
  for (Cell cell : raw.listCells()) {
    byte[] tag = cell.getTagsArray();
    if (tag != null && tag.length > KeyValue.MAX_TAGS_LENGTH) tag = null;
    KeyValue kv =
        new KeyValue(indexColumn[0], CellUtil.cloneFamily(cell), CellUtil.cloneQualifier(cell),
            cell.getTimestamp(), KeyValue.Type.codeToType(cell.getTypeByte()),
            CellUtil.cloneValue(cell), tag);
    list.add(kv);
  }
  list.add(new KeyValue(indexColumn[0], family, qualifier, indexColumn[1]));
  Collections.sort(list, KeyValue.COMPARATOR);
  return new Result(list);
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:18,代码来源:BaseIndexScanner.java

示例4: testMergeTool

import org.apache.hadoop.hbase.CellUtil; //导入方法依赖的package包/类
/**
 * Test merge tool.
 * @throws Exception
 */
public void testMergeTool() throws Exception {
  // First verify we can read the rows from the source regions and that they
  // contain the right data.
  for (int i = 0; i < regions.length; i++) {
    for (int j = 0; j < rows[i].length; j++) {
      Get get = new Get(rows[i][j]);
      get.addFamily(FAMILY);
      Result result = regions[i].get(get);
      byte [] bytes =  CellUtil.cloneValue(result.rawCells()[0]);
      assertNotNull(bytes);
      assertTrue(Bytes.equals(bytes, rows[i][j]));
    }
    // Close the region and delete the log
    HRegion.closeHRegion(regions[i]);
  }
  WAL log = wals.getWAL(new byte[]{});
   // Merge Region 0 and Region 1
  HRegion merged = mergeAndVerify("merging regions 0 and 1 ",
    this.sourceRegions[0].getRegionNameAsString(),
    this.sourceRegions[1].getRegionNameAsString(), log, 2);

  // Merge the result of merging regions 0 and 1 with region 2
  merged = mergeAndVerify("merging regions 0+1 and 2",
    merged.getRegionInfo().getRegionNameAsString(),
    this.sourceRegions[2].getRegionNameAsString(), log, 3);

  // Merge the result of merging regions 0, 1 and 2 with region 3
  merged = mergeAndVerify("merging regions 0+1+2 and 3",
    merged.getRegionInfo().getRegionNameAsString(),
    this.sourceRegions[3].getRegionNameAsString(), log, 4);

  // Merge the result of merging regions 0, 1, 2 and 3 with region 4
  merged = mergeAndVerify("merging regions 0+1+2+3 and 4",
    merged.getRegionInfo().getRegionNameAsString(),
    this.sourceRegions[4].getRegionNameAsString(), log, rows.length);
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:41,代码来源:TestMergeTool.java

示例5: SerializableCell

import org.apache.hadoop.hbase.CellUtil; //导入方法依赖的package包/类
/**
 * Copy data from {@code Cell} instance.
 *
 * @param cell
 */
public SerializableCell( Cell cell ) {
    rowKey = CellUtil.cloneRow(cell);
    family = CellUtil.cloneFamily(cell);
    qualifier = CellUtil.cloneQualifier(cell);
    value = CellUtil.cloneValue(cell);
    timestamp = cell.getTimestamp();
    type = cell.getTypeByte();
}
 
开发者ID:i-knowledge,项目名称:hbase-client,代码行数:14,代码来源:SerializableCell.java

示例6: assertNResult

import org.apache.hadoop.hbase.CellUtil; //导入方法依赖的package包/类
private void assertNResult(Result result, byte [] row,
    byte [][] families, byte [][] qualifiers, byte [][] values,
    int [][] idxs)
throws Exception {
  assertTrue("Expected row [" + Bytes.toString(row) + "] " +
      "Got row [" + Bytes.toString(result.getRow()) +"]",
      equals(row, result.getRow()));
  assertTrue("Expected " + idxs.length + " keys but result contains "
      + result.size(), result.size() == idxs.length);

  Cell [] keys = result.rawCells();

  for(int i=0;i<keys.length;i++) {
    byte [] family = families[idxs[i][0]];
    byte [] qualifier = qualifiers[idxs[i][1]];
    byte [] value = values[idxs[i][2]];
    Cell key = keys[i];

    byte[] famb = CellUtil.cloneFamily(key);
    byte[] qualb = CellUtil.cloneQualifier(key);
    byte[] valb = CellUtil.cloneValue(key);
    assertTrue("(" + i + ") Expected family [" + Bytes.toString(family)
        + "] " + "Got family [" + Bytes.toString(famb) + "]",
        equals(family, famb));
    assertTrue("(" + i + ") Expected qualifier [" + Bytes.toString(qualifier)
        + "] " + "Got qualifier [" + Bytes.toString(qualb) + "]",
        equals(qualifier, qualb));
    assertTrue("(" + i + ") Expected value [" + Bytes.toString(value) + "] "
        + "Got value [" + Bytes.toString(valb) + "]",
        equals(value, valb));
  }
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:33,代码来源:TestFromClientSide.java

示例7: getValue

import org.apache.hadoop.hbase.CellUtil; //导入方法依赖的package包/类
@Override
public BigDecimal getValue(byte[] colFamily, byte[] colQualifier, Cell kv)
    throws IOException {
  if (kv == null || CellUtil.cloneValue(kv) == null) {
    return null;
  }
  return Bytes.toBigDecimal(kv.getValueArray(), kv.getValueOffset(), kv.getValueLength()).
      setScale(2, RoundingMode.HALF_EVEN);
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:10,代码来源:BigDecimalColumnInterpreter.java

示例8: verifyMerge

import org.apache.hadoop.hbase.CellUtil; //导入方法依赖的package包/类
private void verifyMerge(final HRegion merged, final int upperbound)
throws IOException {
  //Test
  Scan scan = new Scan();
  scan.addFamily(FAMILY);
  InternalScanner scanner = merged.getScanner(scan);
  try {
  List<Cell> testRes = null;
    while (true) {
      testRes = new ArrayList<Cell>();
      boolean hasNext = scanner.next(testRes);
      if (!hasNext) {
        break;
      }
    }
  } finally {
    scanner.close();
  }

  //!Test

  for (int i = 0; i < upperbound; i++) {
    for (int j = 0; j < rows[i].length; j++) {
      Get get = new Get(rows[i][j]);
      get.addFamily(FAMILY);
      Result result = merged.get(get);
      assertEquals(1, result.size());
      byte [] bytes = CellUtil.cloneValue(result.rawCells()[0]);
      assertNotNull(Bytes.toStringBinary(rows[i][j]), bytes);
      assertTrue(Bytes.equals(bytes, rows[i][j]));
    }
  }
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:34,代码来源:TestMergeTool.java

示例9: assertGet

import org.apache.hadoop.hbase.CellUtil; //导入方法依赖的package包/类
private static void assertGet(final HRegion region, byte [] row, byte [] familiy,
    byte[] qualifier, byte[] value) throws IOException {
  // run a get and see if the value matches
  Get get = new Get(row);
  get.addColumn(familiy, qualifier);
  Result result = region.get(get);
  assertEquals(1, result.size());

  Cell kv = result.rawCells()[0];
  byte[] r = CellUtil.cloneValue(kv);
  assertTrue(Bytes.compareTo(r, value) == 0);
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:13,代码来源:TestParallelPut.java

示例10: assertGet

import org.apache.hadoop.hbase.CellUtil; //导入方法依赖的package包/类
static void assertGet(final HRegion r, final byte[] family, final byte[] k) throws IOException {
  // Now I have k, get values out and assert they are as expected.
  Get get = new Get(k).addFamily(family).setMaxVersions();
  Cell[] results = r.get(get).rawCells();
  for (int j = 0; j < results.length; j++) {
    byte[] tmp = CellUtil.cloneValue(results[j]);
    // Row should be equal to value every time.
    assertTrue(Bytes.equals(k, tmp));
  }
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:11,代码来源:TestHRegion.java

示例11: assertScan

import org.apache.hadoop.hbase.CellUtil; //导入方法依赖的package包/类
private void assertScan(final HRegion r, final byte[] fs, final byte[] firstValue)
    throws IOException {
  byte[][] families = { fs };
  Scan scan = new Scan();
  for (int i = 0; i < families.length; i++)
    scan.addFamily(families[i]);
  InternalScanner s = r.getScanner(scan);
  try {
    List<Cell> curVals = new ArrayList<Cell>();
    boolean first = true;
    OUTER_LOOP: while (s.next(curVals)) {
      for (Cell kv : curVals) {
        byte[] val = CellUtil.cloneValue(kv);
        byte[] curval = val;
        if (first) {
          first = false;
          assertTrue(Bytes.compareTo(curval, firstValue) == 0);
        } else {
          // Not asserting anything. Might as well break.
          break OUTER_LOOP;
        }
      }
    }
  } finally {
    s.close();
  }
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:28,代码来源:TestHRegion.java

示例12: getMap

import org.apache.hadoop.hbase.CellUtil; //导入方法依赖的package包/类
/**
 * Map of families to all versions of its qualifiers and values.
 * <p>
 * Returns a three level Map of the form:
 * <code>Map&amp;family,Map&lt;qualifier,Map&lt;timestamp,value&gt;&gt;&gt;</code>
 * <p>
 * Note: All other map returning methods make use of this map internally.
 * @return map from families to qualifiers to versions
 */
public NavigableMap<byte[], NavigableMap<byte[], NavigableMap<Long, byte[]>>> getMap() {
  if (this.familyMap != null) {
    return this.familyMap;
  }
  if(isEmpty()) {
    return null;
  }
  this.familyMap = new TreeMap<byte[], NavigableMap<byte[], NavigableMap<Long, byte[]>>>(Bytes.BYTES_COMPARATOR);
  for(Cell kv : this.cells) {
    byte [] family = CellUtil.cloneFamily(kv);
    NavigableMap<byte[], NavigableMap<Long, byte[]>> columnMap =
      familyMap.get(family);
    if(columnMap == null) {
      columnMap = new TreeMap<byte[], NavigableMap<Long, byte[]>>
        (Bytes.BYTES_COMPARATOR);
      familyMap.put(family, columnMap);
    }
    byte [] qualifier = CellUtil.cloneQualifier(kv);
    NavigableMap<Long, byte[]> versionMap = columnMap.get(qualifier);
    if(versionMap == null) {
      versionMap = new TreeMap<Long, byte[]>(new Comparator<Long>() {
        @Override
        public int compare(Long l1, Long l2) {
          return l2.compareTo(l1);
        }
      });
      columnMap.put(qualifier, versionMap);
    }
    Long timestamp = kv.getTimestamp();
    byte [] value = CellUtil.cloneValue(kv);

    versionMap.put(timestamp, value);
  }
  return this.familyMap;
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:45,代码来源:Result.java

示例13: value

import org.apache.hadoop.hbase.CellUtil; //导入方法依赖的package包/类
/**
 * Returns the value of the first column in the Result.
 * @return value of the first column
 */
public byte [] value() {
  if (isEmpty()) {
    return null;
  }
  return CellUtil.cloneValue(cells[0]);
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:11,代码来源:Result.java

示例14: getValue

import org.apache.hadoop.hbase.CellUtil; //导入方法依赖的package包/类
@Override
@Deprecated
public byte[] getValue() {
  return CellUtil.cloneValue(this);
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:6,代码来源:BufferedDataBlockEncoder.java

示例15: CellModel

import org.apache.hadoop.hbase.CellUtil; //导入方法依赖的package包/类
/**
 * Constructor from KeyValue
 * @param cell
 */
public CellModel(org.apache.hadoop.hbase.Cell cell) {
  this(CellUtil.cloneFamily(cell), CellUtil.cloneQualifier(cell), cell.getTimestamp(), CellUtil
      .cloneValue(cell));
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:9,代码来源:CellModel.java


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