Main DBreeze Database class.
Inheritance: IDisposable
示例#1
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            // Set our view from the "main" layout resource
            SetContentView(Resource.Layout.Main);

            // Get our button from the layout resource,
            // and attach an event to it
            Button button = FindViewById<Button>(Resource.Id.MyButton);

            if (engine == null)
            {
                engine = new DBreezeEngine(@"./sdcard/tiesky.com/DBreezeTest");
            }

            button.Click += delegate {

                using (var tran = engine.GetTransaction())
                {
                    tran.Insert<int, string>("t1", count, "val" + count);
                    tran.Commit();
                }

                using (var tran = engine.GetTransaction())
                {
                    button.Text = "Please, read detailed documentation on http://dbreeze.codeplex.com/ or http://dbreeze.tiesky.com/" +
                        "... Inserted value is " + tran.Select<int, string>("t1", count).Value;

                }

                count++;

            };
        }
        public PersistentCookieStorage(DBreezeEngine db) {
            if (db == null) {
                throw new ArgumentNullException("db");
            }

            this.db = db;
        }
 public void CreateMockObjects() {
     this.storageEngine = new DBreezeEngine(new DBreezeConfiguration { Storage = DBreezeConfiguration.eStorage.MEMORY });
     this.localRootPath = Path.Combine(Path.GetTempPath(), Path.GetTempFileName());
     this.matcher = new PathMatcher(this.localRootPath, this.remoteRootPath);
     this.queue = new Mock<ISyncEventQueue>();
     this.remoteFolder = MockOfIFolderUtil.CreateRemoteFolderMock(this.remoteRootId, this.remoteRootPath, this.remoteRootPath);
     this.remoteFolder.SetupDescendants();
     this.localFolder = new Mock<IDirectoryInfo>();
     this.localFolder.Setup(f => f.FullName).Returns(this.localRootPath);
     this.localFolder.Setup(f => f.Exists).Returns(true);
     this.localFolder.Setup(f => f.IsExtendedAttributeAvailable()).Returns(true);
     this.localFolder.SetupGuid(this.rootGuid);
     this.localFolder.Setup(f => f.LastWriteTimeUtc).Returns(this.lastLocalWriteTime);
     this.fsFactory = new Mock<IFileSystemInfoFactory>();
     this.fsFactory.AddIDirectoryInfo(this.localFolder.Object);
     this.mappedRootObject = new MappedObject(
         this.remoteRootPath,
         this.remoteRootId,
         MappedObjectType.Folder,
         null,
         "changeToken") {
         Guid = this.rootGuid,
         LastLocalWriteTimeUtc = this.lastLocalWriteTime
     };
     this.storage = new MetaDataStorage(this.storageEngine, this.matcher, true);
     this.storage.SaveMappedObject(this.mappedRootObject);
     this.filter = MockOfIFilterAggregatorUtil.CreateFilterAggregator().Object;
     this.listener = new Mock<IActivityListener>();
 }
示例#4
0
        /// <summary>
        /// Constructor (automatically starts unfinished indexing job)
        /// </summary>
        /// <param name="DBreezeEngine">must be already initialized</param>
        public Storage(DBreezeEngine DBreezeEngine)
        {
            this.OnProcessingStarted += Storage_OnProcessingStarted;
            this.OnProcessingStopped += Storage_OnProcessingStopped;
            if (DBreezeEngine == null)
                throw ThrowException("Storage", "DBreezeEngine must be instantiated");
            //if(SearchWordMinimalLength < 1)
            //    throw ThrowException("Storage", "SearchWordMinimalLength must be > 0");
            //if (DocumentsStorageTablesPrefix.Length < 1)
            //    throw ThrowException("Storage", "DocumentsStorageTablesPrefix.Length must be > 0");

            this.DBreezeEngine = DBreezeEngine;

            //Preparing Protobuf
            ProtoBuf.Serializer.PrepareSerializer<Document>();
            ProtoBuf.Serializer.PrepareSerializer<SearchRequest>();
            ProtoBuf.Serializer.PrepareSerializer<SearchResponse>();
            Document o1 = new Document();
            o1.SerializeProtobuf();
            SearchRequest o2 = new SearchRequest();
            o2.SerializeProtobuf();
            SearchResponse o3 = new SearchResponse();
            o3.SerializeProtobuf();

            //Automatic indexing of unfinished documents
            StartDocumentsIndexing();
        }
