public _IProcedure4_108(ClassMarshaller _enclosing, IntByRef len, ObjectContainerBase stream) { this._enclosing = _enclosing; this.len = len; this.stream = stream; }
private bool Descend1(QQuery query, string fieldName, IntByRef run) { if (run.value == 2 || i_constraints.Size() == 0) { // On the second run we are really creating a second independant // query network that is not joined to other higher level // constraints. // Let's see how this works out. We may need to join networks. run.value = 0; // prevent a double run of this code Stream().ClassCollection().AttachQueryNode(fieldName, new _IVisitor4_275(this)); } CheckConstraintsEvaluationMode(); BooleanByRef foundClass = new BooleanByRef(false); IEnumerator i = IterateConstraints(); while (i.MoveNext()) { if (((QCon)i.Current).Attach(query, fieldName)) { foundClass.value = true; } } return(foundClass.value); }
public virtual void DebugCheckIntegrity() { var lastStart = new IntByRef(); var lastEnd = new IntByRef(); Traverse(new _IVisitor4_131(lastEnd, lastStart)); }
private long IdSystemUsage() { IntByRef usage = new IntByRef(); _db.IdSystem().TraverseOwnSlots(new _IProcedure4_217(this, usage)); return(usage.value); }
public virtual int TotalFreespace() { var mint = new IntByRef(); Traverse(new _IVisitor4_99(mint)); return(mint.value); }
private int CountSlotChanges(IVisitable slotChanges) { IntByRef slotChangeCount = new IntByRef(); slotChanges.Accept(new _IVisitor4_40(slotChangeCount)); return(slotChangeCount.value); }
public virtual void TestCancelledTraversalWithStartingPointInTheTree() { IntByRef visits = new IntByRef(); TreeInt tree = CreateTree(); Tree.Traverse(tree, new TreeInt(6), new _ICancellableVisitor4_41(visits)); Assert.AreEqual(1, visits.value); }
private int EstimateMappingCount(IVisitable slotChanges) { IntByRef count = new IntByRef(); count.value = _ids == null ? 0 : _ids.Size(); slotChanges.Accept(new _IVisitor4_103(count)); return(count.value); }
public override void Rollback() { IntByRef newReferencesCount = new IntByRef(); TraverseNewReferences(new _IVisitor4_63(newReferencesCount)); CreateNewReferences(); ReferenceCountChanged(-newReferencesCount.value); }
public override void Commit() { IntByRef removedReferenceCount = new IntByRef(); TraverseNewReferences(new _IVisitor4_26(this, removedReferenceCount)); CreateNewReferences(); ReferenceCountChanged(-removedReferenceCount.value); }
//private void AssertSingleNullTypeHandlerAspect(Type storedClass) //{ // AssertSingleTypeHandlerAspect(storedClass, typeof(IgnoreFieldsTypeHandler)); //} private void AssertSingleTypeHandlerAspect(Type storedClass, Type typeHandlerClass ) { var aspectCount = new IntByRef(0); var classMetadata = ClassMetadata(storedClass); classMetadata.TraverseDeclaredAspects(new _IProcedure4_51(aspectCount, typeHandlerClass )); }
public _IVisitor4_167(FileUsageStatsCollector _enclosing, IntByRef numInstances, LongByRef slotUsage, IMiscCollector miscCollector, LongByRef miscUsage) { this._enclosing = _enclosing; this.numInstances = numInstances; this.slotUsage = slotUsage; this.miscCollector = miscCollector; this.miscUsage = miscUsage; }
public int MarshalledLength() { if (VariableLength()) { IntByRef length = new IntByRef(Const4.IntLength); Traverse(new _IVisitor4_152(length)); return(length.value); } return(MarshalledLength(Size())); }
public virtual int MarshalledLength(ObjectContainerBase stream, ClassMetadata clazz ) { var len = new IntByRef(stream.StringIO().ShortLength(clazz.NameToWrite()) + Const4.ObjectLength + (Const4.IntLength * 2) + (Const4.IdLength)); len.value += clazz.Index().OwnLength(); clazz.TraverseDeclaredAspects(new _IProcedure4_108(this, len, stream)); return(len.value); }
public _IProcedure4_136(ClassMarshaller _enclosing, IntByRef processedAspectCount , int aspectCount, ClassMetadata classMetadata, LatinStringIO sio, DefragmentContextImpl context) { this._enclosing = _enclosing; this.processedAspectCount = processedAspectCount; this.aspectCount = aspectCount; this.classMetadata = classMetadata; this.sio = sio; this.context = context; }
public virtual void AssertEquals(int expected, int maxChecks) { IntByRef ret = new IntByRef(); for (int checkCount = 0; checkCount < MaxChecks && ret.value != expected; checkCount ++) { _lock.Run(new _IClosure4_140(this, expected, ret)); } Assert.AreEqual(expected, ret.value); }
private static ITest[] Tests(IntByRef counter, int numTests, int[] failingIndices ) { ITest[] tests = new ITest[numTests]; for (int i = 0; i < numTests; i++) { tests[i] = new OpaqueTestSuiteTestCase.CountingTest(counter, i + 1, Arrays4.IndexOf (failingIndices, i) >= 0); } return(tests); }
private static ITest[] Tests(IntByRef counter, int numTests, int[] failingIndices ) { var tests = new ITest[numTests]; for (var i = 0; i < numTests; i++) { tests[i] = new CountingTest(counter, i + 1, Arrays4.IndexOf (failingIndices, i) >= 0); } return(tests); }
private void AssertTestRuns(int[] failingIndices) { IntByRef counter = new IntByRef(); TestResult result = new _TestResult_29(); new TestRunner(Iterators.Iterable(new OpaqueTestSuiteTestCase.SimpleTestSuite[] { new OpaqueTestSuiteTestCase.SimpleTestSuite(counter, NumTests, failingIndices) } )).Run(result); Assert.AreEqual(NumTests, result.TestCount); Assert.AreEqual(failingIndices.Length, result.Failures.Count); Assert.AreEqual(NumTests + 2, counter.value); }
public virtual void TestItemCountChanged() { IntByRef changedCount = new IntByRef(); IBTreeStructureListener listener = new _IBTreeStructureListener_63(changedCount); _btree.StructureListener(listener); changedCount.value = 0; Add(42); Assert.AreEqual(1, changedCount.value); Remove(42); Assert.AreEqual(-1, changedCount.value); changedCount.value = 0; Remove(42); Assert.AreEqual(0, changedCount.value); }
public virtual void TestDelete() { IntByRef deletedCount = new IntByRef(); IBTreeStructureListener listener = new _IBTreeStructureListener_39(deletedCount); _btree.StructureListener(listener); for (int i = 0; i < BtreeNodeSize + 1; i++) { Add(i); } for (int i = 0; i < BtreeNodeSize + 1; i++) { Remove(i); } Assert.AreEqual(2, deletedCount.value); }
private FileUsageStatsCollector.InstanceUsage ClassSlotUsage(ClassMetadata clazz) { if (!clazz.HasClassIndex()) { return(new FileUsageStatsCollector.InstanceUsage(0, 0, 0)); } IMiscCollector miscCollector = ((IMiscCollector)MiscCollectors[clazz.GetName()]); LongByRef slotUsage = new LongByRef(); LongByRef miscUsage = new LongByRef(); IntByRef numInstances = new IntByRef(); BTreeClassIndexStrategy index = (BTreeClassIndexStrategy)clazz.Index(); index.TraverseIds(_db.SystemTransaction(), new _IVisitor4_167(this, numInstances, slotUsage, miscCollector, miscUsage)); return(new FileUsageStatsCollector.InstanceUsage(slotUsage.value, miscUsage.value , numInstances.value)); }
private int FindFreeId(int start, int end) { if (_ids == null) { return(start); } IntByRef lastId = new IntByRef(); IntByRef freeId = new IntByRef(); Tree.Traverse(_ids, new TreeInt(start), new _ICancellableVisitor4_204(lastId, start , freeId)); if (freeId.value > 0) { return(freeId.value); } if (lastId.value < end) { return(Math.Max(start, lastId.value + 1)); } return(0); }
/// <summary> /// Partitions an enumerable into individual pages of a specified size, still scanning the source enumerable just once /// </summary> /// <typeparam name="T">The element type</typeparam> /// <param name="enumerable">The source enumerable</param> /// <param name="pageSize">The number of elements to return in each page</param> /// <returns></returns> public static IEnumerable <IEnumerable <T> > Partition <T>(this IEnumerable <T> enumerable, int pageSize) { var enumerator = enumerable.GetEnumerator(); while (enumerator.MoveNext()) { var indexWithinPage = new IntByRef { Value = 0 }; yield return(SubPartition(enumerator, pageSize, indexWithinPage)); // Continue iterating through any remaining items in the page, to align with the start of the next page for (; indexWithinPage.Value < pageSize; indexWithinPage.Value++) { if (!enumerator.MoveNext()) { yield break; } } } }
private void AssertStoredField(Type objectClass, string fieldName, object expectedFieldValue , Type expectedFieldType, bool hasIndex, bool isArray) { IStoredClass storedClass = StoredClass(objectClass); IStoredField[] storedFields = storedClass.GetStoredFields(); Assert.AreEqual(1, storedFields.Length); IStoredField storedField = storedFields[0]; Assert.AreEqual(fieldName, storedField.GetName()); IStoredField storedFieldByName = storedClass.StoredField(fieldName, expectedFieldType ); Assert.AreEqual(storedField, storedFieldByName); object item = RetrieveOnlyInstance(objectClass); Assert.AreEqual(expectedFieldValue, storedField.Get(item)); IReflectClass fieldType = storedField.GetStoredType(); Assert.AreEqual(Reflector().ForClass(expectedFieldType), fieldType); Assert.AreEqual(isArray, storedField.IsArray()); if (IsMultiSession()) { return; } Assert.AreEqual(hasIndex, storedField.HasIndex()); // FIXME: test rename if (!hasIndex) { Assert.Expect(typeof(Exception), new _ICodeBlock_113(storedField)); } else { IntByRef count = new IntByRef(); storedField.TraverseValues(new _IVisitor4_123(count, expectedFieldValue)); Assert.AreEqual(1, count.value); } }
public virtual IQuery Descend(string a_field) { lock (StreamLock()) { QQuery query = new QQuery(_trans, _this, a_field); IntByRef run = new IntByRef(1); if (!Descend1(query, a_field, run)) { // try to add unparented nodes on the second run, // if not added in the first run and a descendant // was not found if (run.value == 1) { run.value = 2; if (!Descend1(query, a_field, run)) { new QConUnconditional(_trans, false).Attach(query, a_field); } } } return(query); } }
public virtual void Defrag(ClassMetadata classMetadata, LatinStringIO sio, DefragmentContextImpl context, int classIndexID) { ReadName(sio, context.SourceBuffer()); ReadName(sio, context.TargetBuffer()); int metaClassID = 0; context.WriteInt(metaClassID); // ancestor ID context.CopyID(); context.WriteInt((classMetadata.HasClassIndex() ? IndexIDForWriting(classIndexID) : 0)); int aspectCount = context.ReadInt(); if (aspectCount > classMetadata.DeclaredAspectCount()) { throw new InvalidOperationException(); } IntByRef processedAspectCount = new IntByRef(0); classMetadata.TraverseDeclaredAspects(new _IProcedure4_136(this, processedAspectCount , aspectCount, classMetadata, sio, context)); }
public virtual MarshallingBuffer CheckBlockAlignment(MarshallingContext context, MarshallingBuffer precedingBuffer, IntByRef precedingLength) { _lastOffSet = Offset(); if (DoBlockAlign()) { precedingBuffer.BlockAlign(context, precedingLength.value); } if (precedingBuffer != null) { precedingLength.value += precedingBuffer.Length(); } precedingBuffer = this; if (_children != null) { IEnumerator i = new Iterator4Impl(_children); while (i.MoveNext()) { precedingBuffer = ((MarshallingBuffer)i.Current).CheckBlockAlignment(context, precedingBuffer , precedingLength); } } return(precedingBuffer); }
public _IVisitor4_40(IntByRef slotChangeCount) { this.slotChangeCount = slotChangeCount; }
private static IEnumerable <T> SubPartition <T>(IEnumerator <T> enumerator, int pageSize, IntByRef index) { for (; index.Value < pageSize; index.Value++) { yield return(enumerator.Current); if (!enumerator.MoveNext()) { yield break; } } }