public void testMaxCapacity() throws Exception {
    StoreConfig config = new StoreConfig(getHomeDir(), Integer.MAX_VALUE);
    config.setIndexesCached(false); // Do not cache indexes in memory

    StaticDataStore store = StoreFactory.createStaticDataStore(config);

    // Check store capacity
    assertEquals(Integer.MAX_VALUE, store.capacity());
    assertEquals(Integer.MAX_VALUE, store.getDataArray().length());

    store.close();
  }
Ejemplo n.º 2
0
  /**
   * Creates a new IndexedDataStore instance. The created store has the following parameters:
   *
   * <pre>
   *   Index cached :             : true
   *   Index segmentFileSizeMB    : 8
   *   Index segmentFactory       : krati.segment.MemorySegmentFactory
   * </pre>
   *
   * @param config - the store configuration
   * @throws Exception if the store cannot be created.
   */
  public IndexedDataStore(StoreConfig config) throws Exception {
    this._homeDir = config.getHomeDir();
    this._batchSize = config.getBatchSize();

    // Create bytesDB
    _storeHome = new File(_homeDir, "store");

    int storeInitialCapacity = config.getInitialCapacity();
    StoreConfig storeConfig = new StoreConfig(_storeHome, storeInitialCapacity);
    storeConfig.setIndexesCached(config.getIndexesCached());
    storeConfig.setBatchSize(config.getBatchSize());
    storeConfig.setNumSyncBatches(config.getNumSyncBatches());
    storeConfig.setSegmentFileSizeMB(config.getSegmentFileSizeMB());
    storeConfig.setSegmentFactory(config.getSegmentFactory());
    storeConfig.setSegmentCompactFactor(config.getSegmentCompactFactor());
    _bytesDB = new BytesDB(storeConfig);

    // Create hash index
    _indexHome = new File(_homeDir, "index");

    int indexInitialCapacity = config.getInitialCapacity();
    StoreConfig indexConfig = new StoreConfig(_indexHome, indexInitialCapacity);
    indexConfig.setBatchSize(config.getBatchSize());
    indexConfig.setNumSyncBatches(config.getNumSyncBatches());
    indexConfig.setIndexesCached(true); // indexes.dat is cached
    indexConfig.setSegmentFileSizeMB(8); // index segment size is 8 MB
    indexConfig.setSegmentFactory(new MemorySegmentFactory()); // index segment is MemorySegment
    indexConfig.setSegmentCompactFactor(config.getSegmentCompactFactor());
    indexConfig.setHashLoadFactor(config.getHashLoadFactor());
    indexConfig.setHashFunction(config.getHashFunction());
    indexConfig.setDataHandler(config.getDataHandler());
    _index = new HashIndex(indexConfig);

    _logger.info(
        "opened indexHome="
            + _indexHome.getAbsolutePath()
            + " storeHome="
            + _storeHome.getAbsolutePath());
  }