//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: public void run(String[] args, java.io.PrintStream out) throws Exception public override void Run(string[] args, PrintStream @out) { long?[] longValues = new long?[args.Length]; for (int i = 0; i < args.Length; i++) { longValues[i] = Convert.ToInt64(args[i]); } MutableLong key = new MutableLong(); try { using (Writer <MutableLong, MutableLong> writer = outerInstance.tree.Writer()) { foreach (long?longValue in longValues) { key.Value = longValue; writer.Remove(key); } } } catch (IOException e) { throw new Exception(e); } outerInstance.maybePrint(); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test void shouldSortAndAddMultipleEntriesInLastBlock() throws java.io.IOException //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: internal virtual void ShouldSortAndAddMultipleEntriesInLastBlock() { // given TrackingMonitor monitor = new TrackingMonitor(); int blockSize = 1_000; IList <BlockEntry <MutableLong, MutableLong> > expected = new List <BlockEntry <MutableLong, MutableLong> >(); using (BlockStorage <MutableLong, MutableLong> storage = new BlockStorage <MutableLong, MutableLong>(_layout, heapBufferFactory(blockSize), _fileSystem, _file, monitor)) { // when for (int i = 0; i < 10; i++) { long keyNumber = Random.nextLong(10_000_000); MutableLong key = new MutableLong(keyNumber); MutableLong value = new MutableLong(i); storage.Add(key, value); expected.Add(new BlockEntry <>(key, value)); } storage.DoneAdding(); // then Sort(expected); AssertContents(_layout, storage, singletonList(expected)); } }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: private java.util.List<java.util.List<BlockEntry<org.apache.commons.lang3.mutable.MutableLong,org.apache.commons.lang3.mutable.MutableLong>>> addACoupleOfBlocksOfEntries(TrackingMonitor monitor, BlockStorage<org.apache.commons.lang3.mutable.MutableLong,org.apache.commons.lang3.mutable.MutableLong> storage, int numberOfBlocks) throws java.io.IOException private IList <IList <BlockEntry <MutableLong, MutableLong> > > AddACoupleOfBlocksOfEntries(TrackingMonitor monitor, BlockStorage <MutableLong, MutableLong> storage, int numberOfBlocks) { Debug.Assert(numberOfBlocks != 1); MutableLongSet uniqueKeys = LongSets.mutable.empty(); IList <IList <BlockEntry <MutableLong, MutableLong> > > expected = new List <IList <BlockEntry <MutableLong, MutableLong> > >(); IList <BlockEntry <MutableLong, MutableLong> > currentExpected = new List <BlockEntry <MutableLong, MutableLong> >(); long currentBlock = 0; while (monitor.BlockFlushedCallCount < numberOfBlocks - 1) { MutableLong key = UniqueKey(uniqueKeys); MutableLong value = new MutableLong(Random.nextLong(10_000_000)); storage.Add(key, value); if (monitor.BlockFlushedCallCount > currentBlock) { Sort(currentExpected); expected.Add(currentExpected); currentExpected = new List <BlockEntry <MutableLong, MutableLong> >(); currentBlock = monitor.BlockFlushedCallCount; } currentExpected.Add(new BlockEntry <>(key, value)); } storage.DoneAdding(); if (currentExpected.Count > 0) { expected.Add(currentExpected); } return(expected); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test void shouldReInitializeTreeLogicWithSameSplitRatioAsInitiallySet0() throws java.io.IOException //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: internal virtual void ShouldReInitializeTreeLogicWithSameSplitRatioAsInitiallySet0() { TreeHeightTracker treeHeightTracker = new TreeHeightTracker(this); try (GBPTree <MutableLong, MutableLong> gbpTree = new GBPTreeBuilder <>(_pageCache, Directory.file("index"), _layout) .with(treeHeightTracker).build(); Writer <MutableLong, MutableLong> writer = gbpTree.writer(0)) { MutableLong dontCare = _layout.value(0); long keySeed = 10_000; while (treeHeightTracker.TreeHeight < 5) { MutableLong key = _layout.key(keySeed--); writer.Put(key, dontCare); } // We now have a tree with height 6. // The leftmost node on all levels should have only a single key. KeyCountingVisitor keyCountingVisitor = new KeyCountingVisitor(this); gbpTree.visit(keyCountingVisitor); foreach (int?leftmostKeyCount in keyCountingVisitor.KeyCountOnLeftmostPerLevel) { assertEquals(1, leftmostKeyCount.Value); } } }
protected override long RunDisruptorPass() { MutableLong value = this.value; CountdownEvent latch = new CountdownEvent(1); long expectedCount = ringBuffer.GetMinimumGatingSequence() + ITERATIONS; handler.reset(latch, expectedCount); var start = Stopwatch.StartNew(); RingBuffer <ValueEvent> rb = ringBuffer; for (long l = 0; l < ITERATIONS; l++) { value.Value = l; rb.PublishEvent(Translator.INSTANCE, value); } latch.Wait(); long opsPerSecond = (ITERATIONS * 1000L) / (start.ElapsedMilliseconds); waitForEventProcessorSequence(expectedCount); PerfTestUtil.failIfNot(expectedResult, handler.Value); return(opsPerSecond); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test void shouldReInitializeTreeLogicWithSameSplitRatioAsInitiallySet1() throws java.io.IOException //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: internal virtual void ShouldReInitializeTreeLogicWithSameSplitRatioAsInitiallySet1() { TreeHeightTracker treeHeightTracker = new TreeHeightTracker(this); try (GBPTree <MutableLong, MutableLong> gbpTree = new GBPTreeBuilder <>(_pageCache, Directory.file("index"), _layout) .with(treeHeightTracker).build(); Writer <MutableLong, MutableLong> writer = gbpTree.writer(1)) { MutableLong dontCare = _layout.value(0); long keySeed = 0; while (treeHeightTracker.TreeHeight < 5) { MutableLong key = _layout.key(keySeed++); writer.Put(key, dontCare); } // We now have a tree with height 6. // The rightmost node on all levels should have either one or zero key (zero for internal nodes). KeyCountingVisitor keyCountingVisitor = new KeyCountingVisitor(this); gbpTree.visit(keyCountingVisitor); foreach (int?rightmostKeyCount in keyCountingVisitor.KeyCountOnRightmostPerLevel) { assertTrue(rightmostKeyCount == 0 || rightmostKeyCount == 1); } } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test void shouldSearchAndFindOnRandomData() internal virtual void ShouldSearchAndFindOnRandomData() { // GIVEN a leaf node with random, although sorted (as of course it must be to binary-search), data _node.initializeLeaf(_cursor, STABLE_GENERATION, UNSTABLE_GENERATION); IList <MutableLong> keys = new List <MutableLong>(); int currentKey = _random.Next(10_000); MutableLong key = _layout.newKey(); int keyCount = 0; while (true) { MutableLong expectedKey = _layout.newKey(); key.Value = currentKey; if (_node.leafOverflow(_cursor, keyCount, key, _dummyValue) != NO) { break; } _layout.copyKey(key, expectedKey); keys.Insert(keyCount, expectedKey); _node.insertKeyValueAt(_cursor, key, _dummyValue, keyCount, keyCount); currentKey += _random.Next(100) + 10; keyCount++; } TreeNode.SetKeyCount(_cursor, keyCount); // WHEN searching for random keys within that general range MutableLong searchKey = _layout.newKey(); for (int i = 0; i < 1_000; i++) { searchKey.Value = _random.Next(currentKey + 10); int searchResult = search(_cursor, _node, LEAF, searchKey, _readKey, keyCount); // THEN position should be as expected bool exists = contains(keys, searchKey, _layout); int position = KeySearch.PositionOf(searchResult); assertEquals(exists, KeySearch.IsHit(searchResult)); if (_layout.Compare(searchKey, keys[0]) <= 0) { // Our search key was lower than any of our keys, expect 0 assertEquals(0, position); } else { // step backwards through our expected keys and see where it should fit, assert that fact bool found = false; for (int j = keyCount - 1; j >= 0; j--) { if (_layout.Compare(searchKey, keys[j]) > 0) { assertEquals(j + 1, position); found = true; break; } } assertTrue(found); } } }
private long ManuallyCountTotalMappedFileSize(File dbDir) { MutableLong result = new MutableLong(); NativeIndexFileFilter nativeIndexFilter = new NativeIndexFileFilter(dbDir); ManuallyCountTotalMappedFileSize(dbDir, result, nativeIndexFilter); return(result.Value); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void testRangeMatchInOrderOnRandomValues() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void TestRangeMatchInOrderOnRandomValues() { Assume.assumeTrue("Assume support for granular composite queries", TestSuite.supportsGranularCompositeQueries()); // given ValueType[] types = RandomSetOfSupportedAndSortableTypes(); ISet <Value> uniqueValues = new HashSet <Value>(); SortedSet <ValueAndId> sortedValues = new SortedSet <ValueAndId>((v1, v2) => Values.COMPARATOR.Compare(v1.value, v2.value)); MutableLong nextId = new MutableLong(); // A couple of rounds of updates followed by lots of range verifications for (int i = 0; i < 5; i++) { //JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET: //ORIGINAL LINE: java.util.List<IndexEntryUpdate<?>> updates = new java.util.ArrayList<>(); IList <IndexEntryUpdate <object> > updates = new List <IndexEntryUpdate <object> >(); if (i == 0) { // The initial batch of data can simply be additions updates = GenerateUpdatesFromValues(GenerateValuesFromType(types, uniqueValues, 20_000), nextId); sortedValues.addAll(updates.Select(u => new ValueAndId(u.values()[0], u.EntityId)).ToList()); } else { // Then do all sorts of updates for (int j = 0; j < 1_000; j++) { int type = Random.intBetween(0, 2); if (type == 0) { // add Value value = GenerateUniqueRandomValue(types, uniqueValues); long id = nextId.AndIncrement; sortedValues.Add(new ValueAndId(value, id)); updates.Add(add(id, Descriptor.schema(), value)); } else if (type == 1) { // update ValueAndId existing = Random.among(sortedValues.toArray(new ValueAndId[0])); sortedValues.remove(existing); Value newValue = GenerateUniqueRandomValue(types, uniqueValues); uniqueValues.remove(existing.Value); sortedValues.Add(new ValueAndId(newValue, existing.Id)); updates.Add(change(existing.Id, Descriptor.schema(), existing.Value, newValue)); } else { // remove ValueAndId existing = Random.among(sortedValues.toArray(new ValueAndId[0])); sortedValues.remove(existing); uniqueValues.remove(existing.Value); updates.Add(remove(existing.Id, Descriptor.schema(), existing.Value)); } } } UpdateAndCommit(updates); VerifyRandomRanges(types, sortedValues); } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldReuseIdsInCluster() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldReuseIdsInCluster() { _cluster = ClusterRule.startCluster(); //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final org.apache.commons.lang3.mutable.MutableLong first = new org.apache.commons.lang3.mutable.MutableLong(); MutableLong first = new MutableLong(); //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final org.apache.commons.lang3.mutable.MutableLong second = new org.apache.commons.lang3.mutable.MutableLong(); MutableLong second = new MutableLong(); CoreClusterMember leader1 = CreateThreeNodes(_cluster, first, second); CoreClusterMember leader2 = RemoveTwoNodes(_cluster, first, second); assumeTrue(leader1 != null && leader1.Equals(leader2)); // Force maintenance on leader IdMaintenanceOnLeader(leader1); IdGeneratorFactory idGeneratorFactory = ResolveDependency(leader1, typeof(IdGeneratorFactory)); //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final org.neo4j.kernel.impl.store.id.IdGenerator idGenerator = idGeneratorFactory.get(org.neo4j.kernel.impl.store.id.IdType.NODE); IdGenerator idGenerator = idGeneratorFactory.Get(IdType.NODE); assertEquals(2, idGenerator.DefragCount); //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final org.apache.commons.lang3.mutable.MutableLong node1id = new org.apache.commons.lang3.mutable.MutableLong(); MutableLong node1id = new MutableLong(); //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final org.apache.commons.lang3.mutable.MutableLong node2id = new org.apache.commons.lang3.mutable.MutableLong(); MutableLong node2id = new MutableLong(); //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final org.apache.commons.lang3.mutable.MutableLong node3id = new org.apache.commons.lang3.mutable.MutableLong(); MutableLong node3id = new MutableLong(); CoreClusterMember clusterMember = _cluster.coreTx((db, tx) => { Node node1 = Db.createNode(); Node node2 = Db.createNode(); Node node3 = Db.createNode(); node1id.Value = node1.Id; node2id.Value = node2.Id; node3id.Value = node3.Id; tx.success(); }); assumeTrue(leader1.Equals(clusterMember)); assertEquals(first.longValue(), node1id.longValue()); assertEquals(second.longValue(), node2id.longValue()); assertEquals(idGenerator.HighestPossibleIdInUse, node3id.longValue()); }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: private org.neo4j.causalclustering.discovery.CoreClusterMember removeTwoNodes(org.neo4j.causalclustering.discovery.Cluster<?> cluster, org.apache.commons.lang3.mutable.MutableLong first, org.apache.commons.lang3.mutable.MutableLong second) throws Exception private CoreClusterMember RemoveTwoNodes <T1>(Cluster <T1> cluster, MutableLong first, MutableLong second) { return(cluster.CoreTx((db, tx) => { Node node1 = Db.getNodeById(first.longValue()); node1.delete(); Db.getNodeById(second.longValue()).delete(); tx.success(); })); }
private void FullLeafWithUniqueKeys() { // [2,4,8,16,32,64,128,512,1024,2048] _node.initializeLeaf(_cursor, STABLE_GENERATION, UNSTABLE_GENERATION); MutableLong key = _layout.newKey(); for (int i = 0; i < KEY_COUNT; i++) { key.Value = key(i); _node.insertKeyValueAt(_cursor, key, _dummyValue, i, i); } TreeNode.SetKeyCount(_cursor, KEY_COUNT); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void newLeaderShouldNotReuseIds() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void NewLeaderShouldNotReuseIds() { _cluster = ClusterRule.startCluster(); //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final org.apache.commons.lang3.mutable.MutableLong first = new org.apache.commons.lang3.mutable.MutableLong(); MutableLong first = new MutableLong(); //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final org.apache.commons.lang3.mutable.MutableLong second = new org.apache.commons.lang3.mutable.MutableLong(); MutableLong second = new MutableLong(); CoreClusterMember creationLeader = CreateThreeNodes(_cluster, first, second); CoreClusterMember deletionLeader = RemoveTwoNodes(_cluster, first, second); // the following assumption is not sufficient for the subsequent assertions, since leadership is a volatile state assumeTrue(creationLeader != null && creationLeader.Equals(deletionLeader)); IdMaintenanceOnLeader(creationLeader); IdGeneratorFactory idGeneratorFactory = ResolveDependency(creationLeader, typeof(IdGeneratorFactory)); IdGenerator creationLeaderIdGenerator = idGeneratorFactory.Get(IdType.NODE); assertEquals(2, creationLeaderIdGenerator.DefragCount); // Force leader switch _cluster.removeCoreMemberWithServerId(creationLeader.ServerId()); // waiting for new leader CoreClusterMember newLeader = _cluster.awaitLeader(); assertNotSame(creationLeader.ServerId(), newLeader.ServerId()); IdMaintenanceOnLeader(newLeader); IdGeneratorFactory newLeaderIdGeneratorFactory = ResolveDependency(newLeader, typeof(IdGeneratorFactory)); //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final org.neo4j.kernel.impl.store.id.IdGenerator idGenerator = newLeaderIdGeneratorFactory.get(org.neo4j.kernel.impl.store.id.IdType.NODE); IdGenerator idGenerator = newLeaderIdGeneratorFactory.Get(IdType.NODE); assertEquals(0, idGenerator.DefragCount); CoreClusterMember newCreationLeader = _cluster.coreTx((db, tx) => { Node node = Db.createNode(); assertEquals(idGenerator.HighestPossibleIdInUse, node.Id); tx.success(); }); assumeTrue(newLeader.Equals(newCreationLeader)); }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: private java.util.List<BlockEntry<org.apache.commons.lang3.mutable.MutableLong,org.apache.commons.lang3.mutable.MutableLong>> addEntries(BlockStorage<org.apache.commons.lang3.mutable.MutableLong,org.apache.commons.lang3.mutable.MutableLong> storage, int numberOfEntries) throws java.io.IOException private IList <BlockEntry <MutableLong, MutableLong> > AddEntries(BlockStorage <MutableLong, MutableLong> storage, int numberOfEntries) { MutableLongSet uniqueKeys = LongSets.mutable.empty(); IList <BlockEntry <MutableLong, MutableLong> > entries = new List <BlockEntry <MutableLong, MutableLong> >(); for (int i = 0; i < numberOfEntries; i++) { MutableLong key = UniqueKey(uniqueKeys); MutableLong value = new MutableLong(Random.nextLong(10_000_000)); storage.Add(key, value); entries.Add(new BlockEntry <>(key, value)); } Sort(entries); return(entries); }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: private org.neo4j.causalclustering.discovery.CoreClusterMember createThreeNodes(org.neo4j.causalclustering.discovery.Cluster<?> cluster, org.apache.commons.lang3.mutable.MutableLong first, org.apache.commons.lang3.mutable.MutableLong second) throws Exception private CoreClusterMember CreateThreeNodes <T1>(Cluster <T1> cluster, MutableLong first, MutableLong second) { return(cluster.CoreTx((db, tx) => { Node node1 = Db.createNode(); first.Value = node1.Id; Node node2 = Db.createNode(); second.Value = node2.Id; Db.createNode(); tx.success(); })); }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: private org.neo4j.unsafe.impl.batchimport.input.Input generateData() throws java.io.IOException private Input GenerateData() { IList <DataFactory> nodeData = new List <DataFactory>(); MutableLong start = new MutableLong(); Groups groups = new Groups(); nodeData.Add(GenerateData(defaultFormatNodeFileHeader(), start, NODE_COUNT / 3, NODE_COUNT, ":ID", "nodes-1.csv", groups)); nodeData.Add(GenerateData(defaultFormatNodeFileHeader(), start, NODE_COUNT / 3, NODE_COUNT, ":ID,:LABEL,name:String,yearOfBirth:int", "nodes-2.csv", groups)); nodeData.Add(GenerateData(defaultFormatNodeFileHeader(), start, NODE_COUNT - start.longValue(), NODE_COUNT, ":ID,name:String,yearOfBirth:int,other", "nodes-3.csv", groups)); IList <DataFactory> relationshipData = new List <DataFactory>(); start.Value = 0; relationshipData.Add(GenerateData(defaultFormatRelationshipFileHeader(), start, RELATIONSHIP_COUNT / 2, NODE_COUNT, ":START_ID,:TYPE,:END_ID", "relationships-1.csv", groups)); relationshipData.Add(GenerateData(defaultFormatRelationshipFileHeader(), start, RELATIONSHIP_COUNT - start.longValue(), NODE_COUNT, ":START_ID,:TYPE,:END_ID,prop1,prop2", "relationships-2.csv", groups)); return(new CsvInput(nodeData, defaultFormatNodeFileHeader(), relationshipData, defaultFormatRelationshipFileHeader(), IdType.Integer, COMMAS, Collector.EMPTY, CsvInput.NoMonitor, groups)); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test void shouldReturnCorrectIndexesForKeysInBetweenExisting() internal virtual void ShouldReturnCorrectIndexesForKeysInBetweenExisting() { // GIVEN FullLeafWithUniqueKeys(); // WHEN MutableLong key = _layout.newKey(); for (int i = 1; i < KEY_COUNT - 1; i++) { key.Value = key(i) - 1; int result = search(_cursor, _node, LEAF, key, _readKey, KEY_COUNT); // THEN AssertSearchResult(false, i, result); } }
/* Below are more thorough tests that look at all keys in node */ //JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test void shouldFindExistingKey() internal virtual void ShouldFindExistingKey() { // GIVEN FullLeafWithUniqueKeys(); // WHEN MutableLong key = _layout.newKey(); for (int i = 0; i < KEY_COUNT; i++) { key.Value = key(i); int result = search(_cursor, _node, LEAF, key, _readKey, KEY_COUNT); // THEN AssertSearchResult(true, i, result); } }
private void ManuallyCountTotalMappedFileSize(File dir, MutableLong result, NativeIndexFileFilter nativeIndexFilter) { //JAVA TO C# CONVERTER TODO TASK: Method reference arbitrary object instance method syntax is not converted by Java to C# Converter: ISet <string> storeFiles = Stream.of(StoreType.values()).filter(StoreType::isRecordStore).map(type => type.DatabaseFile.Name).collect(Collectors.toSet()); foreach (File file in dir.listFiles()) { if (file.Directory) { ManuallyCountTotalMappedFileSize(file, result, nativeIndexFilter); } else if (storeFiles.Contains(file.Name) || file.Name.Equals(DatabaseFile.LABEL_SCAN_STORE.Name) || nativeIndexFilter.Accept(file)) { result.add(file.length()); } } }
private IList <BlockEntry <MutableLong, MutableLong> > SomeBlockEntries(ISet <MutableLong> uniqueKeys) { IList <BlockEntry <MutableLong, MutableLong> > entries = new List <BlockEntry <MutableLong, MutableLong> >(); int size = Rnd.Next(10); for (int i = 0; i < size; i++) { MutableLong key; do { key = _layout.key(Rnd.nextLong(10_000)); } while (!uniqueKeys.Add(key)); MutableLong value = _layout.value(Rnd.nextLong(10_000)); entries.Add(new BlockEntry <>(key, value)); } entries.sort(_blockEntryComparator); return(entries); }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: private static long[] calculatePageCacheFileSize(org.neo4j.io.layout.DatabaseLayout databaseLayout) throws java.io.IOException private static long[] CalculatePageCacheFileSize(DatabaseLayout databaseLayout) { MutableLong pageCacheTotal = new MutableLong(); MutableLong luceneTotal = new MutableLong(); foreach (StoreType storeType in StoreType.values()) { if (storeType.RecordStore) { long length = databaseLayout.file(storeType.DatabaseFile).mapToLong(File.length).sum(); pageCacheTotal.add(length); } } Files.walkFileTree(IndexDirectoryStructure.baseSchemaIndexFolder(databaseLayout.DatabaseDirectory()).toPath(), new SimpleFileVisitorAnonymousInnerClass(pageCacheTotal, luceneTotal)); pageCacheTotal.add(databaseLayout.LabelScanStore().length()); return(new long[] { pageCacheTotal.longValue(), luceneTotal.longValue() }); }
/// <summary>Run the pipeline on an input annotation.</summary> /// <remarks> /// Run the pipeline on an input annotation. /// The annotation is modified in place. /// </remarks> /// <param name="annotation">The input annotation, usually a raw document</param> public virtual void Annotate(Annotation annotation) { IEnumerator <MutableLong> it = accumulatedTime.GetEnumerator(); Timing t = new Timing(); foreach (IAnnotator annotator in annotators) { if (Thread.Interrupted()) { // Allow interrupting throw new RuntimeInterruptedException(); } t.Start(); annotator.Annotate(annotation); long elapsed = t.Stop(); MutableLong m = it.Current; m.IncValue(elapsed); } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test void shouldReadWriteSingleEntry() internal virtual void ShouldReadWriteSingleEntry() { // given MutableLong writeKey = _layout.key(Rnd.nextLong()); MutableLong writeValue = _layout.value(Rnd.nextLong()); int offset = _pageCursor.Offset; BlockEntry.Write(_pageCursor, _layout, writeKey, writeValue); // when MutableLong readKey = _layout.newKey(); MutableLong readValue = _layout.newValue(); _pageCursor.Offset = offset; BlockEntry.Read(_pageCursor, _layout, readKey, readValue); // then assertEquals(0, _layout.Compare(writeKey, readKey)); assertEquals(0, _layout.Compare(writeValue, readValue)); }
/// <summary> /// Return a String that gives detailed human-readable information about /// how much time was spent by each annotator and by the entire annotation /// pipeline. /// </summary> /// <remarks> /// Return a String that gives detailed human-readable information about /// how much time was spent by each annotator and by the entire annotation /// pipeline. This String includes newline characters but does not end /// with one, and so it is suitable to be printed out with a /// <c>println()</c> /// . /// </remarks> /// <returns>Human readable information on time spent in processing.</returns> public virtual string TimingInformation() { StringBuilder sb = new StringBuilder(); sb.Append("Annotation pipeline timing information:"); sb.Append(IOUtils.eolChar); IEnumerator <MutableLong> it = accumulatedTime.GetEnumerator(); long total = 0; foreach (IAnnotator annotator in annotators) { MutableLong m = it.Current; sb.Append(StringUtils.GetShortClassName(annotator)).Append(": "); sb.Append(Timing.ToSecondsString(m)).Append(" sec."); sb.Append(IOUtils.eolChar); total += m; } sb.Append("TOTAL: ").Append(Timing.ToSecondsString(total)).Append(" sec."); return(sb.ToString()); }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: private DataFactory generateData(Header.Factory factory, org.apache.commons.lang3.mutable.MutableLong start, long count, long nodeCount, String headerString, String fileName, org.neo4j.unsafe.impl.batchimport.input.Groups groups) throws java.io.IOException private DataFactory GenerateData(Header.Factory factory, MutableLong start, long count, long nodeCount, string headerString, string fileName, Groups groups) { File file = Directory.file(fileName); Header header = factory.Create(charSeeker(wrap(headerString), COMMAS, false), COMMAS, IdType.Integer, groups); Distribution <string> distribution = new Distribution <string>(new string[] { "Token" }); Deserialization <string> deserialization = new StringDeserialization(COMMAS); using (PrintWriter @out = new PrintWriter(new StreamWriter(file)), RandomEntityDataGenerator generator = new RandomEntityDataGenerator(nodeCount, count, toIntExact(count), Random.seed(), start.longValue(), header, distribution, distribution, 0, 0), InputChunk chunk = generator.NewChunk(), InputEntity entity = new InputEntity()) { @out.println(headerString); while (generator.Next(chunk)) { while (chunk.Next(entity)) { @out.println(convert(entity, deserialization, header)); } } } start.add(count); return(DataFactories.Data(InputEntityDecorators.NO_DECORATOR, Charsets.UTF_8, file)); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test void shouldAddSingleEntryInLastBlock() throws java.io.IOException //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: internal virtual void ShouldAddSingleEntryInLastBlock() { // given TrackingMonitor monitor = new TrackingMonitor(); int blockSize = 100; MutableLong key = new MutableLong(10); MutableLong value = new MutableLong(20); using (BlockStorage <MutableLong, MutableLong> storage = new BlockStorage <MutableLong, MutableLong>(_layout, heapBufferFactory(blockSize), _fileSystem, _file, monitor)) { // when storage.Add(key, value); storage.DoneAdding(); // then assertEquals(1, monitor.BlockFlushedCallCount); assertEquals(1, monitor.LastKeyCount); assertEquals(BlockStorage.BlockHeaderSize + monitor.TotalEntrySize, monitor.LastNumberOfBytes); assertEquals(blockSize, monitor.LastPositionAfterFlush); assertThat(monitor.LastNumberOfBytes, lessThan(blockSize)); AssertContents(_layout, storage, singletonList(singletonList(new BlockEntry <>(key, value)))); } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void reusePreviouslyFreedIds() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ReusePreviouslyFreedIds() { _cluster = ClusterRule.startCluster(); //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final org.apache.commons.lang3.mutable.MutableLong first = new org.apache.commons.lang3.mutable.MutableLong(); MutableLong first = new MutableLong(); //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final org.apache.commons.lang3.mutable.MutableLong second = new org.apache.commons.lang3.mutable.MutableLong(); MutableLong second = new MutableLong(); CoreClusterMember creationLeader = CreateThreeNodes(_cluster, first, second); CoreClusterMember deletionLeader = RemoveTwoNodes(_cluster, first, second); assumeTrue(creationLeader != null && creationLeader.Equals(deletionLeader)); IdGeneratorFactory idGeneratorFactory = ResolveDependency(creationLeader, typeof(IdGeneratorFactory)); IdMaintenanceOnLeader(creationLeader); IdGenerator creationLeaderIdGenerator = idGeneratorFactory.Get(IdType.NODE); assertEquals(2, creationLeaderIdGenerator.DefragCount); // Restart and re-elect first leader _cluster.removeCoreMemberWithServerId(creationLeader.ServerId()); _cluster.addCoreMemberWithId(creationLeader.ServerId()).start(); CoreClusterMember leader = _cluster.awaitLeader(); while (leader.ServerId() != creationLeader.ServerId()) { _cluster.removeCoreMemberWithServerId(leader.ServerId()); _cluster.addCoreMemberWithId(leader.ServerId()).start(); leader = _cluster.awaitLeader(); } IdMaintenanceOnLeader(leader); IdGeneratorFactory leaderIdGeneratorFactory = ResolveDependency(leader, typeof(IdGeneratorFactory)); creationLeaderIdGenerator = leaderIdGeneratorFactory.Get(IdType.NODE); assertEquals(2, creationLeaderIdGenerator.DefragCount); //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final org.apache.commons.lang3.mutable.MutableLong node1id = new org.apache.commons.lang3.mutable.MutableLong(); MutableLong node1id = new MutableLong(); //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final org.apache.commons.lang3.mutable.MutableLong node2id = new org.apache.commons.lang3.mutable.MutableLong(); MutableLong node2id = new MutableLong(); CoreClusterMember reuseLeader = _cluster.coreTx((db, tx) => { Node node1 = Db.createNode(); Node node2 = Db.createNode(); node1id.Value = node1.Id; node2id.Value = node2.Id; tx.success(); }); assumeTrue(leader.Equals(reuseLeader)); assertEquals(first.longValue(), node1id.longValue()); assertEquals(second.longValue(), node2id.longValue()); }
private void Put( Writer<MutableLong, MutableLong> writer, long key ) { MutableLong insertKey = Layout.key( key ); MutableLong insertValue = Layout.value( Value( key ) ); writer.Put( insertKey, insertValue ); }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: public void verifyContent(java.io.File storeFile) throws java.io.IOException public override void VerifyContent( File storeFile ) { PageCache pageCache = _pageCacheRule.getPageCache( GlobalFs.get() ); using ( GBPTree<MutableLong, MutableLong> tree = ( new GBPTreeBuilder<MutableLong, MutableLong>( pageCache, storeFile, Layout ) ).build() ) { { // WHEN reading from the tree // THEN initial keys should be there tree.ConsistencyCheck(); using ( RawCursor<Hit<MutableLong, MutableLong>, IOException> cursor = tree.Seek( Layout.key( 0 ), Layout.key( long.MaxValue ) ) ) { foreach ( long? expectedKey in _initialKeys ) { AssertHit( cursor, expectedKey ); } assertFalse( cursor.Next() ); } } { // WHEN writing more to the tree // THEN we should not see any format conflicts using ( Writer<MutableLong, MutableLong> writer = tree.Writer() ) { while ( _keysToAdd.Count > 0 ) { int next = _random.Next( _keysToAdd.Count ); Put( writer, _keysToAdd[next] ); _keysToAdd.RemoveAt( next ); } } } { // WHEN reading from the tree again // THEN all keys including newly added should be there tree.ConsistencyCheck(); using ( RawCursor<Hit<MutableLong, MutableLong>, IOException> cursor = tree.Seek( Layout.key( 0 ), Layout.key( 2 * INITIAL_KEY_COUNT ) ) ) { foreach ( long? expectedKey in _allKeys ) { AssertHit( cursor, expectedKey ); } assertFalse( cursor.Next() ); } } { // WHEN randomly removing half of tree content // THEN we should not see any format conflicts using ( Writer<MutableLong, MutableLong> writer = tree.Writer() ) { int size = _allKeys.Count; while ( _allKeys.Count > size / 2 ) { int next = _random.Next( _allKeys.Count ); MutableLong key = Layout.key( _allKeys[next] ); writer.Remove( key ); _allKeys.RemoveAt( next ); } } } { // WHEN reading from the tree after remove // THEN we should see everything that is left in the tree tree.ConsistencyCheck(); using ( RawCursor<Hit<MutableLong, MutableLong>, IOException> cursor = tree.Seek( Layout.key( 0 ), Layout.key( 2 * INITIAL_KEY_COUNT ) ) ) { foreach ( long? expectedKey in _allKeys ) { AssertHit( cursor, expectedKey ); } assertFalse( cursor.Next() ); } } } }
//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET: //ORIGINAL LINE: private java.util.List<IndexEntryUpdate<?>> generateUpdatesFromValues(java.util.List<org.neo4j.values.storable.ValueTuple> values, org.apache.commons.lang3.mutable.MutableLong nextId) internal virtual IList <IndexEntryUpdate <object> > GenerateUpdatesFromValues(IList <ValueTuple> values, MutableLong nextId) { //JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET: //ORIGINAL LINE: java.util.List<IndexEntryUpdate<?>> updates = new java.util.ArrayList<>(); IList <IndexEntryUpdate <object> > updates = new List <IndexEntryUpdate <object> >(); foreach (ValueTuple value in values) { updates.Add(add(nextId.AndIncrement, Descriptor.schema(), (object[])value.Values)); } return(updates); }