RazorDB.KeyValueStore.ItemKeyFromIndex C# (CSharp) Method

ItemKeyFromIndex() private static method

Get the item key from an index
private static ItemKeyFromIndex ( byte[]>.KeyValuePair indexPair, int indexKeyLen = -1 ) : byte[]
indexPair byte[]>.KeyValuePair
indexKeyLen int
return byte[]
        private static byte[] ItemKeyFromIndex(KeyValuePair<byte[], byte[]> indexPair, int indexKeyLen = -1) {
            int offset = 0;
            if (indexPair.Value.Length > 4) {
                return indexPair.Value;
            } else {
                indexKeyLen = indexKeyLen == -1 ? Helper.Decode7BitInt(indexPair.Value, ref offset) : indexKeyLen;
                var objectKey = new byte[indexPair.Key.Length - indexKeyLen];
                Helper.BlockCopy(indexPair.Key, indexKeyLen, objectKey, 0, indexPair.Key.Length - indexKeyLen);
                return objectKey;
            }
        }

Usage Example

コード例 #1
0
ファイル: KeyValueStore.cs プロジェクト: lanicon/razordb
        public void CleanIndex(string indexName)
        {
            KeyValueStore indexStore         = GetSecondaryIndex(indexName);
            var           allValueStoreItems = new HashSet <ByteArray>(this.Enumerate().Select(item => new ByteArray(item.Key)));

            foreach (var indexItem in indexStore.Enumerate())
            {
                byte[] itemKey = KeyValueStore.ItemKeyFromIndex(indexItem);
                if (!allValueStoreItems.Contains(new ByteArray(itemKey)))
                {
                    indexStore.Delete(indexItem.Key);
                }
            }
        }
All Usage Examples Of RazorDB.KeyValueStore::ItemKeyFromIndex