/// <summary>
        /// Read all colleciton, indexes and documents inside current datafile
        /// Drop per index, per collection and shrink
        /// This steps will check/validate all file data
        /// </summary>
        private void CheckIntegrity()
        {
            using (var db = new LiteEngine(this.Filename))
            {
                var cols = db.GetCollectionNames().ToArray();

                foreach (var col in cols)
                {
                    var indexes = db.GetIndexes(col).ToArray();

                    foreach (var idx in indexes)
                    {
                        var q = db.Find(col, Query.All(idx.Field));

                        foreach (var doc in q)
                        {
                            // document are ok!
                        }

                        // lets drop this index (if not _id)
                        if (idx.Field != "_id")
                        {
                            db.DropIndex(col, idx.Field);
                        }
                    }

                    // and drop collection
                    db.DropCollection(col);
                }

                // and now shrink
                db.Shrink();
            }
        }
Exemplo n.º 2
0
        public void DropCollection_Test()
        {
            using (var file = new TempFile())
            using (var db = new LiteEngine(file.Filename))
            {
                Assert.IsFalse(db.GetCollectionNames().Any(x => x == "col"));

                db.Insert("col", new BsonDocument { { "a", 1 } });
                Assert.IsTrue(db.GetCollectionNames().Any(x => x == "col"));

                db.DropCollection("col");

                Assert.IsFalse(db.GetCollectionNames().Any(x => x == "col"));
            }
        }
Exemplo n.º 3
0
        public void DropCollection()
        {
            using (var file = new TempFile())
                using (var db = new LiteEngine(file.Filename))
                {
                    Assert.IsFalse(db.GetCollectionNames().Any(x => x == "col"));

                    db.Insert("col", new BsonDocument {
                        { "a", 1 }
                    });
                    Assert.IsTrue(db.GetCollectionNames().Any(x => x == "col"));

                    db.DropCollection("col");

                    Assert.IsFalse(db.GetCollectionNames().Any(x => x == "col"));
                }
        }
Exemplo n.º 4
0
        public void Shrink_After_DropCollection()
        {
            using (var file = new TempFile())
                using (var db = new LiteEngine(file.Filename))
                {
                    db.InsertBulk("col", GetDocs(1, 10000));

                    db.DropCollection("col");

                    // full disk usage
                    var size = file.Size;

                    var r = db.Shrink();

                    // only header page + reserved lock page
                    Assert.AreEqual(8192, size - r);
                }
        }
Exemplo n.º 5
0
 public void Drop()
 {
     _db.DropCollection("col_bulk");
 }
Exemplo n.º 6
0
        public IEnumerable <BsonValue> Execute(StringScanner s, LiteEngine engine)
        {
            var col = this.ReadCollection(engine, s);

            yield return(engine.DropCollection(col));
        }
Exemplo n.º 7
0
        public void Execute(LiteEngine engine, StringScanner s, Display display, InputCommand input, Env env)
        {
            var col = this.ReadCollection(engine, s);

            display.WriteResult(engine.DropCollection(col));
        }
Exemplo n.º 8
0
Arquivo: Drop.cs Projeto: apkd/LiteDB
        public void Execute(LiteEngine engine, StringScanner s, Display display, InputCommand input, Env env)
        {
            var col = this.ReadCollection(engine, s);

            display.WriteResult(engine.DropCollection(col));
        }