示例#5
0
 public void TearDown() {
     this.engine.Dispose();
     this.engine = null;
     if (Directory.Exists(this.path)) {
         Directory.Delete(this.path, true);
     }
 }
示例#6
0
        public override void AwakeFromNib() {
            base.AwakeFromNib();

            var config = ConfigManager.CurrentConfig;
            this.folderSelection.RemoveAllItems();
            this.output.Editable = false;
            this.RunButton.Activated += (object sender, EventArgs e) => {
                var folder = config.Folders.Find(f => f.DisplayName == this.folderSelection.SelectedItem.Title);
                using (var dbEngine = new DBreezeEngine(folder.GetDatabasePath())) {
                    var storage = new MetaDataStorage(dbEngine, new PathMatcher(folder.LocalPath, folder.RemotePath), false);
                    try {
                        storage.ValidateObjectStructure();
                        this.output.StringValue = string.Format("{0}: DB structure of {1} is fine", DateTime.Now, folder.GetDatabasePath());
                    } catch(Exception ex) {
                        this.output.StringValue = ex.ToString();
                    }
                }
            };
            this.DumpTree.Activated += (object sender, EventArgs e) => {
                this.output.StringValue = string.Empty;
                var folder = config.Folders.Find(f => f.DisplayName == this.folderSelection.SelectedItem.Title);
                using (var dbEngine = new DBreezeEngine(folder.GetDatabasePath())) {
                    var storage = new MetaDataStorage(dbEngine, new PathMatcher(folder.LocalPath, folder.RemotePath), false);
                    try {
                        var ignoreStorage = new IgnoredEntitiesStorage(new IgnoredEntitiesCollection(), storage);
                        var session = SessionFactory.NewInstance().CreateSession(folder, "DSS-DIAGNOSE-TOOL");
                        var remoteFolder = session.GetObjectByPath(folder.RemotePath) as IFolder;
                        var filterAggregator = new FilterAggregator(
                            new IgnoredFileNamesFilter(),
                            new IgnoredFolderNameFilter(),
                            new InvalidFolderNameFilter(),
                            new IgnoredFoldersFilter());
                        var treeBuilder = new DescendantsTreeBuilder(
                            storage,
                            remoteFolder,
                            new DirectoryInfoWrapper(new DirectoryInfo(folder.LocalPath)),
                            filterAggregator,
                            ignoreStorage);
                        var trees = treeBuilder.BuildTrees();
                        var suffix = string.Format("{0}-{1}", folder.DisplayName.Replace(Path.DirectorySeparatorChar,'_'), Guid.NewGuid().ToString());
                        var localTree = Path.Combine(Path.GetTempPath(), string.Format("LocalTree-{0}.dot", suffix));
                        var remoteTree = Path.Combine(Path.GetTempPath(), string.Format("StoredTree-{0}.dot", suffix));
                        var storedTree = Path.Combine(Path.GetTempPath(), string.Format("RemoteTree-{0}.dot", suffix));
                        trees.LocalTree.ToDotFile(localTree);
                        trees.StoredTree.ToDotFile(remoteTree);
                        trees.RemoteTree.ToDotFile(storedTree);
                        this.output.StringValue = string.Format("Written to:\n{0}\n{1}\n{2}", localTree, remoteTree, storedTree);
                    } catch (Exception ex) {
                        this.output.StringValue = ex.ToString();
                    }
                }
            };

            foreach (var folder in config.Folders) {
                this.folderSelection.AddItem(folder.DisplayName);
            }
        }
