Beispiel #1
0
        public DBPartition(string fileName)
        {
            logger.Message("FileName: " + fileName);
            this.partitionName = Path.GetFileName(fileName);
            this.path          = Path.GetDirectoryName(fileName);

            if (!path.EndsWith("/"))
            {
                path += '/';
            }

            this._db = RocksDbStore.Instance(path);

            // Create partition if it doesn't exist already
            try
            {
                logger.Message("Getting partition: " + this.partitionName);
                this.partition = this._db.GetColumnFamily(partitionName);
            }
            catch
            {
                logger.Message("Partition not found, create it now: " + this.partitionName);

                // TODO different partitions might need different options...
                this.partition = this._db.CreateColumnFamily(new ColumnFamilyOptions(), partitionName);
            }
        }
Beispiel #2
0
        public DBPartition(Logger logger, string fileName)
        {
            this.partitionName = Path.GetFileName(fileName);
            this.path          = Path.GetDirectoryName(fileName);
            this.logger        = logger;

            if (string.IsNullOrEmpty(path))
            {
                throw new Exception("Rocksdb storage path was not configured properly");
            }

            if (!path.EndsWith("/"))
            {
                path += '/';
            }

            //logger.Message($"RocksDB partition path: {fileName}");

            this._db = RocksDbStore.Instance(logger, path);

            // Create partition if it doesn't exist already
            try
            {
                logger.Message("Getting partition: " + this.partitionName);
                this.partition = this._db.GetColumnFamily(partitionName);
            }
            catch
            {
                logger.Message("Partition not found, create it now: " + this.partitionName);
                var cf = new ColumnFamilyOptions();
                // TODO different partitions might need different options...
                this.partition = this._db.CreateColumnFamily(cf, partitionName);
            }
        }