filebacked

package
v1.7.1 Latest Latest
Warning

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

Go to latest
Published: Sep 16, 2021 License: Apache-2.0 Imports: 12 Imported by: 2

Documentation

Overview

Provides file-backed collections.

File backing for collections. File format:

| kind: 2 (uint16)
| size: 8 (uint64)
| object: n (gob encoded)
| ...

Provides file-backed list.

// // New list. list := fb.NewList()

// // Append an object. list.Append(object)

// // Iterate the list. itr := list.Iter()

for i := 0; i < itr.Len(); i++ {
    person := itr.At(i)
    ...
}

// // Iterate the list. itr := list.Iter()

for i := 0; i < itr.Len(); i++ {
    person := Person{}
    itr.AtWith(i, &person))
    ...
}

// // Iterate the list. itr := list.Iter()

for {
    object, hasNext := itr.Next()
    if !hasNext {
        break
    }
    ...
}

// // Iterate the list. itr := list.Iter()

for object, hasNext := itr.Next(); hasNext; object, hasNext = itr.Next() {
    ...
}

// // Iterate the list. itr := list.Iter()

for {
    person := Person{}
    hasNext := itr.NextWith(&person))
    if !hasNext {
        break
    }
    ...
}

Index

Constants

View Source
const (
	Extension = ".fb"
)

File extension.

Variables

View Source
var WorkingDir = "/tmp"

Working Directory.

Functions

This section is empty.

Types

type Catalog

type Catalog struct {
	sync.Mutex
	// contains filtered or unexported fields
}

Type catalog.

type EmptyIterator

type EmptyIterator struct {
}

Empty.

func (*EmptyIterator) At added in v0.4.6

func (*EmptyIterator) At(int) interface{}

Object at index.

func (*EmptyIterator) AtWith added in v0.4.6

func (*EmptyIterator) AtWith(int, interface{})

Object at index.

func (*EmptyIterator) Close

func (*EmptyIterator) Close()

Close the iterator.

func (*EmptyIterator) Len

func (*EmptyIterator) Len() int

Length.

func (*EmptyIterator) Next

func (*EmptyIterator) Next() (interface{}, bool)

Next object.

func (*EmptyIterator) NextWith

func (*EmptyIterator) NextWith(object interface{}) bool

Next object.

func (*EmptyIterator) Reverse added in v0.7.0

func (*EmptyIterator) Reverse()

Reverse.

type FbIterator added in v0.4.6

type FbIterator struct {
	// Reader.
	*Reader
	// contains filtered or unexported fields
}

Iterator.

func (*FbIterator) Next added in v0.4.6

func (r *FbIterator) Next() (object interface{}, hasNext bool)

Next object.

func (*FbIterator) NextWith added in v0.4.6

func (r *FbIterator) NextWith(object interface{}) (hasNext bool)

Next object.

func (*FbIterator) Reverse added in v0.7.0

func (r *FbIterator) Reverse()

Reverse the list.

type Iterator

type Iterator interface {
	// Number of items.
	Len() int
	// Reverse.
	Reverse()
	// Object at index.
	At(index int) interface{}
	// Object at index (with).
	AtWith(int, interface{})
	// Next object.
	Next() (interface{}, bool)
	// Next object (with).
	NextWith(object interface{}) bool
	// Close the iterator.
	Close()
}

Iterator. Read-only collection with stateful iteration.

type List

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

File-backed list.

func NewList added in v0.3.7

func NewList() (list *List)

List factory.

func (*List) Append

func (l *List) Append(object interface{})

Append an object.

func (*List) At added in v0.4.6

func (l *List) At(index int) (object interface{})

Object at index.

func (*List) AtWith added in v0.4.6

func (l *List) AtWith(index int, object interface{})

Object at index.

func (*List) Close

func (l *List) Close()

Close (delete) the list.

func (*List) Iter

func (l *List) Iter() (itr Iterator)

Get an iterator.

func (*List) Len

func (l *List) Len() int

Length. Number of objects.

type Reader

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

Reader.

func (*Reader) At added in v0.4.6

func (r *Reader) At(index int) (object interface{})

Get the object at index.

func (*Reader) AtWith added in v0.4.6

func (r *Reader) AtWith(index int, object interface{})

Get the object at index.

func (*Reader) Close

func (r *Reader) Close()

Close the reader.

func (*Reader) Len

func (r *Reader) Len() (length int)

Length. Number of objects in the list.

type Writer

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

Writer.

func (*Writer) Append

func (w *Writer) Append(object interface{})

Append (write) object.

func (*Writer) Close

func (w *Writer) Close()

Close the writer.

func (*Writer) Reader

func (w *Writer) Reader(shared bool) (reader *Reader)

Build a reader.

Jump to

Keyboard shortcuts

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