org.apache.hadoop.hbase.KeyValue.createKeyOnly()方法的使用及代码示例

x33g5p2x  于2022-01-23 转载在 其他  
字(10.3k)|赞(0)|评价(0)|浏览(95)

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

KeyValue.createKeyOnly介绍

[英]Creates a new KeyValue that only contains the key portion (the value is set to be null). TODO only used by KeyOnlyFilter -- move there.
[中]创建仅包含键部分的新KeyValue(该值设置为null)。TODO仅由KeyOnlyFilter使用--移动到那里。

代码示例

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

@Override
  public Tuple2<RowKeyWritable, KeyValue> call(Tuple2<Text, Text> textTextTuple2) throws Exception {
    KeyValue outputValue = keyValueCreators.get(0).create(textTextTuple2._1,
        textTextTuple2._2.getBytes(), 0, textTextTuple2._2.getLength());
    return new Tuple2<>(new RowKeyWritable(outputValue.createKeyOnly(false).getKey()), outputValue);
  }
});

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

@Override
public void doMap(Text key, Text value, Context context) throws IOException, InterruptedException {
  KeyValue outputValue;
  int n = keyValueCreators.size();
  if (n == 1 && keyValueCreators.get(0).isFullCopy) { // shortcut for simple full copy
    outputValue = keyValueCreators.get(0).create(key, value.getBytes(), 0, value.getLength());
    rowKeyWritable.set(outputValue.createKeyOnly(false).getKey());
    context.write(rowKeyWritable, outputValue);
  } else { // normal (complex) case that distributes measures to multiple HBase columns
    inputCodec.decode(ByteBuffer.wrap(value.getBytes(), 0, value.getLength()), inputMeasures);
    for (int i = 0; i < n; i++) {
      outputValue = keyValueCreators.get(i).create(key, inputMeasures);
      rowKeyWritable.set(outputValue.createKeyOnly(false).getKey());
      context.write(rowKeyWritable, outputValue);
    }
  }
}

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

@Override
  public Iterator<Tuple2<RowKeyWritable, KeyValue>> call(Tuple2<Text, Text> textTextTuple2)
      throws Exception {
    List<Tuple2<RowKeyWritable, KeyValue>> result = Lists.newArrayListWithExpectedSize(cfNum);
    Object[] inputMeasures = new Object[cubeDesc.getMeasures().size()];
    inputCodec.decode(ByteBuffer.wrap(textTextTuple2._2.getBytes(), 0, textTextTuple2._2.getLength()),
        inputMeasures);
    for (int i = 0; i < cfNum; i++) {
      KeyValue outputValue = keyValueCreators.get(i).create(textTextTuple2._1, inputMeasures);
      result.add(new Tuple2<>(new RowKeyWritable(outputValue.createKeyOnly(false).getKey()),
          outputValue));
    }
    return result.iterator();
  }
});

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

new RowKeyWritable(KeyValueUtil.createFirstOnRow(splits.get(i), 9223372036854775807L).createKeyOnly(false).getKey()),
NullWritable.get());

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

KeyValue expectedKey =
  new KeyValue(startKey, family, qualify, Long.MAX_VALUE, Type.Put, startKey);
KeyValue seekKey = expectedKey.createKeyOnly(false);
Cell cell = cachedMobFile.readCell(seekKey, false);
MobTestUtil.assertCellEquals(expectedKey, cell);
seekKey = expectedKey.createKeyOnly(false);
cell = cachedMobFile.readCell(seekKey, false);
MobTestUtil.assertCellEquals(expectedKey, cell);
seekKey = expectedKey.createKeyOnly(false);
cell = cachedMobFile.readCell(seekKey, false);
MobTestUtil.assertCellEquals(expectedKey, cell);

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

KeyValue expectedKey =
  new KeyValue(startKey, family, qualify, Long.MAX_VALUE, Type.Put, startKey);
KeyValue seekKey = expectedKey.createKeyOnly(false);
Cell cell = mobFile.readCell(seekKey, false);
MobTestUtil.assertCellEquals(expectedKey, cell);
seekKey = expectedKey.createKeyOnly(false);
cell = mobFile.readCell(seekKey, false);
MobTestUtil.assertCellEquals(expectedKey, cell);
seekKey = expectedKey.createKeyOnly(false);
cell = mobFile.readCell(seekKey, false);
MobTestUtil.assertCellEquals(expectedKey, cell);

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

