下面列出了怎么用org.apache.hadoop.hbase.protobuf.generated.ClientProtos.MutationProto.MutationType的API类实例代码及写法,或者点击链接到github查看源代码。
private static MutationType getType(Mutation mutation) {
if (mutation instanceof Put) {
return MutationType.PUT;
} else if (mutation instanceof Delete) {
return MutationType.DELETE;
} else {
// Increment and Append are not idempotent. They should not be used in distributed jobs.
throw new IllegalArgumentException("Only Put and Delete are supported");
}
}
public static MutationProto toProto(Mutation mutation) throws IOException {
MutationType type;
if (mutation instanceof Put) {
type = MutationType.PUT;
} else if (mutation instanceof Delete) {
type = MutationType.DELETE;
} else {
throw new IllegalArgumentException("Only Put and Delete are supported");
}
return org.apache.hadoop.hbase.protobuf.ProtobufUtil.toMutation(type, mutation);
}
protected MutationProto toMutationProto(Mutation mutation) throws IOException {
MutationProto m = null;
if(mutation instanceof Put){
m = org.apache.hadoop.hbase.protobuf.ProtobufUtil.toMutation(MutationType.PUT,
mutation);
} else if(mutation instanceof Delete) {
m = org.apache.hadoop.hbase.protobuf.ProtobufUtil.toMutation(MutationType.DELETE,
mutation);
} else {
throw new IOException("Put/Delete mutations only supported");
}
return m;
}
private static MutationType getMutationType(Mutation m) throws IOException {
if (m instanceof Put) {
return MutationType.PUT;
} else if (m instanceof Delete) {
return MutationType.DELETE;
} else {
throw new DoNotRetryIOException("Unsupported mutation type in stats commit"
+ m.getClass().getName());
}
}
public static MutationProto toProto(Mutation mutation) throws IOException {
MutationType type;
if (mutation instanceof Put) {
type = MutationType.PUT;
} else if (mutation instanceof Delete) {
type = MutationType.DELETE;
} else {
throw new IllegalArgumentException("Only Put and Delete are supported");
}
return org.apache.hadoop.hbase.protobuf.ProtobufUtil.toMutation(type, mutation);
}
protected MutationProto toMutationProto(Mutation mutation) throws IOException {
MutationProto m = null;
if(mutation instanceof Put){
m = org.apache.hadoop.hbase.protobuf.ProtobufUtil.toMutation(MutationType.PUT,
mutation);
} else if(mutation instanceof Delete) {
m = org.apache.hadoop.hbase.protobuf.ProtobufUtil.toMutation(MutationType.DELETE,
mutation);
} else {
throw new IOException("Put/Delete mutations only supported");
}
return m;
}
private static MutationType getMutationType(Mutation m) throws IOException {
if (m instanceof Put) {
return MutationType.PUT;
} else if (m instanceof Delete) {
return MutationType.DELETE;
} else {
throw new DoNotRetryIOException("Unsupported mutation type in stats commit" + m.getClass().getName());
}
}
@Override
public void encode(Mutation mutation, OutputStream outStream) throws IOException {
MutationType type = getType(mutation);
MutationProto proto = ProtobufUtil.toMutation(type, mutation);
proto.writeDelimitedTo(outStream);
}