예제 #1
0
 inline void check_curblock(size_t toread) {
     if (curblock == NULL || curblock->end < edataoffset+toread) {
         if (curblock != NULL) {
             if (!curblock->active) {
                 curblock->release(iomgr);
             }
         }
         // Load next
         std::string blockfilename = filename_shard_edata_block(filename_edata, (int) (edataoffset / blocksize), blocksize);
         int edata_session = iomgr->open_session(blockfilename, false, true);
         sblock<ET> newblock(edata_session, edata_session, true, blockfilename);
         
         // We align blocks always to the blocksize, even if that requires
         // allocating and reading some unnecessary data.
         newblock.offset = (edataoffset / blocksize) * blocksize; // Align
         size_t correction = edataoffset - newblock.offset;
         newblock.end = std::min(edatafilesize, newblock.offset + blocksize);
         assert(newblock.end >= newblock.offset);
         int realsize = get_block_uncompressed_size(blockfilename, newblock.end - newblock.offset);
         iomgr->managed_malloc(edata_session, &newblock.data, realsize, newblock.offset);
         newblock.ptr = newblock.data + correction;
         activeblocks.push_back(newblock);
         curblock = &activeblocks[activeblocks.size()-1];
         curblock->active = true;
         curblock->read_now(iomgr);
     }
 }
예제 #2
0
 void read_now(stripedio * iomgr) {
     if (is_edata_block) {
         int realsize = get_block_uncompressed_size(blockfilename, end-offset);
         iomgr->managed_preada_now(readdesc, &data, realsize, 0);
         int nedges = (end - offset) / sizeof(int); // Ugly
         dynblock = new dynamicdata_block<ET>(nedges, (uint8_t *) data, realsize);
     } else {
         iomgr->managed_preada_now(readdesc, &data, end - offset, offset);
     }
 }
예제 #3
0
 vdblock load_block(int blockid) {
     vdblock db(blockid);
     
     std::string blockfname = blockfilename(blockid);
     db.fd = iomgr->open_session(blockfname, false, true);
     int realsize = get_block_uncompressed_size(blockfname, -1);
     assert(realsize > 0);
     
     iomgr->managed_malloc(db.fd, &db.data, realsize, 0);
     iomgr->managed_preada_now(db.fd, &db.data, realsize, 0);
     db.dblock = new dynamicdata_block<VertexDataType>(verticesperblock, (uint8_t *)db.data, realsize);
     return db;
 }