本文整理汇总了C#中Key.WithSequence方法的典型用法代码示例。如果您正苦于以下问题:C# Key.WithSequence方法的具体用法?C# Key.WithSequence怎么用?C# Key.WithSequence使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Key
的用法示例。
在下文中一共展示了Key.WithSequence方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AssembleGetResult
private byte[] AssembleGetResult(Key lookupKey, Value result) {
switch (result.Type) {
case ValueFlag.Null:
case ValueFlag.Deleted:
return null;
case ValueFlag.SmallValue:
return result.ValueBytes;
case ValueFlag.LargeValueDescriptor: {
lock (multiPageLock) {
// read the descriptor again in case it changed
result = InternalGet(lookupKey);
// make sure type is still large value descriptor and continue
if (result.Type == ValueFlag.LargeValueDescriptor) {
int valueSize = BitConverter.ToInt32(result.ValueBytes, 0);
byte[] bytes = new byte[valueSize];
int offset = 0;
byte seqNum = 1;
while (offset < valueSize) {
var blockKey = lookupKey.WithSequence(seqNum);
var block = InternalGet(blockKey);
if (block.Type != ValueFlag.LargeValueChunk)
throw new InvalidDataException(string.Format("Corrupted data: block is missing. Block Type: {0} SeqNum: {1}, Block Key: {2}", block.Type, seqNum, blockKey));
offset += block.CopyValueBytesTo(bytes, offset);
seqNum++;
}
return bytes;
} else {
return AssembleGetResult(lookupKey, result);
}
}
}
default:
throw new InvalidOperationException("Unexpected value flag for result.");
}
}