本文整理汇总了Java中org.apache.hadoop.hbase.KeyValue.Type方法的典型用法代码示例。如果您正苦于以下问题:Java KeyValue.Type方法的具体用法?Java KeyValue.Type怎么用?Java KeyValue.Type使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.hadoop.hbase.KeyValue
的用法示例。
在下文中一共展示了KeyValue.Type方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: toDeleteType
import org.apache.hadoop.hbase.KeyValue; //导入方法依赖的package包/类
/**
* Convert a delete KeyValue type to protocol buffer DeleteType.
*
* @param type
* @return protocol buffer DeleteType
* @throws IOException
*/
public static DeleteType toDeleteType(
KeyValue.Type type) throws IOException {
switch (type) {
case Delete:
return DeleteType.DELETE_ONE_VERSION;
case DeleteColumn:
return DeleteType.DELETE_MULTIPLE_VERSIONS;
case DeleteFamily:
return DeleteType.DELETE_FAMILY;
case DeleteFamilyVersion:
return DeleteType.DELETE_FAMILY_VERSION;
default:
throw new IOException("Unknown delete type: " + type);
}
}
示例2: fromDeleteType
import org.apache.hadoop.hbase.KeyValue; //导入方法依赖的package包/类
/**
* Convert a protocol buffer DeleteType to delete KeyValue type.
*
* @param type The DeleteType
* @return The type.
* @throws IOException
*/
public static KeyValue.Type fromDeleteType(
DeleteType type) throws IOException {
switch (type) {
case DELETE_ONE_VERSION:
return KeyValue.Type.Delete;
case DELETE_MULTIPLE_VERSIONS:
return KeyValue.Type.DeleteColumn;
case DELETE_FAMILY:
return KeyValue.Type.DeleteFamily;
case DELETE_FAMILY_VERSION:
return KeyValue.Type.DeleteFamilyVersion;
default:
throw new IOException("Unknown delete type: " + type);
}
}
示例3: generateKeyType
import org.apache.hadoop.hbase.KeyValue; //导入方法依赖的package包/类
public static KeyValue.Type generateKeyType(Random rand) {
if (rand.nextBoolean()) {
// Let's make half of KVs puts.
return KeyValue.Type.Put;
} else {
KeyValue.Type keyType =
KeyValue.Type.values()[1 + rand.nextInt(NUM_VALID_KEY_TYPES)];
if (keyType == KeyValue.Type.Minimum || keyType == KeyValue.Type.Maximum)
{
throw new RuntimeException("Generated an invalid key type: " + keyType
+ ". " + "Probably the layout of KeyValue.Type has changed.");
}
return keyType;
}
}
示例4: generateKeyType
import org.apache.hadoop.hbase.KeyValue; //导入方法依赖的package包/类
private static KeyValue.Type generateKeyType(Random rand) {
if (rand.nextBoolean()) {
// Let's make half of KVs puts.
return KeyValue.Type.Put;
} else {
KeyValue.Type keyType =
KeyValue.Type.values()[1 + rand.nextInt(NUM_VALID_KEY_TYPES)];
if (keyType == KeyValue.Type.Minimum || keyType == KeyValue.Type.Maximum)
{
throw new RuntimeException("Generated an invalid key type: " + keyType
+ ". " + "Probably the layout of KeyValue.Type has changed.");
}
return keyType;
}
}
示例5: generateKeyType
import org.apache.hadoop.hbase.KeyValue; //导入方法依赖的package包/类
public static KeyValue.Type generateKeyType(Random rand) {
if (rand.nextBoolean()) {
// Let's make half of KVs puts.
return KeyValue.Type.Put;
} else {
KeyValue.Type keyType = KeyValue.Type.values()[1 + rand.nextInt(NUM_VALID_KEY_TYPES)];
if (keyType == KeyValue.Type.Minimum || keyType == KeyValue.Type.Maximum) {
throw new RuntimeException("Generated an invalid key type: " + keyType + ". "
+ "Probably the layout of KeyValue.Type has changed.");
}
return keyType;
}
}
示例6: toMutation
import org.apache.hadoop.hbase.KeyValue; //导入方法依赖的package包/类
public static MutationProto toMutation(final MutationType type, final Mutation mutation,
MutationProto.Builder builder, long nonce)
throws IOException {
builder = getMutationBuilderAndSetCommonFields(type, mutation, builder);
if (nonce != HConstants.NO_NONCE) {
builder.setNonce(nonce);
}
ColumnValue.Builder columnBuilder = ColumnValue.newBuilder();
QualifierValue.Builder valueBuilder = QualifierValue.newBuilder();
for (Map.Entry<byte[],List<Cell>> family: mutation.getFamilyCellMap().entrySet()) {
columnBuilder.clear();
columnBuilder.setFamily(ByteStringer.wrap(family.getKey()));
for (Cell cell: family.getValue()) {
valueBuilder.clear();
valueBuilder.setQualifier(ByteStringer.wrap(
cell.getQualifierArray(), cell.getQualifierOffset(), cell.getQualifierLength()));
valueBuilder.setValue(ByteStringer.wrap(
cell.getValueArray(), cell.getValueOffset(), cell.getValueLength()));
valueBuilder.setTimestamp(cell.getTimestamp());
if (type == MutationType.DELETE || (type == MutationType.PUT && CellUtil.isDelete(cell))) {
KeyValue.Type keyValueType = KeyValue.Type.codeToType(cell.getTypeByte());
valueBuilder.setDeleteType(toDeleteType(keyValueType));
}
columnBuilder.addQualifierValue(valueBuilder.build());
}
builder.addColumnValue(columnBuilder.build());
}
return builder.build();
}