comparer

package
v0.0.0-...-cd2696f Latest Latest
Warning

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

Go to latest
Published: Mar 5, 2013 License: BSD-2-Clause Imports: 1 Imported by: 0

Documentation

Overview

Package comparer provides interface and implementation for ordering sets of data.

Index

Constants

This section is empty.

Variables

View Source
var DefaultComparer = BytesComparer{}

DefaultComparer are default comparer used by LevelDB.

Functions

This section is empty.

Types

type BasicComparer

type BasicComparer interface {
	// Three-way comparison.
	//
	// Returns value:
	//   < 0 iff "a" < "b",
	//   == 0 iff "a" == "b",
	//   > 0 iff "a" > "b"
	Compare(a, b []byte) int
}

BasicComparer is the interface that wraps the basic Compare method.

type BytesComparer

type BytesComparer struct{}

func (BytesComparer) Compare

func (BytesComparer) Compare(a, b []byte) int

func (BytesComparer) Name

func (BytesComparer) Name() string

func (BytesComparer) Separator

func (BytesComparer) Separator(a, b []byte) []byte

func (BytesComparer) Successor

func (BytesComparer) Successor(b []byte) []byte

type Comparer

type Comparer interface {
	BasicComparer

	// The name of the comparer.  Used to check for comparer
	// mismatches (i.e., a DB created with one comparer is
	// accessed using a different comparer.
	//
	// The client of this package should switch to a new name whenever
	// the comparer implementation changes in a way that will cause
	// the relative ordering of any two keys to change.
	//
	// Names starting with "leveldb." are reserved and should not be used
	// by any clients of this package.
	Name() string

	// If 'a' < 'b', changes 'a' to a short string in [a,b).
	//
	// This is an advanced function that's used to reduce the space
	// requirements for internal data structures such as index blocks.
	//
	// Simple Comparer implementations may return with 'a' unchanged,
	// i.e., an implementation of this method that does nothing is correct.
	//
	// NOTE: Don't modify content of either 'a' or 'b', if modification
	// is necessary copy it first. It is ok to return slice of it.
	Separator(a, b []byte) []byte

	// Changes 'b' to a short string >= 'b'.
	//
	// This is an advanced function that's used to reduce the space
	// requirements for internal data structures such as index blocks.
	//
	// Simple Comparer implementations may return with 'b' unchanged,
	// i.e., an implementation of this method that does nothing is correct.
	//
	// NOTE: Don't modify content of 'b', if modification is necessary
	// copy it first. It is ok to return slice of it.
	Successor(b []byte) []byte
}

Jump to

Keyboard shortcuts

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