Git Product home page Git Product logo

goskizze's Introduction

goskizze

goskizze is a Go client for the Skizze database.

Documentation

Installation

Install goskizze with the go get command:

go get gopkg.in/skizzehq/goskizze.v1/skizze

Example

package main

import (
	"fmt"
	"gopkg.in/skizzehq/goskizze.v1/skizze"
)

func main() {
	client, err := skizze.Dial("127.0.0.1:3596", skizze.Options{Insecure: true})
	if err != nil {
		fmt.Printf("Error connecting to Skizze: %s\n", err)
		return
	}
	
	// A domain is an easy way to use the same data set for multiple statistics
	name := "testdomain"
	client.CreateDomain(name)

	// Adding values to a domain will trigger statistics generation for each of
	// the supported Sketches in the domain
	client.AddToDomain(name, "alvin", "simon", "theodore")
	
	// The Membership sketch will test if a value resides in a data set, returning
	// true or false
	membs, _ := client.GetMembership(name, "alvin", "simon", "theodore", "gary")
	for _, m := range membs {
		fmt.Printf("MEMB: %s is in %s: %v\n", m.Value, name, m.IsMember)
	}


	// The Frequency sketch will return how many times a value occurs in a sketch
	freqs, _ := client.GetFrequency(name, "alvin", "simon", "theodore", "gary")
	for _, f := range freqs {
		fmt.Printf("FREQ: %s appears in %s %v times\n", f.Value, name, f.Count)
	}

	// The Rankings sketch will always keep the top N (configurable) rankings and
	// their occurrance counts
	ranks, _ := client.GetRankings(name)
	for i, r := range ranks {
		fmt.Printf("RANK: #%v = %s (count=%v)\n", i, r.Value, r.Count)
	}

	// Finally, the Cardinality sketch will keep a count of how many unique items
	// have been added to the data set
	card, _ := client.GetCardinality(name)
	fmt.Printf("CARD: There are %v items in the %s domain\n\n", card, name)
	
	client.DeleteDomain(name)
}

Output:

MEMB: alvin is in testdomain: true
MEMB: simon is in testdomain: true
MEMB: theodore is in testdomain: true
MEMB: gary is in testdomain: false

FREQ: alvin appears in testdomain 1 times
FREQ: simon appears in testdomain 1 times
FREQ: theodore appears in testdomain 1 times
FREQ: gary appears in testdomain 0 times

RANK: #0 = alvin (count=1)
RANK: #1 = simon (count=1)
RANK: #2 = theodore (count=1)

CARD: There are 3 items in the testdomain domain

Note: Error checking has been removed for readability, but should be done in production code.

TODO

  • Support customized domain/sketch creation (with properties)
  • Benchmarking
  • Reduce allocations

License

goskizze is available under the Apache License, Version 2.0.

Authors

goskizze's People

Contributors

njpatel avatar seiflotfy avatar

Stargazers

巴拉巴拉小魔仙 avatar Glenn 'devalias' Grant avatar Tom Thorogood avatar George Erickson avatar Jonathan Gautheron avatar Florian Schlachter avatar Alix Axel avatar  avatar  avatar  avatar

Watchers

 avatar James Cloos avatar Martin avatar  avatar  avatar

Forkers

njpatel

goskizze's Issues

Add State and Property to Sketch Info

Every sketch should have the following extra attributes:

  • State (change):
    • FillRate: how full is the sketch
    • LastSnapshot: when was the last snapshot taken
  • Properties (don't change):
    • Threshold:
    • ErrorRate:
    • Guarantee: how full the sketch can get to ensure the error < ErrorRate

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.