コード例 #1
0
ファイル: tocentry.c プロジェクト: ncbi/ncbi-vdb
rc_t KTocInflatePBSTree ( KToc * self, uint64_t arcsize, const void * treestart, uint32_t maxsize,
			 uint64_t offset, bool rev, const char * path )
{
    rc_t rc;
    PBSTree * pbst;

    rc = PBSTreeMake (&pbst, treestart, maxsize, rev);
    if (rc == 0)
    {
        KTocEntryInflateData data;

        data.toc = self;
        data.path = path;
        data.arcsize = arcsize;
        data.rc = 0;
        data.rev = rev;
        data.offset = offset;
        
        PBSTreeForEach (pbst, false, KTocEntryInflate, &data);

        rc = data.rc;

        PBSTreeWhack (pbst);
    }
    return rc;
}
コード例 #2
0
ファイル: wu64idx-v3.c プロジェクト: ImAWolf/ncbi-vdb
rc_t KU64IndexOpen_v3(KU64Index_v3* self, struct KMMap const *mm, bool byteswap)
{
    rc_t rc = 0;
    const char* maddr;
    size_t msize;
    PBSTree* ptree = NULL;

    self->rc = 0;
    BSTreeInit(&self->tree);

    /* when opened for create, there will be no existing index */
    if( mm == NULL ) {
        return 0;
    }

    /* open the prior index in persisted mode */
    rc = KMMapAddrRead(mm, (const void**)&maddr);
    if( rc != 0 ) {
        return rc;
    }
    rc = KMMapSize(mm, &msize);
    if( rc != 0 ) {
        return rc;
    }
    if( msize <= sizeof(struct KIndexFileHeader_v3) ) {
        return 0;
    }

    rc = PBSTreeMake(&ptree, (const void**)(maddr + sizeof(struct KIndexFileHeader_v3)),
                     msize - sizeof(struct KIndexFileHeader_v3), byteswap);
    if( rc != 0 ) {
        return rc;
    }

    PBSTreeDoUntil(ptree, false, KU64Index_UnrollPersisted, self);
    rc = self->rc;

    PBSTreeWhack(ptree);

    if( rc != 0 ) {
        KU64IndexWhack_v3(self);
    }
    return rc;
}