@Test
public void testCreateKeyOnly() throws Exception {
 long ts = 1;
 byte [] value = Bytes.toBytes("a real value");
 byte [] evalue = new byte[0]; // empty value
 for (byte[] val : new byte[][]{value, evalue}) {
  for (boolean useLen : new boolean[]{false,true}) {
   KeyValue kv1 = new KeyValue(rowA, family, qualA, ts, val);
   KeyValue kv1ko = kv1.createKeyOnly(useLen);
   // keys are still the same
   assertTrue(kv1.equals(kv1ko));
   // but values are not
   assertTrue(kv1ko.getValueLength() == (useLen?Bytes.SIZEOF_INT:0));
   if (useLen) {
    assertEquals(kv1.getValueLength(),
     Bytes.toInt(kv1ko.getValueArray(), kv1ko.getValueOffset(), kv1ko.getValueLength()));
   }
  }
 }
}

代码示例来源:origin: co.cask.hbase/hbase

@Override
public KeyValue transform(KeyValue kv) {
 return kv.createKeyOnly(this.lenAsVal);
}

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

@Override
  public Tuple2<RowKeyWritable, KeyValue> call(Tuple2<Text, Text> textTextTuple2) throws Exception {
    KeyValue outputValue = keyValueCreators.get(0).create(textTextTuple2._1,
        textTextTuple2._2.getBytes(), 0, textTextTuple2._2.getLength());
    return new Tuple2<>(new RowKeyWritable(outputValue.createKeyOnly(false).getKey()), outputValue);
  }
});

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

@Override
public void doMap(Text key, Text value, Context context) throws IOException, InterruptedException {
  KeyValue outputValue;
  int n = keyValueCreators.size();
  if (n == 1 && keyValueCreators.get(0).isFullCopy) { // shortcut for simple full copy
    outputValue = keyValueCreators.get(0).create(key, value.getBytes(), 0, value.getLength());
    rowKeyWritable.set(outputValue.createKeyOnly(false).getKey());
    context.write(rowKeyWritable, outputValue);
  } else { // normal (complex) case that distributes measures to multiple HBase columns
    inputCodec.decode(ByteBuffer.wrap(value.getBytes(), 0, value.getLength()), inputMeasures);
    for (int i = 0; i < n; i++) {
      outputValue = keyValueCreators.get(i).create(key, inputMeasures);
      rowKeyWritable.set(outputValue.createKeyOnly(false).getKey());
      context.write(rowKeyWritable, outputValue);
    }
  }
}

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

@Override
  public Iterator<Tuple2<RowKeyWritable, KeyValue>> call(Tuple2<Text, Text> textTextTuple2)
      throws Exception {
    List<Tuple2<RowKeyWritable, KeyValue>> result = Lists.newArrayListWithExpectedSize(cfNum);
    Object[] inputMeasures = new Object[cubeDesc.getMeasures().size()];
    inputCodec.decode(ByteBuffer.wrap(textTextTuple2._2.getBytes(), 0, textTextTuple2._2.getLength()),
        inputMeasures);
    for (int i = 0; i < cfNum; i++) {
      KeyValue outputValue = keyValueCreators.get(i).create(textTextTuple2._1, inputMeasures);
      result.add(new Tuple2<>(new RowKeyWritable(outputValue.createKeyOnly(false).getKey()),
          outputValue));
    }
    return result.iterator();
  }
});

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

new RowKeyWritable(KeyValueUtil.createFirstOnRow(splits.get(i), 9223372036854775807L).createKeyOnly(false).getKey()),
NullWritable.get());

代码示例来源:origin: com.aliyun.hbase/alihbase-mapreduce

/**
 * @param row The current table row key.
 * @param value The columns.
 * @param context The current context.
 * @throws IOException When something is broken with the data.
 */
@Override
public void map(ImmutableBytesWritable row, Result value, Context context) throws IOException {
 try {
  if (LOG.isTraceEnabled()) {
   LOG.trace(
    "Considering the row." + Bytes.toString(row.get(), row.getOffset(), row.getLength()));
  }
  if (filter == null || !filter.filterRowKey(
   PrivateCellUtil.createFirstOnRow(row.get(), row.getOffset(), (short) row.getLength()))) {
   for (Cell kv : value.rawCells()) {
    kv = filterKv(filter, kv);
    // skip if we filtered it out
    if (kv == null) continue;
    // TODO get rid of ensureKeyValue
    KeyValue ret = KeyValueUtil.ensureKeyValue(convertKv(kv, cfRenameMap));
    context.write(new KeyValueWritableComparable(ret.createKeyOnly(false)), ret);
   }
  }
 } catch (InterruptedException e) {
  e.printStackTrace();
 }
}

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

