/** * If there at least as many leading zeros and as many trailing zeros as previous value, control bit = 0 (type a) * store the meaningful XORed value * * @param xor XOR between previous value and current */ private void writeExistingLeading(long xor) { out.skipBit(); int significantBits = 64 - storedLeadingZeros - storedTrailingZeros; xor >>>= storedTrailingZeros; out.writeBits(xor, significantBits); }
/** * If there at least as many leading zeros and as many trailing zeros as previous value, control bit = 0 (type a) * store the meaningful XORed value * * @param xor XOR between previous value and current */ private void writeExistingLeading(long xor) { out.skipBit(); int significantBits = 64 - storedLeadingZeros - storedTrailingZeros; xor >>>= storedTrailingZeros; out.writeBits(xor, significantBits); }
/** * If there at least as many leading zeros and as many trailing zeros as previous value, control bit = 0 (type a) * store the meaningful XORed value * * @param xor XOR between previous value and current */ private void writeExistingLeading(long xor) { out.skipBit(); int significantBits = 64 - storedLeadingZeros - storedTrailingZeros; out.writeBits(xor >>> storedTrailingZeros, significantBits); }
/** * If there at least as many leading zeros and as many trailing zeros as previous value, control bit = 0 (type a) * store the meaningful XORed value * * @param xor XOR between previous value and current */ private void writeExistingLeading(long xor) { out.skipBit(); int significantBits = 64 - storedLeadingZeros - storedTrailingZeros; out.writeBits(xor >>> storedTrailingZeros, significantBits); }
private void compressValue(long value) { // TODO Fix already compiled into a big method long xor = storedVal ^ value; if(xor == 0) { // Write 0 out.skipBit(); } else { int leadingZeros = Long.numberOfLeadingZeros(xor); int trailingZeros = Long.numberOfTrailingZeros(xor); // Check overflow of leading? Can't be 32! if(leadingZeros >= 32) { leadingZeros = 31; } // Store bit '1' out.writeBit(); if(leadingZeros >= storedLeadingZeros && trailingZeros >= storedTrailingZeros) { writeExistingLeading(xor); } else { writeNewLeading(xor, leadingZeros, trailingZeros); } } storedVal = value; }
/** * Closes the block and writes the remaining stuff to the BitOutput. */ public void close() { out.writeBits(0x0F, 4); out.writeBits(0xFFFFFFFF, 32); out.skipBit(); out.flush(); }
/** * Closes the block and writes the remaining stuff to the BitOutput. */ public void close() { // These are selected to test interoperability and correctness of the solution, this can be read with go-tsz out.writeBits(0x0F, 4); out.writeBits(0xFFFFFFFF, 32); out.skipBit(); out.flush(); }
/** * Closes the block and writes the remaining stuff to the BitOutput. */ public void close() { out.writeBits(0x0F, 4); out.writeBits(0xFFFFFFFF, 32); out.skipBit(); out.flush(); }
/** * Closes the block and writes the remaining stuff to the BitOutput. */ public void close() { // These are selected to test interoperability and correctness of the solution, this can be read with go-tsz out.writeBits(0x0F, 4); out.writeBits(0xFFFFFFFF, 32); out.skipBit(); out.flush(); }
private void compressValue(long value) { // TODO Fix already compiled into a big method long xor = storedVal ^ value; if(xor == 0) { // Write 0 out.skipBit(); } else { int leadingZeros = Long.numberOfLeadingZeros(xor); int trailingZeros = Long.numberOfTrailingZeros(xor); // Check overflow of leading? Can't be 32! if(leadingZeros >= 32) { leadingZeros = 31; } // Store bit '1' out.writeBit(); if(leadingZeros >= storedLeadingZeros && trailingZeros >= storedTrailingZeros) { writeExistingLeading(xor); } else { writeNewLeading(xor, leadingZeros, trailingZeros); } } storedVal = value; }
protected void compressValue(long value) { // In original Gorilla, Last-Value predictor is used long diff = predictor.predict() ^ value; predictor.update(value); if(diff == 0) { // Write 0 out.skipBit(); } else { int leadingZeros = Long.numberOfLeadingZeros(diff); int trailingZeros = Long.numberOfTrailingZeros(diff); out.writeBit(); // Optimize to writeNewLeading / writeExistingLeading? if(leadingZeros >= storedLeadingZeros && trailingZeros >= storedTrailingZeros) { writeExistingLeading(diff); } else { writeNewLeading(diff, leadingZeros, trailingZeros); } } }
protected void compressValue(long value) { // In original Gorilla, Last-Value predictor is used long diff = predictor.predict() ^ value; predictor.update(value); if(diff == 0) { // Write 0 out.skipBit(); } else { int leadingZeros = Long.numberOfLeadingZeros(diff); int trailingZeros = Long.numberOfTrailingZeros(diff); out.writeBit(); // Optimize to writeNewLeading / writeExistingLeading? if(leadingZeros >= storedLeadingZeros && trailingZeros >= storedTrailingZeros) { writeExistingLeading(diff); } else { writeNewLeading(diff, leadingZeros, trailingZeros); } } }
out.skipBit(); } else { deltaD = encodeZigZag32(deltaD);
out.skipBit(); } else { deltaD = encodeZigZag32(deltaD);
out.skipBit(); } else if(deltaD >= -63 && deltaD <= 64) { out.writeBits(0x02, 2); // store '10'
out.skipBit(); } else if(deltaD >= -63 && deltaD <= 64) { out.writeBits(0x02, 2); // store '10'