From 11bd2fc1ee6b087416e7c60f6080505f6f0cecc2 Mon Sep 17 00:00:00 2001 From: Cedric Fung Date: Thu, 19 Sep 2024 18:00:52 +0000 Subject: [PATCH] upgrade the dgraph ristretto module --- go.mod | 4 +- go.sum | 8 +- p2p/handle.go | 35 -------- .../cpuguy83/go-md2man/v2/md2man/debug.go | 62 +++++++++++++ .../cpuguy83/go-md2man/v2/md2man/md2man.go | 9 +- .../cpuguy83/go-md2man/v2/md2man/roff.go | 88 ++++++++++++------- .../github.com/dgraph-io/ristretto/.gitignore | 3 + .../github.com/dgraph-io/ristretto/cache.go | 16 ++-- .../github.com/dgraph-io/ristretto/store.go | 1 + vendor/github.com/dgraph-io/ristretto/ttl.go | 72 ++++++++++----- .../dgraph-io/ristretto/z/allocator.go | 4 +- .../dgraph-io/ristretto/z/mmap_js.go | 40 +++++++++ .../dgraph-io/ristretto/z/mmap_linux.go | 3 + .../dgraph-io/ristretto/z/mmap_unix.go | 4 +- .../dgraph-io/ristretto/z/mremap_nosize.go | 3 +- .../dgraph-io/ristretto/z/mremap_size.go | 4 +- vendor/modules.txt | 4 +- 17 files changed, 247 insertions(+), 113 deletions(-) create mode 100644 vendor/github.com/cpuguy83/go-md2man/v2/md2man/debug.go create mode 100644 vendor/github.com/dgraph-io/ristretto/.gitignore create mode 100644 vendor/github.com/dgraph-io/ristretto/z/mmap_js.go diff --git a/go.mod b/go.mod index c25bc1907..44df4de5b 100644 --- a/go.mod +++ b/go.mod @@ -7,7 +7,7 @@ replace github.com/dgraph-io/badger/v4 => github.com/MixinNetwork/badger/v4 v4.3 require ( filippo.io/edwards25519 v1.1.0 github.com/dgraph-io/badger/v4 v4.3.0 - github.com/dgraph-io/ristretto v0.1.2-0.20240116140435-c67e07994f91 + github.com/dgraph-io/ristretto v1.0.0 github.com/pelletier/go-toml v1.9.5 github.com/quic-go/quic-go v0.47.0 github.com/shopspring/decimal v1.4.0 @@ -19,7 +19,7 @@ require ( require ( github.com/cespare/xxhash/v2 v2.3.0 // indirect - github.com/cpuguy83/go-md2man/v2 v2.0.4 // indirect + github.com/cpuguy83/go-md2man/v2 v2.0.5 // indirect github.com/davecgh/go-spew v1.1.1 // indirect github.com/dustin/go-humanize v1.0.1 // indirect github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572 // indirect diff --git a/go.sum b/go.sum index e8bb28c51..1e60b38f4 100644 --- a/go.sum +++ b/go.sum @@ -4,13 +4,13 @@ github.com/MixinNetwork/badger/v4 v4.3.0-F1 h1:s6/DUM3qFyqPcESwSerpvCmWtpQ2TL8wQ github.com/MixinNetwork/badger/v4 v4.3.0-F1/go.mod h1:42o0EL86yekTcj8jpQ7sX2s3hE6A8VC57pJBiC3IqdU= github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs= github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= -github.com/cpuguy83/go-md2man/v2 v2.0.4 h1:wfIWP927BUkWJb2NmU/kNDYIBTh/ziUX91+lVfRxZq4= -github.com/cpuguy83/go-md2man/v2 v2.0.4/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= +github.com/cpuguy83/go-md2man/v2 v2.0.5 h1:ZtcqGrnekaHpVLArFSe4HK5DoKx1T0rq2DwVB0alcyc= +github.com/cpuguy83/go-md2man/v2 v2.0.5/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/dgraph-io/ristretto v0.1.2-0.20240116140435-c67e07994f91 h1:Pux6+xANi0I7RRo5E1gflI4EZ2yx3BGZ75JkAIvGEOA= -github.com/dgraph-io/ristretto v0.1.2-0.20240116140435-c67e07994f91/go.mod h1:swkazRqnUf1N62d0Nutz7KIj2UKqsm/H8tD0nBJAXqM= +github.com/dgraph-io/ristretto v1.0.0 h1:SYG07bONKMlFDUYu5pEu3DGAh8c2OFNzKm6G9J4Si84= +github.com/dgraph-io/ristretto v1.0.0/go.mod h1:jTi2FiYEhQ1NsMmA7DeBykizjOuY88NhKBkepyu1jPc= github.com/dustin/go-humanize v1.0.1 h1:GzkhY7T5VNhEkwH0PVJgjz+fX1rhBrR7pRT3mDkpeCY= github.com/dustin/go-humanize v1.0.1/go.mod h1:Mu1zIs6XwVuF/gI1OepvI0qD18qycQx+mFykh5fBlto= github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572 h1:tfuBGBXKqDEevZMzYi5KSi8KkcZtzBcTgAUUtapy0OI= diff --git a/p2p/handle.go b/p2p/handle.go index b9630a209..e7e1a10a1 100644 --- a/p2p/handle.go +++ b/p2p/handle.go @@ -588,38 +588,3 @@ func unmarshalSyncPoints(b []byte) ([]*SyncPoint, error) { } return points, nil } - -func marshalPeers(peers []string) []byte { - enc := common.NewMinimumEncoder() - enc.WriteInt(len(peers)) - for _, p := range peers { - enc.WriteInt(len(p)) - enc.Write([]byte(p)) - } - return enc.Bytes() -} - -func unmarshalPeers(b []byte) ([]string, error) { - dec, err := common.NewMinimumDecoder(b) - if err != nil { - return nil, err - } - count, err := dec.ReadInt() - if err != nil { - return nil, err - } - peers := make([]string, count) - for i := range peers { - as, err := dec.ReadInt() - if err != nil { - return nil, err - } - addr := make([]byte, as) - err = dec.Read(addr) - if err != nil { - return nil, err - } - peers[i] = string(addr) - } - return peers, nil -} diff --git a/vendor/github.com/cpuguy83/go-md2man/v2/md2man/debug.go b/vendor/github.com/cpuguy83/go-md2man/v2/md2man/debug.go new file mode 100644 index 000000000..0ec4b12c7 --- /dev/null +++ b/vendor/github.com/cpuguy83/go-md2man/v2/md2man/debug.go @@ -0,0 +1,62 @@ +package md2man + +import ( + "fmt" + "io" + "os" + "strings" + + "github.com/russross/blackfriday/v2" +) + +func fmtListFlags(flags blackfriday.ListType) string { + knownFlags := []struct { + name string + flag blackfriday.ListType + }{ + {"ListTypeOrdered", blackfriday.ListTypeOrdered}, + {"ListTypeDefinition", blackfriday.ListTypeDefinition}, + {"ListTypeTerm", blackfriday.ListTypeTerm}, + {"ListItemContainsBlock", blackfriday.ListItemContainsBlock}, + {"ListItemBeginningOfList", blackfriday.ListItemBeginningOfList}, + {"ListItemEndOfList", blackfriday.ListItemEndOfList}, + } + + var f []string + for _, kf := range knownFlags { + if flags&kf.flag != 0 { + f = append(f, kf.name) + flags &^= kf.flag + } + } + if flags != 0 { + f = append(f, fmt.Sprintf("Unknown(%#x)", flags)) + } + return strings.Join(f, "|") +} + +type debugDecorator struct { + blackfriday.Renderer +} + +func depth(node *blackfriday.Node) int { + d := 0 + for n := node.Parent; n != nil; n = n.Parent { + d++ + } + return d +} + +func (d *debugDecorator) RenderNode(w io.Writer, node *blackfriday.Node, entering bool) blackfriday.WalkStatus { + fmt.Fprintf(os.Stderr, "%s%s %v %v\n", + strings.Repeat(" ", depth(node)), + map[bool]string{true: "+", false: "-"}[entering], + node, + fmtListFlags(node.ListFlags)) + var b strings.Builder + status := d.Renderer.RenderNode(io.MultiWriter(&b, w), node, entering) + if b.Len() > 0 { + fmt.Fprintf(os.Stderr, ">> %q\n", b.String()) + } + return status +} diff --git a/vendor/github.com/cpuguy83/go-md2man/v2/md2man/md2man.go b/vendor/github.com/cpuguy83/go-md2man/v2/md2man/md2man.go index 42bf32aab..62d91b77d 100644 --- a/vendor/github.com/cpuguy83/go-md2man/v2/md2man/md2man.go +++ b/vendor/github.com/cpuguy83/go-md2man/v2/md2man/md2man.go @@ -1,16 +1,23 @@ package md2man import ( + "os" + "strconv" + "github.com/russross/blackfriday/v2" ) // Render converts a markdown document into a roff formatted document. func Render(doc []byte) []byte { renderer := NewRoffRenderer() + var r blackfriday.Renderer = renderer + if v, _ := strconv.ParseBool(os.Getenv("MD2MAN_DEBUG")); v { + r = &debugDecorator{Renderer: r} + } return blackfriday.Run(doc, []blackfriday.Option{ - blackfriday.WithRenderer(renderer), + blackfriday.WithRenderer(r), blackfriday.WithExtensions(renderer.GetExtensions()), }...) } diff --git a/vendor/github.com/cpuguy83/go-md2man/v2/md2man/roff.go b/vendor/github.com/cpuguy83/go-md2man/v2/md2man/roff.go index 8a290f197..9d6c473fd 100644 --- a/vendor/github.com/cpuguy83/go-md2man/v2/md2man/roff.go +++ b/vendor/github.com/cpuguy83/go-md2man/v2/md2man/roff.go @@ -14,10 +14,8 @@ import ( // roffRenderer implements the blackfriday.Renderer interface for creating // roff format (manpages) from markdown text type roffRenderer struct { - extensions blackfriday.Extensions listCounters []int firstHeader bool - firstDD bool listDepth int } @@ -43,7 +41,7 @@ const ( quoteTag = "\n.PP\n.RS\n" quoteCloseTag = "\n.RE\n" listTag = "\n.RS\n" - listCloseTag = "\n.RE\n" + listCloseTag = ".RE\n" dtTag = "\n.TP\n" dd2Tag = "\n" tableStart = "\n.TS\nallbox;\n" @@ -56,23 +54,18 @@ const ( // NewRoffRenderer creates a new blackfriday Renderer for generating roff documents // from markdown func NewRoffRenderer() *roffRenderer { // nolint: golint - var extensions blackfriday.Extensions - - extensions |= blackfriday.NoIntraEmphasis - extensions |= blackfriday.Tables - extensions |= blackfriday.FencedCode - extensions |= blackfriday.SpaceHeadings - extensions |= blackfriday.Footnotes - extensions |= blackfriday.Titleblock - extensions |= blackfriday.DefinitionLists - return &roffRenderer{ - extensions: extensions, - } + return &roffRenderer{} } // GetExtensions returns the list of extensions used by this renderer implementation -func (r *roffRenderer) GetExtensions() blackfriday.Extensions { - return r.extensions +func (*roffRenderer) GetExtensions() blackfriday.Extensions { + return blackfriday.NoIntraEmphasis | + blackfriday.Tables | + blackfriday.FencedCode | + blackfriday.SpaceHeadings | + blackfriday.Footnotes | + blackfriday.Titleblock | + blackfriday.DefinitionLists } // RenderHeader handles outputting the header at document start @@ -103,7 +96,23 @@ func (r *roffRenderer) RenderNode(w io.Writer, node *blackfriday.Node, entering switch node.Type { case blackfriday.Text: - escapeSpecialChars(w, node.Literal) + // Special case: format the NAME section as required for proper whatis parsing. + // Refer to the lexgrog(1) and groff_man(7) manual pages for details. + if node.Parent != nil && + node.Parent.Type == blackfriday.Paragraph && + node.Parent.Prev != nil && + node.Parent.Prev.Type == blackfriday.Heading && + node.Parent.Prev.FirstChild != nil && + bytes.EqualFold(node.Parent.Prev.FirstChild.Literal, []byte("NAME")) { + before, after, found := bytes.Cut(node.Literal, []byte(" - ")) + escapeSpecialChars(w, before) + if found { + out(w, ` \- `) + escapeSpecialChars(w, after) + } + } else { + escapeSpecialChars(w, node.Literal) + } case blackfriday.Softbreak: out(w, crTag) case blackfriday.Hardbreak: @@ -141,14 +150,25 @@ func (r *roffRenderer) RenderNode(w io.Writer, node *blackfriday.Node, entering case blackfriday.Document: break case blackfriday.Paragraph: - // roff .PP markers break lists - if r.listDepth > 0 { - return blackfriday.GoToNext - } if entering { - out(w, paraTag) + if r.listDepth > 0 { + // roff .PP markers break lists + if node.Prev != nil { // continued paragraph + if node.Prev.Type == blackfriday.List && node.Prev.ListFlags&blackfriday.ListTypeDefinition == 0 { + out(w, ".IP\n") + } else { + out(w, crTag) + } + } + } else if node.Prev != nil && node.Prev.Type == blackfriday.Heading { + out(w, crTag) + } else { + out(w, paraTag) + } } else { - out(w, crTag) + if node.Next == nil || node.Next.Type != blackfriday.List { + out(w, crTag) + } } case blackfriday.BlockQuote: if entering { @@ -211,6 +231,10 @@ func (r *roffRenderer) handleHeading(w io.Writer, node *blackfriday.Node, enteri func (r *roffRenderer) handleList(w io.Writer, node *blackfriday.Node, entering bool) { openTag := listTag closeTag := listCloseTag + if (entering && r.listDepth == 0) || (!entering && r.listDepth == 1) { + openTag = crTag + closeTag = "" + } if node.ListFlags&blackfriday.ListTypeDefinition != 0 { // tags for definition lists handled within Item node openTag = "" @@ -239,23 +263,25 @@ func (r *roffRenderer) handleItem(w io.Writer, node *blackfriday.Node, entering } else if node.ListFlags&blackfriday.ListTypeTerm != 0 { // DT (definition term): line just before DD (see below). out(w, dtTag) - r.firstDD = true } else if node.ListFlags&blackfriday.ListTypeDefinition != 0 { // DD (definition description): line that starts with ": ". // // We have to distinguish between the first DD and the // subsequent ones, as there should be no vertical // whitespace between the DT and the first DD. - if r.firstDD { - r.firstDD = false - } else { - out(w, dd2Tag) + if node.Prev != nil && node.Prev.ListFlags&(blackfriday.ListTypeTerm|blackfriday.ListTypeDefinition) == blackfriday.ListTypeDefinition { + if node.Prev.Type == blackfriday.Item && + node.Prev.LastChild != nil && + node.Prev.LastChild.Type == blackfriday.List && + node.Prev.LastChild.ListFlags&blackfriday.ListTypeDefinition == 0 { + out(w, ".IP\n") + } else { + out(w, dd2Tag) + } } } else { out(w, ".IP \\(bu 2\n") } - } else { - out(w, "\n") } } diff --git a/vendor/github.com/dgraph-io/ristretto/.gitignore b/vendor/github.com/dgraph-io/ristretto/.gitignore new file mode 100644 index 000000000..64bd91384 --- /dev/null +++ b/vendor/github.com/dgraph-io/ristretto/.gitignore @@ -0,0 +1,3 @@ +# IDE +.idea +.vscode \ No newline at end of file diff --git a/vendor/github.com/dgraph-io/ristretto/cache.go b/vendor/github.com/dgraph-io/ristretto/cache.go index 398ee1413..7a40b0e75 100644 --- a/vendor/github.com/dgraph-io/ristretto/cache.go +++ b/vendor/github.com/dgraph-io/ristretto/cache.go @@ -72,7 +72,7 @@ type Cache[K Key, V any] struct { // stop is used to stop the processItems goroutine. stop chan struct{} // indicates whether cache is closed. - isClosed bool + isClosed atomic.Bool // cost calculates cost from a value. cost func(value V) int64 // ignoreInternalCost dictates whether to ignore the cost of internally storing @@ -221,7 +221,7 @@ func NewCache[K Key, V any](config *Config[K, V]) (*Cache[K, V], error) { // Wait blocks until all buffered writes have been applied. This ensures a call to Set() // will be visible to future calls to Get(). func (c *Cache[K, V]) Wait() { - if c == nil || c.isClosed { + if c == nil || c.isClosed.Load() { return } wg := &sync.WaitGroup{} @@ -234,7 +234,7 @@ func (c *Cache[K, V]) Wait() { // value was found or not. The value can be nil and the boolean can be true at // the same time. Get will not return expired items. func (c *Cache[K, V]) Get(key K) (V, bool) { - if c == nil || c.isClosed { + if c == nil || c.isClosed.Load() { return zeroValue[V](), false } keyHash, conflictHash := c.keyToHash(key) @@ -267,7 +267,7 @@ func (c *Cache[K, V]) Set(key K, value V, cost int64) bool { // expires, which is identical to calling Set. A negative value is a no-op and the value // is discarded. func (c *Cache[K, V]) SetWithTTL(key K, value V, cost int64, ttl time.Duration) bool { - if c == nil || c.isClosed { + if c == nil || c.isClosed.Load() { return false } @@ -316,7 +316,7 @@ func (c *Cache[K, V]) SetWithTTL(key K, value V, cost int64, ttl time.Duration) // Del deletes the key-value item from the cache if it exists. func (c *Cache[K, V]) Del(key K) { - if c == nil || c.isClosed { + if c == nil || c.isClosed.Load() { return } keyHash, conflictHash := c.keyToHash(key) @@ -363,7 +363,7 @@ func (c *Cache[K, V]) GetTTL(key K) (time.Duration, bool) { // Close stops all goroutines and closes all channels. func (c *Cache[K, V]) Close() { - if c == nil || c.isClosed { + if c == nil || c.isClosed.Load() { return } c.Clear() @@ -374,14 +374,14 @@ func (c *Cache[K, V]) Close() { close(c.setBuf) c.cachePolicy.Close() c.cleanupTicker.Stop() - c.isClosed = true + c.isClosed.Store(true) } // Clear empties the hashmap and zeroes all cachePolicy counters. Note that this is // not an atomic operation (but that shouldn't be a problem as it's assumed that // Set/Get calls won't be occurring until after this). func (c *Cache[K, V]) Clear() { - if c == nil || c.isClosed { + if c == nil || c.isClosed.Load() { return } // Block until processItems goroutine is returned. diff --git a/vendor/github.com/dgraph-io/ristretto/store.go b/vendor/github.com/dgraph-io/ristretto/store.go index 3a53d593f..e2ca800c1 100644 --- a/vendor/github.com/dgraph-io/ristretto/store.go +++ b/vendor/github.com/dgraph-io/ristretto/store.go @@ -111,6 +111,7 @@ func (sm *shardedMap[V]) Clear(onEvict func(item *Item[V])) { for i := uint64(0); i < numShards; i++ { sm.shards[i].Clear(onEvict) } + sm.expiryMap.clear() } type lockedMap[V any] struct { diff --git a/vendor/github.com/dgraph-io/ristretto/ttl.go b/vendor/github.com/dgraph-io/ristretto/ttl.go index b71c1d80d..08e77c169 100644 --- a/vendor/github.com/dgraph-io/ristretto/ttl.go +++ b/vendor/github.com/dgraph-io/ristretto/ttl.go @@ -42,12 +42,14 @@ type bucket map[uint64]uint64 // expirationMap is a map of bucket number to the corresponding bucket. type expirationMap[V any] struct { sync.RWMutex - buckets map[int64]bucket + buckets map[int64]bucket + lastCleanedBucketNum int64 } func newExpirationMap[V any]() *expirationMap[V] { return &expirationMap[V]{ - buckets: make(map[int64]bucket), + buckets: make(map[int64]bucket), + lastCleanedBucketNum: cleanupBucket(time.Now()), } } @@ -87,6 +89,11 @@ func (m *expirationMap[_]) update(key, conflict uint64, oldExpTime, newExpTime t delete(oldBucket, key) } + // Items that don't expire don't need to be in the expiration map. + if newExpTime.IsZero() { + return + } + newBucketNum := storageBucket(newExpTime) newBucket, ok := m.buckets[newBucketNum] if !ok { @@ -121,29 +128,50 @@ func (m *expirationMap[V]) cleanup(store store[V], policy policy[V], onEvict fun m.Lock() now := time.Now() - bucketNum := cleanupBucket(now) - keys := m.buckets[bucketNum] - delete(m.buckets, bucketNum) + currentBucketNum := cleanupBucket(now) + // Clean up all buckets up to and including currentBucketNum, starting from + // (but not including) the last one that was cleaned up + var buckets []bucket + for bucketNum := m.lastCleanedBucketNum + 1; bucketNum <= currentBucketNum; bucketNum++ { + buckets = append(buckets, m.buckets[bucketNum]) + delete(m.buckets, bucketNum) + } + m.lastCleanedBucketNum = currentBucketNum m.Unlock() - for key, conflict := range keys { - expr := store.Expiration(key) - // Sanity check. Verify that the store agrees that this key is expired. - if expr.After(now) { - continue + for _, keys := range buckets { + for key, conflict := range keys { + expr := store.Expiration(key) + // Sanity check. Verify that the store agrees that this key is expired. + if expr.After(now) { + continue + } + + cost := policy.Cost(key) + policy.Del(key) + _, value := store.Del(key, conflict) + + if onEvict != nil { + onEvict(&Item[V]{Key: key, + Conflict: conflict, + Value: value, + Cost: cost, + Expiration: expr, + }) + } } + } +} - cost := policy.Cost(key) - policy.Del(key) - _, value := store.Del(key, conflict) - - if onEvict != nil { - onEvict(&Item[V]{Key: key, - Conflict: conflict, - Value: value, - Cost: cost, - Expiration: expr, - }) - } +// clear clears the expirationMap, the caller is responsible for properly +// evicting the referenced items +func (m *expirationMap[V]) clear() { + if m == nil { + return } + + m.Lock() + m.buckets = make(map[int64]bucket) + m.lastCleanedBucketNum = cleanupBucket(time.Now()) + m.Unlock() } diff --git a/vendor/github.com/dgraph-io/ristretto/z/allocator.go b/vendor/github.com/dgraph-io/ristretto/z/allocator.go index eae0f8344..dc272f68f 100644 --- a/vendor/github.com/dgraph-io/ristretto/z/allocator.go +++ b/vendor/github.com/dgraph-io/ristretto/z/allocator.go @@ -56,9 +56,7 @@ func init() { allocs = make(map[uint64]*Allocator) // Set up a unique Ref per process. - rand.Seed(time.Now().UnixNano()) - allocRef = uint64(rand.Int63n(1<<16)) << 48 //nolint:gosec // cryptographic precision not needed - + allocRef = uint64(rand.Int63n(1<<16)) << 48 calculatedLog2 = make([]int, 1025) for i := 1; i <= 1024; i++ { calculatedLog2[i] = int(math.Log2(float64(i))) diff --git a/vendor/github.com/dgraph-io/ristretto/z/mmap_js.go b/vendor/github.com/dgraph-io/ristretto/z/mmap_js.go new file mode 100644 index 000000000..d15b56296 --- /dev/null +++ b/vendor/github.com/dgraph-io/ristretto/z/mmap_js.go @@ -0,0 +1,40 @@ +//go:build js + +/* + * Copyright 2023 Dgraph Labs, Inc. and Contributors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package z + +import ( + "os" + "syscall" +) + +func mmap(fd *os.File, writeable bool, size int64) ([]byte, error) { + return nil, syscall.ENOSYS +} + +func munmap(b []byte) error { + return syscall.ENOSYS +} + +func madvise(b []byte, readahead bool) error { + return syscall.ENOSYS +} + +func msync(b []byte) error { + return syscall.ENOSYS +} diff --git a/vendor/github.com/dgraph-io/ristretto/z/mmap_linux.go b/vendor/github.com/dgraph-io/ristretto/z/mmap_linux.go index 331330cff..1d68f8fe8 100644 --- a/vendor/github.com/dgraph-io/ristretto/z/mmap_linux.go +++ b/vendor/github.com/dgraph-io/ristretto/z/mmap_linux.go @@ -1,3 +1,6 @@ +//go:build !js +// +build !js + /* * Copyright 2020 Dgraph Labs, Inc. and Contributors * diff --git a/vendor/github.com/dgraph-io/ristretto/z/mmap_unix.go b/vendor/github.com/dgraph-io/ristretto/z/mmap_unix.go index 629449f9d..13f2bb0c6 100644 --- a/vendor/github.com/dgraph-io/ristretto/z/mmap_unix.go +++ b/vendor/github.com/dgraph-io/ristretto/z/mmap_unix.go @@ -1,5 +1,5 @@ -//go:build !windows && !darwin && !plan9 && !linux && !wasip1 -// +build !windows,!darwin,!plan9,!linux,!wasip1 +//go:build !windows && !darwin && !plan9 && !linux && !wasip1 && !js +// +build !windows,!darwin,!plan9,!linux,!wasip1,!js /* * Copyright 2019 Dgraph Labs, Inc. and Contributors diff --git a/vendor/github.com/dgraph-io/ristretto/z/mremap_nosize.go b/vendor/github.com/dgraph-io/ristretto/z/mremap_nosize.go index d31009a8b..c052bebba 100644 --- a/vendor/github.com/dgraph-io/ristretto/z/mremap_nosize.go +++ b/vendor/github.com/dgraph-io/ristretto/z/mremap_nosize.go @@ -1,6 +1,7 @@ -//go:build (arm64 || arm) && linux +//go:build (arm64 || arm) && linux && !js // +build arm64 arm // +build linux +// +build !js /* * Copyright 2020 Dgraph Labs, Inc. and Contributors diff --git a/vendor/github.com/dgraph-io/ristretto/z/mremap_size.go b/vendor/github.com/dgraph-io/ristretto/z/mremap_size.go index 35ff3ef17..958587d73 100644 --- a/vendor/github.com/dgraph-io/ristretto/z/mremap_size.go +++ b/vendor/github.com/dgraph-io/ristretto/z/mremap_size.go @@ -1,5 +1,5 @@ -//go:build linux && !arm64 && !arm -// +build linux,!arm64,!arm +//go:build linux && !arm64 && !arm && !js +// +build linux,!arm64,!arm,!js /* * Copyright 2020 Dgraph Labs, Inc. and Contributors diff --git a/vendor/modules.txt b/vendor/modules.txt index 738a403e2..3885ff6de 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -5,7 +5,7 @@ filippo.io/edwards25519/field # github.com/cespare/xxhash/v2 v2.3.0 ## explicit; go 1.11 github.com/cespare/xxhash/v2 -# github.com/cpuguy83/go-md2man/v2 v2.0.4 +# github.com/cpuguy83/go-md2man/v2 v2.0.5 ## explicit; go 1.11 github.com/cpuguy83/go-md2man/v2/md2man # github.com/davecgh/go-spew v1.1.1 @@ -21,7 +21,7 @@ github.com/dgraph-io/badger/v4/skl github.com/dgraph-io/badger/v4/table github.com/dgraph-io/badger/v4/trie github.com/dgraph-io/badger/v4/y -# github.com/dgraph-io/ristretto v0.1.2-0.20240116140435-c67e07994f91 +# github.com/dgraph-io/ristretto v1.0.0 ## explicit; go 1.19 github.com/dgraph-io/ristretto github.com/dgraph-io/ristretto/z