Esempio n. 1
0
        /// <exception cref="System.Exception"></exception>
        public static void AssertAllSlotsFreed(LocalTransaction trans, BTree bTree, ICodeBlock
                                               block)
        {
            LocalObjectContainer   container  = (LocalObjectContainer)trans.Container();
            ITransactionalIdSystem idSystem   = trans.IdSystem();
            IEnumerator            allSlotIDs = bTree.AllNodeIds(trans.SystemTransaction());
            Collection4            allSlots   = new Collection4();

            while (allSlotIDs.MoveNext())
            {
                int  slotID = ((int)allSlotIDs.Current);
                Slot slot   = idSystem.CurrentSlot(slotID);
                allSlots.Add(slot);
            }
            Slot bTreeSlot = idSystem.CurrentSlot(bTree.GetID());

            allSlots.Add(bTreeSlot);
            Collection4       freedSlots       = new Collection4();
            IFreespaceManager freespaceManager = container.FreespaceManager();

            container.InstallDebugFreespaceManager(new FreespaceManagerForDebug(new _ISlotListener_99
                                                                                    (freedSlots)));
            block.Run();
            container.InstallDebugFreespaceManager(freespaceManager);
            Assert.IsTrue(freedSlots.ContainsAll(allSlots.GetEnumerator()));
        }
Esempio n. 2
0
        public virtual void TestContainsAll()
        {
            Collection4TestCase.Item a  = new Collection4TestCase.Item(42);
            Collection4TestCase.Item b  = new Collection4TestCase.Item(a.id + 1);
            Collection4TestCase.Item c  = new Collection4TestCase.Item(b.id + 1);
            Collection4TestCase.Item a_ = new Collection4TestCase.Item(a.id);
            Collection4 needle          = new Collection4();
            Collection4 haystack        = new Collection4();

            haystack.Add(a);
            needle.Add(a);
            needle.Add(b);
            Assert.IsFalse(haystack.ContainsAll(needle));
            needle.Remove(b);
            Assert.IsTrue(haystack.ContainsAll(needle));
            needle.Add(b);
            haystack.Add(b);
            Assert.IsTrue(haystack.ContainsAll(needle));
            needle.Add(a_);
            Assert.IsTrue(haystack.ContainsAll(needle));
            needle.Add(c);
            Assert.IsFalse(haystack.ContainsAll(needle));
            needle.Clear();
            Assert.IsTrue(haystack.ContainsAll(needle));
            haystack.Clear();
            Assert.IsTrue(haystack.ContainsAll(needle));
        }
Esempio n. 3
0
        private IReflectClass EnsureClassAvailability(int id)
        {
            if (id == 0)
            {
                return(null);
            }
            IReflectClass ret = (IReflectClass)_classByID.Get(id);

            if (ret != null)
            {
                return(ret);
            }
            ByteArrayBuffer classreader = _stream.ReadStatefulBufferById(_trans, id);
            ClassMarshaller marshaller  = MarshallerFamily()._class;
            RawClassSpec    spec        = marshaller.ReadSpec(_trans, classreader);
            string          className   = spec.Name();

            ret = LookupByName(className);
            if (ret != null)
            {
                _classByID.Put(id, ret);
                _pendingClasses.Add(id);
                return(ret);
            }
            ReportMissingClass(className);
            ret = _builder.CreateClass(className, EnsureClassAvailability(spec.SuperClassID()
                                                                          ), spec.NumFields());
            // step 1 only add to _classByID, keep the class out of _classByName and _classes
            _classByID.Put(id, ret);
            _pendingClasses.Add(id);
            return(ret);
        }
