Beispiel #1
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;
		}
Beispiel #2
0
		//    	throw new IllegalStateException();
		public virtual void CollectIDs(QueryingReadContext readContext)
		{
			IInternalReadContext context = (IInternalReadContext)readContext;
			int payloadOffset = context.ReadInt();
			if (payloadOffset == 0)
			{
				return;
			}
			int savedOffSet = context.Offset();
			try
			{
				ITypeHandler4 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);
			}
		}
Beispiel #3
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;
 }
Beispiel #4
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;
 }