Пример #1
0
        public FileLoader(MetaDB mDB, int bufferCount = 0, string metaInfoString = null, Func <HashLib.IHash> getHP = null)
        {
            var sep = new char[] { ':' };

            if (bufferCount != 0)
            {
                BufferCount = bufferCount;
            }

            GetHP = getHP;
            if (GetHP == null)
            {
                GetHP = new Func <HashLib.IHash>(() => { return(HashLib.HashFactory.Crypto.CreateTiger2()); });
            }

            MDB = mDB;
            HDB = mDB.HDB;

            MetaInfoString = metaInfoString;

            DBFile   = HDB.HashDBFile;
            SortMask = HDB.DBEntriesMask << HASH_SHIFT;

            MinHashSize = HDB.MinBlockSize;

            ScanExtensions = ScanExtensionsSpec.ToUpper().Split(sep, StringSplitOptions.RemoveEmptyEntries);
            MaskedEntries  = MaskedEntriesSpec.ToUpper().Split(sep, StringSplitOptions.RemoveEmptyEntries);
        }
Пример #2
0
        public override void Merge(ISnapshot snapshot)
        {
            HashDB hash_db = null;

            if (((Snapshot)snapshot).db is HashDB)
            {
                hash_db = (HashDB)((Snapshot)snapshot).db;
                IEnumerator <KeyValuePair <Key, Value> > it = hash_db.GetEnumerator();

                while (it.MoveNext())
                {
                    this.db.Put(it.Current.Key, it.Current.Value);
                }
            }
        }
Пример #3
0
        private bool disposedValue = false; // To detect redundant calls

        protected virtual void Dispose(bool disposing)
        {
            if (!disposedValue)
            {
                if (disposing)
                {
                    if (HDB != null)
                    {
                        HDB.Dispose();
                    }


                    if (ReadyQueue != null)
                    {
                        ReadyQueue.Dispose();
                    }

                    HDB        = null;
                    ReadyQueue = null;
                }
                disposedValue = true;
            }
        }
Пример #4
0
        public MetaDB(string WorkingDir, int minHashSize = 256, long DBSize = 0, int loadBufferCount = 50000000, string NewInfoString = null)
        {
            RootFolder = WorkingDir;
            if (!Directory.Exists(RootFolder))
            {
                Directory.CreateDirectory(RootFolder);
            }

            MDBName         = Path.Combine(RootFolder, mdbName);
            HDBName         = Path.Combine(RootFolder, hdbName);
            BDBName         = Path.Combine(RootFolder, bdbName);
            RelocName       = Path.Combine(RootFolder, relocFolder);
            LoadBufferCount = loadBufferCount;

            if (File.Exists(MDBName))
            {
                xDoc = XDocument.Load(MDBName);
            }
            else
            {
                xDoc = new XDocument(new XDeclaration("1.0", Encoding.Default.WebName, "yes"), new XElement(ElementNames.xRoot));
            }

            mData = xDoc.Root;

            var currID = ((Int32?)mData.Attribute(AttributeNames.xNextHashID) ?? 0);

            if (currID == 0)
            {
                mData.SetAttributeValue(AttributeNames.xNextHashID, 1);
                currHID = 1;
            }
            else
            {
                currHID = currID;
            }

            if (mData.Element(ElementNames.xRecords) != null)
            {
                mRecords = mData.Element(ElementNames.xRecords);
            }
            else
            {
                mRecords = new XElement(ElementNames.xRecords);
                mData.Add(mRecords);
            }

            if (mData.Element(ElementNames.xMetaInfoStrings) != null)
            {
                infoStrings = mData.Element(ElementNames.xMetaInfoStrings);
            }
            else
            {
                infoStrings = new XElement(ElementNames.xMetaInfoStrings);
                mData.Add(infoStrings);
            }
            infoString  = NewInfoString;
            MinHashSize = minHashSize;

            ReRe = new ReReDB(RelocName);

            HDB      = new HashDB(MinHashSize, HDBName, RelocName, DBSize);
            HDB.ReRe = ReRe;

            Loader = new FileLoader(this, LoadBufferCount, infoString);

            cLoader            = new CloudLoader(Loader, MinHashSize, RelocName);
            cLoader.InfoString = infoString;
            ReRe.AzureCnx      = cLoader;
        }