Pckbuckettable *gt_pckbuckettable_map(const char *indexname, unsigned int numofchars, GtError *err) { size_t numofbytes; void *mapptr; unsigned int maxdepth; Pckbuckettable *pckbt; gt_error_check(err); mapptr = gt_fa_mmap_read_with_suffix(indexname,PCKBUCKETTABLE, &numofbytes,err); if (mapptr == NULL) { return NULL; } maxdepth = (unsigned int) ((unsigned long *) mapptr)[0]; pckbt = pckbuckettable_allocandinittable(numofchars,maxdepth,false); pckbt->mapptr = mapptr; pckbt->mbtab[0] = (Mbtab *) (((unsigned long *) mapptr) + 1); pckbuckettable_settaboffsets(pckbt); gt_assert(numofbytes == sizeof (unsigned long) + sizeof (Mbtab) * pckbt->maxnumofvalues); return pckbt; }
Tyrcountinfo *gt_tyrcountinfo_new(const Tyrindex *tyrindex, const char *tyrindexname, GtError *err) { size_t numofbytes; void *tmp; bool haserr = false; Tyrcountinfo *tyrcountinfo; gt_error_check(err); tyrcountinfo = gt_malloc(sizeof *tyrcountinfo); tyrcountinfo->indexfilename = tyrindexname; tyrcountinfo->mappedmctfileptr = gt_fa_mmap_read_with_suffix(tyrindexname,COUNTSSUFFIX,&numofbytes,err); if (tyrcountinfo->mappedmctfileptr == NULL) { tyrcountinfo->smallcounts = NULL; haserr = true; } else { tyrcountinfo->smallcounts = (GtUchar *) tyrcountinfo->mappedmctfileptr; tmp = &tyrcountinfo->smallcounts[tyrindex->numofmers]; tyrcountinfo->largecounts = (Largecount *) tmp; if (numofbytes < tyrindex->numofmers) { gt_error_set(err,"size of file \"%s.%s\" is smaller than minimum size " ""GT_WU"",tyrindexname,COUNTSSUFFIX, (GtUword) tyrindex->numofmers); haserr = true; } } if (!haserr && (numofbytes - tyrindex->numofmers) % sizeof (Largecount) != 0) { gt_error_set(err,"(numofbytes - numofmers) = "GT_WU " must be a multiple of "GT_WU, (GtUword) (numofbytes - tyrindex->numofmers), (GtUword) sizeof (Largecount)); haserr = true; } if (!haserr) { tyrcountinfo->numoflargecounts = (GtUword) (numofbytes - tyrindex->numofmers)/ (GtUword) sizeof (Largecount); } if (haserr) { if (tyrcountinfo->mappedmctfileptr != NULL) { gt_fa_xmunmap(tyrcountinfo->mappedmctfileptr); tyrcountinfo->mappedmctfileptr = NULL; } gt_free(tyrcountinfo); } return haserr ? NULL : tyrcountinfo; }
Tyrindex *gt_tyrindex_new(const char *tyrindexname,GtError *err) { bool haserr = false; size_t numofbytes, rest; Tyrindex *tyrindex; gt_error_check(err); tyrindex = gt_malloc(sizeof *tyrindex); tyrindex->indexfilename = tyrindexname; tyrindex->mappedfileptr = gt_fa_mmap_read_with_suffix(tyrindexname,MERSUFFIX, &numofbytes,err); if (tyrindex->mappedfileptr == NULL) { haserr = true; } if (!haserr) { tyrindex->mertable = (GtUchar *) tyrindex->mappedfileptr; rest = sizeof (GtUword) * EXTRAINTEGERS; if (rest > numofbytes) { gt_error_set(err,"index must contain at least "GT_WU" bytes", (GtUword) rest); haserr = true; } } if (!haserr) { gt_assert(tyrindex->mertable != NULL); tyrindex->mersize = gt_decodesingleinteger(tyrindex->mertable + numofbytes - rest); tyrindex->alphasize = (unsigned int) gt_decodesingleinteger(tyrindex->mertable + numofbytes - rest + sizeof (GtUword)); tyrindex->merbytes = MERBYTES(tyrindex->mersize); if ((numofbytes - rest) % tyrindex->merbytes != 0) { gt_error_set(err,"size of index is "GT_WU " which is not a multiple of "GT_WU, (GtUword) (numofbytes - rest), tyrindex->merbytes); haserr = true; } } if (!haserr) { tyrindex->numofmers = (numofbytes - rest) / tyrindex->merbytes; gt_assert(tyrindex->mertable != NULL); if (tyrindex->numofmers == 0) { tyrindex->lastmer = tyrindex->mertable - 1; } else { tyrindex->lastmer = tyrindex->mertable + numofbytes - rest - tyrindex->merbytes; } } if (haserr) { if (tyrindex->mappedfileptr != NULL) { gt_fa_xmunmap(tyrindex->mappedfileptr); tyrindex->mappedfileptr = NULL; } gt_free(tyrindex); } return haserr ? NULL : tyrindex; }