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); } }
/// <exception cref="Db4objects.Db4o.Ext.Db4oIOException"></exception> private bool CollectIDsByTypehandlerAspect(QueryingReadContext context) { BooleanByRef aspectFound = new BooleanByRef(false); CollectIdContext 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); }
public static ITypeHandler4 ArrayElementHandler(ITypeHandler4 handler, QueryingReadContext queryingReadContext) { if (!(handler is ICascadingTypeHandler)) { return(null); } var cascadingHandler = (ICascadingTypeHandler)HandlerRegistry.CorrectHandlerVersion (queryingReadContext, handler); return(HandlerRegistry.CorrectHandlerVersion(queryingReadContext, cascadingHandler .ReadCandidateHandler(queryingReadContext))); }
private object ReadFieldValue(int id, FieldMetadata field) { ByteArrayBuffer buffer = BufferFor(id); HandlerVersion handlerVersion = field.ContainingClass().SeekToField(_transaction, buffer, field); if (handlerVersion == HandlerVersion.Invalid) { return(null); } QueryingReadContext context = new QueryingReadContext(_transaction, handlerVersion ._number, buffer, id); return(field.Read(context)); }
public static void CollectIdsInternal(CollectIdContext context, ITypeHandler4 handler , int linkLength, bool doWithSlotIndirection) { if (!(IsCascading(handler))) { var buffer = context.Buffer(); buffer.Seek(buffer.Offset() + linkLength); return; } if (handler is StandardReferenceTypeHandler) { context.AddId(); return; } var container = (LocalObjectContainer)context.Container(); var slotFormat = context.SlotFormat(); if (HandleAsObject(handler)) { // TODO: Code is similar to QCandidate.readArrayCandidates. Try to refactor to one place. var collectionID = context.ReadInt(); var collectionBuffer = container.ReadBufferById(context.Transaction() , collectionID); var objectHeader = new ObjectHeader(container, collectionBuffer); var subContext = new QueryingReadContext(context.Transaction(), context .HandlerVersion(), collectionBuffer, collectionID, context.Collector()); objectHeader.ClassMetadata().CollectIDs(subContext); return; } var 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(); } }
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)); }
private IInternalCandidate ReadSubCandidate(QCandidates candidateCollection) { Read(); if (_bytes == null || _fieldMetadata == null) { return(null); } int offset = CurrentOffSet(); QueryingReadContext context = NewQueryingReadContext(); ITypeHandler4 handler = HandlerRegistry.CorrectHandlerVersion(context, _fieldMetadata .GetHandler()); IInternalCandidate subCandidate = candidateCollection.ReadSubCandidate(context, handler ); Seek(offset); if (subCandidate != null) { subCandidate.Root(GetRoot()); return(subCandidate); } return(null); }
private Db4objects.Db4o.Internal.Query.Processor.QCandidate ReadSubCandidate(QCandidates candidateCollection) { Read(); if (_bytes == null || _fieldMetadata == null) { return null; } int offset = CurrentOffSet(); QueryingReadContext context = NewQueryingReadContext(); ITypeHandler4 handler = HandlerRegistry.CorrectHandlerVersion(context, _fieldMetadata .GetHandler()); Db4objects.Db4o.Internal.Query.Processor.QCandidate subCandidate = candidateCollection .ReadSubCandidate(context, handler); Seek(offset); if (subCandidate != null) { subCandidate._root = GetRoot(); return subCandidate; } return null; }
public IInternalCandidate 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) { int id = context.Container().GetID(context.Transaction(), obj); if (id == 0) { return(new QPrimitiveCandidate(this, obj)); } QCandidate candidate = new QCandidate(this, obj, id); candidate.ClassMetadata(context.Container().ClassMetadataForObject(obj)); return(candidate); } } } catch (Exception) { } // FIXME: Catchall return(null); }
/// <exception cref="Db4objects.Db4o.Ext.Db4oIOException"></exception> private void CollectIDsByInstantiatingCollection(QueryingReadContext context) { int id = context.CollectionID(); if (id == 0) { return; } Transaction transaction = context.Transaction(); ObjectContainerBase container = context.Container(); object obj = container.GetByID(transaction, id); if (obj == null) { return; } // FIXME: [TA] review activation depth int depth = DepthUtil.AdjustDepthToBorders(2); container.Activate(transaction, obj, container.ActivationDepthProvider().ActivationDepth (depth, ActivationMode.Activate)); Platform4.ForEachCollectionElement(obj, new _IVisitor4_390(context)); }
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); }
public _IClosure4_263(ITypeHandler4 handler, QueryingReadContext queryingReadContext ) { this.handler = handler; this.queryingReadContext = queryingReadContext; }
public virtual ITypeHandler4 ReadCandidateHandler(QueryingReadContext context) { return(this); }
public virtual void CollectIDs(QueryingReadContext context) { ITypeHandler4 handler = HandlerRegistry.CorrectHandlerVersion(context, _handler); ForEachElement(context, new _IRunnable_71(context, handler)); }
public virtual void CollectIDs(QueryingReadContext context) { throw new NotImplementedException(); }
// do nothing public virtual void CollectIDs(QueryingReadContext context) { }
public ITypeHandler4 ReadCandidateHandler(QueryingReadContext context) { return(null); }
public _IVisitor4_390(QueryingReadContext context) { this.context = context; }
// TODO Auto-generated method stub public virtual ITypeHandler4 ReadCandidateHandler(QueryingReadContext context) { // TODO Auto-generated method stub return(null); }
public _IRunnable_71(QueryingReadContext context, ITypeHandler4 handler) { this.context = context; this.handler = handler; }
public _CollectIdContext_203(QueryingReadContext readContext, Transaction baseArg1 , IdObjectCollector baseArg2, ObjectHeader baseArg3, IReadBuffer baseArg4) : base (baseArg1, baseArg2, baseArg3, baseArg4) { this.readContext = readContext; }
public virtual ITypeHandler4 ReadCandidateHandler(QueryingReadContext context) { throw new NotImplementedException(); }
internal virtual bool CreateChild(QCandidates a_candidates) { if (!_include) { return(false); } if (_fieldMetadata != null) { ITypeHandler4 handler = _fieldMetadata.GetHandler(); if (handler != null) { QueryingReadContext queryingReadContext = new QueryingReadContext(Transaction(), MarshallerFamily().HandlerVersion(), _bytes, _key); ITypeHandler4 arrayElementHandler = Handlers4.ArrayElementHandler(handler, queryingReadContext ); if (arrayElementHandler != null) { int offset = queryingReadContext.Offset(); bool 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! IEnumerator i = a_candidates.IterateConstraints(); while (i.MoveNext()) { QCon qcon = (QCon)i.Current; QField qf = qcon.GetField(); if (qf == null || qf.Name().Equals(_fieldMetadata.GetName())) { QCon tempParent = qcon.Parent(); qcon.SetParent(null); QCandidates candidates = new QCandidates(a_candidates.i_trans, null, qf); candidates.AddConstraint(qcon); qcon.SetCandidates(candidates); ReadArrayCandidates(handler, queryingReadContext.Buffer(), arrayElementHandler, candidates ); queryingReadContext.Seek(offset); bool isNot = qcon.IsNot(); if (isNot) { qcon.RemoveNot(); } candidates.Evaluate(); ByRef pending = ByRef.NewInstance(); bool[] innerRes = new bool[] { 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); Db4objects.Db4o.Internal.Query.Processor.QCandidate 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 ()) { ITypeHandler4 handler = _fieldMetadata.GetHandler(); if (Handlers4.IsUntyped(handler)) { handler = TypeHandlerFor(candidate); } if (handler == null) { return(false); } } AddDependant(a_candidates.Add(candidate)); return(true); }
public virtual void CollectIDs(QueryingReadContext context) { ReadArrayHandler(context).CollectIDs(context); }