Esempio n. 1
0
        private void WriteItem(BaseReference itemRef)
        {
            ItemHolder  item  = itemRef.Item;
            IStorable   item2 = item.Item;
            ReferenceID id    = itemRef.Id;
            long        num   = m_storage.Allocate(item2);

            if (id.HasMultiPart && !id.IsTemporary)
            {
                m_partitionManager.UpdateTreePartitionOffset(id, num);
                if (itemRef.PinCount == 0)
                {
                    CacheRemoveValue(id);
                }
            }
            else
            {
                id              = new ReferenceID(num);
                id.IsTemporary  = false;
                id.HasMultiPart = false;
                itemRef.Id      = id;
            }
            if (itemRef.PinCount == 0)
            {
                item.Item      = null;
                item.Reference = null;
                itemRef.Item   = null;
            }
        }
        public void Deserialize(IntermediateFormatReader reader)
        {
            reader.RegisterDeclaration(m_declaration);
            long num = 0L;

            while (reader.NextMember())
            {
                if (reader.CurrentMember.MemberName == MemberName.ID)
                {
                    num = reader.ReadInt64();
                }
                else
                {
                    Global.Tracer.Assert(condition: false);
                }
            }
            BaseScalabilityCache baseScalabilityCache = reader.PersistenceHelper as BaseScalabilityCache;
            ScalabilityCacheType cacheType            = baseScalabilityCache.CacheType;

            if (num < 0 && cacheType != ScalabilityCacheType.GroupTree && cacheType != ScalabilityCacheType.Lookup)
            {
                PairObj <ReferenceID, BaseScalabilityCache> pairObj = (PairObj <ReferenceID, BaseScalabilityCache>)baseScalabilityCache.FetchStaticReference((int)num);
                m_id = pairObj.First;
                baseScalabilityCache = pairObj.Second;
            }
            else
            {
                m_id = new ReferenceID(num);
            }
            SetScalabilityCache(baseScalabilityCache);
        }
        internal override void Free(BaseReference reference)
        {
            if (reference == null)
            {
                return;
            }
            ReferenceID id = reference.Id;

            if (CacheTryGetValue(id, out StorageItem item))
            {
                CacheRemoveValue(id);
            }
            if (item == null)
            {
                item = (StorageItem)reference.Item;
            }
            if (item != null)
            {
                if (item.InQueue == InQueueState.InQueue)
                {
                    m_cachePriority.Remove(item);
                }
                int num = ItemSizes.SizeOf(item);
                m_cacheSizeBytes    -= num;
                m_totalAuditedBytes -= num;
                m_totalFreedBytes   += num;
                UpdatePeakCacheSize();
                item.Item = null;
                item.UnlinkReferences(updateId: false);
            }
            reference.Item = null;
        }
        public void Deserialize(IntermediateFormatReader reader)
        {
            reader.RegisterDeclaration(m_declaration);
            while (reader.NextMember())
            {
                switch (reader.CurrentMember.MemberName)
                {
                case MemberName.Item:
                    Item = (IStorable)reader.ReadRIFObject();
                    break;

                case MemberName.Priority:
                    Priority = reader.ReadInt32();
                    break;

                case MemberName.ID:
                    Id = new ReferenceID(reader.ReadInt64());
                    break;

                default:
                    Global.Tracer.Assert(condition: false);
                    break;
                }
            }
        }
Esempio n. 5
0
 internal void CacheSetValue(ReferenceID id, BaseReference value)
 {
     if (m_cacheLookup == null)
     {
         m_cacheLookup = new SegmentedDictionary <ReferenceID, BaseReference>(503, 17, ReferenceIDEqualityComparer.Instance);
     }
     m_cacheLookup[id] = value;
 }
 public StorageItem(ReferenceID id, int priority, IStorable item, int initialSize)
 {
     Priority      = priority;
     Item          = item;
     Offset        = -1L;
     Id            = id;
     PersistedSize = -1L;
     m_size        = CalculateSize(initialSize);
 }
Esempio n. 7
0
        internal bool CacheRemoveValue(ReferenceID id)
        {
            bool result = false;

            if (m_cacheLookup != null)
            {
                result = m_cacheLookup.Remove(id);
            }
            return(result);
        }
Esempio n. 8
0
        internal bool CacheTryGetValue(ReferenceID id, out BaseReference item)
        {
            item = null;
            bool result = false;

            if (m_cacheLookup != null)
            {
                result = m_cacheLookup.TryGetValue(id, out item);
            }
            return(result);
        }
        internal override void ReferenceSerializeCallback(BaseReference reference)
        {
            ReferenceID id = reference.Id;

            if (id.IsTemporary)
            {
                StorageItem storageItem = (StorageItem)reference.Item;
                ReferenceID referenceID = m_offsetMap.GenerateId(id);
                if (id != referenceID)
                {
                    reference.Id   = referenceID;
                    storageItem.Id = referenceID;
                    CacheRemoveValue(id);
                }
                CacheSetValue(reference.Id, storageItem);
            }
        }
