Esempio n. 1
0
        public override void Execute()
        {
            var popts = new PlaneDBOptions().DisableJournal();

            if (!string.IsNullOrEmpty(Owner.Passphrase))
            {
                popts = popts.EnableEncryption(Owner.Passphrase);
            }
            else if (Owner.Compressed)
            {
                popts = popts.EnableCompression();
            }

            if (!string.IsNullOrEmpty(Owner.Tablespace))
            {
                popts = popts.UsingTableSpace(Owner.Tablespace);
            }

            if (From == null)
            {
                throw new GetOptException("No from");
            }

            if (To == null)
            {
                throw new GetOptException("No to");
            }

            using var rocks           = RocksDb.OpenReadOnly(new DbOptions(), From.FullName, false);
            using var plane           = new PlaneDB(To, FileMode.OpenOrCreate, popts);
            plane.OnFlushMemoryTable += (_, __) => Console.WriteLine("Flushed memory table");
            plane.OnMergedTables     += (_, __) => Console.WriteLine("Merged tables");
            plane.Clear();

            var iter = rocks.NewIterator();

            plane.MassInsert(() => CopyFromRocks(plane, iter));

            Console.WriteLine($"{copyCount:N0} entries copied in total");
        }
Esempio n. 2
0
        public override void Execute()
        {
            var popts = new PlaneDBOptions().DisableJournal().WithBlockCacheCapacity(2_048);

            if (!string.IsNullOrEmpty(Owner.Passphrase))
            {
                popts = popts.EnableEncryption(Owner.Passphrase);
            }
            else if (Owner.Compressed)
            {
                popts = popts.EnableCompression();
            }

            if (DB == null || DB.Length != 1)
            {
                throw new GetOptException("No database specified");
            }

            var db = DB[0];

            if (!string.IsNullOrEmpty(Owner.Tablespace))
            {
                InfoOne(db, popts.UsingTableSpace(Owner.Tablespace));
            }
            else if (AllTablespaces)
            {
                foreach (var tableSpace in Options.GetTableSpaces(db))
                {
                    InfoOne(db, popts.UsingTableSpace(tableSpace));
                }
            }
            else
            {
                InfoOne(db, popts);
            }
        }