kv

package
Version: v0.0.0-...-731618e Latest Latest
Warning

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

Go to latest
Published: Mar 13, 2016 License: BSD-2-Clause Imports: 6 Imported by: 49

Documentation

Overview

Package kv supporting read and write of a simple file formating for Sophie, which stores key-value pairs.

KVFile format:

vint(key-len) key vint(val-len) val

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ReadAsByteOffs

func ReadAsByteOffs(fp sophie.FsPath) (buffer bytesp.Slice, keyOffs, keyEnds, valOffs, valEnds villa.IntSlice, err error)

ReadAsByteOffs reads a kv file as a slice of buffer and some int slices of key offsets, key ends, value offsets, and value ends.

func WriteByteOffs

func WriteByteOffs(fp sophie.FsPath, buffer []byte, keyOffs, keyEnds, valOffs, valEnds []int) error

WriteByteOffs generates a kv file with key-value pairs represented as a slice of buffer and some int slices of key offsets, key ends, value offsets, and value ends.

Types

type DirInput

type DirInput sophie.FsPath

A folder with KV Files as an mr.Input

func (DirInput) Iterator

func (in DirInput) Iterator(index int) (sophie.IterateCloser, error)

mr.Input interface

func (DirInput) PartCount

func (in DirInput) PartCount() (int, error)

mr.Input interface

type DirOutput

type DirOutput sophie.FsPath

A folder with KV Files as an Output

func (DirOutput) Clean

func (out DirOutput) Clean() error

Clean removes the folder.

func (DirOutput) Collector

func (out DirOutput) Collector(index int) (sophie.CollectCloser, error)

mr.Output interface

type Reader

type Reader struct {
	// contains filtered or unexported fields
}

kv.Reader is a struct for reading a kv file.

func NewReader

func NewReader(fp sophie.FsPath) (*Reader, error)

NewReader returns a *Reader for reading the kv file at the specified FsPath.

func (*Reader) Close

func (kvr *Reader) Close() error

io.Closer interface

func (*Reader) Next

func (kvr *Reader) Next(key, val sophie.SophieReader) error

Next fetches next key/val pair

type Writer

type Writer struct {
	// contains filtered or unexported fields
}

kv.Writer is a struct for generating a kv file. *kv.Writer implements the sophie.CollectCloser interface.

func NewWriter

func NewWriter(fp sophie.FsPath) (*Writer, error)

NewWriter returns a *kv.Writer for writing a kv file at the specified FsPath.

func (*Writer) Close

func (kvw *Writer) Close() error

io.Closer interface

func (*Writer) Collect

func (kvw *Writer) Collect(key, val sophie.SophieWriter) error

sophie.CollectCloser interface

Source Files

Jump to

Keyboard shortcuts

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