]> git.donarmstrong.com Git - samtools.git/commitdiff
bugfix in caching
authorHeng Li <lh3@me.com>
Sun, 18 Mar 2012 16:12:23 +0000 (12:12 -0400)
committerHeng Li <lh3@me.com>
Sun, 18 Mar 2012 16:12:23 +0000 (12:12 -0400)
bgzf.c
sam_view.c

diff --git a/bgzf.c b/bgzf.c
index 281aac0d932191b0faa99361772fefdfce5e094b..9de2fc356bd927d85bae6ba30ced1010cff69560 100644 (file)
--- a/bgzf.c
+++ b/bgzf.c
@@ -267,7 +267,7 @@ static int load_block_from_cache(BGZF *fp, int64_t block_address)
        if (fp->block_length != 0) fp->block_offset = 0;
        fp->block_address = block_address;
        fp->block_length = p->size;
-       memcpy(fp->uncompressed_block, p->block, BGZF_BLOCK_SIZE);
+       memcpy(fp->uncompressed_block, p->block, BGZF_MAX_BLOCK_SIZE);
        _bgzf_seek((_bgzf_file_t)fp->fp, p->end_offset, SEEK_SET);
        return p->size;
 }
@@ -278,8 +278,8 @@ static void cache_block(BGZF *fp, int size)
        khint_t k;
        cache_t *p;
        khash_t(cache) *h = (khash_t(cache)*)fp->cache;
-       if (BGZF_BLOCK_SIZE >= fp->cache_size) return;
-       if ((kh_size(h) + 1) * BGZF_BLOCK_SIZE > fp->cache_size) {
+       if (BGZF_MAX_BLOCK_SIZE >= fp->cache_size) return;
+       if ((kh_size(h) + 1) * BGZF_MAX_BLOCK_SIZE > fp->cache_size) {
                /* A better way would be to remove the oldest block in the
                 * cache, but here we remove a random one for simplicity. This
                 * should not have a big impact on performance. */
@@ -295,8 +295,8 @@ static void cache_block(BGZF *fp, int size)
        p = &kh_val(h, k);
        p->size = fp->block_length;
        p->end_offset = fp->block_address + size;
-       p->block = malloc(BGZF_BLOCK_SIZE);
-       memcpy(kh_val(h, k).block, fp->uncompressed_block, BGZF_BLOCK_SIZE);
+       p->block = malloc(BGZF_MAX_BLOCK_SIZE);
+       memcpy(kh_val(h, k).block, fp->uncompressed_block, BGZF_MAX_BLOCK_SIZE);
 }
 #else
 static void free_cache(BGZF *fp) {}
index b9bde44ebd4b6e28d03f909a2ee4c6cc586c43f1..f198591e9aabbe44f67ee35c1497d2e73d0a3d7d 100644 (file)
@@ -209,7 +209,7 @@ int main_samview(int argc, char *argv[])
                ret = 1;
                goto view_end;
        }
-       if (n_threads > 1) samthreads(out, n_threads, 16); 
+       if (n_threads > 1) samthreads(out, n_threads, 256); 
        if (is_header_only) goto view_end; // no need to print alignments
 
        if (argc == optind + 1) { // convert/print the entire file