@gmod/tabix 3.4.0 → 3.4.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chunk.d.ts +2 -1
- package/dist/chunk.js +8 -2
- package/dist/chunk.js.map +1 -1
- package/dist/csi.js +5 -1
- package/dist/csi.js.map +1 -1
- package/dist/indexFile.d.ts +6 -0
- package/dist/indexFile.js.map +1 -1
- package/dist/tabix-bundle.js +1 -1
- package/dist/tabixIndexedFile.d.ts +1 -1
- package/dist/tbi.js +5 -1
- package/dist/tbi.js.map +1 -1
- package/dist/util.d.ts +1 -0
- package/dist/util.js +34 -1
- package/dist/util.js.map +1 -1
- package/esm/chunk.d.ts +2 -1
- package/esm/chunk.js +8 -2
- package/esm/chunk.js.map +1 -1
- package/esm/csi.js +6 -2
- package/esm/csi.js.map +1 -1
- package/esm/indexFile.d.ts +6 -0
- package/esm/indexFile.js.map +1 -1
- package/esm/tabixIndexedFile.d.ts +1 -1
- package/esm/tbi.js +6 -2
- package/esm/tbi.js.map +1 -1
- package/esm/util.d.ts +1 -0
- package/esm/util.js +33 -1
- package/esm/util.js.map +1 -1
- package/package.json +8 -8
- package/src/chunk.ts +13 -2
- package/src/csi.ts +6 -1
- package/src/indexFile.ts +6 -0
- package/src/tabixIndexedFile.ts +1 -1
- package/src/tbi.ts +9 -1
- package/src/util.ts +34 -0
package/src/util.ts
CHANGED
|
@@ -65,6 +65,7 @@ export function optimizeChunks(chunks: Chunk[], lowest?: VirtualOffset) {
|
|
|
65
65
|
lastChunk.minv,
|
|
66
66
|
chunk.maxv,
|
|
67
67
|
lastChunk.bin,
|
|
68
|
+
chunk.endPosition,
|
|
68
69
|
)
|
|
69
70
|
lastMaxBlock = chunkMaxBlock
|
|
70
71
|
}
|
|
@@ -78,6 +79,39 @@ export function optimizeChunks(chunks: Chunk[], lowest?: VirtualOffset) {
|
|
|
78
79
|
return mergedChunks
|
|
79
80
|
}
|
|
80
81
|
|
|
82
|
+
// Tighten each chunk's endPosition (default: a full max-size BGZF block past
|
|
83
|
+
// maxv) down to the next known block boundary. Every chunk min/maxv blockPosition
|
|
84
|
+
// and every extraBoundary (e.g. linear-index entries) is a real BGZF block start;
|
|
85
|
+
// since blocks don't overlap, the first boundary strictly greater than a chunk's
|
|
86
|
+
// maxv.blockPosition is an upper bound on where that final block ends — always at
|
|
87
|
+
// least the true block end, so the clamped fetch still contains the whole block.
|
|
88
|
+
// Shrinks both the byte estimate and the actual fetch with no extra I/O.
|
|
89
|
+
export function clampChunkEnds(chunks: Chunk[], extraBoundaries: number[] = []) {
|
|
90
|
+
const boundaries = [...extraBoundaries]
|
|
91
|
+
for (const c of chunks) {
|
|
92
|
+
boundaries.push(c.minv.blockPosition, c.maxv.blockPosition)
|
|
93
|
+
}
|
|
94
|
+
boundaries.sort((a, b) => a - b)
|
|
95
|
+
|
|
96
|
+
for (const c of chunks) {
|
|
97
|
+
const max = c.maxv.blockPosition
|
|
98
|
+
// first boundary strictly greater than max
|
|
99
|
+
let lo = 0
|
|
100
|
+
let hi = boundaries.length
|
|
101
|
+
while (lo < hi) {
|
|
102
|
+
const mid = (lo + hi) >>> 1
|
|
103
|
+
if (boundaries[mid]! > max) {
|
|
104
|
+
hi = mid
|
|
105
|
+
} else {
|
|
106
|
+
lo = mid + 1
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
if (lo < boundaries.length) {
|
|
110
|
+
c.endPosition = Math.min(c.endPosition, boundaries[lo]!)
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
|
|
81
115
|
export function findFirstData(
|
|
82
116
|
currentFdl: VirtualOffset | undefined,
|
|
83
117
|
virtualOffset: VirtualOffset,
|