示例#7
0
 public DBreezeInstance(IPathProvider pathProvider)
 {
     var dbConf = new DBreezeConfiguration()
     {
         DBreezeDataFolderName = Path.Combine(pathProvider.BasePath, "DBR"),
         Storage = DBreezeConfiguration.eStorage.DISK
     };
     this.engine = new DBreezeEngine(dbConf);
 }
示例#8
0
 public void SetUp() {
     this.path = Path.Combine(Path.GetTempPath(), "DBreeze");
     this.engine = new DBreezeEngine(new DBreezeConfiguration { Storage = DBreezeConfiguration.eStorage.MEMORY });
     this.file = new Mock<IFileInfo>();
     this.file.SetupAllProperties();
     this.file.Setup(f => f.Length).Returns(1024);
     this.file.Setup(f => f.Name).Returns("FileTransmissionObjectsTest.file");
     this.file.Setup(f => f.FullName).Returns(Path.Combine(Path.GetTempPath(), this.file.Object.Name));
     this.file.Setup(f => f.Exists).Returns(true);
     this.file.Object.LastWriteTimeUtc = DateTime.UtcNow;
 }
示例#9
0
 /// <summary>
 /// constructor
 /// </summary>
 /// <param name="engine"></param>
 internal DBreezeResources(DBreezeEngine engine)
 {
     this.DBreezeEngine = engine;
     LTrieSettings      = new TrieSettings()
     {
         InternalTable = true
     };
     Storage         = new StorageLayer(Path.Combine(engine.MainFolder, TableFileName), LTrieSettings, engine.Configuration);
     LTrie           = new LTrie(Storage);
     LTrie.TableName = "DBreezeResources";
 }
        public void Run(string directory, string filter, double minSimilarity, Func<bool> continueTest)
        {
            var allfiles = System.IO.Directory.GetFiles(directory, filter, System.IO.SearchOption.AllDirectories);

            using (var engine = new DBreezeEngine(dbConf))
            {
                allfiles.AsParallel().ForAll(f =>
                {
                    if (continueTest())
                    {
                        using (var tran = engine.GetTransaction())
                        {
                            GetHistogram(tran, f);
                            tran.Commit();
                        }
                        OnPrepareProgress(allfiles.Length);
                    }
                });

                var list = ((ushort)allfiles.Length).GetIndexCombinations();
                var total = list.Count();

                if (continueTest())
                {
                    list.AsParallel().ForAll(c =>
                    {
                        if (!continueTest())
                        {
                            return;
                        }
                        var f = allfiles[c[0]];
                        var l = allfiles[c[1]];
                        var value = 0.0;
                        using (var tran = engine.GetTransaction())
                        {
                            tran.ValuesLazyLoadingIsOn = false;
                            value = GetComparisonResult(tran, f, l);
                            tran.Commit();
                        }
                        if (OnCompareProgress != null)
                        {
                            if (value >= minSimilarity)
                            {
                                OnCompareProgress(total, f, l, value);
                            }
                            else
                            {
                                OnCompareProgress(total, null, null, 0);
                            }
                        }
                    });
                }
            }
        }
        public FileTransmissionStorage(DBreezeEngine engine, long chunkSize = CmisSync.Lib.Config.Config.DefaultChunkSize) {
            if (engine == null) {
                throw new ArgumentNullException("engine");
            }

            if (chunkSize < 1) {
                throw new ArgumentException(string.Format("Given chunkSize \"{0}\" is too low", chunkSize),"chunkSize");
            }

            this.engine = engine;
            this.ChunkSize = chunkSize;
        }
        public static IDisposableAuthProvider CreateAuthProvider(Config.AuthenticationType type, Uri url, DBreezeEngine db) {
            ICookieStorage storage = new PersistentCookieStorage(db);

            switch (type) {
            case Config.AuthenticationType.BASIC:
                return new PersistentStandardAuthenticationProvider(storage, url);
            case Config.AuthenticationType.KERBEROS:
                goto case Config.AuthenticationType.NTLM;
            case Config.AuthenticationType.NTLM:
                return new PersistentNtlmAuthenticationProvider(storage, url);
            default:
                return new StandardAuthenticationProviderWrapper();
            }
        }
