chunk

package
v0.0.0-...-7d0c36d Latest Latest
Warning

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

Go to latest
Published: Feb 19, 2014 License: BSD-2-Clause Imports: 9 Imported by: 0

Documentation

Overview

A tiedot collection is made of chunks, each chunk is independent fully featured collection.

Index

Constants

View Source
const (
	DAT_FILENAME_MAGIC = "_data" // Name of collection data file
	PK_FILENAME_MAGIC  = "_pk"   // Name of PK (primary index) file
)

Variables

This section is empty.

Functions

func StrHash

func StrHash(thing interface{}) uint64

Return string hash code using sdbm algorithm.

Types

type ChunkCol

type ChunkCol struct {
	Number  int                  // Number of the chunk in collection
	BaseDir string               // File system directory path of the chunk
	Data    *chunkfile.ColFile   // Collection document data file
	PK      *chunkfile.HashTable // PK hash table
}

func OpenChunk

func OpenChunk(number int, baseDir string) (chunk *ChunkCol, err error)

Open a chunk.

func (*ChunkCol) Close

func (col *ChunkCol) Close()

Close the collection.

func (*ChunkCol) Delete

func (col *ChunkCol) Delete(id uint64)

Delete a document by physical ID.

func (*ChunkCol) DeserializeAll

func (col *ChunkCol) DeserializeAll(template interface{}, fun func() bool)

Deserialize each document into template (pointer to an initialized struct), invoke the function on the deserialized document (Collection Scan).

func (*ChunkCol) Flush

func (col *ChunkCol) Flush() (err error)

Flush collection data and index files.

func (*ChunkCol) ForAll

func (col *ChunkCol) ForAll(fun func(id uint64, doc map[string]interface{}) bool)

Deserialize each document and invoke the function on the deserialized document (Collection Scan).

func (*ChunkCol) GetPhysicalID

func (col *ChunkCol) GetPhysicalID(id uint64) (physID uint64, err error)

Return the physical ID of document specified by primary key ID.

func (*ChunkCol) Insert

func (col *ChunkCol) Insert(doc map[string]interface{}) (id uint64, err error)

Insert a document.

func (*ChunkCol) Read

func (col *ChunkCol) Read(id uint64, doc interface{}) error

Retrieve document by physical ID.

func (*ChunkCol) Update

func (col *ChunkCol) Update(id uint64, doc map[string]interface{}) (newID uint64, err error)

Update a document by physical ID, return its new physical ID.

Jump to

Keyboard shortcuts

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