Ejemplo n.º 1
0
        public byte[] GetValue(HashBin key)
        {
            var  hint  = CbIndex.GetAddressHintForKey(key);
            bool found = CbKey.GetKeyDataAddr(key, out var addr, hint, CbIndex.IndexKeyLen);

            if (found)
            {
                return(CbData.GetValue(addr));
            }
            return(null);
        }
Ejemplo n.º 2
0
        private CacheyBashi(string directory, string dbName, ushort keyLength, byte indexKeyLength = 2, bool createNew = false)
        {
            //todo: load the index.cb files into memory
            Dir       = directory;
            DbName    = dbName;
            IndexFile = Path.Combine(Dir, dbName) + ".index";
            KeyFile   = Path.Combine(Dir, dbName) + ".key";
            DatFile   = Path.Combine(Dir, dbName) + ".dat";

            CbIndex = new CbIndex(IndexFile, indexKeyLength, createNew);
            CbKey   = new CbKeyFixed(KeyFile, keyLength, createNew);
            CbData  = new CbData(DatFile, createNew);
        }
Ejemplo n.º 3
0
        public bool IndexHasKeySpaceForKey(byte[] key)
        {
            var hint = CbIndex.GetAddressHintForKey(key);

            return(hint.EndAddr > hint.StartAddr);
        }
Ejemplo n.º 4
0
        public bool HasKey(HashBin key)
        {
            var hint = CbIndex.GetAddressHintForKey(key);

            return(CbKey.HasKey(key, out var unused, false, hint, CbIndex.IndexKeyLen));
        }