bucket

package module
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 7, 2016 License: Apache-2.0 Imports: 4 Imported by: 2

README

go-bucket

Golang concurrent storage elements to the containers and return to a specified number of a single container

Usage

$ go get github.com/antlinker/go-bucket

Benchmark

Ran 100 samples:
  push:
    Fastest Time: 0.029s
    Slowest Time: 0.034s
    Average Time: 0.031s ± 0.001s
------------------------------

写入数据条数: 10000000
总耗时:3.09s

License

Copyright 2016.All rights reserved.

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.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Bucket

type Bucket interface {
	// Push Insert the elements to the bucket,return bucket length
	// If the exception occurs, it returns an error
	Push(v interface{}) (int, error)
	// Pop Pop an element
	// If the exception occurs, it returns an error
	Pop() (interface{}, error)
	// Len Get bucket length
	Len() int
	// ToSlice Get all the elements of the slice
	// If the exception occurs, it returns an error
	ToSlice() ([]interface{}, error)
	// Reset Empty bucket elements
	Reset()
	// Clone Get bucket duplicate
	Clone() Bucket
	// CloneAndReset Get bucket duplicate and empty elements
	CloneAndReset() Bucket
}

Bucket Concurrent storage container element

func NewListBucket

func NewListBucket() Bucket

NewListBucket Based on the list container implementation bucket

type BucketGroup

type BucketGroup interface {
	// Open Open the bucket group waits to receive bucket
	// If already open,it returns an error
	Open() (<-chan Bucket, error)
	// Push Insert the elements to the bucket group
	// If the exception occurs, it returns an error
	Push(v interface{}) error
	// Len Get current use bucket length
	Len() int
	// Close Close bucket group,stop receive data
	// If the exception occurs, it returns an error
	Close() error
}

BucketGroup Concurrent storage elements to the bucket group return to a specified number of a single bucket

func NewBucketGroup

func NewBucketGroup(popBucketElementCount int, bucketPoolsNum ...int) BucketGroup

NewBucketGroup Create instances of BucketGroup popBucketElementCount The number of pop-up bucket required elements bucketPoolsNum The number of buckets within the group

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL