perf

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2019 License: Apache-2.0 Imports: 7 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var EntityBinding = entity_EntityInfo{
	Entity: objectbox.Entity{
		Id: 1,
	},
	Uid: 1737161401460991620,
}
View Source
var Entity_ = struct {
	Id      *objectbox.PropertyUint64
	Int32   *objectbox.PropertyInt32
	Int64   *objectbox.PropertyInt64
	String  *objectbox.PropertyString
	Float64 *objectbox.PropertyFloat64
}{
	Id: &objectbox.PropertyUint64{
		BaseProperty: &objectbox.BaseProperty{
			Id:     1,
			Entity: &EntityBinding.Entity,
		},
	},
	Int32: &objectbox.PropertyInt32{
		BaseProperty: &objectbox.BaseProperty{
			Id:     2,
			Entity: &EntityBinding.Entity,
		},
	},
	Int64: &objectbox.PropertyInt64{
		BaseProperty: &objectbox.BaseProperty{
			Id:     3,
			Entity: &EntityBinding.Entity,
		},
	},
	String: &objectbox.PropertyString{
		BaseProperty: &objectbox.BaseProperty{
			Id:     4,
			Entity: &EntityBinding.Entity,
		},
	},
	Float64: &objectbox.PropertyFloat64{
		BaseProperty: &objectbox.BaseProperty{
			Id:     5,
			Entity: &EntityBinding.Entity,
		},
	},
}

Entity_ contains type-based Property helpers to facilitate some common operations such as Queries.

Functions

func ObjectBoxModel

func ObjectBoxModel() *objectbox.Model

ObjectBoxModel declares and builds the model from all the entities in the package. It is usually used when setting-up ObjectBox as an argument to the Builder.Model() function.

Types

type Entity

type Entity struct {
	Id      uint64
	Int32   int32
	Int64   int64
	String  string
	Float64 float64
}

type EntityBox

type EntityBox struct {
	*objectbox.Box
}

Box provides CRUD access to Entity objects

func BoxForEntity

func BoxForEntity(ob *objectbox.ObjectBox) *EntityBox

BoxForEntity opens a box of Entity objects

func (*EntityBox) Get

func (box *EntityBox) Get(id uint64) (*Entity, error)

Get reads a single object.

Returns nil (and no error) in case the object with the given ID doesn't exist.

func (*EntityBox) GetAll

func (box *EntityBox) GetAll() ([]*Entity, error)

Get reads all stored objects

func (*EntityBox) Put added in v0.7.0

func (box *EntityBox) Put(object *Entity) (uint64, error)

Put synchronously inserts/updates a single object. In case the Id is not specified, it would be assigned automatically (auto-increment). When inserting, the Entity.Id property on the passed object will be assigned the new ID as well.

func (*EntityBox) PutAll added in v0.7.0

func (box *EntityBox) PutAll(objects []*Entity) ([]uint64, error)

PutAll inserts multiple objects in single transaction. In case Ids are not set on the objects, they would be assigned automatically (auto-increment).

Returns: IDs of the put objects (in the same order). When inserting, the Entity.Id property on the objects in the slice will be assigned the new IDs as well.

Note: In case an error occurs during the transaction, some of the objects may already have the Entity.Id assigned even though the transaction has been rolled back and the objects are not stored under those IDs.

Note: The slice may be empty or even nil; in both cases, an empty IDs slice and no error is returned.

func (*EntityBox) PutAsync added in v0.7.0

func (box *EntityBox) PutAsync(object *Entity) (uint64, error)

PutAsync asynchronously inserts/updates a single object. When inserting, the Entity.Id property on the passed object will be assigned the new ID as well.

It's executed on a separate internal thread for better performance.

There are two main use cases:

1) "Put & Forget:" you gain faster puts as you don't have to wait for the transaction to finish.

2) Many small transactions: if your write load is typically a lot of individual puts that happen in parallel, this will merge small transactions into bigger ones. This results in a significant gain in overall throughput.

In situations with (extremely) high async load, this method may be throttled (~1ms) or delayed (<1s). In the unlikely event that the object could not be enqueued after delaying, an error will be returned.

Note that this method does not give you hard durability guarantees like the synchronous Put provides. There is a small time window (typically 3 ms) in which the data may not have been committed durably yet.

func (*EntityBox) Query added in v0.8.0

func (box *EntityBox) Query(conditions ...objectbox.Condition) *EntityQuery

Creates a query with the given conditions. Use the fields of the Entity_ struct to create conditions. Keep the *EntityQuery if you intend to execute the query multiple times. Note: this function panics if you try to create illegal queries; e.g. use properties of an alien type. This is typically a programming error. Use QueryOrError instead if you want the explicit error check.

func (*EntityBox) QueryOrError added in v0.8.0

func (box *EntityBox) QueryOrError(conditions ...objectbox.Condition) (*EntityQuery, error)

Creates a query with the given conditions. Use the fields of the Entity_ struct to create conditions. Keep the *EntityQuery if you intend to execute the query multiple times.

func (*EntityBox) Remove

func (box *EntityBox) Remove(object *Entity) (err error)

Remove deletes a single object

type EntityQuery added in v0.8.0

type EntityQuery struct {
	*objectbox.Query
}

Query provides a way to search stored objects

For example, you can find all Entity which Id is either 42 or 47:

box.Query(Entity_.Id.In(42, 47)).Find()

func (*EntityQuery) Find added in v0.8.0

func (query *EntityQuery) Find() ([]*Entity, error)

Find returns all objects matching the query

func (*EntityQuery) Limit added in v0.9.0

func (query *EntityQuery) Limit(limit uint64) *EntityQuery

Limit sets the number of elements to process by the query

func (*EntityQuery) Offset added in v0.9.0

func (query *EntityQuery) Offset(offset uint64) *EntityQuery

Offset defines the index of the first object to process (how many objects to skip)

type Executor

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

func CreateExecutor

func CreateExecutor(dbName string) *Executor

func (*Executor) ChangeValues

func (perf *Executor) ChangeValues(items []*Entity)

func (*Executor) Close

func (perf *Executor) Close()

func (*Executor) PrepareData

func (perf *Executor) PrepareData(count int) []*Entity

func (*Executor) PrintTimes

func (perf *Executor) PrintTimes(functions []string)

func (*Executor) PutAll

func (perf *Executor) PutAll(items []*Entity)

func (*Executor) PutAsync

func (perf *Executor) PutAsync(items []*Entity)

func (*Executor) ReadAll

func (perf *Executor) ReadAll(count int) []*Entity

func (*Executor) RemoveAll

func (perf *Executor) RemoveAll()

func (*Executor) UpdateAll

func (perf *Executor) UpdateAll(items []*Entity)

Jump to

Keyboard shortcuts

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