Exemplo n.º 1
0
 //    	throw new IllegalStateException();
 public virtual void CollectIDs(QueryingReadContext readContext)
 {
     IInternalReadContext context = readContext;
     var payloadOffset = context.ReadInt();
     if (payloadOffset == 0)
     {
         return;
     }
     var savedOffSet = context.Offset();
     try
     {
         var typeHandler = ReadTypeHandler(context, payloadOffset);
         if (typeHandler == null)
         {
             return;
         }
         SeekSecondaryOffset(context, typeHandler);
         if (IsPlainObject(typeHandler))
         {
             readContext.Collector().AddId(readContext.ReadInt());
             return;
         }
         CollectIdContext collectIdContext = new _CollectIdContext_203(readContext, readContext
             .Transaction(), readContext.Collector(), null, readContext.Buffer());
         Handlers4.CollectIdsInternal(collectIdContext, context.Container().Handlers.CorrectHandlerVersion
             (typeHandler, context.HandlerVersion()), 0, false);
     }
     finally
     {
         context.Seek(savedOffSet);
     }
 }
Exemplo n.º 2
0
			public object Run()
			{
				QueryingReadContext queryingReadContext = new QueryingReadContext(context.Transaction
					(), context.HandlerVersion(), context.Buffer(), 0, context.Collector());
				((ICascadingTypeHandler)this._enclosing._typeHandler).CollectIDs(queryingReadContext
					);
				return null;
			}
		public virtual void CollectIDs(QueryingReadContext context)
		{
			ITypeHandler4 elementHandler = ReadElementTypeHandler(context, context);
			int elementCount = context.ReadInt();
			for (int i = 0; i < elementCount; i++)
			{
				context.ReadId(elementHandler);
			}
		}
Exemplo n.º 4
0
 public virtual void CollectIDs(QueryingReadContext context)
 {
     var handlers = ReadKeyValueTypeHandlers(context, context);
     var elementCount = context.ReadInt();
     for (var i = 0; i < elementCount; i++)
     {
         context.ReadId(handlers._keyHandler);
         context.SkipId(handlers._valueHandler);
     }
 }
Exemplo n.º 5
0
		public virtual ITypeHandler4 ReadCandidateHandler(QueryingReadContext context)
		{
			int payLoadOffSet = context.ReadInt();
			if (payLoadOffSet == 0)
			{
				return null;
			}
			context.Seek(payLoadOffSet);
			int classMetadataID = context.ReadInt();
			ClassMetadata classMetadata = context.Container().ClassMetadataForID(classMetadataID
				);
			if (classMetadata == null)
			{
				return null;
			}
			return classMetadata.ReadCandidateHandler(context);
		}
Exemplo n.º 6
0
		public override ITypeHandler4 ReadCandidateHandler(QueryingReadContext context)
		{
			int id = 0;
			int offset = context.Offset();
			try
			{
				id = context.ReadInt();
			}
			catch (Exception)
			{
			}
			context.Seek(offset);
			if (id != 0)
			{
				StatefulBuffer reader = context.Container().ReadStatefulBufferById(context.Transaction
					(), id);
				if (reader != null)
				{
					ObjectHeader oh = new ObjectHeader(context.Container(), reader);
					try
					{
						if (oh.ClassMetadata() != null)
						{
							context.Buffer(reader);
							return oh.ClassMetadata().SeekCandidateHandler(context);
						}
					}
					catch (Exception e)
					{
					}
				}
			}
			// TODO: Check Exception Types
			// Errors typically occur, if classes don't match
			return null;
		}
Exemplo n.º 7
0
 // TODO Auto-generated method stub
 public virtual ITypeHandler4 ReadCandidateHandler(QueryingReadContext context)
 {
     // TODO Auto-generated method stub
     return null;
 }
Exemplo n.º 8
0
 // TODO Auto-generated method stub
 public virtual void CollectIDs(QueryingReadContext context)
 {
 }
Exemplo n.º 9
0
 private object ReadFieldValue(int id, FieldMetadata field)
 {
     var buffer = BufferFor(id);
     var handlerVersion = field.ContainingClass().SeekToField(_transaction,
         buffer, field);
     if (handlerVersion == HandlerVersion.Invalid)
     {
         return null;
     }
     var context = new QueryingReadContext(_transaction, handlerVersion
         ._number, buffer, id);
     return field.Read(context);
 }
