src/storage/source/PartitionedFile.cc
PageID PartitionedFile::loadPageIdFromCurPos(FilePartitionID partitionId,
                                             unsigned int pageSeqInPartition,
                                             char* pageInCache,
                                             size_t length) {
    FILE* curFile = this->dataFiles.at(partitionId);
    if (curFile == nullptr) {
        return 0;
    }
    if (pageSeqInPartition < this->getMetaData()->getPartition(partitionId)->getNumPages()) {
        PageID pageId;
        size_t size = fread(&pageId, sizeof(char), sizeof(PageID), curFile);
        if (size == 0) {
            std::cout << "PartitionedFile: Read failed" << std::endl;
            return (PageID)(-1);
        }
        return pageId;
    } else {
        return (PageID)(-1);
    }
}
/**
  * Similar with above method.
  * The difference is this method will not seek, it just load sequentially,
  * so the caller needs to make sure current position is correct.
  */
Similar with above method.
The difference is this method will not seek, it just load sequentially,
so the caller needs to make sure current position is correct.
Similar with above method . The difference is this method will not seek it just load sequentially so the caller needs to make sure current position is correct .
PageID PartitionedFile::loadPageIdFromCurPos(FilePartitionID partitionId,
                                             unsigned int pageSeqInPartition,
                                             char* pageInCache,
                                             size_t length) {
    FILE* curFile = this->dataFiles.at(partitionId);
    if (curFile == nullptr) {
        return 0;
    }
    if (pageSeqInPartition < this->getMetaData()->getPartition(partitionId)->getNumPages()) {
        PageID pageId;
        size_t size = fread(&pageId, sizeof(char), sizeof(PageID), curFile);
        if (size == 0) {
            std::cout << "PartitionedFile: Read failed" << std::endl;
            return (PageID)(-1);
        }
        return pageId;
    } else {
        return (PageID)(-1);
    }
}
PageID PartitionedFile :: loadPageIdFromCurPos ( FilePartitionID partitionId , unsigned int pageSeqInPartition , char * pageInCache , size_t length ) { FILE * curFile = this -> dataFiles . at ( partitionId ) ; if ( curFile == nullptr ) { return 0 ; } if ( pageSeqInPartition < this -> getMetaData ( ) -> getPartition ( partitionId ) -> getNumPages ( ) ) { PageID pageId ; size_t size = fread ( & pageId , sizeof ( char ) , sizeof ( PageID ) , curFile ) ; if ( size == 0 ) { std :: cout << " " << std :: endl ; return ( PageID ) ( -1 ) ; } return pageId ; } else { return ( PageID ) ( -1 ) ; } }
Similar with above method.
Similar with above method .