void BingoPgBuildEngine::loadDictionary(BingoPgIndex& bingo_index) {
   _setBingoContext();

   QS_DEF(Array<char>, dict);
   bingo_index.readDictionary(dict);
   bingoSetConfigBin("cmf_dict", dict.ptr(), dict.sizeInBytes());
}
void BingoPgSearchEngine::prepareQuerySearch(BingoPgIndex& bingo_idx, PG_OBJECT) {
   _bufferIndexPtr = &bingo_idx;
   _currentSection = -1;
   _currentIdx = -1;
   _fetchFound = false;
   _blockBegin=0;
   _blockEnd=bingo_idx.getSectionNumber();
}
void BingoPgSearchEngine::loadDictionary(BingoPgIndex& bingo_index) {
   QS_DEF(Array<char>, dict);
   bingo_index.readDictionary(dict);
   bingoSetConfigBin("cmf_dict", dict.ptr(), dict.sizeInBytes());
}
Beispiel #4
0
BingoPgSection::BingoPgSection(BingoPgIndex& bingo_idx, int idx_strategy, int offset):
_index(bingo_idx.getIndexPtr()),
_offset(offset),
_idxStrategy(idx_strategy){

   /*
    * Clear section metainfo
    */
   clear();

   /*
    * Prepare section strategy
    */
   bool write = (_idxStrategy == BingoPgIndex::BUILDING_STRATEGY);
   if(write) {
      /*
       * If write then create new buffers
       */
      _sectionInfoBuffer.writeNewBuffer(_index, offset);
      _sectionInfoBuffer.changeAccess(BINGO_PG_NOLOCK);
      _sectionInfo.n_blocks_for_map = bingo_idx.getMapSize();
      _sectionInfo.n_blocks_for_fp = bingo_idx.getFpSize();
      /*
       * Initialize existing structures fingerprint
       */
      _existStructures.reset(new BingoPgBufferCacheFp(offset + 1, _index, true));

      /*
       * Initialize bits number buffers
       */
      for (int idx = 0; idx < SECTION_BITSNUMBER_PAGES; ++idx) {
         BingoPgBuffer& bits_buffer = _bitsCountBuffers.push();
         bits_buffer.writeNewBuffer(_index, offset + idx + SECTION_META_PAGES);
         bits_buffer.formEmptyIndexTuple(SECTION_BITS_PER_BLOCK * sizeof(unsigned short));
         bits_buffer.changeAccess(BINGO_PG_NOLOCK);
      }

   } else {
      /*
       * Read section meta info
       */
      _sectionInfoBuffer.readBuffer(_index, _offset, BINGO_PG_READ);
      int data_len;
      BingoSectionInfoData* data = (BingoSectionInfoData*)_sectionInfoBuffer.getIndexData(data_len);
      _sectionInfo = *data;
      _sectionInfoBuffer.changeAccess(BINGO_PG_NOLOCK);
      
      _existStructures.reset(new BingoPgBufferCacheFp(offset + 1, _index, false));
   }
   
   int fp_count = _sectionInfo.n_blocks_for_fp;
   int map_count = _sectionInfo.n_blocks_for_map;
   int bin_count = _sectionInfo.n_blocks_for_bin;
   /*
    * Prepare for reading or writing all the data buffers
    */
   int block_offset = offset + SECTION_META_PAGES + SECTION_BITSNUMBER_PAGES;
   for (int i = 0; i < map_count; ++i) {
      _buffersMap.add(new BingoPgBufferCacheMap(block_offset, _index, write));
      ++block_offset;
   }
   for (int i = 0; i < fp_count; ++i) {
      _buffersFp.add(new BingoPgBufferCacheFp(block_offset, _index, write));
      ++block_offset;
   }
   
   for (int i = 0; i < bin_count; ++i) {
      _buffersBin.add(new BingoPgBufferCacheBin(block_offset, _index, write));
      ++block_offset;
   }

}