示例#1
0
        //internal bool IfWriteThread()
        //{
        //    return (_masterTrie.NestedTablesCoordinator.ModificationThreadId == System.Threading.Thread.CurrentThread.ManagedThreadId);
        //}


        internal NestedTable GetTable <TKey>(TKey key, uint tableIndex, bool insertIsAllowed)
        {
            byte[]   btKey = DataTypesConvertor.ConvertKey <TKey>(key);
            LTrieRow row   = null;

            if (insertIsAllowed)        //Insert of table is allowed by calls generation
            {
                row = table.GetKey(ref btKey, null);
                return(table.GetTable(row, ref btKey, tableIndex, this._masterTrie, true, false));
            }

            //Only selects are allowed

            if (_masterTrie.NestedTablesCoordinator.ModificationThreadId == System.Threading.Thread.CurrentThread.ManagedThreadId)
            {
                //This thread must NOT use cache
                row = table.GetKey(ref btKey, null);
                return(table.GetTable(row, ref btKey, tableIndex, this._masterTrie, false, false));
            }
            else
            {
                LTrieRootNode readRootNode = new LTrieRootNode(table);
                row = table.GetKey(ref btKey, readRootNode);

                return(table.GetTable(row, ref btKey, tableIndex, this._masterTrie, false, true));
            }
        }
示例#2
0
        /// <summary>
        /// Concept of the objects storage (read docu from 20170321)
        /// Get object from a datablock with a fixed address,
        /// having that the pointer to the object (16 byte) is saved from the startIndex inside of a row's value.
        /// Returns null if object is not found.
        /// </summary>
        /// <typeparam name="TVal"></typeparam>
        /// <returns></returns>
        public DBreeze.Objects.DBreezeObject <TVal> ObjectGet <TVal>()
        {
            var ret = new Objects.DBreezeObject <TVal>();

            byte[] dataBlockId = null;
            int    startIndex  = 0;

            if (_exists)
            {
                if (_row.ValueIsReadOut)
                {
                    if (_row.Value == null)
                    {
                        return(null);
                    }

                    dataBlockId = _row.Value.Substring(startIndex, 16);
                }
                else
                {
                    long valueStartPointer = 0;
                    uint valueFullLength   = 0;
                    dataBlockId = this._row.Root.Tree.Cache.ReadValuePartially(this._row.LinkToValue, (uint)startIndex, 16, this._useCache, out valueStartPointer, out valueFullLength);
                }
            }
            else
            {
                return(null);
            }

            if (dataBlockId == null)
            {
                return(null);
            }

            ret.ptrToExisingEntity = dataBlockId;
            dataBlockId            = this._row.Root.Tree.Cache.ReadDynamicDataBlock(ref dataBlockId, this._useCache);
            Dictionary <uint, byte[]> d = new Dictionary <uint, byte[]>();

            ret.ExisingEntity = this._row.Root.Tree.Cache.ReadDynamicDataBlock(ref dataBlockId, this._useCache);
            Biser.Decode_DICT_PROTO_UINT_BYTEARRAY(ret.ExisingEntity, d);
            if (d == null || d.Count < 1)
            {
                return(null);
            }
            ret.Entity = DataTypesConvertor.ConvertBack <TVal>(d[0]);
            return(ret);
        }
示例#3
0
        //byte[] btKey = null;

        public Row(LTrieRow row, LTrie masterTrie, bool useCache)
        {
            if (row == null)
            {
                _exists = false;
            }
            else
            {
                _row = row;
                //_root = row._root;
                //_ptrToValue = row.LinkToValue;
                _exists = row.Exists;
            }
            _useCache   = useCache;
            _masterTrie = masterTrie;

            if (_exists)
            {
                _key = DataTypesConvertor.ConvertBack <TKey>(row.Key);
            }
        }
示例#4
0
        /// <summary>
        /// Returns datablock which fixed address, which identifier is stored in this row from specified index.
        /// </summary>
        /// <typeparam name="TVal"></typeparam>
        /// <param name="startIndex"></param>
        /// <returns></returns>
        public TVal GetDataBlockWithFixedAddress <TVal>(uint startIndex = 0)
        {
            byte[] dataBlockId = null;

            if (_exists)
            {
                if (_row.ValueIsReadOut)
                {
                    if (_row.Value == null)
                    {
                        return(default(TVal));
                    }

                    dataBlockId = _row.Value.Substring((int)startIndex, 16);

                    //dataBlockId=this._row.Root.Tree.Cache.ReadDynamicDataBlock(ref dataBlockId, this._useCache);
                    //return DataTypesConvertor.ConvertBack<TValue>(this._row.Root.Tree.Cache.ReadDynamicDataBlock(ref dataBlockId, this._useCache));

                    //return this._row.Root.Tree.Cache.ReadDynamicDataBlock(ref dataBlockId, this._useCache);
                }

                long valueStartPointer = 0;
                uint valueFullLength   = 0;
                dataBlockId = this._row.Root.Tree.Cache.ReadValuePartially(this._row.LinkToValue, startIndex, 16, this._useCache, out valueStartPointer, out valueFullLength);
                //return this._row.Root.Tree.Cache.ReadDynamicDataBlock(ref dataBlockId, this._useCache);

                //dataBlockId = this._row.Root.Tree.Cache.ReadDynamicDataBlock(ref dataBlockId, this._useCache);
                //return DataTypesConvertor.ConvertBack<TValue>(this._row.Root.Tree.Cache.ReadDynamicDataBlock(ref dataBlockId, this._useCache));
            }

            if (dataBlockId == null)
            {
                return(default(TVal));
            }

            dataBlockId = this._row.Root.Tree.Cache.ReadDynamicDataBlock(ref dataBlockId, this._useCache);
            return(DataTypesConvertor.ConvertBack <TVal>(this._row.Root.Tree.Cache.ReadDynamicDataBlock(ref dataBlockId, this._useCache)));
        }