public virtual void Initialize() { #region Main Tree Initialization var treeOptions = new BPlusTree <AttributeValue, long> .OptionsV2(AttributeValueSerializer.Global, new PrimitiveSerializer()); if (_configuration.JournalEnabled) { var transactionLogOptions = new TransactionLogOptions <AttributeValue, long>(_path + ".tlog", new AttributeValueSerializer(), new PrimitiveSerializer()); transactionLogOptions.FileOptions = FileOptions.WriteThrough; transactionLogOptions.FileBuffer = 4096; treeOptions.TransactionLog = new TransactionLog <AttributeValue, long>(transactionLogOptions); treeOptions.TransactionLogFileName = transactionLogOptions.FileName; treeOptions.StoragePerformance = StoragePerformance.LogFileNoCache; } else { treeOptions.StoragePerformance = StoragePerformance.LogFileInCache; } if (_configuration.CachePolicy != null) { switch (_configuration.CachePolicy.ToLower()) { case "all": treeOptions.CachePolicy = CachePolicy.All; break; case "none": treeOptions.CachePolicy = CachePolicy.None; break; default: treeOptions.CachePolicy = CachePolicy.Recent; break; } } else { treeOptions.CachePolicy = CachePolicy.Recent; } treeOptions.FileName = _path; treeOptions.StorageType = StorageType.Disk; treeOptions.CreateFile = CreatePolicy.IfNeeded; treeOptions.BTreeOrder = 64; treeOptions.LockingFactory = new IgnoreLockFactory(); treeOptions.CallLevelLock = new IgnoreLocking(); treeOptions.StoragePerformance = StoragePerformance.Default; try { _tree = new BPlusTree <AttributeValue, long>(treeOptions); _tree.EnableCount(); if (LoggerManager.Instance.IndexLogger != null && LoggerManager.Instance.IndexLogger.IsInfoEnabled) { LoggerManager.Instance.IndexLogger.Info("BPlusIndex", "Index (s) " + _indexKey.ToString() + " defined"); } } catch (Exception ex) { if (LoggerManager.Instance.IndexLogger != null) { LoggerManager.Instance.IndexLogger.Error("BPlusIndex", "Error: " + ErrorCodes.Indexes.TREE_INITIALIZATION_FAILURE + " - Failed to initialize Index for attribute(s) " + _indexKey.ToString() + Environment.NewLine + ex.ToString()); throw new IndexException(ErrorCodes.Indexes.TREE_INITIALIZATION_FAILURE); } } #endregion #region Transitory Tree Initialization var _transitoryTreeOps = new BPlusTree <AttributeValue, IndexOp <long> > .Options(AttributeValueSerializer.Global, IndexOpSerializer <long> .Global); _transitoryTreeOps.StorageType = StorageType.Memory; _transitoryTreeOps.LockingFactory = new LockFactory <ReaderWriterLocking>(); _transitoryTreeOps.CallLevelLock = new ReaderWriterLocking(); _transitionTree = new BPlusTree <AttributeValue, IndexOp <long> >(_transitoryTreeOps); opsToCommit = new ConcurrentDictionary <long, IList <IndexOp <long> > >(); appliedOps = new ClusteredList <long>(); #endregion _bounds = new BoundingBox(1); try { RestoreBoundsFromTree(); } catch (Exception ex) { if (LoggerManager.Instance.IndexLogger != null) { LoggerManager.Instance.IndexLogger.Error("BPlusIndex", "Error: " + ErrorCodes.Indexes.NUMERIC_BOUNDS_CALCULATION_FAILURE + " - Failed to calculate numeric bounds of Index for attribute(s) " + _indexKey.ToString() + Environment.NewLine + ex); throw new IndexException(ErrorCodes.Indexes.NUMERIC_BOUNDS_CALCULATION_FAILURE); } } }
public static string Dump(this IndexKey value) { return(string.Format("{0}{1}{0}", value.Type == IndexDataType.String ? "'" : "", value.ToString())); }