Documentation

Overview

Package index implements index operations.

Index is linear list of pairs (k, v), where len(v) = const, and ki = i, that defines Get and Set operations that has complexity of O(1).

Index is represented by:

N    - max(i)
Vlen - len(v) = const
Blob - {v0, v1, ..., vi, ... vN}

Vi is ReadAt(buf[:Vlen], Vlen*i) on Blob.

Index

Constants

const StartID int64 = 0

Variables

This section is empty.

Functions

This section is empty.

Types

type Backend

type Backend interface {
	io.ReaderAt
	io.WriterAt
	io.Closer
}

type Index

type Index interface {
	io.Closer
	Get(k int64, b []byte) error
	Set(k int64, v []byte) error
	Len() (int64, error)
}

Index is k-v database, where len(v) = const and k is {1, 2, 3, ..., n}, which is mapped to file.

type Iterator

type Iterator struct {
	Index Index
	Size  int
}

func (Iterator) All

func (i Iterator) All(w Walker) error

type RWAtIndex

type RWAtIndex struct {
	Backend Backend
	Size    int
	Length  int
}

func (RWAtIndex) Close

func (i RWAtIndex) Close() error

func (RWAtIndex) Get

func (i RWAtIndex) Get(k int64, b []byte) error

func (RWAtIndex) Len

func (i RWAtIndex) Len() (int64, error)

func (RWAtIndex) Set

func (i RWAtIndex) Set(k int64, b []byte) error

type Ranger

type Ranger interface {
	All(w Walker) error
	Range(start, end int64, w Walker) error
}

Ranger is Index that supports iteration.

type Walker

type Walker func(k int64, v []byte) error

Walker is function that is used as callback while iterating over index.

Source Files