func NewNRTCachingDirectory(delegate Directory, maxMergeSizeMB, maxCachedMB float64) (nrt *NRTCachingDirectory) {
	nrt = &NRTCachingDirectory{
		Directory:         delegate,
		Locker:            &sync.Mutex{},
		cache:             NewRAMDirectory(),
		maxMergeSizeBytes: int64(maxMergeSizeMB * 1024 * 1024),
		maxCachedBytes:    int64(maxCachedMB * 1024 * 1024),
		uncacheLock:       &sync.Mutex{},
	}
	nrt.doCacheWrite = func(name string, context IOContext) bool {
		var bytes int64
		if context.MergeInfo != nil {
			bytes = context.MergeInfo.EstimatedMergeBytes
		} else if context.FlushInfo != nil {
			bytes = context.FlushInfo.EstimatedSegmentSize
		}
		if NRT_VERBOSE {
			log.Printf("CACHE check merge=%v flush=%v size=%v",
				context.MergeInfo, context.FlushInfo, bytes)
		}
		return name != "segments.gen" &&
			bytes <= nrt.maxMergeSizeBytes &&
			bytes+nrt.cache.RamBytesUsed() <= nrt.maxCachedBytes
	}
	return
}
/*
We will cache a newly created output if 1) it's a flush or a merge
and the estimated size of the merged segment is <= maxMergedSizeMB,
and 2) the total cached bytes is <= maxCachedMB.
package store
import (
	"fmt"
	"log"
	"sync"
)
const NRT_VERBOSE = false
type NRTCachingDirectory struct {
	Directory
	sync.Locker
	cache             *RAMDirectory
	maxMergeSizeBytes int64
	maxCachedBytes    int64
	doCacheWrite func(name string, context IOContext) bool
	uncacheLock  sync.Locker
}