VCDiffAddressCache { public abstract int DecodeAddress(int here_address, short vcDiffMode, ByteBuffer address_stream) throws IOException; protected  VCDiffAddressCache(); protected  VCDiffAddressCache(short near_cache_size, short same_cache_size); abstract void Init(); short FirstSameMode(); short LastMode(); final int DecodeSameAddress(short mode, short encoded_address); final boolean WriteAddressAsVarintForMode(short mode); abstract void UpdateCache(int address); abstract short EncodeAddress(int address,
            int here_address,
            AtomicInteger encoded_addr); abstract int DecodeAddress(int here_address, short vcDiffMode, ByteBuffer address_stream); static final short VCD_SELF_MODE; static final short VCD_HERE_MODE; static final short VCD_FIRST_NEAR_MODE; static final short VCD_MAX_MODES; }
@Test public void DecodeAddressZeroCacheSizes() throws IOException { VCDiffAddressCacheImpl zero_cache = new VCDiffAddressCacheImpl((short) 0, (short) 0); ByteBuffer buffer = ByteBuffer.allocate(2048); VarInt.putInt(buffer, 0xCAFE); VarInt.putInt(buffer, 0xCAFE); VarInt.putInt(buffer, 0xDAFE); buffer.flip(); assertEquals(0xCAFE, zero_cache.DecodeAddress(0x10000, VCDiffAddressCache.VCD_SELF_MODE, buffer)); assertEquals(3, buffer.position()); assertEquals(0x20000 - 0xCAFE, zero_cache.DecodeAddress(0x20000, VCDiffAddressCache.VCD_HERE_MODE, buffer)); assertEquals(6, buffer.position()); assertEquals(0xDAFE, zero_cache.DecodeAddress(0x30000, VCDiffAddressCache.VCD_SELF_MODE, buffer)); assertEquals(9, buffer.position()); assertEquals(0, buffer.remaining()); }