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 IndexTokens(attr string, src types.Val) ([]string, error)
- func Init(ps *store.Store)
- func RebuildIndex(ctx context.Context, attr string) error
- func SyncMarkFor(group uint32) *x.WaterMark
- func TypeID(edge *task.DirectedEdge) types.TypeID
- 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) Facets(param *facets.Param) (fs []*facets.Facet, ferr error)
- func (l *List) FacetsForUids(opt ListOptions, param *facets.Param) []*facets.Facets
- 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 ¶
func CommitLists(numRoutines int)
func IndexTokens ¶
IndexTokens return tokens, without the predicate prefix and index rune.
func RebuildIndex ¶
RebuildIndex rebuilds index for a given attribute.
func SyncMarkFor ¶
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 ¶
AddMutationWithIndex is AddMutation with support for indexing. It also supports reverse edges.
func (*List) FacetsForUids ¶
FacetsForUids gives Facets for postings common with uids in opt listOptions.
func (*List) Iterate ¶
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 ¶
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 ¶
func (*List) Uids ¶
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 ¶
func (l *List) WaitForCommit()
type ListOptions ¶
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.