From 4f2d61b22a43dbf3d4fc08be66c8c0edc7516d7d Mon Sep 17 00:00:00 2001 From: yah01 Date: Tue, 5 Dec 2023 11:34:46 +0800 Subject: [PATCH] feat: support enabling mmap for collection Signed-off-by: yah01 --- entity/collection_attr.go | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/entity/collection_attr.go b/entity/collection_attr.go index c96f297a6..38164da6f 100644 --- a/entity/collection_attr.go +++ b/entity/collection_attr.go @@ -22,6 +22,7 @@ const ( cakTTL = `collection.ttl.seconds` // cakAutoCompaction const for collection attribute key autom compaction enabled. cakAutoCompaction = `collection.autocompaction.enabled` + kMmap = "mmap.enabled" ) // CollectionAttribute is the interface for altering collection attributes. @@ -89,3 +90,23 @@ func CollectionAutoCompactionEnabled(enabled bool) autoCompactionCollAttr { ca.value = strconv.FormatBool(enabled) return ca } + +type mmapAttr struct { + collAttrBase +} + +func Mmap(enabled bool) mmapAttr { + attr := mmapAttr{} + attr.key = kMmap + attr.value = strconv.FormatBool(enabled) + return attr +} + +func (ca mmapAttr) Valid() error { + _, err := strconv.ParseBool(ca.value) + if err != nil { + return errors.Wrap(err, "mmap setting is not valid boolean") + } + + return nil +}