Exemplo n.º 10
0
			public _CollectIdContext_203(QueryingReadContext readContext, Transaction baseArg1
				, IdObjectCollector baseArg2, ObjectHeader baseArg3, IReadBuffer baseArg4) : base
				(baseArg1, baseArg2, baseArg3, baseArg4)
			{
				this.readContext = readContext;
			}
Exemplo n.º 11
0
		public static void CollectIdsInternal(CollectIdContext context, ITypeHandler4 handler
			, int linkLength, bool doWithSlotIndirection)
		{
			if (!(IsCascading(handler)))
			{
				IReadBuffer buffer = context.Buffer();
				buffer.Seek(buffer.Offset() + linkLength);
				return;
			}
			if (handler is StandardReferenceTypeHandler)
			{
				context.AddId();
				return;
			}
			LocalObjectContainer container = (LocalObjectContainer)context.Container();
			SlotFormat slotFormat = context.SlotFormat();
			if (HandleAsObject(handler))
			{
				// TODO: Code is similar to QCandidate.readArrayCandidates. Try to refactor to one place.
				int collectionID = context.ReadInt();
				ByteArrayBuffer collectionBuffer = container.ReadBufferById(context.Transaction()
					, collectionID);
				ObjectHeader objectHeader = new ObjectHeader(container, collectionBuffer);
				QueryingReadContext subContext = new QueryingReadContext(context.Transaction(), context
					.HandlerVersion(), collectionBuffer, collectionID, context.Collector());
				objectHeader.ClassMetadata().CollectIDs(subContext);
				return;
			}
			QueryingReadContext queryingReadContext = new QueryingReadContext(context.Transaction
				(), context.HandlerVersion(), context.Buffer(), 0, context.Collector());
			IClosure4 collectIDsFromQueryingContext = new _IClosure4_263(handler, queryingReadContext
				);
			if (doWithSlotIndirection)
			{
				slotFormat.DoWithSlotIndirection(queryingReadContext, handler, collectIDsFromQueryingContext
					);
			}
			else
			{
				collectIDsFromQueryingContext.Run();
			}
		}
Exemplo n.º 12
0
		public static void CollectIDs(QueryingReadContext context, ITypeHandler4 typeHandler
			)
		{
			if (typeHandler is ICascadingTypeHandler)
			{
				((ICascadingTypeHandler)typeHandler).CollectIDs(context);
			}
		}
Exemplo n.º 13
0
 public _IVisitor4_390(QueryingReadContext context)
 {
     this.context = context;
 }
Exemplo n.º 14
0
 /// <exception cref="Db4objects.Db4o.Ext.Db4oIOException"></exception>
 private bool CollectIDsByTypehandlerAspect(QueryingReadContext context)
 {
     var aspectFound = new BooleanByRef(false);
     var subContext = CollectIdContext.ForID(context.Transaction(), context
         .Collector(), context.CollectionID());
     ITraverseAspectCommand command = new _MarshallingInfoTraverseAspectCommand_349(this
         , aspectFound, subContext, EnsureFieldList(subContext));
     TraverseAllAspects(subContext, command);
     return aspectFound.value;
 }
Exemplo n.º 15
0
 /// <exception cref="Db4objects.Db4o.Ext.Db4oIOException"></exception>
 private void CollectIDsByInstantiatingCollection(QueryingReadContext context)
 {
     var id = context.CollectionID();
     if (id == 0)
     {
         return;
     }
     var transaction = context.Transaction();
     var container = context.Container();
     var obj = container.GetByID(transaction, id);
     if (obj == null)
     {
         return;
     }
     // FIXME: [TA] review activation depth
     var depth = DepthUtil.AdjustDepthToBorders(2);
     container.Activate(transaction, obj, container.ActivationDepthProvider().ActivationDepth
         (depth, ActivationMode.Activate));
     Platform4.ForEachCollectionElement(obj, new _IVisitor4_390(context));
 }
Exemplo n.º 16
0
 /// <exception cref="Db4objects.Db4o.Ext.Db4oIOException"></exception>
 public virtual void CollectIDs(QueryingReadContext context)
 {
     if (CollectIDsByTypehandlerAspect(context))
     {
         return;
     }
     CollectIDsByInstantiatingCollection(context);
 }
Exemplo n.º 17
0
 public virtual ITypeHandler4 ReadCandidateHandler(QueryingReadContext context)
 {
     if (ClassMetadata().IsArray())
     {
         return this;
     }
     return null;
 }
 public virtual void CollectIDs(QueryingReadContext context)
 {
     throw new NotImplementedException();
 }
