public Slice(SliceOptions options) { Options = options; _pointer = null; _array = null; _size = 0; }
public Slice(byte* key, ushort size) { _size = size; Options = SliceOptions.Key; _array = null; _pointer = key; }
public Slice(byte[] key, ushort size) { if (key == null) throw new ArgumentNullException("key"); _size = size; Options = SliceOptions.Key; _pointer = null; _array = key; }
public Slice(byte[] key) { if (key == null) throw new ArgumentNullException("key"); _pointerSize = 0; Options = SliceOptions.Key; _pointer = null; _array = key; }
public Slice(SliceOptions options) { Options = options; Pointer = null; Array = null; Size = 0; KeyLength = 0; }
protected MemorySlice(SliceOptions options) { this.Options = options; }
public Slice(SliceOptions options) : base( options ) {}
public Slice(NodeHeader* node) { Options = SliceOptions.Key; Set(node); }
public Slice(SliceOptions options) : base(options) { }
protected MemorySlice(SliceOptions options, ushort size, ushort keyLength) { this.Options = options; this.Size = size; this.KeyLength = keyLength; }
public Slice(NodeHeader *node) { Options = SliceOptions.Key; Set(node); }
public TreeNodeHeader *Original_WithPrefetch_Search(TreePage page, ByteStringContext allocator, Slice key) { int numberOfEntries = page.NumberOfEntries; if (numberOfEntries == 0) { goto NoEntries; } int lastMatch = -1; int lastSearchPosition = 0; SliceOptions options = key.Options; if (options == SliceOptions.Key) { if (numberOfEntries == 1) { goto SingleEntryKey; } int low = page.IsLeaf ? 0 : 1; int high = numberOfEntries - 1; int position = 0; ushort *offsets = page.KeysOffsets; byte * @base = page.Base; while (low <= high) { position = (low + high) >> 1; var node = (TreeNodeHeader *)(@base + offsets[position]); Slice pageKey; using (TreeNodeHeader.ToSlicePtr(allocator, node, out pageKey)) { Sse.Prefetch0(pageKey.Content.Ptr); lastMatch = SliceComparer.CompareInline(key, pageKey); } if (lastMatch == 0) { break; } if (lastMatch > 0) { low = position + 1; } else { high = position - 1; } } if (lastMatch > 0) // found entry less than key { position++; // move to the smallest entry larger than the key } lastSearchPosition = position; goto MultipleEntryKey; } if (options == SliceOptions.BeforeAllKeys) { lastMatch = 1; goto MultipleEntryKey; } if (options == SliceOptions.AfterAllKeys) { lastSearchPosition = numberOfEntries - 1; goto MultipleEntryKey; } return(null); NoEntries: { page.LastSearchPosition = 0; page.LastMatch = 1; return(null); } SingleEntryKey: { var node = page.GetNode(0); Slice pageKey; using (TreeNodeHeader.ToSlicePtr(allocator, node, out pageKey)) { page.LastMatch = SliceComparer.CompareInline(key, pageKey); } page.LastSearchPosition = page.LastMatch > 0 ? 1 : 0; return(page.LastSearchPosition == 0 ? node : null); } MultipleEntryKey: { page.LastMatch = lastMatch; page.LastSearchPosition = lastSearchPosition; if (lastSearchPosition >= numberOfEntries) { return(null); } return(page.GetNode(lastSearchPosition)); } }
public Slice(SliceOptions options, ByteString content) { Content = content; Content.SetUserDefinedFlags((ByteStringType)options); }
public PrefixedSlice(SliceOptions options) : this() { Options = options; }