func OpenTable(path string) (*Table, error) {
	path = filepath.Clean(path)
	logger.Infof("opening table %q...", path)
	startTime := time.Now()

	// Create a directory for the table if it doesn't exist yet.
	if err := fs.MkdirAllIfNotExist(path); err != nil {
		return nil, fmt.Errorf("cannot create directory %q: %s", path, err)
	}

	// Protect from concurrent opens.
	flockFile := path + "/flock.lock"
	flockF, err := os.Create(flockFile)
	if err != nil {
		return nil, fmt.Errorf("cannot create lock file %q: %s", flockFile, err)
	}
	if err := unix.Flock(int(flockF.Fd()), unix.LOCK_EX|unix.LOCK_NB); err != nil {
		return nil, fmt.Errorf("cannot acquire lock on file %q: %s", flockFile, err)
	}

	// Open table parts.
	pws, err := openParts(path)
	if err != nil {
		return nil, fmt.Errorf("cannot open table parts at %q: %s", path, err)
	}

	tb := &Table{
		path:     path,
		parts:    pws,
		mergeIdx: uint64(time.Now().UnixNano()),
		flockF:   flockF,
		stopCh:   make(chan struct{}),
	}
	tb.startPartMergers()
	tb.startRawItemsFlusher()

	var m TableMetrics
	tb.UpdateMetrics(&m)
	logger.Infof("table %q has been opened in %s; partsCount: %d; blocksCount: %d, itemsCount: %d",
		path, time.Since(startTime), m.PartsCount, m.BlocksCount, m.ItemsCount)

	return tb, nil
}
// OpenTable opens a table on the given path.
//
// The table is created if it doesn't exist yet.
OpenTable opens a table on the given path.

The table is created if it doesn't exist yet.
// OpenTable opens a table on the given path . // // The table is created if it doesn ' t exist yet .
func OpenTable(path string) (*Table, error) {
	path = filepath.Clean(path)
	logger.Infof("opening table %q...", path)
	startTime := time.Now()
	if err := fs.MkdirAllIfNotExist(path); err != nil {
		return nil, fmt.Errorf("cannot create directory %q: %s", path, err)
	}
	flockFile := path + "/flock.lock"
	flockF, err := os.Create(flockFile)
	if err != nil {
		return nil, fmt.Errorf("cannot create lock file %q: %s", flockFile, err)
	}
	if err := unix.Flock(int(flockF.Fd()), unix.LOCK_EX|unix.LOCK_NB); err != nil {
		return nil, fmt.Errorf("cannot acquire lock on file %q: %s", flockFile, err)
	}
	pws, err := openParts(path)
	if err != nil {
		return nil, fmt.Errorf("cannot open table parts at %q: %s", path, err)
	}
	tb := &Table{
		path:     path,
		parts:    pws,
		mergeIdx: uint64(time.Now().UnixNano()),
		flockF:   flockF,
		stopCh:   make(chan struct{}),
	}
	tb.startPartMergers()
	tb.startRawItemsFlusher()
	var m TableMetrics
	tb.UpdateMetrics(&m)
	logger.Infof("table %q has been opened in %s; partsCount: %d; blocksCount: %d, itemsCount: %d",
		path, time.Since(startTime), m.PartsCount, m.BlocksCount, m.ItemsCount)
	return tb, nil
}
func OpenTable ( path string ) ( * Table , error ) { path = filepath . Clean ( path ) logger . Infof ( " " , path ) startTime := time . Now ( ) if err := fs . MkdirAllIfNotExist ( path ) ; err != nil { return nil , fmt . Errorf ( " " , path , err ) } flockFile := path + " " flockF , err := os . Create ( flockFile ) if err != nil { return nil , fmt . Errorf ( " " , flockFile , err ) } if err := unix . Flock ( int ( flockF . Fd ( ) ) , unix . LOCK_EX | unix . LOCK_NB ) ; err != nil { return nil , fmt . Errorf ( " " , flockFile , err ) } pws , err := openParts ( path ) if err != nil { return nil , fmt . Errorf ( " " , path , err ) } tb := & Table { path : path , parts : pws , mergeIdx : uint64 ( time . Now ( ) . UnixNano ( ) ) , flockF : flockF , stopCh : make ( chan struct { } ) , } tb . startPartMergers ( ) tb . startRawItemsFlusher ( ) var m TableMetrics tb . UpdateMetrics ( & m ) logger . Infof ( " " , path , time . Since ( startTime ) , m . PartsCount , m . BlocksCount , m . ItemsCount ) return tb , nil }
OpenTable opens a table on the given path.
OpenTable opens a table on the given path .
// Create a directory for the table if it doesn't exist yet. // Protect from concurrent opens. // Open table parts.