Esempio n. 4
0
        public virtual void TestContainsAll()
        {
            var a        = new Item(42);
            var b        = new Item(a.id + 1);
            var c        = new Item(b.id + 1);
            var a_       = new Item(a.id);
            var needle   = new Collection4();
            var haystack = new Collection4();

            haystack.Add(a);
            needle.Add(a);
            needle.Add(b);
            Assert.IsFalse(haystack.ContainsAll(needle));
            needle.Remove(b);
            Assert.IsTrue(haystack.ContainsAll(needle));
            needle.Add(b);
            haystack.Add(b);
            Assert.IsTrue(haystack.ContainsAll(needle));
            needle.Add(a_);
            Assert.IsTrue(haystack.ContainsAll(needle));
            needle.Add(c);
            Assert.IsFalse(haystack.ContainsAll(needle));
            needle.Clear();
            Assert.IsTrue(haystack.ContainsAll(needle));
            haystack.Clear();
            Assert.IsTrue(haystack.ContainsAll(needle));
        }
Esempio n. 5
0
        public virtual void TestToString()
        {
            Collection4 c = new Collection4();

            Assert.AreEqual("[]", c.ToString());
            c.Add("foo");
            Assert.AreEqual("[foo]", c.ToString());
            c.Add("bar");
            Assert.AreEqual("[foo, bar]", c.ToString());
        }
Esempio n. 6
0
        public virtual void TestGetByIndex()
        {
            Collection4 c = new Collection4();

            c.Add("one");
            c.Add("two");
            Assert.AreEqual("one", c.Get(0));
            Assert.AreEqual("two", c.Get(1));
            AssertIllegalIndex(c, -1);
            AssertIllegalIndex(c, 2);
        }
Esempio n. 7
0
        private CompositeIterator4 NewIterator()
        {
            var iterators = new Collection4();

            iterators.Add(IntArrays4.NewIterator(new[] { 1, 2, 3 }));
            iterators.Add(IntArrays4.NewIterator(new int[] {}));
            iterators.Add(IntArrays4.NewIterator(new[] { 4 }));
            iterators.Add(IntArrays4.NewIterator(new[] { 5, 6 }));
            var iterator = new CompositeIterator4(iterators.GetEnumerator());

            return(iterator);
        }
Esempio n. 8
0
        public virtual void TestContains()
        {
            object      a = new object();
            Collection4 c = new Collection4();

            c.Add(new object());
            Assert.IsFalse(c.Contains(a));
            c.Add(a);
            Assert.IsTrue(c.Contains(a));
            c.Remove(a);
            Assert.IsFalse(c.Contains(a));
        }
Esempio n. 9
0
        private void CollectStandaloneNode(QConObject conObject)
        {
            IndexedLeaf existing = FindLeafOnSameField(conObject);

            if (existing != null)
            {
                CollectImplicitAnd(conObject, existing, new IndexedLeaf(conObject));
            }
            else
            {
                _nodes.Add(new IndexedLeaf(conObject));
            }
        }
Esempio n. 10
0
        public virtual void TestReplace()
        {
            Collection4 c = new Collection4();

            c.Replace("one", "two");
            c.Add("one");
            c.Add("two");
            c.Add("three");
            c.Replace("two", "two.half");
            AssertCollection(new string[] { "one", "two.half", "three" }, c);
            c.Replace("two.half", "one");
            c.Replace("one", "half");
            AssertCollection(new string[] { "half", "one", "three" }, c);
        }
 public void AddClassMetadata(ClassMetadata clazz)
 {
     Container().SetDirtyInSystemTransaction(this);
     _classes.Add(clazz);
     if (clazz.StateUnread())
     {
         _classMetadataByBytes.Put(clazz.i_nameBytes, clazz);
     }
     else
     {
         _classMetadataByClass.Put(clazz.ClassReflector(), clazz);
     }
     RegisterClassMetadataById(clazz);
 }
Esempio n. 12
0
        public virtual IEnumerator IteratorFor(object collection)
        {
            IDictionary map    = (IDictionary)collection;
            Collection4 result = new Collection4();
            IEnumerator it     = map.GetEnumerator();

            while (it.MoveNext())
            {
                DictionaryEntry entry = (DictionaryEntry)it.Current;
                result.Add(entry.Key);
                result.Add(entry.Value);
            }
            return(result.GetEnumerator());
        }
