From d4dee7633fde56cc271aa29e45944d9811d4f6bf Mon Sep 17 00:00:00 2001 From: yah01 Date: Tue, 30 Jan 2024 14:08:17 +0800 Subject: [PATCH] Reapply "feat: support enabling mmap for collection (#632)" (#635) This reverts commit 43226a3ea27a218698f5c13fe58cab73750633a6. --- entity/collection_attr.go | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/entity/collection_attr.go b/entity/collection_attr.go index c96f297a..ff739c38 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` + akMmap = "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 = akMmap + 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 +}