public virtual int PrefetchObjects(ClientObjectContainer container, Transaction trans
			, IIntIterator4 ids, object[] prefetched, int prefetchCount)
		{
			int count = 0;
			IList idsToGet = new ArrayList();
			while (count < prefetchCount)
			{
				if (!ids.MoveNext())
				{
					break;
				}
				int id = ids.CurrentInt();
				if (id > 0)
				{
					object obj = trans.ObjectForIdFromCache(id);
					if (obj != null)
					{
						prefetched[count] = obj;
					}
					else
					{
						idsToGet.Add(Pair.Of(id, count));
					}
					count++;
				}
			}
			if (idsToGet.Count > 0)
			{
				ByteArrayBuffer[] buffers = container.ReadObjectSlots(trans, IdArrayFor(idsToGet)
					);
				for (int i = 0; i < buffers.Length; i++)
				{
					Pair pair = ((Pair)idsToGet[i]);
					int id = (((int)pair.first));
					int position = (((int)pair.second));
					object obj = trans.ObjectForIdFromCache(id);
					if (obj != null)
					{
						prefetched[position] = obj;
					}
					else
					{
						prefetched[position] = new ObjectReference(id).ReadPrefetch(trans, buffers[i], Const4
							.AddToIdTree);
					}
				}
			}
			return count;
		}
示例#2
0
		public object GetActivatedObjectFromCache(Transaction ta, int id)
		{
			object obj = ta.ObjectForIdFromCache(id);
			if (obj == null)
			{
				return null;
			}
			Activate(ta, obj);
			return obj;
		}
示例#3
0
		public virtual bool IsCached(Transaction trans, long id)
		{
			lock (_lock)
			{
				trans = CheckTransaction(trans);
				return trans.ObjectForIdFromCache((int)id) != null;
			}
		}
示例#4
0
		public virtual object GetByID2(Transaction ta, int id)
		{
			object obj = ta.ObjectForIdFromCache(id);
			if (obj != null)
			{
				// Take care about handling the returned candidate reference.
				// If you loose the reference, weak reference management might
				// also.
				return obj;
			}
			return new ObjectReference(id).Read(ta, new LegacyActivationDepth(0), Const4.AddToIdTree
				, true);
		}