Esempio n. 13
0
        public virtual void TestIndexOf()
        {
            Collection4 c = new Collection4();

            Assert.AreEqual(-1, c.IndexOf("notInCollection"));
            c.Add("one");
            Assert.AreEqual(-1, c.IndexOf("notInCollection"));
            Assert.AreEqual(0, c.IndexOf("one"));
            c.Add("two");
            c.Add("three");
            Assert.AreEqual(0, c.IndexOf("one"));
            Assert.AreEqual(1, c.IndexOf("two"));
            Assert.AreEqual(2, c.IndexOf("three"));
            Assert.AreEqual(-1, c.IndexOf("notInCollection"));
        }
Esempio n. 14
0
        private bool AttachToExistingConstraints(Collection4 newConstraintsCollector, object
                                                 obj, bool onlyForPaths)
        {
            bool        found = false;
            IEnumerator j     = IterateConstraints();

            while (j.MoveNext())
            {
                QCon         existingConstraint = (QCon)j.Current;
                BooleanByRef removeExisting     = new BooleanByRef(false);
                if (!onlyForPaths || (existingConstraint is QConPath))
                {
                    QCon newConstraint = existingConstraint.ShareParent(obj, removeExisting);
                    if (newConstraint != null)
                    {
                        newConstraintsCollector.Add(newConstraint);
                        AddConstraint(newConstraint);
                        if (removeExisting.value)
                        {
                            RemoveConstraint(existingConstraint);
                        }
                        found = true;
                        if (!onlyForPaths)
                        {
                            break;
                        }
                    }
                }
            }
            return(found);
        }
Esempio n. 15
0
        internal virtual void Process(ClassMetadata newClassMetadata)
        {
            if (_pending.Contains(newClassMetadata))
            {
                return;
            }
            ClassMetadata ancestor = newClassMetadata.GetAncestor();

            if (ancestor != null)
            {
                Process(ancestor);
            }
            _pending.Add(newClassMetadata);
            _members.Add(newClassMetadata);
            if (_running)
            {
                return;
            }
            _running = true;
            try
            {
                CheckInits();
                _pending = new Collection4();
            }
            finally
            {
                _running = false;
            }
        }
Esempio n. 16
0
        // do nothing
        public virtual void Delete(object obj)
        {
            IDrsUUID uuid = ProduceReference(obj, null, null).Uuid();

            _uuidsDeletedSinceLastReplication.Add(uuid);
            Sharpen.Collections.Remove(_storedObjects, obj);
        }
Esempio n. 17
0
            public void OnEvent(object sender, ObjectInfoEventArgs args
                                )
            {
                ObjectEventArgs objectArgs = args;

                updated.Add(objectArgs.Object);
            }
        public void WriteAllClasses()
        {
            Collection4 deadClasses = new Collection4();

            IStoredClass[] storedClasses = StoredClasses();
            for (int i = 0; i < storedClasses.Length; i++)
            {
                ClassMetadata clazz = (ClassMetadata)storedClasses[i];
                clazz.SetStateDirty();
                if (clazz.StateDead())
                {
                    deadClasses.Add(clazz);
                    clazz.SetStateOK();
                }
            }
            for (int i = 0; i < storedClasses.Length; i++)
            {
                ClassMetadata clazz = (ClassMetadata)storedClasses[i];
                clazz.Write(_systemTransaction);
            }
            IEnumerator it = deadClasses.GetEnumerator();

            while (it.MoveNext())
            {
                ((ClassMetadata)it.Current).SetStateDead();
            }
        }
        private void EnsureAllClassesRead()
        {
            bool allClassesRead = false;

            while (!allClassesRead)
            {
                Collection4 unreadClasses = new Collection4();
                int         numClasses    = _classes.Size();
                IEnumerator classIter     = _classes.GetEnumerator();
                while (classIter.MoveNext())
                {
                    ClassMetadata clazz = (ClassMetadata)classIter.Current;
                    if (clazz.StateUnread())
                    {
                        unreadClasses.Add(clazz);
                    }
                }
                IEnumerator unreadIter = unreadClasses.GetEnumerator();
                while (unreadIter.MoveNext())
                {
                    ClassMetadata clazz = (ClassMetadata)unreadIter.Current;
                    clazz = ReadClassMetadata(clazz, null);
                    if (clazz.ClassReflector() == null)
                    {
                        clazz.ForceRead();
                    }
                }
                allClassesRead = (_classes.Size() == numClasses);
            }
            ApplyReadAs();
        }
