posting

package
v0.7.3 Latest Latest
Warning

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

Go to latest
Published: Feb 22, 2017 License: Apache-2.0 Imports: 30 Imported by: 0

Documentation

Overview

Package posting takes care of posting lists. It contains logic for mutation layers, merging them with RocksDB, etc.

Index

Constants

View Source
const (
	// Set means overwrite in mutation layer. It contributes 0 in Length.
	Set uint32 = 0x01
	// Del means delete in mutation layer. It contributes -1 in Length.
	Del uint32 = 0x02
	// Add means add new element in mutation layer. It contributes 1 in Length.
	Add uint32 = 0x03
)

Variables

View Source
var (
	// ErrRetry can be triggered if the posting list got deleted from memory due to a hard commit.
	// In such a case, retry.
	ErrRetry = fmt.Errorf("Temporary Error. Please retry.")
	// ErrNoValue would be returned if no value was found in the posting list.
	ErrNoValue = fmt.Errorf("No value found")
)

Functions

func CommitLists added in v0.7.0

func CommitLists(numRoutines int)

func IndexTokens added in v0.7.1

func IndexTokens(attr string, src types.Val) ([]string, error)

IndexTokens return tokens, without the predicate prefix and index rune.

func Init

func Init(ps *store.Store)

Init initializes the posting lists package, the in memory and dirty list hash.

func RebuildIndex added in v0.7.2

func RebuildIndex(ctx context.Context, attr string) error

RebuildIndex rebuilds index for a given attribute.

func SyncMarkFor added in v0.7.2

func SyncMarkFor(group uint32) *x.WaterMark

SyncMarkFor returns the synced watermark for the given RAFT group. We use this to determine the index to use when creating a new snapshot.

func TypeID added in v0.7.3

func TypeID(edge *task.DirectedEdge) types.TypeID

TypeID returns the typeid of destiantion vertex

Types

type ByUid

type ByUid []*types.Posting

func (ByUid) Len

func (pa ByUid) Len() int

func (ByUid) Less

func (pa ByUid) Less(i, j int) bool

func (ByUid) Swap

func (pa ByUid) Swap(i, j int)

type List

type List struct {
	x.SafeMutex
	// contains filtered or unexported fields
}

func GetOrCreate

func GetOrCreate(key []byte, group uint32) (rlist *List, decr func())

GetOrCreate stores the List corresponding to key, if it's not there already. to lhmap and returns it. It also returns a reference decrement function to be called by caller.

plist, decr := GetOrCreate(key, store) defer decr() ... // Use plist TODO: This should take a node id and index. And just append all indices to a list. When doing a commit, it should update all the sync index watermarks. worker pkg would push the indices to the watermarks held by lists. And watermark stuff would have to be located outside worker pkg, maybe in x. That way, we don't have a dependency conflict.

func (*List) AddMutation

func (l *List) AddMutation(ctx context.Context, t *task.DirectedEdge) (bool, error)

AddMutation adds mutation to mutation layers. Note that it does not write anything to disk. Some other background routine will be responsible for merging changes in mutation layers to RocksDB. Returns whether any mutation happens.

func (*List) AddMutationWithIndex added in v0.7.0

func (l *List) AddMutationWithIndex(ctx context.Context, t *task.DirectedEdge) error

AddMutationWithIndex is AddMutation with support for indexing. It also supports reverse edges.

func (*List) Facets added in v0.7.3

func (l *List) Facets(param *facets.Param) (fs []*facets.Facet, ferr error)

Facets gives facets for the posting representing value.

func (*List) FacetsForUids added in v0.7.3

func (l *List) FacetsForUids(opt ListOptions, param *facets.Param) []*facets.Facets

FacetsForUids gives Facets for postings common with uids in opt listOptions.

func (*List) Iterate added in v0.7.0

func (l *List) Iterate(afterUid uint64, f func(obj *types.Posting) bool)

Iterate will allow you to iterate over this Posting List, while having acquired a read lock. So, please keep this iteration cheap, otherwise mutations would get stuck. The iteration will start after the provided UID. The results would not include this UID. The function will loop until either the Posting List is fully iterated, or you return a false in the provided function, which will indicate to the function to break out of the iteration.

	pl.Iterate(func(p *types.Posting) bool {
   // Use posting p
   return true  // to continue iteration.
   return false // to break iteration.
 })

func (*List) LastCompactionTs

func (l *List) LastCompactionTs() time.Time

func (*List) Length

func (l *List) Length(afterUid uint64) int

Length iterates over the mutation layer and counts number of elements.

func (*List) PostingList added in v0.7.0

func (l *List) PostingList() *types.PostingList

func (*List) SetForDeletion

func (l *List) SetForDeletion()

SetForDeletion will mark this List to be deleted, so no more mutations can be applied to this.

func (*List) SyncIfDirty added in v0.7.2

func (l *List) SyncIfDirty(ctx context.Context) (committed bool, err error)

func (*List) Uids added in v0.4.3

func (l *List) Uids(opt ListOptions) *task.List

Uids returns the UIDs given some query params. We have to apply the filtering before applying (offset, count).

func (*List) Value

func (l *List) Value() (rval types.Val, rerr error)

func (*List) WaitForCommit added in v0.7.0

func (l *List) WaitForCommit()

type ListOptions added in v0.4.3

type ListOptions struct {
	AfterUID   uint64              // Any UID returned must be after this value.
	Intersect  *task.List          // Intersect results with this list of UIDs.
	ExcludeSet map[uint64]struct{} // Exclude UIDs in this set.
}

ListOptions is used in List.Uids (in posting) to customize our output list of UIDs, for each posting list. It should be internal to this package.

Jump to

Keyboard shortcuts

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