示例#13
0
        public ScpDb()
        {
            var jSettings = new JsonSerializerSettings()
            {
                TypeNameHandling = TypeNameHandling.All
            };

            DBreeze.Utils.CustomSerializator.Serializator =
                o => JsonConvert.SerializeObject(o, Formatting.Indented, jSettings);

            DBreeze.Utils.CustomSerializator.Deserializator = 
                (s, type) => JsonConvert.DeserializeObject(s, jSettings);

            Engine = new DBreezeEngine(DbPath);
        }
示例#14
0
 public static void Reinitialize(this DBreeze.DBreezeEngine engine, string dbPath)
 {
     if (dbPath == null)
     {
         return;
     }
     if (StaticKeyValueDatabase.IsDisposed || engine == null || engine?.IsDatabaseOperable == false || engine?.Disposed == true)
     {
         BLogger.I("Database is not operable or it was disposed. Reinitializing. Message: {message}", engine.DatabaseNotOperableReason ?? "");
         _dbPath = dbPath;
         StaticKeyValueDatabase.DisposeDatabaseEngine();
         engine = StaticKeyValueDatabase.GetDatabaseEngine(dbPath);
         BLogger.I("Engine reintialized. Path: {path}", dbPath);
     }
 }
示例#15
0
        void InitDBEngines()
        {
            if (DBEngineClient != null)
            {
                return;
            }

            DBEngineClient  = new DBreezeEngine(textBox1.Text);
            DBEngineClient2 = new DBreezeEngine(textBox3.Text);
            DBEngine        = new DBreezeEngine(textBox4.Text);

            //Specifying byte[] serializator / deserializator for DBreeze - it will be used internally by SyncEngines for deserializing incoming entites
            DBreeze.Utils.CustomSerializator.ByteArraySerializator   = EntitySyncingClientTester.ProtobufSerializer.SerializeProtobuf;
            DBreeze.Utils.CustomSerializator.ByteArrayDeSerializator = EntitySyncingClientTester.ProtobufSerializer.DeserializeProtobuf;
        }
示例#16
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="dbEngine"></param>
        /// <param name="serverSender"></param>
        /// <param name="resetWebSession"></param>
        /// <param name="syncIsFinishing"></param>
        /// <param name="logger">can be null</param>
        /// <param name="byteArraySerializer">can be null then DBreeze embedded serializer will be used</param>
        /// <param name="byteArrayDeSerializer">can be null then DBreeze embedded deserializer will be used</param>
        public Engine(DBreeze.DBreezeEngine dbEngine, Func <string, byte[], Task <byte[]> > serverSender, Action resetWebSession, Action syncIsFinishing, ILogger logger,
                      Func <object, byte[]> byteArraySerializer = null, Func <byte[], Type, object> byteArrayDeSerializer = null)
        {
            if (logger == null)
            {
                Logger.log = new LoggerWrapper();
            }
            else
            {
                Logger.log = logger;
            }

            if (dbEngine == null)
            {
                Logger.LogException("EntitySyncingClient.Engine", "Init", new Exception("DBreezeEngine is not specified"), "");
                return;
            }


            if ((byteArraySerializer != null && byteArrayDeSerializer == null) || (byteArraySerializer != null && byteArrayDeSerializer == null))
            {
                throw new Exception("EntitySyncing.Engine.Init: please supply both ByteArrayDeSerializator and ByteArraySerializator");
            }

            if (byteArraySerializer == null && byteArrayDeSerializer == null)
            {
                //Trying to use DBreeze serializers
                if (DBreeze.Utils.CustomSerializator.ByteArrayDeSerializator == null || DBreeze.Utils.CustomSerializator.ByteArraySerializator == null)
                {
                    throw new Exception("EntitySyncing.Engine.Init: please supply both ByteArrayDeSerializator and ByteArraySerializator or embed serializers to DBreeze");
                }

                this.Serialize   = DBreeze.Utils.CustomSerializator.ByteArraySerializator;
                this.Deserialize = DBreeze.Utils.CustomSerializator.ByteArrayDeSerializator;
            }
            else
            {
                this.Serialize   = byteArraySerializer;
                this.Deserialize = byteArrayDeSerializer;
            }


            DBEngine = dbEngine;

            _serverSender    = serverSender;
            _resetWebSession = resetWebSession;
            _syncIsFinishing = syncIsFinishing;
        }
