db

package
v2.0.0-...-d8030fd Latest Latest
Warning

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

Go to latest
Published: Jul 22, 2022 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Block

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

Block represents a block file

func LoadBlock

func LoadBlock(blockFilePath, key string) *Block

LoadBlock loads a block at a particular path

func (*Block) Add

func (b *Block) Add(recordID, value string)

Add a record to Block

func (*Block) BadRecords

func (b *Block) BadRecords() []string

BadRecords returns all bad records found in a block

func (*Block) Dataset

func (b *Block) Dataset() *Dataset

Dataset returns the dataset *Block belongs to

func (*Block) Delete

func (b *Block) Delete(key string) error

Delete a record by key from a Block

func (*Block) Filter

func (b *Block) Filter(recordIDs map[string]string)

func (*Block) Get

func (b *Block) Get(key string) (*Record, error)

Get a record by key from a Block

func (*Block) HumanSize

func (b *Block) HumanSize() string

HumanSize returns human readable size of a block

func (*Block) Len

func (b *Block) Len() int

Len returns length of block

func (*Block) MarshalJSON

func (b *Block) MarshalJSON() ([]byte, error)

MarshalJSON implements json.MarshalJSON

func (*Block) Path

func (b *Block) Path() string

Path returns path to block file

func (*Block) Record

func (b *Block) Record(i int) *Record

Record returns record in specifed index i

func (*Block) RecordCount

func (b *Block) RecordCount() int

RecordCount returns the number of records in a block

func (*Block) Records

func (b *Block) Records() []*Record

Records returns decrypted slice of all Records in a Block sorted in asc order of id

func (*Block) UnmarshalJSON

func (b *Block) UnmarshalJSON(data []byte) error

UnmarshalJSON implements json.UnmarshalJSON

type Dataset

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

Dataset represent a collection of blocks

func LoadDataset

func LoadDataset(datasetPath, key string) *Dataset

LoadDataset loads the dataset at path

func LoadDatasets

func LoadDatasets(dbPath, key string) []*Dataset

LoadDatasets loads all datasets in given gitdb path

func (*Dataset) BadBlocks

func (d *Dataset) BadBlocks() []string

BadBlocks returns all the bad blocks in a dataset

func (*Dataset) BadBlocksCount

func (d *Dataset) BadBlocksCount() int

BadBlocksCount returns the number of bad blocks in a DataSet

func (*Dataset) BadRecords

func (d *Dataset) BadRecords() []string

BadRecords returns all the bad records in a dataset

func (*Dataset) BadRecordsCount

func (d *Dataset) BadRecordsCount() int

BadRecordsCount returns the number of bad records in a DataSet

func (*Dataset) Block

func (d *Dataset) Block(i int) *Block

Block returns block at index i of a DataSet

func (*Dataset) BlockCount

func (d *Dataset) BlockCount() int

BlockCount returns the number of blocks in a DataSet

func (*Dataset) Blocks

func (d *Dataset) Blocks() []*Block

Blocks returns all the Blocks in a dataset

func (*Dataset) HumanSize

func (d *Dataset) HumanSize() string

HumanSize returns human friendly size of a DataSet

func (*Dataset) Indexes

func (d *Dataset) Indexes() []string

Indexes returns the indexes set on a DataSet

func (*Dataset) LastModifiedDate

func (d *Dataset) LastModifiedDate() string

LastModifiedDate returns the last modification time of a DataSet

func (*Dataset) Name

func (d *Dataset) Name() string

Name returns name of dataset

func (*Dataset) Path

func (d *Dataset) Path() string

Path returns path to dataset

func (*Dataset) RecordCount

func (d *Dataset) RecordCount() int

RecordCount returns the number of records in a DataSet

func (*Dataset) Size

func (d *Dataset) Size() int64

Size returns the total size of all blocks in a DataSet

type EmptyBlock

type EmptyBlock struct {
	Block
}

EmptyBlock is used for hydration

func NewEmptyBlock

func NewEmptyBlock(key string) *EmptyBlock

NewEmptyBlock should be used to store records from multiple blocks

func (*EmptyBlock) Hydrate

func (b *EmptyBlock) Hydrate(blockFilePath string) error

Hydrate should be called on EmptyBlock

func (*EmptyBlock) HydrateByPositions

func (b *EmptyBlock) HydrateByPositions(blockFilePath string, positions ...[]int) error

HydrateByPositions should be called on EmptyBlock pos must be []int{offset, position}

type Record

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

Record represents a model stored in gitdb

func ConvertModel

func ConvertModel(id string, m interface{}) *Record

ConvertModel converts a Model to a record

func (*Record) Data

func (r *Record) Data() string

Data returns record data unmodified

func (*Record) Hydrate

func (r *Record) Hydrate(model interface{}) error

Hydrate populates given interfacce with underlying record data

func (*Record) ID

func (r *Record) ID() string

ID returns record id

func (*Record) JSON

func (r *Record) JSON() string

JSON returns data decrypted and indented

func (*Record) Version

func (r *Record) Version() string

Version returns the version of the record

Jump to

Keyboard shortcuts

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