public LazyClientQueryResult(Transaction trans, ClientObjectContainer client, int queryResultID) : base(trans) { _client = client; _queryResultID = queryResultID; _iterator = new LazyClientIdIterator(this); }
public override int InstanceCount(ClassMetadata clazz, Transaction trans) { lock (Lock()) { return clazz.IndexEntryCount(trans); } }
public override void Write(Transaction trans, ClassMetadata clazz, ClassAspect aspect , ByteArrayBuffer writer) { writer.WriteShortString(trans, aspect.GetName()); if (!(aspect is FieldMetadata)) { return; } FieldMetadata field = (FieldMetadata)aspect; field.Alive(); if (field.IsVirtual()) { return; } ITypeHandler4 handler = field.GetHandler(); if (handler is StandardReferenceTypeHandler) { // TODO: ensure there is a test case, to make this happen if (((StandardReferenceTypeHandler)handler).ClassMetadata().GetID() == 0) { trans.Container().NeedsUpdate(clazz); } } writer.WriteInt(field.FieldTypeID()); BitMap4 bitmap = new BitMap4(3); bitmap.Set(0, field.IsPrimitive()); bitmap.Set(1, Handlers4.HandlesArray(handler)); bitmap.Set(2, Handlers4.HandlesMultidimensionalArray(handler)); // keep the order writer.WriteByte(bitmap.GetByte(0)); }
public virtual void Release(ShutdownMode mode, Transaction transaction, bool rollbackOnClose ) { lock (_mainContainer.Lock()) { ClientTransactionPool.ContainerCount entry = (ClientTransactionPool.ContainerCount )_transaction2Container.Get(transaction); entry.Container().CloseTransaction(transaction, false, mode.IsFatal() ? false : rollbackOnClose ); _transaction2Container.Remove(transaction); entry.Release(); if (entry.IsEmpty()) { _fileName2Container.Remove(entry.FileName()); try { entry.Close(mode); } catch (Exception t) { // If we are in fatal ShutdownMode close will // throw but we want to continue shutting down // all entries. Sharpen.Runtime.PrintStackTrace(t); } } } }
public StatefulBuffer(Transaction trans, int initialBufferSize ) { _trans = trans; _length = initialBufferSize; _buffer = new byte[_length]; }
public override object GetOrCreate(Transaction a_trans, object a_OnObject) { // This is the first part of marshalling // Virtual fields do it all in #marshall(), the object is never used. // Returning any object here prevents triggering null handling. return AnyObject; }
public virtual bool Dispatch(Transaction trans, object obj, int eventID) { if (methods[eventID] == null) { return true; } object[] parameters = new object[] { trans.ObjectContainer() }; ObjectContainerBase container = trans.Container(); int stackDepth = container.StackDepth(); int topLevelCallId = container.TopLevelCallId(); container.StackDepth(0); try { object res = methods[eventID].Invoke(obj, parameters); if (res is bool) { return ((bool)res); } } finally { container.StackDepth(stackDepth); container.TopLevelCallId(topLevelCallId); } return true; }
public virtual object CreateDefault(Transaction a_trans) { BlobImpl bi = null; bi = (BlobImpl)this.MemberwiseClone(); bi.SetTrans(a_trans); return bi; }
private void EnsureSingleOccurence(Transaction trans, IObjectInfoCollection col) { IEnumerator i = col.GetEnumerator(); while (i.MoveNext()) { IObjectInfo objectInfo = (IObjectInfo)i.Current; if (this.ReflectClass() != this._enclosing.ReflectorFor(trans, objectInfo.GetObject ())) { continue; } object obj = this.ObjectFor(trans, objectInfo); object fieldValue = this.FieldMetadata().GetOn(trans, obj); if (fieldValue == null) { continue; } IBTreeRange range = this.FieldMetadata().Search(trans, fieldValue); if (range.Size() > 1) { throw new UniqueFieldValueConstraintViolationException(this.ClassMetadata().GetName (), this.FieldMetadata().GetName()); } } }
internal QConClass(Transaction trans, QCon parent, QField field, IReflectClass claxx ) : base(trans, parent, field, null) { // C/S if (claxx != null) { ObjectContainerBase container = trans.Container(); _classMetadata = container.ClassMetadataForReflectClass(claxx); if (_classMetadata == null) { // could be an aliased class, try to resolve. string className = claxx.GetName(); string aliasRunTimeName = container.Config().ResolveAliasStoredName(className); if (!className.Equals(aliasRunTimeName)) { _classMetadata = container.ClassMetadataForName(aliasRunTimeName); } } if (claxx.Equals(container._handlers.IclassObject)) { _classMetadata = (ClassMetadata)_classMetadata.TypeHandler(); } } _claxx = claxx; }
protected virtual void Remove(Transaction transaction, int[] keys) { for (var i = 0; i < keys.Length; i++) { Remove(transaction, keys[i]); } }
public StatefulBuffer(Db4objects.Db4o.Internal.Transaction trans, int initialBufferSize ) { _trans = trans; _length = initialBufferSize; _buffer = new byte[_length]; }
public _IRunnable_50(EventRegistryImpl _enclosing, Transaction transaction, IQuery query) { this._enclosing = _enclosing; this.transaction = transaction; this.query = query; }
public override void TraverseAll(Transaction ta, IVisitor4 command) { if (_btreeIndex != null) { _btreeIndex.TraverseKeys(ta, command); } }
public BTree(Transaction trans, BTreeConfiguration config, int id, IIndexable4 keyHandler , int treeNodeSize) : base(config._idSystem) { _config = config; if (null == keyHandler) { throw new ArgumentNullException(); } _nodeSize = treeNodeSize; _nodeCache = CacheFactory.NewLRUIntCache(config._cacheSize); _halfNodeSize = _nodeSize / 2; _nodeSize = _halfNodeSize * 2; _keyHandler = keyHandler; SetID(id); if (IsNew()) { SetStateDirty(); _root = new BTreeNode(this, 0, true, 0, 0, 0); _root.Write(trans.SystemTransaction()); AddNode(_root); Write(trans.SystemTransaction()); } else { SetStateDeactivated(); } }
public MsgD GetWriterForByte(Transaction trans , byte b) { var msg = GetWriterForLength(trans, 1); msg._payLoad.WriteByte(b); return msg; }
public Db4objects.Db4o.CS.Internal.Messages.MsgD GetWriterForByte(Transaction trans , byte b) { Db4objects.Db4o.CS.Internal.Messages.MsgD msg = GetWriterForLength(trans, 1); msg._payLoad.WriteByte(b); return msg; }
public static void AssertEmpty(Transaction transaction, BTree tree) { ExpectingVisitor visitor = new ExpectingVisitor(new object[0]); tree.TraverseKeys(transaction, visitor); visitor.AssertExpectations(); Assert.AreEqual(0, tree.Size(transaction)); }
protected virtual void Rename(Transaction transaction, string from, string to) { var item = Query(transaction, from); Assert.IsNotNull(item); item.name = to; Container().Store(transaction, item); }
public virtual Db4objects.Db4o.Internal.VirtualAttributes VirtualAttributes(Db4objects.Db4o.Internal.Transaction trans, bool lastCommitted) { if (trans == null) { return(_virtualAttributes); } lock (trans.Container().Lock()) { if (_virtualAttributes == null) { if (_class.HasVirtualAttributes()) { _virtualAttributes = new Db4objects.Db4o.Internal.VirtualAttributes(); _class.ReadVirtualAttributes(trans, this, lastCommitted); } } else { if (!_virtualAttributes.SuppliesUUID()) { if (_class.HasVirtualAttributes()) { _class.ReadVirtualAttributes(trans, this, lastCommitted); } } } return(_virtualAttributes); } }
public FrozenObjectInfo(Transaction trans, ObjectReference @ref, bool committed) : this(@ref, IsInstantiatedReference(@ref) ? @ref.VirtualAttributes(trans, committed ) : null) { }
public virtual void InitOnUp(Transaction systemTrans, FieldMetadata fieldMetadata ) { ObjectContainerBase anyStream = systemTrans.Container(); if (!anyStream.MaintainsIndices()) { return; } if (!fieldMetadata.SupportsIndex()) { Indexed(false); } TernaryBool indexedFlag = _config.GetAsTernaryBool(IndexedKey); if (indexedFlag.DefiniteNo()) { fieldMetadata.DropIndex((LocalTransaction)systemTrans); return; } if (UseExistingIndex(systemTrans, fieldMetadata)) { return; } if (!indexedFlag.DefiniteYes()) { return; } fieldMetadata.CreateIndex(); }
private void UnmarshallParent(Db4objects.Db4o.Internal.Transaction a_trans) { if (i_parent != null) { i_parent.Unmarshall(a_trans); } }
public virtual void ReadTypeInfo(Transaction trans, IReadBuffer buffer, ArrayInfo info, int classID) { BitMap4 typeInfoBitmap = new BitMap4(buffer.ReadByte()); info.Primitive(typeInfoBitmap.IsTrue(0)); info.Nullable(typeInfoBitmap.IsTrue(1)); }
protected virtual void Add(Transaction transaction, int[] keys) { for (int i = 0; i < keys.Length; i++) { Add(transaction, keys[i]); } }
public UnmarshallingContext(Transaction transaction, ByteArrayBuffer buffer, ObjectReference @ref, int addToIDTree, bool checkIDTree) : base(transaction, buffer, null, @ref ) { _addToIDTree = addToIDTree; _checkIDTree = checkIDTree; }
public override object Rollback(Transaction trans, BTree btree) { if (_transaction == trans) { return RolledBack(btree); } return this; }
internal QConPath(Transaction a_trans, QCon a_parent, QField a_field) : base(a_trans , a_parent, a_field, null) { if (a_field != null) { _classMetadata = a_field.GetFieldType(); } }
protected virtual bool ObjectCanUpdate(Db4objects.Db4o.Internal.Transaction transaction , object obj) { ObjectContainerBase container = transaction.Container(); return(container.Callbacks().ObjectCanUpdate(transaction, this) && _class.DispatchEvent (transaction, obj, EventDispatchers.CanUpdate)); }
public _IProcedure4_39(ClassMarshaller _enclosing, Transaction trans, ClassMetadata clazz, ByteArrayBuffer writer) { this._enclosing = _enclosing; this.trans = trans; this.clazz = clazz; this.writer = writer; }
public Transaction(ObjectContainerBase container, Db4objects.Db4o.Internal.Transaction systemTransaction, IReferenceSystem referenceSystem) { // contains DeleteInfo nodes _container = container; _systemTransaction = systemTransaction; _referenceSystem = referenceSystem; }
private void ObjectOnNew(Db4objects.Db4o.Internal.Transaction transaction, object obj) { ObjectContainerBase container = transaction.Container(); container.Callbacks().ObjectOnNew(transaction, this); _class.DispatchEvent(transaction, obj, EventDispatchers.New); }
public Db4objects.Db4o.CS.Internal.Messages.MsgD GetWriterForBuffer(Transaction trans , ByteArrayBuffer buffer) { Db4objects.Db4o.CS.Internal.Messages.MsgD writer = GetWriterForLength(trans, buffer .Length()); writer.WriteBytes(buffer._buffer); return writer; }
public virtual void Activate(Db4objects.Db4o.Internal.Transaction ta, object obj, IActivationDepth depth) { ObjectContainerBase container = ta.Container(); ActivateInternal(container.ActivationContextFor(ta, obj, depth)); container.ActivatePending(ta); }
public override object Key(Transaction trans) { if (_transaction != trans) { return No4.Instance; } return GetObject(); }
public virtual void SetTransaction(Transaction trans) { if (trans != null) { _trans = trans; _stream = trans.Container(); } }
protected QQueryBase(Db4objects.Db4o.Internal.Transaction a_trans, QQuery a_parent , string a_field) { _this = Cast(this); _trans = a_trans; i_parent = a_parent; i_field = a_field; }
public void UseTransaction(MUseTransaction message) { int threadID = message.ReadInt(); Db4objects.Db4o.Internal.Transaction transToUse = _server.FindTransaction(threadID ); _transactionHandle.Transaction(transToUse); }
public virtual object ReadPrefetch(Db4objects.Db4o.Internal.Transaction trans, ByteArrayBuffer buffer, int addToIDTree) { UnmarshallingContext context = new UnmarshallingContext(trans, buffer, this, addToIDTree , false); context.ActivationDepth(new FixedActivationDepth(1, ActivationMode.Prefetch)); return(context.Read()); }
private void UnmarshallChildren(Db4objects.Db4o.Internal.Transaction a_trans) { IEnumerator i = IterateChildren(); while (i.MoveNext()) { ((Db4objects.Db4o.Internal.Query.Processor.QCon)i.Current).Unmarshall(a_trans); } }
public virtual void PurgeFieldIndexEntriesOnUpdate(Db4objects.Db4o.Internal.Transaction transaction, ArrayType arrayType) { if (!UpdateDepth().CanSkip(_reference)) { transaction.WriteUpdateAdjustIndexes(_reference.GetID(), _reference.ClassMetadata (), arrayType); } }
public BigSet(LocalObjectContainer db) { if (db == null) { return; } _transaction = db.Transaction; _bTree = BTreeManager().NewBTree(); }
protected Db4objects.Db4o.Internal.Transaction CheckParentTransaction(Db4objects.Db4o.Internal.Transaction a_trans, ByteArrayBuffer reader) { if (reader.ReadByte() == Const4.SystemTrans && a_trans.ParentTransaction() != null) { return(a_trans.ParentTransaction()); } return(a_trans); }
private IActivator ActivatorForObject(Db4objects.Db4o.Internal.Transaction transaction , ObjectReference objectReference) { if (IsEmbeddedClient(transaction)) { return(new TransactionalActivator(transaction, objectReference)); } return(objectReference); }
public object Read(Db4objects.Db4o.Internal.Transaction trans, ByteArrayBuffer buffer , object obj, IActivationDepth instantiationDepth, int addToIDTree, bool checkIDTree ) { UnmarshallingContext context = new UnmarshallingContext(trans, buffer, this, addToIDTree , checkIDTree); context.PersistentObject(obj); context.ActivationDepth(instantiationDepth); return(context.Read()); }
internal virtual void Unmarshall(Db4objects.Db4o.Internal.Transaction a_trans) { if (i_trans != null) { return; } i_trans = a_trans; UnmarshallParent(a_trans); UnmarshallJoins(a_trans); UnmarshallChildren(a_trans); }
public ActivationContext4(Db4objects.Db4o.Internal.Transaction transaction, object obj, IActivationDepth depth) { if (null == obj) { throw new ArgumentNullException(); } _transaction = transaction; _targetObject = obj; _depth = depth; }
public virtual void Unmarshall(Transaction a_trans) { _evaluationMode = QueryEvaluationMode.FromInt(_evaluationModeAsInt); _trans = a_trans; IEnumerator i = IterateConstraints(); while (i.MoveNext()) { ((QCon)i.Current).Unmarshall(a_trans); } }
internal void Store(Db4objects.Db4o.Internal.Transaction trans, Db4objects.Db4o.Internal.ClassMetadata classMetadata, object obj) { _object = obj; _class = classMetadata; int id = trans.Container().IdForNewUserObject(trans); SetID(id); // will be ended in continueset() BeginProcessing(); BitTrue(Const4.Continue); }
private void BindActivatableToActivator(ObjectEventArgs oea) { object obj = oea.Object; if (obj is IActivatable) { Db4objects.Db4o.Internal.Transaction transaction = (Db4objects.Db4o.Internal.Transaction )oea.Transaction(); ObjectReference objectReference = transaction.ReferenceForObject(obj); Bind(obj, ActivatorForObject(transaction, objectReference)); } }
private void UnbindAll(IInternalObjectContainer container) { Db4objects.Db4o.Internal.Transaction transaction = container.Transaction; // FIXME should that ever happen? if (transaction == null) { return; } IReferenceSystem referenceSystem = transaction.ReferenceSystem(); referenceSystem.TraverseReferences(new _IVisitor4_95(this)); }
public virtual void Read(IReadContext context) { int id = context.ReadInt(); if (_bTree != null) { AssertCurrentBTreeId(id); return; } _transaction = context.Transaction(); _bTree = BTreeManager().ProduceBTree(id); }
public BTreeRangeSingle(Db4objects.Db4o.Internal.Transaction transaction, BTree btree , BTreePointer first, BTreePointer end) { if (transaction == null || btree == null) { throw new ArgumentNullException(); } _transaction = transaction; _btree = btree; _first = first; _end = end; }
public virtual void WriteUpdate(Db4objects.Db4o.Internal.Transaction transaction, IUpdateDepth updatedepth) { ContinueSet(transaction, updatedepth); // make sure, a concurrent new, possibly triggered by objectOnNew // is written to the file // preventing recursive if (!BeginProcessing()) { return; } object obj = GetObject(); if (!ObjectCanUpdate(transaction, obj) || !IsActive() || obj == null || !ClassMetadata ().IsModified(obj)) { EndProcessing(); return; } MarshallingContext context = new MarshallingContext(transaction, this, updatedepth , false); if (context.UpdateDepth().Negative()) { EndProcessing(); return; } ObjectContainerBase container = transaction.Container(); LogEvent(container, "update", Const4.State); SetStateClean(); context.PurgeFieldIndexEntriesOnUpdate(transaction, container._handlers.ArrayType (obj)); Handlers4.Write(_class.TypeHandler(), context, obj); if (context.UpdateDepth().CanSkip(this)) { EndProcessing(); return; } Pointer4 pointer = context.AllocateSlot(); ByteArrayBuffer buffer = context.ToWriteBuffer(pointer); container.WriteUpdate(transaction, pointer, _class, container._handlers.ArrayType (obj), buffer); if (IsActive()) { SetStateClean(); } EndProcessing(); container.Callbacks().ObjectOnUpdate(transaction, this); ClassMetadata().DispatchEvent(transaction, obj, EventDispatchers.Update); }
public MarshallingContext(Db4objects.Db4o.Internal.Transaction trans, ObjectReference @ref, IUpdateDepth updateDepth, bool isNew) { // YapClass ID // Marshaller Version // number of fields _transaction = trans; _reference = @ref; _nullBitMap = new BitMap4(AspectCount()); _updateDepth = ClassMetadata().AdjustUpdateDepth(trans, updateDepth); _isNew = isNew; _writeBuffer = new MarshallingBuffer(); _currentBuffer = _writeBuffer; }
/// <exception cref="Db4objects.Db4o.Ext.Db4oIOException"></exception> protected static StatefulBuffer ReadMessageBuffer(Db4objects.Db4o.Internal.Transaction trans, Socket4Adapter socket, int length) { StatefulBuffer buffer = new StatefulBuffer(trans, length); int offset = 0; while (length > 0) { int read = socket.Read(buffer._buffer, offset, length); if (read < 0) { throw new Db4oIOException(); } offset += read; length -= read; } return(buffer); }
public virtual void Deactivate(Db4objects.Db4o.Internal.Transaction trans, IActivationDepth depth) { if (!depth.RequiresActivation()) { return; } object obj = GetObject(); if (obj == null) { return; } ObjectContainerBase container = trans.Container(); LogActivation(container, "deactivate"); SetStateDeactivated(); _class.Deactivate(trans, this, depth); }
internal QCon(Db4objects.Db4o.Internal.Transaction a_trans) { //Used for query debug only. // our candidate object tree // collection of QCandidates to collect children elements and to // execute children. For convenience we hold them in the constraint, // so we can do collection and execution in two steps // all subconstraints // for evaluation // ID handling for fast find of QConstraint objects in // pending OR evaluations // ANDs and ORs on this constraint // the parent of this constraint or null, if this is a root // our transaction to get a stream object anywhere // whether or not this constraint was used to get the initial set // in the FieldIndexProcessor // C/S only i_id = idGenerator.Next(); i_trans = a_trans; }
/// <summary>return false if class not completely initialized, otherwise true</summary> internal virtual bool ContinueSet(Db4objects.Db4o.Internal.Transaction trans, IUpdateDepth updateDepth) { if (!BitIsTrue(Const4.Continue)) { return(true); } if (!_class.StateOK()) { return(false); } if (!_class.AspectsAreInitialized()) { return(false); } if (DTrace.enabled) { DTrace.Continueset.Log(GetID()); } BitFalse(Const4.Continue); MarshallingContext context = new MarshallingContext(trans, this, updateDepth, true ); Handlers4.Write(ClassMetadata().TypeHandler(), context, GetObject()); Pointer4 pointer = context.AllocateSlot(); ByteArrayBuffer buffer = context.ToWriteBuffer(pointer); ObjectContainerBase container = trans.Container(); container.WriteNew(trans, pointer, _class, buffer); object obj = _object; ObjectOnNew(trans, obj); if (_class.HasIdentity()) { _object = container.NewWeakReference(this, obj); } SetStateClean(); EndProcessing(); return(true); }