示例#17
0
        public static void Main(string[] args) {
            var config = ConfigManager.CurrentConfig;

            foreach (var repoInfo in config.Folders) {
                using (var dbEngine = new DBreezeEngine(repoInfo.GetDatabasePath())) {
                    var storage = new MetaDataStorage(dbEngine, new PathMatcher(repoInfo.LocalPath, repoInfo.RemotePath), false);
                    Console.WriteLine(string.Format("Checking {0} and DB Path \"{1}\"", repoInfo.DisplayName, repoInfo.GetDatabasePath()));
                    storage.ValidateObjectStructure();
                }
            }

            foreach (var repoInfo in config.Folders) {
                try {
                    using (var dbEngine = new DBreezeEngine(repoInfo.GetDatabasePath())) {
                        var storage = new MetaDataStorage(dbEngine, new PathMatcher(repoInfo.LocalPath, repoInfo.RemotePath), false);
                        var ignoreStorage = new IgnoredEntitiesStorage(new IgnoredEntitiesCollection(), storage);
                        var session = SessionFactory.NewInstance().CreateSession(repoInfo, "DSS-DIAGNOSE-TOOL");
                        var remoteFolder = session.GetObjectByPath(repoInfo.RemotePath) as IFolder;
                        var filterAggregator = new FilterAggregator(
                            new IgnoredFileNamesFilter(),
                            new IgnoredFolderNameFilter(),
                            new InvalidFolderNameFilter(),
                            new IgnoredFoldersFilter());
                        var treeBuilder = new DescendantsTreeBuilder(
                            storage,
                            remoteFolder,
                            new DirectoryInfoWrapper(new DirectoryInfo(repoInfo.LocalPath)),
                            filterAggregator,
                            ignoreStorage);
                        Console.WriteLine(string.Format("Creating local, stored and remote tree in \"{0}\"", Path.GetTempPath()));
                        var trees = treeBuilder.BuildTrees();
                        var suffix = string.Format("{0}-{1}", repoInfo.DisplayName.Replace(Path.DirectorySeparatorChar,'_'), Guid.NewGuid().ToString());
                        var localTree = Path.Combine(Path.GetTempPath(), string.Format("LocalTree-{0}.dot", suffix));
                        var remoteTree = Path.Combine(Path.GetTempPath(), string.Format("StoredTree-{0}.dot", suffix));
                        var storedTree = Path.Combine(Path.GetTempPath(), string.Format("RemoteTree-{0}.dot", suffix));
                        trees.LocalTree.ToDotFile(localTree);
                        trees.StoredTree.ToDotFile(remoteTree);
                        trees.RemoteTree.ToDotFile(storedTree);
                        Console.WriteLine(string.Format("Written to:\n{0}\n{1}\n{2}", localTree, remoteTree, storedTree));
                    }
                } catch (Exception ex) {
                    Console.Error.WriteLine(ex.Message);
                }
            }
        }
        public void SetUp() {
            this.engine = new DBreezeEngine(new DBreezeConfiguration { Storage = DBreezeConfiguration.eStorage.MEMORY });

            this.persistentDBreezePath = Path.Combine(Path.GetTempPath(), "FileTransmissionStorageTest-DBreeze");

            this.localFile = new Mock<IFileInfo>();
            this.localFile.SetupAllProperties();
            this.localFile.Setup(f => f.Length).Returns(1024);
            this.localFile.Setup(f => f.Name).Returns("FileTransmissionStorageTest.file");
            this.localFile.Setup(f => f.FullName).Returns(Path.Combine(Path.GetTempPath(), this.localFile.Object.Name));
            this.localFile.Setup(f => f.Exists).Returns(true);
            this.localFile.Object.LastWriteTimeUtc = DateTime.UtcNow;

            this.remoteFile = new Mock<DotCMIS.Client.IDocument>();
            this.remoteFile.Setup(m => m.LastModificationDate).Returns(this.localFile.Object.LastWriteTimeUtc);
            this.remoteFile.Setup(m => m.Paths).Returns(new List<string>() { "/RemoteFile" });
            this.remoteFile.Setup(m => m.ChangeToken).Returns("ChangeToken");
        }
