Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reapply "feat: support enabling mmap for collection (#632)" (#635) #661

Merged
merged 1 commit into from
Jan 30, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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`
akMmap = "mmap.enabled"
)

// 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 = 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
}
Loading