Exemple #1
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 DBriize.Objects.DBriizeObject <TVal> ObjectGet <TVal>()
        {
            var ret = new Objects.DBriizeObject <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);
        }
Exemple #2
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);
            }
        }
Exemple #3
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)));
        }