示例#19
0
        public MetaDataStorage(DBreezeEngine engine, IPathMatcher matcher, bool fullValidation, bool disableInitialValidation = false) {
            if (engine == null) {
                throw new ArgumentNullException("engine");
            }

            if (matcher == null) {
                throw new ArgumentNullException("matcher");
            }

            this.engine = engine;
            this.matcher = matcher;
            this.fullValidationOnEachManipulation = fullValidation;

            if (!disableInitialValidation) {
                try {
                    this.ValidateObjectStructure();
                } catch(InvalidDataException e) {
                    Logger.Fatal("Database object structure is invalid", e);
                }
            }
        }
示例#20
0
文件: Main.cs 项目: hhblaze/DBreeze
        // This is the main entry point of the application.
        static void Main(string[] args)
        {
            // if you want to use a different Application Delegate class from "AppDelegate"
            // you can specify it here.
            UIApplication.Main(args, null, "AppDelegate");

            if (engine == null)
            {
                engine = new DBreezeEngine(@"ADD YOUR FILESYSTEM PATH TO DBREEZE FOLDER");
            }

            using (var tran = engine.GetTransaction())
            {
                tran.Insert<int, string>("t1", 1, "val1");
                tran.Insert<int, string>("t1", 2, "val1");
                tran.Commit();
            }

            using (var tran = engine.GetTransaction())
            {
                Console.WriteLine("Inserted val" + tran.Select<int, string>("t1", 1).Value);

            }
        }
示例#21
0
        private void UseValues(string databasePath, int key, int val)
        {
            using (var engine = new DBreeze.DBreezeEngine(databasePath))
            {
                using (var transaction = engine.GetTransaction())
                {
                    //var row = transaction.Select<int, int>("t", key);

                    transaction.Insert("t", key, val);

                    transaction.Commit();
                }
            }

            using (var engine = new DBreeze.DBreezeEngine(databasePath))
            {
                using (var transaction = engine.GetTransaction())
                {
                    var row = transaction.Select<int, int>("t", key);

                    if (!row.Exists)
                    {
                        Console.WriteLine("Stored value incorrect");
                    }
                }
            }
        }
 public void SetUp() {
     this.engine = new DBreezeEngine(new DBreezeConfiguration { Storage = DBreezeConfiguration.eStorage.MEMORY });
 }
