/** * Reads 2 compressed longs from buf into seqnos * <p/> * Once variable-length encoding has been implemented, this method will probably get dropped as we can simply * read the 2 longs individually. * @param buf the buffer to read from * @param seqnos the array to read the seqnos into, needs to have a length of 2 */ public static void readLongSequence(ByteBuffer buf, long seqnos[]) { byte len=buf.get(); if(len == 0) { seqnos[0]=seqnos[1]=0; return; } byte len1=firstNibble(len), len2=secondNibble(len); seqnos[0]=makeLong(buf, len1); seqnos[1]=makeLong(buf, len2) + seqnos[0]; }
/** * Reads 2 compressed longs into an array of 2 longs. * <p/> * Once variable-length encoding has been implemented, this method will probably get dropped as we can simply * read the 2 longs individually. * @param in the input stream to read from * @param seqnos the array to read the seqnos into, needs to have a length of 2 * @param index the index of the first element to be written; the seqnos are written to seqnos[index] and seqnos[index+1] */ public static void readLongSequence(DataInput in, long[] seqnos, int index) throws IOException { byte len=in.readByte(); if(len == 0) { seqnos[index]=seqnos[index+1]=0; return; } byte len1=firstNibble(len), len2=secondNibble(len); seqnos[index]=makeLong(in, len1); seqnos[index+1]=makeLong(in, len2) + seqnos[index]; }
/** * Reads 2 compressed longs from buf into seqnos * <p/> * Once variable-length encoding has been implemented, this method will probably get dropped as we can simply * read the 2 longs individually. * @param buf the buffer to read from * @param seqnos the array to read the seqnos into, needs to have a length of 2 */ public static void readLongSequence(ByteBuffer buf, long seqnos[]) { byte len=buf.get(); if(len == 0) { seqnos[0]=seqnos[1]=0; return; } byte len1=firstNibble(len), len2=secondNibble(len); seqnos[0]=makeLong(buf, len1); seqnos[1]=makeLong(buf, len2) + seqnos[0]; }
/** * Reads 2 compressed longs into an array of 2 longs. * <p/> * Once variable-length encoding has been implemented, this method will probably get dropped as we can simply * read the 2 longs individually. * @param in the input stream to read from * @param seqnos the array to read the seqnos into, needs to have a length of 2 * @param index the index of the first element to be written; the seqnos are written to seqnos[index] and seqnos[index+1] */ public static void readLongSequence(DataInput in, long[] seqnos, int index) throws IOException { byte len=in.readByte(); if(len == 0) { seqnos[index]=seqnos[index+1]=0; return; } byte len1=firstNibble(len), len2=secondNibble(len); seqnos[index]=makeLong(in, len1); seqnos[index+1]=makeLong(in, len2) + seqnos[index]; }