Beispiel #1
0
        private IEnumerator <KeyValuePair <Key, Value> > GetEnumerator()
        {
            if (NextPageIndex < 0)
            {
                StopEnumerating = true;
                yield break;
            }

            PageRecord page = ActiveManifest.FindPageForIndex(Level, NextPageIndex++);

            if (page == null)
            {
                StopEnumerating = true;
                yield break;
            }

            var sbt = new SortedBlockTable(Cache, BaseFileName, page.Level, page.Version);

            try {
                foreach (var pair in sbt.EnumerateFromKey(Cache, StartKey))
                {
                    yield return(pair);
                }
            } finally {
                sbt.Close();
            }
        }
Beispiel #2
0
        public static bool Lookup(string baseFileName, int level, int version, RazorCache cache, Key key, out Value value, ExceptionHandling exceptionHandling, Action <string> logger)
        {
            PerformanceCounters.SBTLookup.Increment();
            SortedBlockTable sbt = new SortedBlockTable(cache, baseFileName, level, version);

            try {
                byte[] lastScanKey;
                int    dataBlockNum = FindBlockForKey(baseFileName, level, version, cache, key, out lastScanKey);
                if (dataBlockNum >= 0 && dataBlockNum < sbt._dataBlocks)
                {
                    byte[] block = sbt.ReadBlock(LocalThreadAllocatedBlock(), dataBlockNum, lastScanKey);
                    return(sbt.ScanBlockForKey(block, key, out value));
                }
            } finally {
                sbt.Close();
            }
            value = Value.Empty;
            return(false);
        }
Beispiel #3
0
        public Key[] GetBlockTableIndex(string baseName, int level, int version)
        {
            string fileName = Config.SortedBlockTableFile(baseName, level, version);

            Key[] index;

            if (_blockIndexCache.TryGetValue(fileName, out index))
            {
                return(index);
            }

            PerformanceCounters.SBTGetBlockTableIndex.Increment();
            var sbt = new SortedBlockTable(null, baseName, level, version);

            try {
                index = sbt.GetIndex();
                _blockIndexCache.Set(fileName, index);
                return(index);
            } finally {
                sbt.Close();
            }
        }