func (rd *RAMDirectory) Close() error {
	rd.IsOpen = false
	rd.fileMapLock.Lock()
	defer rd.fileMapLock.Unlock()
	rd.fileMap = make(map[string]*RAMFile)
	return nil
}
Closes the store to future operations, releasing associated memroy.
package store
import (
	"errors"
	"fmt"
	"github.com/balzaczyy/golucene/core/util"
	"hash"
	"hash/crc32"
	"math"
	"os"
	"sync"
	"sync/atomic"
	"unsafe"
)
type RAMDirectory struct {
	*DirectoryImpl
	*BaseDirectory
	sizeInBytes int64  
	fileMap     map[string]*RAMFile  
	fileMapLock *sync.RWMutex
}
func NewRAMDirectory() *RAMDirectory {
	ans := &RAMDirectory{
		fileMap:     make(map[string]*RAMFile),
		fileMapLock: &sync.RWMutex{},
	}
	ans.DirectoryImpl = NewDirectoryImpl(ans)
	ans.BaseDirectory = NewBaseDirectory(ans)
	ans.SetLockFactory(newSingleInstanceLockFactory())
	return ans
}
func (d *RAMDirectory) LockID() string {
	return fmt.Sprintf("lucene-%v", util.ItoHex(int64(uintptr(unsafe.Pointer(&d)))))
}
func (rd *RAMDirectory) ListAll() (names []string, err error) {
	rd.EnsureOpen()
	rd.fileMapLock.RLock()
	defer rd.fileMapLock.RUnlock()
	names = make([]string, 0, len(rd.fileMap))
	for name, _ := range rd.fileMap {
		names = append(names, name)
	}
	return names, nil
}
func (rd *RAMDirectory) FileExists(name string) bool {
	rd.EnsureOpen()
	rd.fileMapLock.RLock()
	defer rd.fileMapLock.RUnlock()
	_, ok := rd.fileMap[name]
	return ok
}
func (rd *RAMDirectory) FileLength(name string) (length int64, err error) {
	rd.EnsureOpen()
	rd.fileMapLock.RLock()
	defer rd.fileMapLock.RUnlock()
	if file, ok := rd.fileMap[name]; ok {
		return file.Length(), nil
	}
	return 0, os.ErrNotExist
}
func (rd *RAMDirectory) RamBytesUsed() int64 {
	rd.EnsureOpen()
	return atomic.LoadInt64(&rd.sizeInBytes)
}
func (rd *RAMDirectory) DeleteFile(name string) error {
	rd.EnsureOpen()
	rd.fileMapLock.RLock()
	defer rd.fileMapLock.RUnlock()
	if file, ok := rd.fileMap[name]; ok {
		file.directory = nil
		atomic.AddInt64(&rd.sizeInBytes, -file.sizeInBytes)
		return nil
	}
	return errors.New(name)
}
func (rd *RAMDirectory) CreateOutput(name string, context IOContext) (out IndexOutput, err error) {
	rd.EnsureOpen()
	file := rd.newRAMFile()
	rd.fileMapLock.Lock()
	defer rd.fileMapLock.Unlock()
	if existing, ok := rd.fileMap[name]; ok {
		atomic.AddInt64(&rd.sizeInBytes, -existing.sizeInBytes)
		existing.directory = nil
	}
	rd.fileMap[name] = file
	return NewRAMOutputStream(file, true), nil
}
func (rd *RAMDirectory) newRAMFile() *RAMFile {
	return NewRAMFile(rd)
}
func (rd *RAMDirectory) Sync(names []string) error {
	return nil
}
func (rd *RAMDirectory) OpenInput(name string, context IOContext) (in IndexInput, err error) {
	rd.EnsureOpen()
	if file, ok := rd.fileMap[name]; ok {
		return newRAMInputStream(name, file)
	}
	return nil, errors.New(name)
}