RazorDB.KeyValueStore.FindKeysByIndexStartsWith C# (CSharp) Method

FindKeysByIndexStartsWith() public method

Return only the bytes for the key linked to the index (record key in this case is the index value)
public FindKeysByIndexStartsWith ( string indexName, byte lookupValue ) : byte[]>>.IEnumerable
indexName string
lookupValue byte
return byte[]>>.IEnumerable
        public IEnumerable<KeyValuePair<byte[], byte[]>> FindKeysByIndexStartsWith(string indexName, byte[] lookupValue) {

            KeyValueStore indexStore = GetSecondaryIndex(indexName);
            // Loop over the values
            foreach (var pair in indexStore.EnumerateFromKey(lookupValue)) {
                // construct our index key pattern (lookupvalue | key)
                if (ByteArray.CompareMemCmp(pair.Key, 0, lookupValue, 0, lookupValue.Length) == 0) {
                    int offset = 0;
                    if (Manifest.RazorFormatVersion < 2) {
                        if (ByteArray.CompareMemCmp(pair.Key, pair.Key.Length - pair.Value.Length, pair.Value, 0, pair.Value.Length) == 0)
                            yield return new KeyValuePair<byte[], byte[]>(pair.Key, pair.Value);
                    } else {
                        int indexKeyLen = Helper.Decode7BitInt(pair.Value, ref offset);
                        if (lookupValue.Length <= indexKeyLen) {
                            var objectKey = ItemKeyFromIndex(pair, indexKeyLen);
                            Helper.BlockCopy(pair.Key, indexKeyLen, objectKey, 0, pair.Key.Length - indexKeyLen);
                            yield return new KeyValuePair<byte[], byte[]>(pair.Key, objectKey);
                        }
                    }
                } else {
                    // if the above condition was not met then we must have enumerated past the end of the indexed value
                    yield break;
                }
            }
        }