/** * @param in to read bytes from * @return decode value * @throws IOException if {@link DataInput} throws {@link IOException} * @throws IllegalArgumentException if variable-length value does not terminate * after 9 bytes have been read * @see #writeSignedVarLong(long, DataOutput) */ public static long readSignedVarLong(DataInput in) throws IOException { long raw = readUnsignedVarLong(in); // This undoes the trick in writeSignedVarLong() long temp = (((raw << 63) >> 63) ^ raw) >> 1; // This extra step lets us deal with the largest signed values by treating // negative results from read unsigned methods as like unsigned values // Must re-flip the top bit if the original read value had it set. return temp ^ (raw & (1L << 63)); }
/** * @param in to read bytes from * @return decode value * @throws IOException if {@link DataInput} throws {@link IOException} * @throws IllegalArgumentException if variable-length value does not terminate * after 9 bytes have been read * @see #writeSignedVarLong(long, DataOutput) */ public static long readSignedVarLong(DataInput in) throws IOException { long raw = readUnsignedVarLong(in); // This undoes the trick in writeSignedVarLong() long temp = (((raw << 63) >> 63) ^ raw) >> 1; // This extra step lets us deal with the largest signed values by treating // negative results from read unsigned methods as like unsigned values // Must re-flip the top bit if the original read value had it set. return temp ^ (raw & (1L << 63)); }
return input.readUTF(); } else if (binding == java.sql.Date.class) { return new java.sql.Date(Varint.readUnsignedVarLong(input)); } else if (binding == java.sql.Time.class) { return new java.sql.Time(Varint.readUnsignedVarLong(input)); } else if (binding == java.sql.Timestamp.class) { return new java.sql.Timestamp(Varint.readUnsignedVarLong(input)); } else if (binding == java.util.Date.class) { return new java.util.Date(Varint.readUnsignedVarLong(input)); } else if (Geometry.class.isAssignableFrom(binding)) { final TWKBReader reader = new TWKBReader();