本文整理汇总了C#中IIterator.CreateValueStream方法的典型用法代码示例。如果您正苦于以下问题:C# IIterator.CreateValueStream方法的具体用法?C# IIterator.CreateValueStream怎么用?C# IIterator.CreateValueStream使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IIterator
的用法示例。
在下文中一共展示了IIterator.CreateValueStream方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: MaybeAddFile
public void MaybeAddFile(InternalKey key, IIterator iterator, CompactionState compactionState, AsyncLock.LockScope locker, ref Slice lastKey, ref ulong lastSequence)
{
var drop = false;
if (lastKey.IsEmpty()
|| state.InternalKeyComparator.UserComparator.Compare(key.UserKey, lastKey) != 0)
{
// First occurrence of this user key
lastKey = key.UserKey.Clone();
lastSequence = Format.MaxSequenceNumber;
}
if (lastSequence <= compactionState.SmallestSnapshot)
{
// Hidden by an newer entry for same user key
drop = true;
}
else if (key.Type == ItemType.Deletion && key.Sequence <= compactionState.SmallestSnapshot
&& compactionState.Compaction.IsBaseLevelForKey(key.UserKey))
{
// For this user key:
// (1) there is no data in higher levels
// (2) data in lower levels will have larger sequence numbers
// (3) data in layers that are being compacted here and have
// smaller sequence numbers will be dropped in the next
// few iterations of this loop (by rule (A) above).
// Therefore this deletion marker is obsolete and can be dropped.
drop = true;
}
lastSequence = key.Sequence;
if (!drop)
{
if (compactionState.Builder == null)
{
using (locker.LockAsync().Result)
OpenCompactionOutputFileIfNecessary(compactionState, locker);
}
Debug.Assert(compactionState.Builder != null);
if (compactionState.Builder.NumEntries == 0)
compactionState.CurrentOutput.SmallestKey = new InternalKey(key.TheInternalKey.Clone());
compactionState.CurrentOutput.LargestKey = new InternalKey(key.TheInternalKey.Clone());
//Console.WriteLine("Adding " + compactionState.CurrentOutput.LargestKey);
using (var stream = iterator.CreateValueStream())
compactionState.Builder.Add(key.TheInternalKey, stream);
FinishCompactionOutputFileIfNecessary(compactionState, iterator);
}
}