Example #1
0
 public BTree(Transaction trans, BTreeConfiguration config, int id, IIndexable4 keyHandler
              , int treeNodeSize) : base(config._idSystem)
 {
     _config = config;
     if (null == keyHandler)
     {
         throw new ArgumentNullException();
     }
     _nodeSize     = treeNodeSize;
     _nodeCache    = CacheFactory.NewLRUIntCache(config._cacheSize);
     _halfNodeSize = _nodeSize / 2;
     _nodeSize     = _halfNodeSize * 2;
     _keyHandler   = keyHandler;
     SetID(id);
     if (IsNew())
     {
         SetStateDirty();
         _root = new BTreeNode(this, 0, true, 0, 0, 0);
         _root.Write(trans.SystemTransaction());
         AddNode(_root);
         Write(trans.SystemTransaction());
     }
     else
     {
         SetStateDeactivated();
     }
 }
Example #2
0
		public BTree(Transaction trans, BTreeConfiguration config, int id, IIndexable4 keyHandler
			, int treeNodeSize) : base(config._idSystem)
		{
			_config = config;
			if (null == keyHandler)
			{
				throw new ArgumentNullException();
			}
			_nodeSize = treeNodeSize;
			_nodeCache = CacheFactory.NewLRUIntCache(config._cacheSize);
			_halfNodeSize = _nodeSize / 2;
			_nodeSize = _halfNodeSize * 2;
			_keyHandler = keyHandler;
			SetID(id);
			if (IsNew())
			{
				SetStateDirty();
				_root = new BTreeNode(this, 0, true, 0, 0, 0);
				_root.Write(trans.SystemTransaction());
				AddNode(_root);
				Write(trans.SystemTransaction());
			}
			else
			{
				SetStateDeactivated();
			}
		}
        protected BTree NewBTree(Transaction systemTrans, int id)
        {
            ObjectContainerBase stream       = systemTrans.Container();
            IIndexable4         indexHandler = IndexHandler(stream);

            if (indexHandler == null)
            {
                return(null);
            }
            return(new BTree(systemTrans, id, new FieldIndexKeyHandler(indexHandler)));
        }
Example #4
0
        private BTreePointer FirstBTreePointer()
        {
            // We don't want nulls included so we have to search for null and use the resulting pointer if we find one.
            IIndexable4 keyHandler = Btree().KeyHandler();

            if (keyHandler is ICanExcludeNullInQueries)
            {
                ICanExcludeNullInQueries canExcludeNullInQueries = (ICanExcludeNullInQueries)keyHandler;
                if (canExcludeNullInQueries.ExcludeNull())
                {
                    BTreeNodeSearchResult searchLeaf = Btree().SearchLeafByObject(Transaction(), null
                                                                                  , SearchTarget.Highest);
                    BTreePointer pointer = searchLeaf.FirstValidPointer();
                    if (pointer != null)
                    {
                        return(pointer);
                    }
                }
            }
            return(Btree().FirstPointer(Transaction()));
        }
Example #5
0
        public static void DefragIndex(DefragmentContextImpl context, IIndexable4 keyHandler
                                       )
        {
            // count
            int count = context.ReadInt();
            // leafByte
            byte leafByte = context.ReadByte();
            bool isLeaf   = (leafByte == 1);

            context.CopyID();
            // parent ID
            context.CopyID();
            // previous ID
            context.CopyID();
            // next ID
            for (int i = 0; i < count; i++)
            {
                keyHandler.DefragIndexEntry(context);
                if (!isLeaf)
                {
                    context.CopyID();
                }
            }
        }
		public FieldIndexKeyHandler(IIndexable4 delegate_)
		{
			_parentIdHandler = new IDHandler();
			_valueHandler = delegate_;
		}
Example #7
0
 public FieldIndexKeyHandler(IIndexable4 delegate_)
 {
     _parentIdHandler = new IDHandler();
     _valueHandler    = delegate_;
 }
Example #8
0
		public BTree(Transaction trans, int id, IIndexable4 keyHandler, int nodeSize) : this
			(trans, BTreeConfiguration.Default, id, keyHandler, nodeSize)
		{
		}
Example #9
0
		public BTree(Transaction trans, BTreeConfiguration config, int id, IIndexable4 keyHandler
			) : this(trans, config, id, keyHandler, Config(trans).BTreeNodeSize())
		{
		}
Example #10
0
		public BTree(Transaction trans, BTreeConfiguration config, IIndexable4 keyHandler
			) : this(trans, config, 0, keyHandler)
		{
		}
Example #11
0
		public static void DefragIndex(DefragmentContextImpl context, IIndexable4 keyHandler
			)
		{
			// count
			int count = context.ReadInt();
			// leafByte
			byte leafByte = context.ReadByte();
			bool isLeaf = (leafByte == 1);
			context.CopyID();
			// parent ID
			context.CopyID();
			// previous ID
			context.CopyID();
			// next ID
			for (int i = 0; i < count; i++)
			{
				keyHandler.DefragIndexEntry(context);
				if (!isLeaf)
				{
					context.CopyID();
				}
			}
		}
Example #12
0
 /// <exception cref="System.Exception"></exception>
 protected override void Db4oSetupBeforeStore()
 {
     _handler = new DoubleHandler();
 }
Example #13
0
		/// <exception cref="System.Exception"></exception>
		protected override void Db4oSetupBeforeStore()
		{
			_handler = new DoubleHandler();
		}
Example #14
0
 public BTree(Transaction trans, BTreeConfiguration config, IIndexable4 keyHandler
              ) : this(trans, config, 0, keyHandler)
 {
 }
Example #15
0
 public BTree(Transaction trans, int id, IIndexable4 keyHandler, int nodeSize) : this
     (trans, BTreeConfiguration.Default, id, keyHandler, nodeSize)
 {
 }
Example #16
0
 public BTree(Transaction trans, BTreeConfiguration config, int id, IIndexable4 keyHandler
              ) : this(trans, config, id, keyHandler, Config(trans).BTreeNodeSize())
 {
 }