Skip to content

sirgallo/cmapv2

Repository files navigation

cmapv2

installation

In your Go project main directory (where the go.mod file is located)

go get github.com/sirgallo/cmapv2
go mod tidy

Make sure to run go mod tidy to install dependencies.

usage

package main

import (
  "github.com/sirgallo/cmapv2"
)

func main() {
  // initialize c map
  cMap := cmap.NewMap()

  // insert key/val pair
  cMap.Put([]byte("hi"), []byte("world"))

  // retrieve value for key
  val := cMap.Get([]byte("hi"))

  // delete key/val pair
  cMap.Delete([]byte("hi"))

  // ===== OR

  // initialize sharded c map with number of shards
  sMap := cmap.NewMap(16)
  sMap.Put([]byte("hi"), []byte("world"))
  val := sMap.Get([]byte("hi"))
  sMap.Delete([]byte("hi"))
}

tests

go test -v ./

or with race:

go test -v -race ./

or bench:

go test -v -bench=. -benchmem -cpuprofile cpu.prof -memprofile mem.prof -coverprofile=coverage.out ./
go tool cover -html=coverage.out -o cov.html
open cov.html

and check results:

go tool pprof -http=:8080 cmapv2.test cpu.prof
go tool pprof -http=:8080 cmapv2.test mem.prof

benchmark

go test -v -bench=. -benchmem -cpuprofile cpu.prof -memprofile mem.prof ./benchmarks

or with race:

go test -race -v -bench=. -benchmem -cpuprofile cpu.prof -memprofile mem.prof ./benchmarks

fuzz

go test -fuzz=FuzzConcurrentOps -fuzztime=30s ./fuzz 

sources

CMap

Murmur

Tests

About

a concurrent hash array mapped trie implementation in go

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages