public static String asString(final long vfp) { return String.format("%d(0x%x): (block address: %d, offset: %d)", vfp, vfp, getBlockAddress(vfp), getBlockOffset(vfp)); } }
private static long shiftVirtualFilePointer(long virtualFilePointer, long offset) { long blockAddress = BlockCompressedFilePointerUtil.getBlockAddress(virtualFilePointer); int blockOffset = BlockCompressedFilePointerUtil.getBlockOffset(virtualFilePointer); return (blockAddress + offset) << 16 | (long) blockOffset; } }
private static long shiftVirtualFilePointer(long virtualFilePointer, long offset) { long blockAddress = BlockCompressedFilePointerUtil.getBlockAddress(virtualFilePointer); int blockOffset = BlockCompressedFilePointerUtil.getBlockOffset(virtualFilePointer); return (blockAddress + offset) << 16 | (long) blockOffset; } }
private static long shiftVirtualFilePointer(long virtualFilePointer, long offset) { long blockAddress = BlockCompressedFilePointerUtil.getBlockAddress(virtualFilePointer); int blockOffset = BlockCompressedFilePointerUtil.getBlockOffset(virtualFilePointer); return (blockAddress + offset) << 16 | (long) blockOffset; } }
public static String asString(final long vfp) { return String.format("%d(0x%x): (block address: %d, offset: %d)", vfp, vfp, getBlockAddress(vfp), getBlockOffset(vfp)); } }
public static String asString(final long vfp) { return String.format("%d(0x%x): (block address: %d, offset: %d)", vfp, vfp, getBlockAddress(vfp), getBlockOffset(vfp)); } }
/** * Returns whether two chunks overlap. * @param other Chunk to which this should be compared. * @return True if the two chunks are adjacent. Returns false if the chunks overlap or are discontinuous. */ public boolean isAdjacentTo(final Chunk other) { // Simpler implementation would be to == the chunk end of one to the chunk start of the other. Chose this implementation to ensure that all chunk // comparisons point directly to the return (BlockCompressedFilePointerUtil.getBlockAddress(this.getChunkEnd()) == BlockCompressedFilePointerUtil.getBlockAddress(other.getChunkStart()) && BlockCompressedFilePointerUtil.getBlockOffset(this.getChunkEnd()) == BlockCompressedFilePointerUtil.getBlockOffset(other.getChunkStart())) || (BlockCompressedFilePointerUtil.getBlockAddress(this.getChunkStart()) == BlockCompressedFilePointerUtil.getBlockAddress(other.getChunkEnd()) && BlockCompressedFilePointerUtil.getBlockOffset(this.getChunkStart()) == BlockCompressedFilePointerUtil.getBlockOffset(other.getChunkEnd())); }
/** * Returns whether two chunks overlap. * @param other Chunk to which this should be compared. * @return True if the two chunks are adjacent. Returns false if the chunks overlap or are discontinuous. */ public boolean isAdjacentTo(final Chunk other) { // Simpler implementation would be to == the chunk end of one to the chunk start of the other. Chose this implementation to ensure that all chunk // comparisons point directly to the return (BlockCompressedFilePointerUtil.getBlockAddress(this.getChunkEnd()) == BlockCompressedFilePointerUtil.getBlockAddress(other.getChunkStart()) && BlockCompressedFilePointerUtil.getBlockOffset(this.getChunkEnd()) == BlockCompressedFilePointerUtil.getBlockOffset(other.getChunkStart())) || (BlockCompressedFilePointerUtil.getBlockAddress(this.getChunkStart()) == BlockCompressedFilePointerUtil.getBlockAddress(other.getChunkEnd()) && BlockCompressedFilePointerUtil.getBlockOffset(this.getChunkStart()) == BlockCompressedFilePointerUtil.getBlockOffset(other.getChunkEnd())); }
/** * Returns whether two chunks overlap. * @param other Chunk to which this should be compared. * @return True if the two chunks are adjacent. Returns false if the chunks overlap or are discontinuous. */ public boolean isAdjacentTo(final Chunk other) { // Simpler implementation would be to == the chunk end of one to the chunk start of the other. Chose this implementation to ensure that all chunk // comparisons point directly to the return (BlockCompressedFilePointerUtil.getBlockAddress(this.getChunkEnd()) == BlockCompressedFilePointerUtil.getBlockAddress(other.getChunkStart()) && BlockCompressedFilePointerUtil.getBlockOffset(this.getChunkEnd()) == BlockCompressedFilePointerUtil.getBlockOffset(other.getChunkStart())) || (BlockCompressedFilePointerUtil.getBlockAddress(this.getChunkStart()) == BlockCompressedFilePointerUtil.getBlockAddress(other.getChunkEnd()) && BlockCompressedFilePointerUtil.getBlockOffset(this.getChunkStart()) == BlockCompressedFilePointerUtil.getBlockOffset(other.getChunkEnd())); }
@Test(dataProvider = "virtualOffsetForSeekData") public void testGetVirtualOffsetForSeek(final long uncompressedOffset, final long expectedBlockAddress, final long expectedBlockOffset, final GZIIndex index) throws Exception { final long virtualOffset = index.getVirtualOffsetForSeek(uncompressedOffset); Assert.assertEquals(BlockCompressedFilePointerUtil.getBlockAddress(virtualOffset), expectedBlockAddress); Assert.assertEquals(BlockCompressedFilePointerUtil.getBlockOffset(virtualOffset), expectedBlockOffset); }
final int uncompressedOffset = BlockCompressedFilePointerUtil.getBlockOffset(pos); final int available; if (mBlockAddress == compressedOffset && mCurrentBlock != null) {
/** * Returns whether two chunks overlap. * @param other Chunk to which this should be compared. * @return True if the chunks overlap. Returns false if the two chunks abut or are disjoint. */ public boolean overlaps(final Chunk other) { final int comparison = this.compareTo(other); if(comparison == 0) return true; // "sort" the two chunks using the comparator. final Chunk leftMost = comparison==-1 ? this : other; final Chunk rightMost = comparison==1 ? this : other; final long leftMostBlockAddress = BlockCompressedFilePointerUtil.getBlockAddress(leftMost.getChunkEnd()); final long rightMostBlockAddress = BlockCompressedFilePointerUtil.getBlockAddress(rightMost.getChunkStart()); // If the left block's address is after the right block's address, compare the two blocks. // If the two blocks are identical, compare the block offsets. // If the right block is after the left block, no overlap is possible. if(leftMostBlockAddress > rightMostBlockAddress) return true; else if(leftMostBlockAddress == rightMostBlockAddress) { final int leftMostOffset = BlockCompressedFilePointerUtil.getBlockOffset(leftMost.getChunkEnd()); final int rightMostOffset = BlockCompressedFilePointerUtil.getBlockOffset(rightMost.getChunkStart()); return leftMostOffset > rightMostOffset; } else return false; }
/** * Returns whether two chunks overlap. * @param other Chunk to which this should be compared. * @return True if the chunks overlap. Returns false if the two chunks abut or are disjoint. */ public boolean overlaps(final Chunk other) { final int comparison = this.compareTo(other); if(comparison == 0) return true; // "sort" the two chunks using the comparator. final Chunk leftMost = comparison==-1 ? this : other; final Chunk rightMost = comparison==1 ? this : other; final long leftMostBlockAddress = BlockCompressedFilePointerUtil.getBlockAddress(leftMost.getChunkEnd()); final long rightMostBlockAddress = BlockCompressedFilePointerUtil.getBlockAddress(rightMost.getChunkStart()); // If the left block's address is after the right block's address, compare the two blocks. // If the two blocks are identical, compare the block offsets. // If the right block is after the left block, no overlap is possible. if(leftMostBlockAddress > rightMostBlockAddress) return true; else if(leftMostBlockAddress == rightMostBlockAddress) { final int leftMostOffset = BlockCompressedFilePointerUtil.getBlockOffset(leftMost.getChunkEnd()); final int rightMostOffset = BlockCompressedFilePointerUtil.getBlockOffset(rightMost.getChunkStart()); return leftMostOffset > rightMostOffset; } else return false; }
/** * Create the virtual file pointer, and also assert that is can be converted back into the input parameters. * @param blockAddress * @param blockOffset * @return block compressed file pointer */ private long makeFilePointer(long blockAddress, int blockOffset) { final long ret = BlockCompressedFilePointerUtil.makeFilePointer(blockAddress, blockOffset); Assert.assertEquals(BlockCompressedFilePointerUtil.getBlockAddress(ret), blockAddress); Assert.assertEquals(BlockCompressedFilePointerUtil.getBlockOffset(ret), blockOffset); Assert.assertEquals(BlockCompressedFilePointerUtil.compare(ret, ret), 0); return ret; }
/** * Returns whether two chunks overlap. * @param other Chunk to which this should be compared. * @return True if the chunks overlap. Returns false if the two chunks abut or are disjoint. */ public boolean overlaps(final Chunk other) { final int comparison = this.compareTo(other); if(comparison == 0) return true; // "sort" the two chunks using the comparator. final Chunk leftMost = comparison==-1 ? this : other; final Chunk rightMost = comparison==1 ? this : other; final long leftMostBlockAddress = BlockCompressedFilePointerUtil.getBlockAddress(leftMost.getChunkEnd()); final long rightMostBlockAddress = BlockCompressedFilePointerUtil.getBlockAddress(rightMost.getChunkStart()); // If the left block's address is after the right block's address, compare the two blocks. // If the two blocks are identical, compare the block offsets. // If the right block is after the left block, no overlap is possible. if(leftMostBlockAddress > rightMostBlockAddress) return true; else if(leftMostBlockAddress == rightMostBlockAddress) { final int leftMostOffset = BlockCompressedFilePointerUtil.getBlockOffset(leftMost.getChunkEnd()); final int rightMostOffset = BlockCompressedFilePointerUtil.getBlockOffset(rightMost.getChunkStart()); return leftMostOffset > rightMostOffset; } else return false; }
final int uncompressedOffset = BlockCompressedFilePointerUtil.getBlockOffset(pos); final int available; if (mCurrentBlock != null && mCurrentBlock.mBlockAddress == compressedOffset) {
final int uncompressedOffset = BlockCompressedFilePointerUtil.getBlockOffset(pos); final int available; if (mCurrentBlock != null && mCurrentBlock.mBlockAddress == compressedOffset) {
final int uncompressedOffset = BlockCompressedFilePointerUtil.getBlockOffset(pos); final int available; if (mCurrentBlock != null && mCurrentBlock.getBlockAddress() == compressedOffset) {
@Test(dataProvider = "gzippedBedTestData") public void testReadActualHeader(final File gzippedBedFile, final int firstFeatureOffset) throws IOException { // Given an indexable SOURCE on a BED file, test that readActualHeader retains the correct offset // of the first feature, whether there is a header or not BEDCodec bedCodec = new BEDCodec(); try (final InputStream is = ParsingUtils.openInputStream(gzippedBedFile.getPath()); final BlockCompressedInputStream bcis = new BlockCompressedInputStream(is)) { AsciiLineReaderIterator it = (AsciiLineReaderIterator) bedCodec.makeIndexableSourceFromStream(bcis); Object header = bedCodec.readActualHeader(it); // BEDCodec doesn't model or return the BED header, even when there is one! Assert.assertNull(header); Assert.assertEquals(BlockCompressedFilePointerUtil.getBlockAddress(it.getPosition()), 0); Assert.assertEquals(BlockCompressedFilePointerUtil.getBlockOffset(it.getPosition()), firstFeatureOffset); } }