Esempio n. 20
0
 internal virtual void CacheDirty(Collection4 col)
 {
     if (!BitIsTrue(Const4.CachedDirty))
     {
         BitTrue(Const4.CachedDirty);
         col.Add(this);
     }
 }
Esempio n. 21
0
 public virtual void AddListener(IDiagnosticListener listener)
 {
     if (_listeners == null)
     {
         _listeners = new Collection4();
     }
     _listeners.Add(listener);
 }
Esempio n. 22
0
 internal virtual void AddJoin(QConJoin a_join)
 {
     if (i_joins == null)
     {
         i_joins = new Collection4();
     }
     i_joins.Add(a_join);
 }
Esempio n. 23
0
 private void Unexpected(object obj)
 {
     if (_ignoreUnexpected)
     {
         return;
     }
     _unexpected.Add(obj);
     Ods("Unexpected: " + obj);
 }
 public ExcludingReflector(Type[] excludedClasses)
 {
     _excludedClasses = new Collection4();
     for (int claxxIndex = 0; claxxIndex < excludedClasses.Length; ++claxxIndex)
     {
         Type claxx = excludedClasses[claxxIndex];
         _excludedClasses.Add(claxx.FullName);
     }
 }
Esempio n. 25
0
 public void AddToBatch(Msg msg)
 {
     lock (Lock())
     {
         _batchedMessages.Add(msg);
         // the first INT_LENGTH is for buffer.length, and then buffer content.
         _batchedQueueLength += Const4.IntLength + msg.PayLoad().Length();
     }
 }
 private void AddServerMessageDispatcher(IServerMessageDispatcher dispatcher)
 {
     lock (_dispatchers)
     {
         _dispatchers.Add(dispatcher);
         CheckCaresAboutCommitted();
     }
     TriggerClientConnected(dispatcher);
 }
Esempio n. 27
0
        public virtual void TestInvalidIteratorException()
        {
            Collection4 c = NewCollection(new string[] { "1", "2" });
            IEnumerator i = c.GetEnumerator();

            Assert.IsTrue(i.MoveNext());
            c.Add("3");
            Assert.Expect(typeof(InvalidIteratorException), new _ICodeBlock_200(i));
        }
Esempio n. 28
0
 public void RegisterTypeHandler(ITypeHandlerPredicate predicate, ITypeHandler4 typeHandler
                                 )
 {
     if (_registeredTypeHandlers == null)
     {
         _registeredTypeHandlers = new Collection4();
     }
     _registeredTypeHandlers.Add(new TypeHandlerPredicatePair(predicate, typeHandler));
 }
Esempio n. 29
0
        public virtual void TestRemove()
        {
            Collection4 c = NewCollection(new string[] { "1", "2", "3", "4" });

            c.Remove("3");
            AssertCollection(new string[] { "1", "2", "4" }, c);
            c.Remove("4");
            AssertCollection(new string[] { "1", "2" }, c);
            c.Add("5");
            AssertCollection(new string[] { "1", "2", "5" }, c);
            c.Remove("1");
            AssertCollection(new string[] { "2", "5" }, c);
            c.Remove("2");
            c.Remove("5");
            AssertCollection(new string[] {  }, c);
            c.Add("6");
            AssertCollection(new string[] { "6" }, c);
        }
Esempio n. 30
0
 public ExcludingReflector(ByRef loaderClass, Type[] excludedClasses)
 {
     _excludedClasses = new Collection4();
     for (var claxxIndex = 0; claxxIndex < excludedClasses.Length; ++claxxIndex)
     {
         var claxx = excludedClasses[claxxIndex];
         _excludedClasses.Add(claxx.FullName);
     }
 }