Exemplo n.º 19
0
 public virtual ITypeHandler4 ReadCandidateHandler(QueryingReadContext context)
 {
     return this;
 }
Exemplo n.º 20
0
			public _IRunnable_71(QueryingReadContext context, ITypeHandler4 handler)
			{
				this.context = context;
				this.handler = handler;
			}
Exemplo n.º 21
0
 public virtual void CollectIDs(QueryingReadContext context)
 {
     ReadArrayHandler(context).CollectIDs(context);
 }
Exemplo n.º 22
0
		public virtual void CollectIDs(QueryingReadContext context)
		{
			ITypeHandler4 handler = HandlerRegistry.CorrectHandlerVersion(context, _handler);
			ForEachElement(context, new _IRunnable_71(context, handler));
		}
Exemplo n.º 23
0
 public virtual ITypeHandler4 SeekCandidateHandler(QueryingReadContext context)
 {
     if (IsArray())
     {
         if (Platform4.IsCollectionTranslator(_config))
         {
             context.Seek(context.Offset() + Const4.IntLength);
             return new ArrayHandler(null, false);
         }
         IncrementFieldsOffset1((ByteArrayBuffer) context.Buffer(), context);
         if (_ancestor != null)
         {
             return _ancestor.SeekCandidateHandler(context);
         }
     }
     return null;
 }
Exemplo n.º 24
0
 public virtual void CollectIDs(QueryingReadContext context)
 {
     if (!StandardReferenceTypeHandlerIsUsed())
     {
         throw new InvalidOperationException();
     }
     Handlers4.CollectIDs(context, CorrectHandlerVersion(context));
 }
Exemplo n.º 25
0
		public static ITypeHandler4 ArrayElementHandler(ITypeHandler4 handler, QueryingReadContext
			 queryingReadContext)
		{
			if (!(handler is ICascadingTypeHandler))
			{
				return null;
			}
			ICascadingTypeHandler cascadingHandler = (ICascadingTypeHandler)HandlerRegistry.CorrectHandlerVersion
				(queryingReadContext, handler);
			return HandlerRegistry.CorrectHandlerVersion(queryingReadContext, cascadingHandler
				.ReadCandidateHandler(queryingReadContext));
		}
Exemplo n.º 26
0
 public object Run()
 {
     QueryingReadContext context = null;
     if (Handlers4.HandleAsObject(arrayElementHandler))
     {
         // TODO: Code is similar to FieldMetadata.collectIDs. Try to refactor to one place.
         var collectionID = buffer.ReadInt();
         var arrayElementBuffer = _enclosing.Container()
             .ReadBufferById(_enclosing.Transaction(), collectionID);
         var objectHeader = ObjectHeader.ScrollBufferToContent(_enclosing.Container
             (), arrayElementBuffer);
         context = new QueryingReadContext(_enclosing.Transaction(), candidates, _enclosing._handlerVersion,
             arrayElementBuffer, collectionID);
         objectHeader.ClassMetadata().CollectIDs(context);
     }
     else
     {
         context = new QueryingReadContext(_enclosing.Transaction(), candidates, _enclosing._handlerVersion,
             buffer, 0);
         ((ICascadingTypeHandler) arrayElementHandler).CollectIDs(context);
     }
     Traverse(context.Ids(), new _IVisitor4_336(candidates));
     var i = context.ObjectsWithoutId();
     while (i.MoveNext())
     {
         var obj = i.Current;
         candidates.Add(new QCandidate(candidates
             , obj, 0));
     }
     return null;
 }
Exemplo n.º 27
0
			public _IClosure4_263(ITypeHandler4 handler, QueryingReadContext queryingReadContext
				)
			{
				this.handler = handler;
				this.queryingReadContext = queryingReadContext;
			}
Exemplo n.º 28
0
		public QCandidate ReadSubCandidate(QueryingReadContext context, ITypeHandler4 handler
			)
		{
			ObjectID objectID = ObjectID.NotPossible;
			try
			{
				int offset = context.Offset();
				if (handler is IReadsObjectIds)
				{
					objectID = ((IReadsObjectIds)handler).ReadObjectID(context);
				}
				if (objectID.IsValid())
				{
					return new QCandidate(this, null, objectID._id);
				}
				if (objectID == ObjectID.NotPossible)
				{
					context.Seek(offset);
					object obj = context.Read(handler);
					if (obj != null)
					{
						QCandidate candidate = new QCandidate(this, obj, context.Container().GetID(context
							.Transaction(), obj));
						candidate.ClassMetadata(context.Container().ClassMetadataForObject(obj));
						return candidate;
					}
				}
			}
			catch (Exception)
			{
			}
			// FIXME: Catchall
			return null;
		}
