func Open(opts Options) (*DB, error) {
	if err := util.MakeDirIfNotExists(opts.RootDir); err != nil {
		return nil, err
	}

	dbOptions = opts

	db := &DB{
		closed:       false,
		fileMap:      make(map[uint32]*logFile),
		staleDataMap: make(map[uint32]uint32),
		opts:         opts,
		rootDir:      opts.RootDir,
		table:        newMemTable(),
	}
	db.compactor = newFileCompactor(db)

	maxFileId, err := db.openLogFiles()
	if err != nil {
		return nil, err
	}
	db.nextFileId.Set(int32(maxFileId))

	manifest, err := openManifestFile(db.rootDir)
	if err != nil {
		return nil, err
	}
	db.manifest = manifest

	if manifest.DBOpen || manifest.IOError {
		log.Println("DB was not correctly closed. Repairing all files.", manifest.DBOpen, manifest.IOError)

		if err := db.repairFiles(); err != nil {
			return nil, err
		}
	}

	manifest.DBOpen = true
	manifest.IOError = false
	if err := manifest.Save(db.rootDir); err != nil {
		return nil, err
	}

	if err := db.recoverFromDisk(); err != nil {
		return nil, err
	}

	db.nextSeqNumber++

	db.compactor.start()

	return db, nil
}
// Open create a new Eagle instance in the target directory and loads existing data from disk.
Open create a new Eagle instance in the target directory and loads existing data from disk.
// Open create a new Eagle instance in the target directory and loads existing data from disk .
func Open(opts Options) (*DB, error) {
	if err := util.MakeDirIfNotExists(opts.RootDir); err != nil {
		return nil, err
	}
	dbOptions = opts
	db := &DB{
		closed:       false,
		fileMap:      make(map[uint32]*logFile),
		staleDataMap: make(map[uint32]uint32),
		opts:         opts,
		rootDir:      opts.RootDir,
		table:        newMemTable(),
	}
	db.compactor = newFileCompactor(db)
	maxFileId, err := db.openLogFiles()
	if err != nil {
		return nil, err
	}
	db.nextFileId.Set(int32(maxFileId))
	manifest, err := openManifestFile(db.rootDir)
	if err != nil {
		return nil, err
	}
	db.manifest = manifest
	if manifest.DBOpen || manifest.IOError {
		log.Println("DB was not correctly closed. Repairing all files.", manifest.DBOpen, manifest.IOError)
		if err := db.repairFiles(); err != nil {
			return nil, err
		}
	}
	manifest.DBOpen = true
	manifest.IOError = false
	if err := manifest.Save(db.rootDir); err != nil {
		return nil, err
	}
	if err := db.recoverFromDisk(); err != nil {
		return nil, err
	}
	db.nextSeqNumber++
	db.compactor.start()
	return db, nil
}
func Open ( opts Options ) ( * DB , error ) { if err := util . MakeDirIfNotExists ( opts . RootDir ) ; err != nil { return nil , err } dbOptions = opts db := & DB { closed : false , fileMap : make ( map [ uint32 ] * logFile ) , staleDataMap : make ( map [ uint32 ] uint32 ) , opts : opts , rootDir : opts . RootDir , table : newMemTable ( ) , } db . compactor = newFileCompactor ( db ) maxFileId , err := db . openLogFiles ( ) if err != nil { return nil , err } db . nextFileId . Set ( int32 ( maxFileId ) ) manifest , err := openManifestFile ( db . rootDir ) if err != nil { return nil , err } db . manifest = manifest if manifest . DBOpen || manifest . IOError { log . Println ( " " , manifest . DBOpen , manifest . IOError ) if err := db . repairFiles ( ) ; err != nil { return nil , err } } manifest . DBOpen = true manifest . IOError = false if err := manifest . Save ( db . rootDir ) ; err != nil { return nil , err } if err := db . recoverFromDisk ( ) ; err != nil { return nil , err } db . nextSeqNumber ++ db . compactor . start ( ) return db , nil }
Open create a new Eagle instance in the target directory and loads existing data from disk.
Open create a new Eagle instance in the target directory and loads existing data from disk .