Giter VIP home page Giter VIP logo

Comments (4)

cuonglm avatar cuonglm commented on August 18, 2024 1

Hmm, my bad, as SimpleMap is only used for testing.

from smt.

cuonglm avatar cuonglm commented on August 18, 2024

cc @odeke-em

from smt.

cuonglm avatar cuonglm commented on August 18, 2024

Note that only the SetString matter, the DeleteString and GetString are just the same as Delete and Get, but for completeness of APIs, better to introduce the string version for all methods.

If we don't care about backward-compatible, then we can just change the current methods signature, and also un-export SimpleMap, too, as it's highly coupled to internal usage only.

from smt.

adlerjohn avatar adlerjohn commented on August 18, 2024

The provided SimpleMap only exists so users can use the library with no external dependencies, e.g. for testing or prototyping purposes. It's absolutely not meant to be used in production; in production, a k-v store like RocksDB will be used that implements the MapStore interface, and for that it's important that the key used is a byte slice []byte since the key will be a hash or something.

smt/mapstore.go

Lines 8 to 12 in 85c78b7

type MapStore interface {
Get(key []byte) ([]byte, error) // Get gets the value for a key.
Set(key []byte, value []byte) error // Set updates the value for a key.
Delete(key []byte) error // Delete deletes a key.
}

TL;DR: no, the MapStore interface should not be changed to use a string as the key. And SimpleMap should not be removed if we want to allow users to start using the library with no external dependencies to at least prototype.

Also, your new benchmark is highly synthetic as it uses the same key over and over. In practice, that won't be the case. Instead, every operation will use a different key. And each key being different means allocating a new slice each time, something that your benchmark omits. If you allocate a new (different) string each iteration, you'll probably see the benchmarks being much closer together.

from smt.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.