Documentation ¶
Overview ¶
Package posting takes care of posting lists. It contains logic for mutation layers, merging them with RocksDB, etc.
Index ¶
- Constants
- Variables
- func CommitLists(numRoutines int)
- func DateIndex(val time.Time) ([]string, error)
- func DefaultIndexKeys(val string) ([]string, error)
- func FloatIndex(val float64) ([]string, error)
- func IndexTokens(attr string, src types.Val) ([]string, error)
- func Init(ps *store.Store)
- func IntIndex(val int32) ([]string, error)
- func RebuildIndex(ctx context.Context, attr string) error
- func SyncMarkFor(group uint32) *x.WaterMark
- func TimeIndex(val time.Time) ([]string, error)
- type ByUid
- type List
- func (l *List) AddMutation(ctx context.Context, t *task.DirectedEdge) (bool, error)
- func (l *List) AddMutationWithIndex(ctx context.Context, t *task.DirectedEdge) error
- func (l *List) Iterate(afterUid uint64, f func(obj *types.Posting) bool)
- func (l *List) LastCompactionTs() time.Time
- func (l *List) Length(afterUid uint64) int
- func (l *List) PostingList() *types.PostingList
- func (l *List) SetForDeletion()
- func (l *List) SyncIfDirty(ctx context.Context) (committed bool, err error)
- func (l *List) Uids(opt ListOptions) *task.List
- func (l *List) Value() (rval types.Val, rerr error)
- func (l *List) WaitForCommit()
- type ListOptions
Constants ¶
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 ¶
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 DefaultIndexKeys ¶ added in v0.7.2
DefaultIndexKeys tokenizes data as a string and return keys for indexing.
func FloatIndex ¶ added in v0.7.2
FloatIndex indexs float type.
func IndexTokens ¶ added in v0.7.1
IndexTokens return tokens, without the predicate prefix and index rune.
func RebuildIndex ¶ added in v0.7.2
RebuildIndex rebuilds index for a given attribute.
func SyncMarkFor ¶ added in v0.7.2
SyncMarkFor returns the synced watermark for the given RAFT group. We use this to determine the index to use when creating a new snapshot.
Types ¶
type List ¶
func GetOrCreate ¶
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 ¶
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
AddMutationWithIndex is AddMutation with support for indexing. It also supports reverse edges.
func (*List) Iterate ¶ added in v0.7.0
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 (*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 (*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) 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. }
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.