示例#23
0
        private void TestMemoryStorage()
        {
            if (memoryEngine == null)
            {
                memoryEngine = new DBreezeEngine(new DBreezeConfiguration()
                {
                     Storage = DBreezeConfiguration.eStorage.MEMORY
                });
            }

            //SortedDictionary<string, int> _d = new SortedDictionary<string, int>();

            //DBreeze.Diagnostic.SpeedStatistic.StartCounter("a");
            //DateTime dt=new DateTime(1970,1,1);

            //for (int i = 0; i < 1000000; i++)
            //{
            //    _d.Add(dt.Ticks.ToString(), i);
            //    dt=dt.AddSeconds(7);
            //}

            //DBreeze.Diagnostic.SpeedStatistic.PrintOut("a", true);

            //DBreeze.Diagnostic.SpeedStatistic.StartCounter("a");
            //int c1 = 0;
            //foreach (var row in _d.OrderBy(r => r.Key))
            //{
            //    c1++;
            //}
            //DBreeze.Diagnostic.SpeedStatistic.PrintOut("a", true);
            //Console.WriteLine(c1);

            //memoryEngine.Scheme.DeleteTable("t1");

            //DBreeze.Diagnostic.SpeedStatistic.StartCounter("a");
            ////DateTime dt = new DateTime(1970, 1, 1);

            //using (var tran = memoryEngine.GetTransaction())
            //{
            //    for (int i = 0; i < 1000000; i++)
            //    {
            //  //      tran.Insert<string, int>("t1", dt.Ticks.ToString(), i);
            //    //    dt = dt.AddSeconds(7);

            //        tran.Insert<byte[], byte[]>("t1", i.To_4_bytes_array_BigEndian(), i.To_4_bytes_array_BigEndian());

            //    }

            //    //Console.WriteLine(tran.Count("t1"));
            //    tran.Commit();
            //}

            //DBreeze.Diagnostic.SpeedStatistic.PrintOut("a", true);

            //int c1 = 0;

            //DBreeze.Diagnostic.SpeedStatistic.StartCounter("a");

            //using (var tran = memoryEngine.GetTransaction())
            //{
            //    DBreeze.Diagnostic.SpeedStatistic.StartCounter("a");

            //    foreach (var row in tran.SelectForward<string, int>("t1"))
            //    {
            //        c1++;
            //    }

            //    DBreeze.Diagnostic.SpeedStatistic.PrintOut("a", true);
            //    Console.WriteLine(c1);
            //}

            ms = new MemoryStorage(10, 10, MemoryStorage.eMemoryExpandStartegy.FIXED_LENGTH_INCREASE);

            ms.Write_ToTheEnd(new byte[] { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 });
            ms.Write_ToTheEnd(new byte[] { 1, 1, 1, 1, 1 });
            //ms.Write_ByOffset(17,new byte[] { 1, 1, 1, 1, 1 });
            //Console.WriteLine(ms.MemorySize);
            //Console.WriteLine(ms.Read(0, ms.MemorySize).ToBytesString(""));
            Console.WriteLine(ms.GetFullData().Length);
        }
示例#24
0
 public void Dispose() {
     if (this.engine != null) {
         this.engine.Dispose();
         this.engine = null;
     }
 }
示例#25
0
 private void InitDb()
 {
     lock(lockInitDb)
     {
         if(engine == null)
             engine = new DBreezeEngine(@"D:\temp\DBreezeTest\DBR1");
     }
 }
        public void GetObjectListOnPersistedStorage() {
            var conf = new DBreezeConfiguration {
                DBreezeDataFolderName = this.persistentDBreezePath,
                Storage = DBreezeConfiguration.eStorage.DISK
            };

            using (var engine = new DBreezeEngine(conf)) {
                var storage = new FileTransmissionStorage(engine);
                for (int i = 1; i <= 10; ++i) {
                    this.remoteFile.Setup(m => m.Id).Returns("RemoteObjectId" + i.ToString());
                    var obj = new FileTransmissionObject(TransmissionType.UPLOAD_NEW_FILE, this.localFile.Object, this.remoteFile.Object);
                    Assert.DoesNotThrow(() => storage.SaveObject(obj));
                    Assert.That(storage.GetObjectList().Count, Is.EqualTo(i));
                    Assert.That(storage.GetObjectList().First(foo => foo.LocalPath == this.localFile.Object.FullName && foo.RemoteObjectId == "RemoteObjectId" + i.ToString()), Is.Not.Null);
                }
            }

            using (var engine = new DBreezeEngine(conf)) {
                var storage = new FileTransmissionStorage(engine);
                for (int i = 1; i <= 10; ++i) {
                    Assert.That(storage.GetObjectList().First(foo => foo.LocalPath == this.localFile.Object.FullName && foo.RemoteObjectId == "RemoteObjectId" + i.ToString()), Is.Not.Null);
                }

                Assert.That(storage.GetObjectList().Count, Is.EqualTo(10));
            }
        }
示例#27
0
 public TransactionsCoordinator(DBreezeEngine engine)
 {
     this._engine = engine;
 }
