Albirew/nyaa-pantsu
Archivé
1
0
Bifurcation 0
Ce dépôt a été archivé le 2022-05-07. Vous pouvez voir ses fichiers ou le cloner, mais pas ouvrir de ticket ou de demandes d'ajout, ni soumettre de changements.
nyaa-pantsu/vendor/github.com/RoaringBitmap/roaring
akuma06 a41f938cec Add Godep support (#758)
As we have seen, dependencies version can prevent the build. We should
user lock versions on dependencies that we know work:
* Packages are vendored
* Add Godep support
* Added addtional install step in readme
* Fix travis build error
2017-05-26 13:07:22 +02:00
..
.gitignore Add Godep support (#758) 2017-05-26 13:07:22 +02:00
.gitmodules Add Godep support (#758) 2017-05-26 13:07:22 +02:00
.travis.yml Add Godep support (#758) 2017-05-26 13:07:22 +02:00
arraycontainer.go Add Godep support (#758) 2017-05-26 13:07:22 +02:00
arraycontainer_gen.go Add Godep support (#758) 2017-05-26 13:07:22 +02:00
AUTHORS Add Godep support (#758) 2017-05-26 13:07:22 +02:00
bitmapcontainer.go Add Godep support (#758) 2017-05-26 13:07:22 +02:00
bitmapcontainer_gen.go Add Godep support (#758) 2017-05-26 13:07:22 +02:00
CONTRIBUTORS Add Godep support (#758) 2017-05-26 13:07:22 +02:00
ctz.go Add Godep support (#758) 2017-05-26 13:07:22 +02:00
fastaggregation.go Add Godep support (#758) 2017-05-26 13:07:22 +02:00
LICENSE Add Godep support (#758) 2017-05-26 13:07:22 +02:00
LICENSE-2.0.txt Add Godep support (#758) 2017-05-26 13:07:22 +02:00
Makefile Add Godep support (#758) 2017-05-26 13:07:22 +02:00
popcnt.go Add Godep support (#758) 2017-05-26 13:07:22 +02:00
popcnt_amd64.s Add Godep support (#758) 2017-05-26 13:07:22 +02:00
popcnt_asm.go Add Godep support (#758) 2017-05-26 13:07:22 +02:00
popcnt_generic.go Add Godep support (#758) 2017-05-26 13:07:22 +02:00
priorityqueue.go Add Godep support (#758) 2017-05-26 13:07:22 +02:00
README.md Add Godep support (#758) 2017-05-26 13:07:22 +02:00
rle.go Add Godep support (#758) 2017-05-26 13:07:22 +02:00
rle16.go Add Godep support (#758) 2017-05-26 13:07:22 +02:00
rle16_gen.go Add Godep support (#758) 2017-05-26 13:07:22 +02:00
rle_gen.go Add Godep support (#758) 2017-05-26 13:07:22 +02:00
rlecommon.go Add Godep support (#758) 2017-05-26 13:07:22 +02:00
rlei.go Add Godep support (#758) 2017-05-26 13:07:22 +02:00
roaring.go Add Godep support (#758) 2017-05-26 13:07:22 +02:00
roaringarray.go Add Godep support (#758) 2017-05-26 13:07:22 +02:00
roaringarray_gen.go Add Godep support (#758) 2017-05-26 13:07:22 +02:00
serialization.go Add Godep support (#758) 2017-05-26 13:07:22 +02:00
serialization_generic.go Add Godep support (#758) 2017-05-26 13:07:22 +02:00
serialization_littleendian.go Add Godep support (#758) 2017-05-26 13:07:22 +02:00
setutil.go Add Godep support (#758) 2017-05-26 13:07:22 +02:00
shortiterator.go Add Godep support (#758) 2017-05-26 13:07:22 +02:00
smat.go Add Godep support (#758) 2017-05-26 13:07:22 +02:00
util.go Add Godep support (#758) 2017-05-26 13:07:22 +02:00

roaring Build Status Coverage Status GoDoc Go Report Card

This is a go port of the Roaring bitmap data structure.

Roaring is used by Apache Spark, Apache Kylin, Netflix Atlas, LinkedIn Pinot, Druid.io, Whoosh, Pilosa, and Apache Lucene (as well as supporting systems such as Solr and Elastic).

Roaring bitmaps are found to work well in many important applications:

Use Roaring for bitmap compression whenever possible. Do not use other bitmap compression methods (Wang et al., SIGMOD 2017)

The roaring Go library is used by

  • Cloud Torrent: a self-hosted remote torrent client
  • runv: an Hypervisor-based runtime for the Open Containers Initiative

There are also Java and C/C++ versions. The Java, C, C++ and Go version are binary compatible: e.g, you can save bitmaps from a Java program and load them back in Go, and vice versa. We have a format specification.

This code is licensed under Apache License, Version 2.0 (ASL2.0).

Copyright 2016 by the authors.

References

Dependencies

Dependencies are fetched automatically by giving the -t flag to go get.

they include

  • github.com/smartystreets/goconvey/convey
  • github.com/willf/bitset
  • github.com/mschoch/smat

Note that the smat library requires Go 1.6 or better.

Installation

  • go get -t github.com/RoaringBitmap/roaring

Example

Here is a simplified but complete example:

package main

import (
    "fmt"
    "github.com/RoaringBitmap/roaring"
    "bytes"
)


func main() {
    // example inspired by https://github.com/fzandona/goroar
    fmt.Println("==roaring==")
    rb1 := roaring.BitmapOf(1, 2, 3, 4, 5, 100, 1000)
    fmt.Println(rb1.String())

    rb2 := roaring.BitmapOf(3, 4, 1000)
    fmt.Println(rb2.String())

    rb3 := roaring.NewBitmap()
    fmt.Println(rb3.String())

    fmt.Println("Cardinality: ", rb1.GetCardinality())

    fmt.Println("Contains 3? ", rb1.Contains(3))

    rb1.And(rb2)

    rb3.Add(1)
    rb3.Add(5)

    rb3.Or(rb1)

    // prints 1, 3, 4, 5, 1000
    i := rb3.Iterator()
    for i.HasNext() {
        fmt.Println(i.Next())
    }
    fmt.Println()

    // next we include an example of serialization
    buf := new(bytes.Buffer)
    rb1.WriteTo(buf) // we omit error handling
    newrb:= roaring.NewBitmap()
    newrb.ReadFrom(buf)
    if rb1.Equals(newrb) {
    	fmt.Println("I wrote the content to a byte stream and read it back.")
    }
}

If you wish to use serialization and handle errors, you might want to consider the following sample of code:

	rb := BitmapOf(1, 2, 3, 4, 5, 100, 1000)
	buf := new(bytes.Buffer)
	size,err:=rb.WriteTo(buf)
	if err != nil {
		t.Errorf("Failed writing")
	}
	newrb:= NewBitmap()
	size,err=newrb.ReadFrom(buf)
	if err != nil {
		t.Errorf("Failed reading")
	}
	if ! rb.Equals(newrb) {
		t.Errorf("Cannot retrieve serialized version")
	}

Given N integers in [0,x), then the serialized size in bytes of a Roaring bitmap should never exceed this bound:

8 + 9 * ((long)x+65535)/65536 + 2 * N

That is, given a fixed overhead for the universe size (x), Roaring bitmaps never use more than 2 bytes per integer. You can call BoundSerializedSizeInBytes for a more precise estimate.

Documentation

Current documentation is available at http://godoc.org/github.com/RoaringBitmap/roaring

Goroutine safety

In general, it should not generally be considered safe to access the same bitmaps using different goroutines--they are left unsynchronized for performance. Should you want to access a Bitmap from more than one goroutine, you should provide synchronization. Typically this is done by using channels to pass the *Bitmap around (in Go style; so there is only ever one owner), or by using sync.Mutex to serialize operations on Bitmaps.

Coverage

We test our software. For a report on our test coverage, see

https://coveralls.io/github/RoaringBitmap/roaring?branch=master

Benchmark

Type

     go test -bench Benchmark -run -

Iterative use

You can use roaring with gore:

  • go get -u github.com/motemen/gore
  • Make sure that $GOPATH/bin is in your $PATH.
  • go get github/RoaringBitmap/roaring
$ gore
gore version 0.2.6  :help for help
gore> :import github.com/RoaringBitmap/roaring
gore> x:=roaring.New()
gore> x.Add(1)
gore> x.String()
"{1}"

Fuzzy testing

You can help us test further the library with fuzzy testing:

     go get github.com/dvyukov/go-fuzz/go-fuzz
     go get github.com/dvyukov/go-fuzz/go-fuzz-build
     go test -tags=gofuzz -run=TestGenerateSmatCorpus
     go-fuzz-build github.com/RoaringBitmap/roaring
     go-fuzz -bin=./roaring-fuzz.zip -workdir=workdir/ -timeout=200

Let it run, and if the # of crashers is > 0, check out the reports in the workdir where you should be able to find the panic goroutine stack traces.

Alternative in Go

There is a Go version wrapping the C/C++ implementation https://github.com/RoaringBitmap/gocroaring

For an alternative implementation in Go, see https://github.com/fzandona/goroar The two versions were written independently.

Mailing list/discussion group

https://groups.google.com/forum/#!forum/roaring-bitmaps