RazorDB.KeyValueStore.AddToIndex C# (CSharp) Method

AddToIndex() public method

public AddToIndex ( byte itemKey, byte[]>.IEnumerable indexValues ) : void
itemKey byte
indexValues byte[]>.IEnumerable
return void
        public void AddToIndex(byte[] itemKey, IEnumerable<KeyValuePair<string, byte[]>> indexValues) {
            foreach (var pair in indexValues) {
                var IndexName = pair.Key;

                // Construct Index key by concatenating the indexed value and the target key
                byte[] indexValue = pair.Value;
                byte[] indexKey = new byte[itemKey.Length + indexValue.Length];
                indexValue.CopyTo(indexKey, 0);
                itemKey.CopyTo(indexKey, indexValue.Length);

                KeyValueStore indexStore = GetSecondaryIndex(IndexName);

                // get indexkey length encoding 
                var lenBytes = new byte[8];
                var indexValueLen = Helper.Encode7BitInt(lenBytes, indexValue.Length);
                var indexValueLenBytes = new byte[indexValueLen];
                Helper.BlockCopy(lenBytes, 0, indexValueLenBytes, 0, indexValueLen);
                indexStore.Set(indexKey, indexValueLenBytes); // we know the key length 
            }
        }