示例#28
0
文件: Scheme.cs 项目: hhblaze/DBreeze
        public Scheme(DBreezeEngine DBreezeEngine)
        {
            Engine = DBreezeEngine;

            this.OpenSchema();
        }
示例#29
0
 public void CreateDbOnFsAndInsertAndSelectObject() {
     var conf = new DBreezeConfiguration {
         DBreezeDataFolderName = this.path,
         Storage = DBreezeConfiguration.eStorage.DISK
     };
     using (var engine = new DBreezeEngine(conf))
     using (var tran = engine.GetTransaction()) {
         var folder = new TestClass {
             Name = "Name"
         };
         tran.Insert<int, DbCustomSerializer<TestClass>>("objects", 1, folder);
         tran.Commit();
         Assert.AreEqual("Name", (tran.Select<int, DbCustomSerializer<TestClass>>("objects", 1).Value.Get as TestClass).Name);
     }
 }
 public void TearDown() {
     this.engine.Dispose();
     this.engine = null;
 }
 public DbReezeUnitOfWork(IUnitOfWorkDefaultOptions defaultOptions, DBreezeEngine dBreezeEngine) : base(defaultOptions)
 {
     this.dBreezeEngine = dBreezeEngine;
 }
示例#32
0
 public DocuExamples(string dbreezeFolder)
 {
     engine = new DBreezeEngine(dbreezeFolder);
 }
示例#33
0
        public TransactionsJournal(DBreezeEngine DBreezeEngine)
        {
            Engine = DBreezeEngine;

            this.Init();
        }
示例#34
0
文件: Scheme.cs 项目: lanicon/DBreeze
        public Scheme(DBreezeEngine DBreezeEngine)
        {
            Engine = DBreezeEngine;

            this.OpenSchema();
        }
示例#35
0
        /// <summary>
        /// With backup
        /// </summary>
        public void StartTest()
        {
            lock (lockInitDb)
            {
                if (engine == null)
                {

                    DBreezeConfiguration conf = new DBreezeConfiguration()
                    {
                        DBreezeDataFolderName = @"D:\temp\DBreezeTest\DBR1",
                        // DBreezeDataFolderName = @"E:\temp\DBreezeTest\DBR1",
                        // DBreezeDataFolderName = @"C:\tmp",
                        Storage = DBreezeConfiguration.eStorage.DISK,
                        // Storage = DBreezeConfiguration.eStorage.MEMORY,
                        //Backup = new Backup()
                        //{
                        //    BackupFolderName = @"D:\temp\DBreezeTest\DBR1\Bup",
                        //    IncrementalBackupFileIntervalMin = 30
                        //}
                    };

                    //conf.AlternativeTablesLocations.Add("t11",@"D:\temp\DBreezeTest\DBR1\INT");
                    //conf.AlternativeTablesLocations.Add("mem_*", String.Empty);
                    //conf.AlternativeTablesLocations.Add("t2", @"D:\temp\DBreezeTest\DBR1\INT");
                    //conf.AlternativeTablesLocations.Add("t*", @"D:\temp\DBreezeTest\DBR1\INT");

                    engine = new DBreezeEngine(conf);

                }
            }

            //  enumtest();

            //MATRIX_BUILD();
            // MATRIX_READOUT_V2();

            // TestSecondaryIndexPreparation();
            //TestNewStorageLayer();

            // TestMemoryStorage();
            //TestClosestToPrefix();

            // testC6();
            //testC7();
            //testC8();
            //testC9();
            //testC10();

            //testF_004();
            // testF_003();
            //testF_009();

            // testF_010();

            // testF_001();
            //testC14();
            //testC15();
            //testC16();

            //TestKrome();
            //testF_002();

            //TestSFI1();
            //TestSFI2();

            //TestMixedStorageMode();

            //TestIterators();
            //TestIteratorsv11();

            //testbackwardwithStrings();

            //TestBackUp();
            //TestSelectBackwardStartWith_WRITE();
            //TestSelectBackwardStartWith_READ();

            //TR();

            //NetworkTest();
            //NetworkTestDisk();
            Test_valueIsUsed();
        }