Skip to content

Commit

Permalink
feat: support enabling mmap for collection
Browse files Browse the repository at this point in the history
Signed-off-by: yah01 <[email protected]>
  • Loading branch information
yah01 committed Dec 5, 2023
1 parent e47dcc1 commit 4f2d61b
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions entity/collection_attr.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Check failure on line 25 in entity/collection_attr.go

View workflow job for this annotation

GitHub Actions / lint

var-naming: don't use leading k in Go names; const kMmap should be mmap (revive)

Check warning on line 25 in entity/collection_attr.go

View workflow job for this annotation

GitHub Actions / lint

var-naming: don't use leading k in Go names; const kMmap should be mmap (revive)
)

// CollectionAttribute is the interface for altering collection attributes.
Expand Down Expand Up @@ -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
}

0 comments on commit 4f2d61b

Please sign in to comment.