Exemplo n.º 29
0
 internal virtual bool CreateChild(QCandidates a_candidates)
 {
     if (!_include)
     {
         return false;
     }
     if (_fieldMetadata != null)
     {
         var handler = _fieldMetadata.GetHandler();
         if (handler != null)
         {
             var queryingReadContext = new QueryingReadContext(Transaction(),
                 MarshallerFamily().HandlerVersion(), _bytes, _key);
             var arrayElementHandler = Handlers4.ArrayElementHandler(handler, queryingReadContext
                 );
             if (arrayElementHandler != null)
             {
                 var offset = queryingReadContext.Offset();
                 var outerRes = true;
                 // The following construct is worse than not ideal.
                 // For each constraint it completely reads the
                 // underlying structure again. The structure could b
                 // kept fairly easy. TODO: Optimize!
                 var i = a_candidates.IterateConstraints();
                 while (i.MoveNext())
                 {
                     var qcon = (QCon) i.Current;
                     var qf = qcon.GetField();
                     if (qf == null || qf.Name().Equals(_fieldMetadata.GetName()))
                     {
                         var tempParent = qcon.Parent();
                         qcon.SetParent(null);
                         var candidates = new QCandidates(a_candidates.i_trans, null, qf);
                         candidates.AddConstraint(qcon);
                         qcon.SetCandidates(candidates);
                         ReadArrayCandidates(handler, queryingReadContext.Buffer(), arrayElementHandler,
                             candidates
                             );
                         queryingReadContext.Seek(offset);
                         var isNot = qcon.IsNot();
                         if (isNot)
                         {
                             qcon.RemoveNot();
                         }
                         candidates.Evaluate();
                         var pending = ByRef.NewInstance();
                         bool[] innerRes = {isNot};
                         candidates.Traverse(new _IVisitor4_160(innerRes, isNot, pending));
                         // Collect all pending subresults.
                         // We need to change
                         // the
                         // constraint here, so
                         // our
                         // pending collector
                         // uses
                         // the right
                         // comparator.
                         // We only keep one
                         // pending result
                         // for
                         // all array
                         // elements.
                         // and memorize,
                         // whether we had a
                         // true or a false
                         // result.
                         // or both.
                         if (isNot)
                         {
                             qcon.Not();
                         }
                         // In case we had pending subresults, we
                         // need to communicate
                         // them up to our root.
                         if (((Tree) pending.value) != null)
                         {
                             ((Tree) pending.value).Traverse(new _IVisitor4_229(this));
                         }
                         if (!innerRes[0])
                         {
                             // Again this could be double triggering.
                             // 
                             // We want to clean up the "No route"
                             // at some stage.
                             qcon.Visit(GetRoot(), qcon.Evaluator().Not(false));
                             outerRes = false;
                         }
                         qcon.SetParent(tempParent);
                     }
                 }
                 return outerRes;
             }
             // We may get simple types here too, if the YapField was null
             // in the higher level simple evaluation. Evaluate these
             // immediately.
             if (Handlers4.IsQueryLeaf(handler))
             {
                 a_candidates.i_currentConstraint.Visit(this);
                 return true;
             }
         }
     }
     if (_fieldMetadata == null)
     {
         return false;
     }
     if (_fieldMetadata is NullFieldMetadata)
     {
         return false;
     }
     _classMetadata.SeekToField(Transaction(), _bytes, _fieldMetadata);
     var candidate = ReadSubCandidate(
         a_candidates);
     if (candidate == null)
     {
         return false;
     }
     // fast early check for ClassMetadata
     if (a_candidates.i_classMetadata != null && a_candidates.i_classMetadata.IsStronglyTyped
         ())
     {
         var handler = _fieldMetadata.GetHandler();
         if (Handlers4.IsUntyped(handler))
         {
             handler = TypeHandlerFor(candidate);
         }
         if (handler == null)
         {
             return false;
         }
     }
     AddDependant(a_candidates.Add(candidate));
     return true;
 }
 public virtual ITypeHandler4 ReadCandidateHandler(QueryingReadContext context)
 {
     throw new NotImplementedException();
 }