示例#1
0
        /// <summary>
        ///  Find key (long)
        /// </summary>
        /// <param name="key"></param>
        /// <param name="op">0 - equal; -1 - nearest left (less than); 1 - nearest right (more than) </param>
        /// <returns>Value</returns>
        public BTResult Find(long key, int op)
        {
            int      i   = find(VSLib.ConvertLongToByteReverse(key), op);
            BTResult ret = new BTResult();

            ret.Key   = (i < 0) ? -1 : VSLib.ConvertByteToLongReverse(BTree[i].Key);
            ret.Value = (i < 0) ? -1 : BTree[i].Value[0];

            return(ret);
        }
示例#2
0
        /// <summary>
        ///  Find all keys (non-unique), long
        /// </summary>
        /// <param name="key"></param>
        /// <param name="op">0 - equal; -1 - nearest left (less than); 1 - nearest right (more than) </param>
        /// <returns></returns>
        public BTResultList FindAll(long key, int op)
        {
            int i = find(VSLib.ConvertLongToByteReverse(key), op);

            BTResultList ret = new BTResultList();

            ret.Key   = (i < 0) ? -1 : VSLib.ConvertByteToLongReverse(BTree[i].Key);
            ret.Value = (i < 0) ? new long[0] : BTree[i].Value.ToArray();

            return(ret);
        }
示例#3
0
        /// <summary>
        /// Delete index (byte key)
        /// </summary>
        /// <param name="key"></param>
        /// <param name="id">For non-unique index. 0 - delete a </param>
        /// <returns></returns>
        public bool Delete(byte[] key, long id)
        {
            if (this.index_name == DEFS.INDEX_CROSS_REFERENCES)
            {
                throw new VSException(DEFS.E0055_INDEX_INVALID_OP_CODE, " - 'Delete' for '" + DEFS.INDEX_CROSS_REFERENCES + "'");
            }

            long av_id = this.delete_node(key, id);

            if (av_id > 0)
            {
                byte[] obj_key = VSLib.ConvertLongToByteReverse(id);
                XRefs.delete_node(obj_key, av_id);
                return(true);
            }
            return(false);
        }
示例#4
0
文件: VSpace.cs 项目: ivvinokurov/VSX
        /// <summary>
        /// Remove all related indexes for object by ID
        /// ONLY for objects and indexes located in THIS space
        /// </summary>
        /// <param name="a"></param>
        private void remove_all_indexes(string space_name, long id)
        {
            VSIndex ref_index = this.get_index(DEFS.PrepareFullIndexName(space_name, DEFS.INDEX_CROSS_REFERENCES));

            if (ref_index != null)
            {
                byte[] key = VSLib.ConvertLongToByteReverse(id);

                long[] ref_nodes = ref_index.FindAll(key, false);         // Get all avl node ids for obj id

                ref_index.delete_node(key, -1);                           // Remove reference record

                for (int i = 0; i < ref_nodes.Length; i++)
                {
                    this.get_index(this.GetAllocation(ref_nodes[i]).ReadLong(VSAvlNode.INDEX_POS)).delete_avl_node(ref_nodes[i], id);
                }
            }
        }
示例#5
0
        /// <summary>
        /// Reset by key
        /// </summary>
        /// <param name="key"></param>
        public void Reset(long key, bool partial = false)
        {
            _current = -1;

            if (ROOT >= 0)
            {
                int id = find(VSLib.ConvertLongToByteReverse(key), (partial? 1 : 0));
                if (id >= 0)
                {
                    _action  = Action.Current;
                    _current = _right = id;
                }
                else
                {
                    _action = Action.End;
                }
            }
            else
            {
                _action = Action.End;
            }
        }
示例#6
0
 /// <summary>
 /// Add key (long)
 /// </summary>
 /// <param name="Value"></param>
 /// <returns></returns>
 public bool Insert(long key, long value)
 {
     return(this.insert(VSLib.ConvertLongToByteReverse(key), value));
 }
示例#7
0
 /// <summary>
 /// Delete key (long)
 /// </summary>
 /// <param name="key"></param>
 /// <returns></returns>
 public bool Delete(long key, long value = -1)
 {
     return(this.delete(VSLib.ConvertLongToByteReverse(key), value));
 }