/**
 * @param row The current table row key.
 * @param value The columns.
 * @param context The current context.
 * @throws IOException When something is broken with the data.
 */
@Override
public void map(ImmutableBytesWritable row, Result value, Context context) throws IOException {
 try {
  if (LOG.isTraceEnabled()) {
   LOG.trace(
    "Considering the row." + Bytes.toString(row.get(), row.getOffset(), row.getLength()));
  }
  if (filter == null || !filter.filterRowKey(
   PrivateCellUtil.createFirstOnRow(row.get(), row.getOffset(), (short) row.getLength()))) {
   for (Cell kv : value.rawCells()) {
    kv = filterKv(filter, kv);
    // skip if we filtered it out
    if (kv == null) continue;
    // TODO get rid of ensureKeyValue
    KeyValue ret = KeyValueUtil.ensureKeyValue(convertKv(kv, cfRenameMap));
    context.write(new KeyValueWritableComparable(ret.createKeyOnly(false)), ret);
   }
  }
 } catch (InterruptedException e) {
  e.printStackTrace();
 }
}

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

KeyValue expectedKey =
  new KeyValue(startKey, family, qualify, Long.MAX_VALUE, Type.Put, startKey);
KeyValue seekKey = expectedKey.createKeyOnly(false);
Cell cell = mobFile.readCell(seekKey, false);
MobTestUtil.assertCellEquals(expectedKey, cell);
seekKey = expectedKey.createKeyOnly(false);
cell = mobFile.readCell(seekKey, false);
MobTestUtil.assertCellEquals(expectedKey, cell);
seekKey = expectedKey.createKeyOnly(false);
cell = mobFile.readCell(seekKey, false);
MobTestUtil.assertCellEquals(expectedKey, cell);

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

KeyValue expectedKey =
  new KeyValue(startKey, family, qualify, Long.MAX_VALUE, Type.Put, startKey);
KeyValue seekKey = expectedKey.createKeyOnly(false);
Cell cell = cachedMobFile.readCell(seekKey, false);
MobTestUtil.assertCellEquals(expectedKey, cell);
seekKey = expectedKey.createKeyOnly(false);
cell = cachedMobFile.readCell(seekKey, false);
MobTestUtil.assertCellEquals(expectedKey, cell);
seekKey = expectedKey.createKeyOnly(false);
cell = cachedMobFile.readCell(seekKey, false);
MobTestUtil.assertCellEquals(expectedKey, cell);

代码示例来源:origin: com.aliyun.hbase/alihbase-common

public void testCreateKeyOnly() throws Exception {
 long ts = 1;
 byte [] value = Bytes.toBytes("a real value");
 byte [] evalue = new byte[0]; // empty value
 for (byte[] val : new byte[][]{value, evalue}) {
  for (boolean useLen : new boolean[]{false,true}) {
   KeyValue kv1 = new KeyValue(rowA, family, qualA, ts, val);
   KeyValue kv1ko = kv1.createKeyOnly(useLen);
   // keys are still the same
   assertTrue(kv1.equals(kv1ko));
   // but values are not
   assertTrue(kv1ko.getValueLength() == (useLen?Bytes.SIZEOF_INT:0));
   if (useLen) {
    assertEquals(kv1.getValueLength(),
     Bytes.toInt(kv1ko.getValueArray(), kv1ko.getValueOffset(), kv1ko.getValueLength()));
   }
  }
 }
}

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

@Test
public void testCreateKeyOnly() throws Exception {
 long ts = 1;
 byte [] value = Bytes.toBytes("a real value");
 byte [] evalue = new byte[0]; // empty value
 for (byte[] val : new byte[][]{value, evalue}) {
  for (boolean useLen : new boolean[]{false,true}) {
   KeyValue kv1 = new KeyValue(rowA, family, qualA, ts, val);
   KeyValue kv1ko = kv1.createKeyOnly(useLen);
   // keys are still the same
   assertTrue(kv1.equals(kv1ko));
   // but values are not
   assertTrue(kv1ko.getValueLength() == (useLen?Bytes.SIZEOF_INT:0));
   if (useLen) {
    assertEquals(kv1.getValueLength(),
     Bytes.toInt(kv1ko.getValueArray(), kv1ko.getValueOffset(), kv1ko.getValueLength()));
   }
  }
 }
}

相关文章

微信公众号

最新文章

更多

KeyValue类方法