本文整理汇总了C#中Slice.ExtractUserKey方法的典型用法代码示例。如果您正苦于以下问题:C# Slice.ExtractUserKey方法的具体用法?C# Slice.ExtractUserKey怎么用?C# Slice.ExtractUserKey使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Slice
的用法示例。
在下文中一共展示了Slice.ExtractUserKey方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: FindShortestSeparator
public override void FindShortestSeparator(ref string start, Slice limit)
{
// Attempt to shorten the user portion of the key
Slice user_start = new Slice(start).ExtractUserKey();
Slice user_limit = limit.ExtractUserKey();
string tmp = user_start.Data.GetString(user_start.Size);
UserComparator.FindShortestSeparator(ref tmp, user_limit);
if (tmp.Length < user_start.Size &&
UserComparator.Compare(user_start, new Slice(tmp)) < 0)
{
// User key has become shorter physically, but larger logically.
// Tack on the earliest possible number to the shortened user key.
Coding.PutFixed64(ref tmp,
Global.PackSequenceAndType(Global.kMaxSequenceNumber, Global.kValueTypeForSeek));
Debug.Assert(this.Compare(new Slice(start), new Slice(tmp)) < 0);
Debug.Assert(this.Compare(new Slice(tmp), limit) < 0);
start = start.Swap(ref tmp);
}
}
示例2: Compare
public override int Compare(Slice akey, Slice bkey)
{
// Order by:
// increasing user key (according to user-supplied comparator)
// decreasing sequence number
// decreasing type (though sequence# should be enough to disambiguate)
int r = UserComparator.Compare(akey.ExtractUserKey(), bkey.ExtractUserKey());
if (r == 0)
{
UInt64 anum = Coding.DecodeFixed64(akey.Data + (akey.Size - 8));
UInt64 bnum = Coding.DecodeFixed64(bkey.Data + (bkey.Size - 8));
if (anum > bnum)
{
r = -1;
}
else if (anum < bnum)
{
r = +1;
}
}
return r;
}