예제 #1
0
  /**
   * Creates a new IndexedDataStore instance. The created store has the following parameters:
   *
   * <pre>
   *   BytesDB segmentCompactFactor : 0.5
   *   Index segmentCompactFactor   : 0.5
   *   Index hashLoadFactor         : 0.75
   *   Index hashFunction           : krati.util.FnvHashFunction
   * </pre>
   *
   * @param homeDir - the home directory of IndexedDataStore
   * @param batchSize - the number of updates per update batch
   * @param numSyncBatches - the number of update batches required for updating <code>indexes.dat
   *     </code>
   * @param indexInitLevel - the level for initializing HashIndex
   * @param indexSegmentFileSizeMB - the segment file size in MB for HashIndex
   * @param indexSegmentFactory - the segment factory for HashIndex
   * @param storeInitLevel - the level for initializing BytesDB
   * @param storeSegmentFileSizeMB - the segment file size in MB for BytesDB
   * @param storeSegmentFactory - the segment factory for BytesDB
   * @throws Exception if this IndexedDataStore cannot be created.
   */
  public IndexedDataStore(
      File homeDir,
      int batchSize,
      int numSyncBatches,
      int indexInitLevel,
      int indexSegmentFileSizeMB,
      SegmentFactory indexSegmentFactory,
      int storeInitLevel,
      int storeSegmentFileSizeMB,
      SegmentFactory storeSegmentFactory)
      throws Exception {
    this._homeDir = homeDir;
    this._batchSize = batchSize;

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

    int storeInitialCapacity = StoreParams.getDynamicStoreInitialCapacity(storeInitLevel);
    StoreConfig storeConfig = new StoreConfig(_storeHome, storeInitialCapacity);
    storeConfig.setBatchSize(batchSize);
    storeConfig.setNumSyncBatches(numSyncBatches);
    storeConfig.setSegmentFileSizeMB(storeSegmentFileSizeMB);
    storeConfig.setSegmentFactory(storeSegmentFactory);
    _bytesDB = new BytesDB(storeConfig);

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

    int indexInitialCapacity = StoreParams.getDynamicStoreInitialCapacity(indexInitLevel);
    StoreConfig indexConfig = new StoreConfig(_indexHome, indexInitialCapacity);
    indexConfig.setBatchSize(batchSize);
    indexConfig.setNumSyncBatches(numSyncBatches);
    indexConfig.setSegmentFileSizeMB(indexSegmentFileSizeMB);
    indexConfig.setSegmentFactory(indexSegmentFactory);
    _index = new HashIndex(indexConfig);

    _logger.info(
        "opened indexHome="
            + _indexHome.getAbsolutePath()
            + " storeHome="
            + _storeHome.getAbsolutePath());
  }
예제 #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());
  }