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 Init(ps *store.Store)
- func KeysForTest(attr string) []string
- func StartCommit()
- type ByUid
- type List
- func (l *List) AddMutation(ctx context.Context, t *task.DirectedEdge, op uint32) (bool, error)
- func (l *List) AddMutationWithIndex(ctx context.Context, t *task.DirectedEdge, op uint32) error
- func (l *List) CommitIfDirty(ctx context.Context) (committed bool, err 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) Uids(opt ListOptions) *task.List
- func (l *List) Value() (val []byte, vtype byte, rerr error)
- func (l *List) WaitForCommit()
- type ListOptions
- type TokensTable
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 KeysForTest ¶ added in v0.7.0
KeysForTest returns keys for a table. This is just for testing / debugging.
func StartCommit ¶ added in v0.7.0
func StartCommit()
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
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.
func (*List) CommitIfDirty ¶ added in v0.7.0
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) 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.
type TokensTable ¶ added in v0.7.0
TokensTable tracks the keys / tokens / buckets for an indexed attribute.
func GetTokensTable ¶ added in v0.7.0
func GetTokensTable(attr string) *TokensTable
GetTokensTable returns TokensTable for an indexed attribute.
func NewTokensTable ¶ added in v0.7.0
func NewTokensTable() *TokensTable
NewTokensTable returns a new TokensTable.
func (*TokensTable) Add ¶ added in v0.7.0
func (t *TokensTable) Add(s string)
Add increments counter for a given key. If it doesn't exist, we create a new entry in TokensTable. We don't support delete yet. We are using a very simple implementation. In the future, as balanced trees / skip lists implementations become standardized for Go, we may consider using them. We also didn't support Delete operations yet. For that, we need to store the counts for each key.
func (*TokensTable) Get ¶ added in v0.7.0
func (t *TokensTable) Get(s string) int
Get returns position of element. If not found, it returns -1.
func (*TokensTable) GetFirst ¶ added in v0.7.0
func (t *TokensTable) GetFirst() string
GetFirst returns the first key in our list of keys. You could also call GetNext("") but that is less efficient.
func (*TokensTable) GetNext ¶ added in v0.7.0
func (t *TokensTable) GetNext(key string) string
GetNextKey returns the next key after given key. If we reach the end, we return an empty string.
func (*TokensTable) Size ¶ added in v0.7.0
func (t *TokensTable) Size() int
Size returns size of TokensTable.