Documentation ¶
Index ¶
- Constants
- Variables
- func LowerCamelCase(s string) string
- func UpperCamelCase(s string) string
- type BinaryMarshaller
- type BinaryMarshallerInto
- type BinaryNoAllocMarshaller
- type ChangeKind
- type Collection
- func (cs Collection) Delete(tx *Tx, id DocID, unmarshalled interface{}, prev func(val mdbx.Val)) (bool, error)
- func (cs Collection) DocID(sequence uint64) DocID
- func (cs Collection) Insert(tx *Tx, id DocID, unmarshalled interface{}, marshalled []byte) error
- func (cs Collection) MaxID() DocID
- func (cs Collection) MinID() DocID
- func (cs Collection) NextID() DocID
- func (cs Collection) Update(tx *Tx, id DocID, unmarshalled interface{}, marshalled []byte, ...) error
- type CollectionCreate
- type CollectionDrop
- type CollectionID
- type CollectionKind
- type CollectionMeta
- type Config
- type Cursor
- type DocID
- type Document
- type EasyJsonMarshaller
- type EvolutionProgress
- type EvolutionState
- type FlatString128
- type FlatString16
- type FlatString255
- type FlatString32
- type FlatString64
- type FlatString96
- type Float64
- type Float64Array
- type Float64ArrayValueOf
- type Float64Unique
- type Float64ValueOf
- type FullText
- type Index
- type IndexCreate
- type IndexDrop
- type IndexKind
- type IndexMeta
- type IndexRebuild
- type InsertCommand
- type Int64
- type Int64Array
- type Int64ArrayValueOf
- type Int64Unique
- type Int64ValueOf
- type JsonMarshaller
- type Marshaller
- type Page
- type ProgressStat
- type Record
- type Schema
- type SchemaMeta
- type SchemaMutation
- type Sort
- type Store
- type Stream
- type String
- type StringArray
- type StringArrayValueOf
- type StringUnique
- type StringValueOf
- type Tx
- type UpdateCommand
- type UpdateSchemaCommand
- type UpdateSchemaResult
Constants ¶
const ( StoreName = "nosql" Version = "0.1.0" )
const ( DefaultDurable = mdbx.EnvSyncDurable | mdbx.EnvNoTLS | mdbx.EnvLIFOReclaim | mdbx.EnvNoMemInit | mdbx.EnvCoalesce DefaultDurableFast = mdbx.EnvNoMetaSync | mdbx.EnvNoTLS | mdbx.EnvLIFOReclaim | mdbx.EnvNoMemInit | mdbx.EnvCoalesce DefaultAsync = mdbx.EnvSafeNoSync | mdbx.EnvNoTLS | mdbx.EnvLIFOReclaim | mdbx.EnvNoMemInit | mdbx.EnvCoalesce DefaultAsyncMap = mdbx.EnvSafeNoSync | mdbx.EnvWriteMap | mdbx.EnvNoTLS | mdbx.EnvLIFOReclaim | mdbx.EnvNoMemInit | mdbx.EnvCoalesce DefaultNoSync = mdbx.EnvUtterlyNoSync | mdbx.EnvWriteMap | mdbx.EnvNoTLS | mdbx.EnvLIFOReclaim | mdbx.EnvNoMemInit | mdbx.EnvCoalesce Kilobyte = 1024 Megabyte = 1024 * 1024 Gigabyte = Megabyte * 1024 Terabyte = Gigabyte * 1024 )
const (
MaxCollectionSize = maxDocSequence - 1
)
const (
MaxIndexKeySize = 4000
)
Variables ¶
var ( ErrSkip = errors.New("skip") ErrIndexCorrupted = errors.New("index corrupted") ErrUniqueConstraint = errors.New("unique constraint") ErrIndexKeyTooBig = errors.New("index key too big") )
var ( ErrNotJSONMarshaller = errors.New("not implements json.Marshaler") ErrNotEasyJSONMarhaller = errors.New("not implements easyjson.EasyJSONMarshaller") ErrNotEasyJSONUnmarshaller = errors.New("not implements easyjson.EasyJSONUnmarshaller") ErrNotBinaryMarshaller = errors.New("not implements encoding.BinaryMarshaler") ErrNotBinaryUnmarshaller = errors.New("not implements encoding.BinaryUnmarshaler") )
var ( ErrAlreadyLoaded = errors.New("already loaded") ErrSchemaFieldNotFound = errors.New("schema field not found: add '*nosql.Schema' field") ErrCollectionStore = errors.New("collection store not exist") ErrCollectionIDExhaustion = errors.New("collection id exhaustion") ErrIndexIDExhaustion = errors.New("index id exhaustion") ErrSchemaIDExhaustion = errors.New("schema id exhaustion") )
var ( DefaultGeometry = mdbx.Geometry{ SizeLower: Megabyte * 1, SizeNow: Megabyte * 1, SizeUpper: Gigabyte * 32, GrowthStep: Megabyte * 4, ShrinkThreshold: Megabyte * 4 * 2, PageSize: 4096, } )
var (
ErrDocumentNil = errors.New("document nil")
)
var (
ErrEvolutionInProcess = errors.New("evolution in process")
)
Functions ¶
func LowerCamelCase ¶
LowerCamelCase converts a string into camel case starting with a lower case letter.
func UpperCamelCase ¶
UpperCamelCase converts a string into camel case starting with a upper case letter.
Types ¶
type BinaryMarshaller ¶
type BinaryMarshaller struct { }
func (BinaryMarshaller) Marshal ¶
func (s BinaryMarshaller) Marshal(unmarshalled interface{}, into []byte) ([]byte, error)
func (BinaryMarshaller) Unmarshal ¶
func (s BinaryMarshaller) Unmarshal(data []byte, unmarshalled interface{}) error
type BinaryMarshallerInto ¶
type BinaryNoAllocMarshaller ¶
type BinaryNoAllocMarshaller struct { }
func (BinaryNoAllocMarshaller) Marshal ¶
func (s BinaryNoAllocMarshaller) Marshal(unmarshalled interface{}, into []byte) ([]byte, error)
func (BinaryNoAllocMarshaller) Unmarshal ¶
func (s BinaryNoAllocMarshaller) Unmarshal(data []byte, unmarshalled interface{}) error
type ChangeKind ¶
type ChangeKind int
const ( ChangeCreate ChangeKind = 1 ChangeDrop ChangeKind = 2 ChangeCreateIndex ChangeKind = 3 ChangeRebuildIndex ChangeKind = 4 ChangeDropIndex ChangeKind = 5 )
type Collection ¶
type Collection struct { Name string Marshaller Marshaller // contains filtered or unexported fields }
type CollectionCreate ¶
type CollectionCreate struct {
// contains filtered or unexported fields
}
type CollectionDrop ¶
type CollectionDrop struct {
// contains filtered or unexported fields
}
CollectionDrop action to delete all of a collection's documents and remove the metadata from the schema.
type CollectionID ¶
type CollectionID uint16
CollectionID is an UID for a single collection used in unique DocID instead of variable length string names. This provides deterministic key operations regardless of length of collection name.
type CollectionKind ¶
type CollectionKind int
const ( CollectionTypeJson CollectionKind = 0 CollectionTypeProto CollectionKind = 1 CollectionTypeProtobuf CollectionKind = 2 CollectionTypeMsgpack CollectionKind = 3 CollectionTypeCustom CollectionKind = 10 )
type CollectionMeta ¶
type DocID ¶
type DocID uint64
DocID
func NewDocID ¶
func NewDocID(collection CollectionID, sequence uint64) DocID
func (DocID) CollectionID ¶
func (r DocID) CollectionID() CollectionID
CollectionID is an UID for a single collection used in unique DocID instead of variable length string names. This provides deterministic key operations regardless of length of collection name.
type EasyJsonMarshaller ¶
type EasyJsonMarshaller struct { }
func (EasyJsonMarshaller) Marshal ¶
func (s EasyJsonMarshaller) Marshal(unmarshalled interface{}, into []byte) ([]byte, error)
func (EasyJsonMarshaller) Unmarshal ¶
func (s EasyJsonMarshaller) Unmarshal(data []byte, unmarshalled interface{}) error
type EvolutionProgress ¶
type EvolutionProgress struct { ProgressStat Context context.Context Cancel context.CancelFunc Time time.Time Started time.Time Prepared time.Duration IndexesDroppedIn time.Duration IndexesCreatedIn time.Duration CollectionsDroppedIn time.Duration State EvolutionState BatchSize int64 IndexDrops ProgressStat IndexCreates ProgressStat CollectionDrops ProgressStat Err error }
type EvolutionState ¶
type EvolutionState int
const ( EvolutionStatePreparing EvolutionState = 0 EvolutionStatePrepared EvolutionState = 1 EvolutionStateDroppingIndex EvolutionState = 2 EvolutionStateCreatingIndex EvolutionState = 3 EvolutionStateDroppingCollection EvolutionState = 4 EvolutionStateCompleted EvolutionState = 10 EvolutionStateError EvolutionState = 100 )
type FlatString128 ¶
func (*FlatString128) Set ¶
func (s *FlatString128) Set(value string)
func (*FlatString128) String ¶
func (s *FlatString128) String() string
func (*FlatString128) Unsafe ¶
func (s *FlatString128) Unsafe() string
type FlatString16 ¶
func (*FlatString16) Set ¶
func (s *FlatString16) Set(value string)
func (*FlatString16) String ¶
func (s *FlatString16) String() string
func (*FlatString16) Unsafe ¶
func (s *FlatString16) Unsafe() string
type FlatString255 ¶
func (*FlatString255) Set ¶
func (s *FlatString255) Set(value string)
func (*FlatString255) String ¶
func (s *FlatString255) String() string
func (*FlatString255) Unsafe ¶
func (s *FlatString255) Unsafe() string
type FlatString32 ¶
func (*FlatString32) Set ¶
func (s *FlatString32) Set(value string)
func (*FlatString32) String ¶
func (s *FlatString32) String() string
func (*FlatString32) Unsafe ¶
func (s *FlatString32) Unsafe() string
type FlatString64 ¶
func (*FlatString64) Set ¶
func (s *FlatString64) Set(value string)
func (*FlatString64) String ¶
func (s *FlatString64) String() string
func (*FlatString64) Unsafe ¶
func (s *FlatString64) Unsafe() string
type FlatString96 ¶
func (*FlatString96) Set ¶
func (s *FlatString96) Set(value string)
func (*FlatString96) String ¶
func (s *FlatString96) String() string
func (*FlatString96) Unsafe ¶
func (s *FlatString96) Unsafe() string
type Float64 ¶
type Float64 struct { ValueOf Float64ValueOf // contains filtered or unexported fields }
func NewFloat64 ¶
func NewFloat64( name, selector, version string, valueOf Float64ValueOf, ) *Float64
func (*Float64) Owner ¶
func (ib *Float64) Owner() CollectionID
type Float64Array ¶
type Float64Array struct { ValueOf Float64ArrayValueOf // contains filtered or unexported fields }
func NewFloat64Array ¶
func NewFloat64Array( name, selector, version string, valueOf Float64ArrayValueOf, ) *Float64Array
func (*Float64Array) Owner ¶
func (ib *Float64Array) Owner() CollectionID
type Float64ArrayValueOf ¶
type Float64Unique ¶
type Float64Unique struct { ValueOf Float64ValueOf // contains filtered or unexported fields }
func NewFloat64Unique ¶
func NewFloat64Unique( name, selector, version string, valueOf Float64ValueOf, ) *Float64Unique
func (*Float64Unique) Owner ¶
func (ib *Float64Unique) Owner() CollectionID
type Float64ValueOf ¶
type Index ¶
type Index interface { ID() uint32 Name() string Owner() CollectionID Meta() IndexMeta // contains filtered or unexported methods }
type IndexCreate ¶
type IndexCreate struct {
// contains filtered or unexported fields
}
type IndexDrop ¶
type IndexDrop struct {
// contains filtered or unexported fields
}
IndexDrop represents an action to drop an index from a schema, delete all data in the index database and remove the metadata from the saved schema.
type IndexMeta ¶
type IndexMeta struct { Owner CollectionID `json:"owner"` DBI mdbx.DBI `json:"dbi"` State int32 `json:"state"` // contains filtered or unexported fields }
type IndexRebuild ¶
type IndexRebuild struct {
// contains filtered or unexported fields
}
type InsertCommand ¶
type InsertCommand struct { Collection FlatString32 Data []byte }
type Int64 ¶
type Int64 struct { ValueOf Int64ValueOf // contains filtered or unexported fields }
func NewInt64 ¶
func NewInt64( name, selector, version string, valueOf Int64ValueOf, ) *Int64
func (*Int64) Owner ¶
func (ib *Int64) Owner() CollectionID
type Int64Array ¶
type Int64Array struct { ValueOf Int64ArrayValueOf // contains filtered or unexported fields }
func NewInt64Array ¶
func NewInt64Array( name, selector, version string, valueOf Int64ArrayValueOf, ) *Int64Array
func (*Int64Array) Owner ¶
func (ib *Int64Array) Owner() CollectionID
type Int64ArrayValueOf ¶
type Int64Unique ¶
type Int64Unique struct { ValueOf Int64ValueOf // contains filtered or unexported fields }
func NewInt64Unique ¶
func NewInt64Unique( name, selector, version string, valueOf Int64ValueOf, ) *Int64Unique
func (*Int64Unique) Owner ¶
func (ib *Int64Unique) Owner() CollectionID
type Int64ValueOf ¶
type JsonMarshaller ¶
type JsonMarshaller struct { }
func (JsonMarshaller) Marshal ¶
func (s JsonMarshaller) Marshal(unmarshalled interface{}, into []byte) ([]byte, error)
func (JsonMarshaller) Unmarshal ¶
func (s JsonMarshaller) Unmarshal(data []byte, unmarshalled interface{}) error
type Marshaller ¶
type Marshaller interface { Marshal(unmarshalled interface{}, into []byte) ([]byte, error) Unmarshal(data []byte, unmarshalled interface{}) error }
func BinaryMarshallerOf ¶
func BinaryMarshallerOf(unmarshalled interface{}) Marshaller
func JsonMarshallerOf ¶
func JsonMarshallerOf(unmarshalled interface{}) Marshaller
func JsonMarshallerOfType ¶
func JsonMarshallerOfType(t reflect.Type) Marshaller
func MarshallerOf ¶
func MarshallerOf(unmarshalled interface{}) Marshaller
func MarshallerOfType ¶
func MarshallerOfType(t reflect.Type) Marshaller
type ProgressStat ¶
func (ProgressStat) Pct ¶
func (p ProgressStat) Pct() float64
type Schema ¶
type Schema struct { Meta SchemaMeta Collections []Collection // contains filtered or unexported fields }
Schema provides a flat list of named Collections and their indexes. It does NOT enforce any layout of the individual document specs. JSON formatted documents support indexing natively. JSON indexes utilize gjson selector to extract the field(s) required to build index.
It is recommended to use the strongly typed Schema pattern. Hydrating a Schema in a Store will produce and apply an evolution to keep the Schema consistent. This simplifies a lot of bug prone manual index and collection bookkeeping.
func ParseSchema ¶
func ParseSchemaWithUID ¶
type SchemaMeta ¶
type SchemaMutation ¶
type SchemaMutation struct { }
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store is a simple embedded Raft replicated ACID noSQL database built on MDBX B+Tree storage.
var (
Default *Store
)
func (*Store) Hydrate ¶
Hydrate sets up a Schema in the store and performs any necessary evolution actions to adhere to the new desired state.
func (*Store) HydrateTyped ¶
func (s *Store) HydrateTyped(ctx context.Context, typed interface{}) (<-chan EvolutionProgress, error)
HydrateTyped parses a typed Schema and calls Hydrate
type Stream ¶
type Stream struct { }
Stream is a special type of collection that provides real-time streaming similar to Kafka. Streams consist of pages which contain individual records. Appending new records occurs through an Appender. Appender is responsible for building new immutable pages and notifying listeners in real-time. Appender does not clear any records until the page the records belong to have been confirmed to be persistent in secondary storage.
Secondary page storage can be any KV store. Since pages are immutable, it is very easy to add caching layers if needed.
Pages can be located by RecordID or by Timestamp.
type String ¶
type String struct { ValueOf StringValueOf // contains filtered or unexported fields }
func NewString ¶
func NewString( name, selector, version string, valueOf StringValueOf, ) *String
func (*String) Owner ¶
func (ib *String) Owner() CollectionID
type StringArray ¶
type StringArray struct { ValueOf StringArrayValueOf // contains filtered or unexported fields }
func NewStringArray ¶
func NewStringArray( name, selector, version string, valueOf StringArrayValueOf, ) *StringArray
func (*StringArray) Owner ¶
func (ib *StringArray) Owner() CollectionID
type StringArrayValueOf ¶
type StringUnique ¶
type StringUnique struct { ValueOf StringValueOf // contains filtered or unexported fields }
func NewStringUnique ¶
func NewStringUnique( name, selector, version string, valueOf StringValueOf, ) *StringUnique
func (*StringUnique) Owner ¶
func (ib *StringUnique) Owner() CollectionID
type StringValueOf ¶
type UpdateCommand ¶
type UpdateCommand struct { Collection FlatString32 Data []byte }
type UpdateSchemaCommand ¶
type UpdateSchemaCommand struct { Collection FlatString255 Data []byte }
type UpdateSchemaResult ¶
Source Files ¶
- collection.go
- command.go
- export.go
- flat.go
- index.go
- index_float64.go
- index_float64s.go
- index_float64u.go
- index_ft.go
- index_int64.go
- index_int64s.go
- index_int64u.go
- index_str.go
- index_strs.go
- index_stru.go
- json.go
- le.go
- marshal.go
- schema.go
- schema_evolution.go
- schema_store.go
- store.go
- stream.go
- stream_store.go
- tx.go
- util.go