Esempio n. 10
0
        public ReferenceID GenerateId(ReferenceID tempId)
        {
            ReferenceID result = tempId;

            if (tempId.IsTemporary)
            {
                if (m_nextIdPageSlot >= m_slotsPerPage)
                {
                    m_nextIdPageSlot = 0L;
                    m_nextIdPageNum++;
                }
                long nextIdPageSlot = m_nextIdPageSlot;
                nextIdPageSlot |= m_nextIdPageNum << m_idShift;
                result          = new ReferenceID(nextIdPageSlot);
                m_nextIdPageSlot++;
            }
            return(result);
        }
Esempio n. 11
0
        private void EnqueueItem(BaseReference itemRef)
        {
            Microsoft.ReportingServices.ReportIntermediateFormat.Persistence.ObjectType objectType = itemRef.GetObjectType();
            if (objectType == Microsoft.ReportingServices.ReportIntermediateFormat.Persistence.ObjectType.SubReportInstanceReference)
            {
                if (m_pinnedItems == null)
                {
                    m_pinnedItems = new LinkedBucketedQueue <BaseReference>(25);
                }
                m_pinnedItems.Enqueue(itemRef);
                return;
            }
            ReferenceID id = itemRef.Id;

            if (!id.IsTemporary && (!id.HasMultiPart || m_partitionManager.GetTreePartitionOffset(id) != TreePartitionManager.EmptyTreePartitionOffset))
            {
                m_cachePriority.Add(itemRef.Item);
                itemRef.InQueue = InQueueState.Exempt;
            }
        }
Esempio n. 12
0
        private IStorable LoadItem(BaseReference reference)
        {
            if (m_inStreamOper)
            {
                Global.Tracer.Assert(condition: false, "PartitionedTreeScalabilityCache should not Load during serialization");
            }
            IStorable storable = null;

            try
            {
                m_inStreamOper = true;
                m_deserializationTimer.Start();
                ReferenceID id = reference.Id;
                long        num;
                if (!id.IsTemporary && id.HasMultiPart)
                {
                    num = m_partitionManager.GetTreePartitionOffset(id);
                    if (num < 0)
                    {
                        return(null);
                    }
                }
                else
                {
                    num = reference.Id.Value;
                }
                if (num < 0)
                {
                    Global.Tracer.Assert(false, "Invalid offset for item.  ReferenceID: {0}, Offset: {1}", id, num);
                }
                storable = (IStorable)m_storage.Retrieve(num, out long _);
            }
            finally
            {
                m_inStreamOper = false;
                m_deserializationTimer.Stop();
            }
            CacheItem(reference, storable, fromDeserialize: true, ItemSizes.SizeOf(storable));
            return(storable);
        }
Esempio n. 13
0
        internal sealed override IStorable Retrieve(BaseReference reference)
        {
            if (reference.Item == null)
            {
                ReferenceID id = reference.Id;
                if (CacheTryGetValue(id, out BaseReference item) && item.Item != null)
                {
                    IStorable item2 = item.Item.Item;
                    CacheItem(reference, item2, fromDeserialize: true, ItemSizes.SizeOf(item2));
                }
                else
                {
                    LoadItem(reference);
                }
            }
            IStorable result = null;

            if (reference.Item != null)
            {
                result = reference.Item.Item;
            }
            return(result);
        }
Esempio n. 14
0
        public void Flush(IStorage storage, IIndexStrategy indexStrategy)
        {
            bool isTemporary = Id.IsTemporary;

            if (isTemporary)
            {
                Id = indexStrategy.GenerateId(Id);
            }
            UnlinkReferences(isTemporary);
            if (Offset >= 0)
            {
                long num = storage.Update(this, Offset, PersistedSize);
                if (num != Offset)
                {
                    Offset = num;
                    indexStrategy.Update(Id, Offset);
                }
            }
            else
            {
                Offset = storage.Allocate(this);
                indexStrategy.Update(Id, Offset);
            }
        }
 internal void Init(BaseScalabilityCache storageManager, ReferenceID id)
 {
     SetScalabilityCache(storageManager);
     m_id = id;
 }
Esempio n. 16
0
        public long Retrieve(ReferenceID id)
        {
            IndexTablePage page = GetPage(id.Value);

            return(ReadValue(id.Value, page));
        }
Esempio n. 17
0
        public void Update(ReferenceID id, long value)
        {
            IndexTablePage page = GetPage(id.Value);

            WriteValue(id.Value, page, value);
        }