/** * Convert a protocol buffer Mutate to a Put. * * @param proto The protocol buffer MutationProto to convert * @return A client Put. * @throws IOException */ public static Put toPut(final MutationProto proto) throws IOException { return toPut(proto, null); }
/** * Return the IOException thrown by the remote server wrapped in * ServiceException as cause. * * @param se ServiceException that wraps IO exception thrown by the server * @return Exception wrapped in ServiceException or * a new IOException that wraps the unexpected ServiceException. */ public static IOException getRemoteException(ServiceException se) { return makeIOExceptionOfException(se); }
/** * @param bytes Bytes to check. * @param offset offset to start at * @param len length to use * @return True if passed <code>bytes</code> has {@link #PB_MAGIC} for a prefix. */ public static boolean isPBMagicPrefix(final byte [] bytes, int offset, int len) { if (bytes == null || len < PB_MAGIC.length) return false; return compareTo(PB_MAGIC, 0, PB_MAGIC.length, bytes, offset, PB_MAGIC.length) == 0; }
/** * Create a protocol buffer Mutate based on a client Mutation * * @param type * @param mutation * @return a protobuf'd Mutation * @throws IOException */ public static MutationProto toMutation(final MutationType type, final Mutation mutation, final long nonce) throws IOException { return toMutation(type, mutation, MutationProto.newBuilder(), nonce); }
public static MutationProto toMutation(final MutationType type, final Mutation mutation, MutationProto.Builder builder) throws IOException { return toMutation(type, mutation, builder, HConstants.NO_NONCE); }
public static Object toJavaObject(MessageOrBuilder messageOrBuilder) throws InvalidProtocolBufferException { JsonElement element = toJsonElement(messageOrBuilder); return toJavaObject(element); } }
/** * Create a protocol buffer MutationProto based on a client Mutation. Does NOT include data. * Understanding is that the Cell will be transported other than via protobuf. * @param type * @param mutation * @param builder * @return a protobuf'd Mutation * @throws IOException */ public static MutationProto toMutationNoData(final MutationType type, final Mutation mutation, final MutationProto.Builder builder) throws IOException { return toMutationNoData(type, mutation, builder, HConstants.NO_NONCE); }
/** * @param bytes Bytes to check. * @return True if passed <code>bytes</code> has {@link ProtobufMagic#PB_MAGIC} for a prefix. */ public static boolean isPBMagicPrefix(final byte [] bytes) { return ProtobufMagic.isPBMagicPrefix(bytes); }
/** * Convert a protocol buffer Mutate to a Delete * * @param proto the protocol buffer Mutate to convert * @return the converted client Delete * @throws IOException */ public static Delete toDelete(final MutationProto proto) throws IOException { return toDelete(proto, null); }
public static JsonElement toJsonElement(MessageOrBuilder messageOrBuilder, boolean removeType) throws InvalidProtocolBufferException { String jsonString = toJsonString(messageOrBuilder); JsonParser parser = new JsonParser(); JsonElement element = parser.parse(jsonString); if (removeType) { removeTypeFromJson(element); } return element; }
/** * @return Length of {@link ProtobufMagic#lengthOfPBMagic()} */ public static int lengthOfPBMagic() { return ProtobufMagic.lengthOfPBMagic(); }
/** * Create a new ReplicateWALEntryRequest from a list of WAL entries * * @param entries the WAL entries to be replicated * @return a pair of ReplicateWALEntryRequest and a CellScanner over all the WALEdit values * found. */ public static Pair<AdminProtos.ReplicateWALEntryRequest, CellScanner> buildReplicateWALEntryRequest(final Entry[] entries) throws IOException { return buildReplicateWALEntryRequest(entries, null, null, null, null); }
public static JsonElement toJsonElement(MessageOrBuilder messageOrBuilder) throws InvalidProtocolBufferException { return toJsonElement(messageOrBuilder, true); }
public static MutationProto toMutation(final MutationType type, final Mutation mutation) throws IOException { return toMutation(type, mutation, HConstants.NO_NONCE); }
/** * @param bytes Bytes to check. * @return True if passed <code>bytes</code> has {@link ProtobufMagic#PB_MAGIC} for a prefix. */ public static boolean isPBMagicPrefix(final byte [] bytes) { return ProtobufMagic.isPBMagicPrefix(bytes); }
/** * @return Length of {@link ProtobufMagic#lengthOfPBMagic()} */ public static int lengthOfPBMagic() { return ProtobufMagic.lengthOfPBMagic(); }
/** * Like {@link #getRemoteException(ServiceException)} but more generic, able to handle more than * just {@link ServiceException}. Prefer this method to * {@link #getRemoteException(ServiceException)} because trying to * contain direct protobuf references. * @param e */ public static IOException handleRemoteException(Exception e) { return makeIOExceptionOfException(e); }
/** * @param bytes Bytes to check. * @param offset offset to start at * @param len length to use * @return True if passed <code>bytes</code> has {@link ProtobufMagic#PB_MAGIC} for a prefix. */ public static boolean isPBMagicPrefix(final byte [] bytes, int offset, int len) { return ProtobufMagic.isPBMagicPrefix(bytes, offset, len); }
/** * @param bytes Bytes to check. * @param offset offset to start at * @param len length to use * @return True if passed <code>bytes</code> has {@link ProtobufMagic#PB_MAGIC} for a prefix. */ public static boolean isPBMagicPrefix(final byte [] bytes, int offset, int len) { return ProtobufMagic.isPBMagicPrefix(bytes, offset, len); }
/** * @param bytes Bytes to check. * @return True if passed <code>bytes</code> has {@link #PB_MAGIC} for a prefix. */ public static boolean isPBMagicPrefix(final byte [] bytes) { if (bytes == null) return false; return isPBMagicPrefix(bytes, 0, bytes.length); }