Skip to content

Commit

Permalink
only merge index chunks that are in the same bgzip block
Browse files Browse the repository at this point in the history
  • Loading branch information
rbuels committed Jul 25, 2019
1 parent bb25513 commit e9bb883
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 5 deletions.
6 changes: 2 additions & 4 deletions src/util.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
const MAX_MERGED_BLOCK_SIZE = 30 * 2 ** 20 // 30 MB

module.exports = {
longToNumber(long) {
if (
Expand Down Expand Up @@ -40,9 +38,9 @@ module.exports = {

canMergeBlocks(block1, block2) {
return (
block1.minv.blockPosition === block1.maxv.blockPosition &&
block1.maxv.blockPosition === block2.minv.blockPosition &&
block2.maxv.blockPosition - block1.minv.blockPosition <=
MAX_MERGED_BLOCK_SIZE
block2.minv.blockPosition === block2.maxv.blockPosition
)
},
}
2 changes: 1 addition & 1 deletion test/csi.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ describe('csi index', () => {
let blocks = await ti.blocksForRange('1', 1, 4000)
expect(blocks.length).toEqual(0)
blocks = await ti.blocksForRange('1', 0, 2000046092)
expect(blocks.length).toEqual(1)
expect(blocks.length).toEqual(2)
expect(blocks[0].minv.blockPosition).toEqual(0)
expect(blocks[0].minv.dataPosition).toEqual(2560)
// console.log( blocks );
Expand Down

0 comments on commit e9bb883

Please sign in to comment.