本文整理汇总了Golang中github.com/degdb/degdb/protocol.Keyspace.Includes方法的典型用法代码示例。如果您正苦于以下问题:Golang Keyspace.Includes方法的具体用法?Golang Keyspace.Includes怎么用?Golang Keyspace.Includes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/degdb/degdb/protocol.Keyspace
的用法示例。
在下文中一共展示了Keyspace.Includes方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: subjInKeyspace
// subjInKeyspace appends an increasing number to the prefix until it finds a
// string that will hash into the given keyspace.
func subjInKeyspace(keyspace *protocol.Keyspace, prefix string) string {
subj := prefix
i := 1
for !keyspace.Includes(murmur3.Sum64([]byte(subj))) {
subj = prefix + strconv.Itoa(i)
i++
}
return subj
}
示例2: Bloom
// Bloom returns a ScalableBloomFilter containing all the triples the current node has in the optional keyspace.
func (ts *TripleStore) Bloom(keyspace *protocol.Keyspace) (*boom.ScalableBloomFilter, error) {
filter := boom.NewDefaultScalableBloomFilter(BloomFalsePositiveRate)
results, errs := ts.EachTripleBatch(DefaultTripleBatchSize)
for triples := range results {
for _, triple := range triples {
if keyspace != nil {
hash := murmur3.Sum64([]byte(triple.Subj))
if !keyspace.Includes(hash) {
continue
}
}
data, err := triple.Marshal()
if err != nil {
return nil, err
}
filter.Add(data)
}
}
for err := range errs {
return nil, err
}
return filter, nil
}