public virtual void coverage() { MapStream.empty().filter(e => false).distinct().sorted().sorted((e1, e2) => 0).peek(e => e.ToString()).limit(0).skip(0).sequential().parallel().unordered().onClose(() => Console.WriteLine()).close(); MapStream.empty().anyMatch(e => true); MapStream.empty().allMatch(e => true); MapStream.empty().noneMatch(e => true); MapStream.empty().count(); MapStream.empty().findAny(); MapStream.empty().findFirst(); MapStream.empty().max((e1, e2) => 0); MapStream.empty().min((e1, e2) => 0); MapStream.empty().GetEnumerator(); MapStream.empty().spliterator(); MapStream.empty().Parallel; MapStream.empty().map(e => e); MapStream.empty().mapToInt(e => 0); MapStream.empty().mapToLong(e => 0); MapStream.empty().mapToDouble(e => 0); MapStream.empty().flatMap(e => Stream.empty()); MapStream.empty().flatMapToDouble(e => DoubleStream.empty()); MapStream.empty().flatMapToInt(e => IntStream.empty()); MapStream.empty().flatMapToLong(e => LongStream.empty()); MapStream.empty().collect(toList()); MapStream.empty().collect(() => null, (o, e) => Console.WriteLine(), (o1, o2) => Console.WriteLine()); MapStream.empty().toArray(); MapStream.empty().toArray(i => new object[0]); MapStream.empty().forEach(e => Console.WriteLine()); MapStream.empty().forEachOrdered(e => Console.WriteLine()); MapStream.empty().reduce(new AbstractMap.SimpleEntry <>(null, null), (o1, o2) => null); MapStream.empty().reduce((o1, o2) => null); MapStream.empty().reduce(null, (o, e) => null, (o1, o2) => null); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void pullRotatesWhenThresholdCrossedAndExplicitlySet() throws java.io.IOException //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void PullRotatesWhenThresholdCrossedAndExplicitlySet() { // given Config config = Config.defaults(); config.Augment(GraphDatabaseSettings.logical_log_rotation_threshold, "1M"); // 1 mebibyte // and Org.Neo4j.Storageengine.Api.StoreId storeId = SimulateStoreCopy(); // and long fromTxId = BASE_TX_ID; TransactionLogCatchUpWriter subject = new TransactionLogCatchUpWriter(_databaseLayout, _fs, _pageCache, config, NullLogProvider.Instance, fromTxId, PartOfStoreCopyConflict, false, true); // when a bunch of transactions received LongStream.range(fromTxId, _manyTransactions).mapToObj(TransactionLogCatchUpWriterTest.tx).map(tx => new TxPullResponse(ToCasualStoreId(storeId), tx)).forEach(subject.onTxReceived); subject.Close(); // then there was a rotation LogFilesBuilder logFilesBuilder = LogFilesBuilder.activeFilesBuilder(_databaseLayout, _fs, _pageCache); LogFiles logFiles = logFilesBuilder.Build(); assertNotEquals(logFiles.LowestLogVersion, logFiles.HighestLogVersion); VerifyTransactionsInLog(logFiles, fromTxId, _manyTransactions); VerifyCheckpointInLog(logFiles, PartOfStoreCopyConflict); }
private void RemoveOldNodes(LongStream idRange) { using (Transaction transaction = Database.beginTx()) { idRange.mapToObj(id => Database.getNodeById(id)).forEach(Node.delete); transaction.Success(); } }
private void UpdateOldNodes(LongStream idRange) { using (Transaction transaction = Database.beginTx()) { IList <Node> nodes = idRange.mapToObj(id => Database.getNodeById(id)).collect(Collectors.toList()); for (int i = 0; i < NUMBER_OF_INDEXES; i++) { string propertyName = PROPERTY_PREFIX + i; nodes.ForEach(node => node.setProperty(propertyName, RandomRule.nextLong())); } transaction.Success(); } }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: private static void transactions1M(org.neo4j.causalclustering.discovery.Cluster<?> cluster) throws Exception private static void Transactions1M <T1>(Cluster <T1> cluster) { int numberOfTransactions = 500; long sizeOfTransaction = (ByteUnit.mebiBytes(1) / numberOfTransactions) + 1; for (int txId = 0; txId < numberOfTransactions; txId++) { cluster.CoreTx((coreGraphDatabase, transaction) => { Node node = coreGraphDatabase.createNode(); string longString = LongStream.range(0, sizeOfTransaction).map(l => l % 10).mapToObj(long?.toString).collect(joining("")); node.setProperty("name", longString); coreGraphDatabase.createNode().createRelationshipTo(node, RelationshipType.withName("KNOWS")); transaction.success(); }); } }
private static void Transactions1M(GraphDatabaseService db) { int numberOfTransactions = 500; long sizeOfTransaction = (ByteUnit.mebiBytes(1) / numberOfTransactions) + 1; for (int txId = 0; txId < numberOfTransactions; txId++) { using (Transaction tx = Db.beginTx()) { Node node = Db.createNode(); string longString = LongStream.range(0, sizeOfTransaction).map(l => l % 10).mapToObj(long?.toString).collect(joining("")); node.SetProperty("name", longString); Db.createNode().createRelationshipTo(node, RelationshipType.withName("KNOWS")); tx.Success(); } } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test void shouldRegisterPeakMemoryUsage() throws Throwable //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: internal virtual void ShouldRegisterPeakMemoryUsage() { // given ThreadSafePeakMemoryAllocationTracker tracker = new ThreadSafePeakMemoryAllocationTracker(GlobalMemoryTracker.Instance); int threads = 200; long[] allocations = new long[threads]; ThreadLocalRandom random = ThreadLocalRandom.current(); long sum = 0; for (int i = 0; i < allocations.Length; i++) { allocations[i] = random.Next(1, 10_000); sum += allocations[i]; } // when Race race = new Race(); for (int i = 0; i < threads; i++) { int id = i; race.AddContestant(() => tracker.allocated(allocations[id])); } race.Go(); long peakAfterAllocation = tracker.PeakMemoryUsage(); LongStream.of(allocations).forEach(tracker.deallocated); long peakAfterDeallocation = tracker.PeakMemoryUsage(); LongStream.of(allocations).forEach(tracker.allocated); tracker.Allocated(10); // <-- 10 more than previous peak long peakAfterHigherReallocation = tracker.PeakMemoryUsage(); LongStream.of(allocations).forEach(tracker.deallocated); tracker.Deallocated(10); long peakAfterFinalDeallocation = tracker.PeakMemoryUsage(); // then assertEquals(sum, peakAfterAllocation); assertEquals(sum, peakAfterDeallocation); assertEquals(sum + 10, peakAfterHigherReallocation); assertEquals(sum + 10, peakAfterFinalDeallocation); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @SuppressWarnings("unchecked") public static java.util.stream.LongStream toLongStream(Object list) public static LongStream ToLongStream(object list) { if (list == null) { return(LongStream.empty()); } else if (list is SequenceValue) { throw new System.ArgumentException("Need to implement support for SequenceValue in CompiledConversionUtils.toLongStream"); } else if (list is System.Collections.IList) { return(((System.Collections.IList)list).Select(n => (( Number )n).longValue())); } else if (list.GetType().IsAssignableFrom(typeof(object[]))) { return(java.util.( object[] )list.Select(n => (( Number )n).longValue())); } else if (list is sbyte[]) { sbyte[] array = ( sbyte[] )list; return(IntStream.range(0, array.Length).mapToLong(i => array[i])); } else if (list is short[]) { short[] array = ( short[] )list; return(IntStream.range(0, array.Length).mapToLong(i => array[i])); } else if (list is int[]) { return(IntStream.of(( int[] )list).mapToLong(i => i)); } else if (list is long[]) { return(LongStream.of(( long[] )list)); } //JAVA TO C# CONVERTER WARNING: The .NET Type.FullName property will not always yield results identical to the Java Class.getName method: throw new System.ArgumentException(format("Can not be converted to stream: %s", list.GetType().FullName)); }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: void prepareIndex(GBPTree<KEY,VALUE> index, java.util.TreeSet<long> dataInIndex, java.util.Queue<long> toRemove, java.util.Queue<long> toAdd, java.util.Random random) throws java.io.IOException internal virtual void PrepareIndex(GBPTree <KEY, VALUE> index, SortedSet <long> dataInIndex, LinkedList <long> toRemove, LinkedList <long> toAdd, Random random) { IList <long> fullRange = LongStream.range(MinRange, MaxRange).boxed().collect(Collectors.toList()); IList <long> rangeOutOfOrder = ShuffleToNewList(fullRange, random); using (Writer <KEY, VALUE> writer = index.Writer()) { foreach (long?key in rangeOutOfOrder) { bool addForRemoval = random.NextDouble() > WritePercentage; if (addForRemoval) { writer.Put(key(key), outerInstance.value(key.Value)); dataInIndex.Add(key); toRemove.AddLast(key); } else { toAdd.AddLast(key); } } } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void concurrentLuceneIndexSnapshotUseDifferentSnapshots() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ConcurrentLuceneIndexSnapshotUseDifferentSnapshots() { Label label = Label.label("testLabel"); Database.withSetting(GraphDatabaseSettings.default_schema_provider, GraphDatabaseSettings.SchemaIndex.NATIVE20.providerName()); PrepareDatabase(label); ForceCheckpoint(_checkPointer); ResourceIterator <File> firstCheckpointSnapshot = _indexingService.snapshotIndexFiles(); GenerateData(label); RemoveOldNodes(LongStream.range(1, 20)); UpdateOldNodes(LongStream.range(30, 40)); ForceCheckpoint(_checkPointer); ResourceIterator <File> secondCheckpointSnapshot = _indexingService.snapshotIndexFiles(); GenerateData(label); RemoveOldNodes(LongStream.range(50, 60)); UpdateOldNodes(LongStream.range(70, 80)); ForceCheckpoint(_checkPointer); ResourceIterator <File> thirdCheckpointSnapshot = _indexingService.snapshotIndexFiles(); ISet <string> firstSnapshotFileNames = GetFileNames(firstCheckpointSnapshot); ISet <string> secondSnapshotFileNames = GetFileNames(secondCheckpointSnapshot); ISet <string> thirdSnapshotFileNames = GetFileNames(thirdCheckpointSnapshot); CompareSnapshotFiles(firstSnapshotFileNames, secondSnapshotFileNames, _fileSystem); CompareSnapshotFiles(secondSnapshotFileNames, thirdSnapshotFileNames, _fileSystem); CompareSnapshotFiles(thirdSnapshotFileNames, firstSnapshotFileNames, _fileSystem); firstCheckpointSnapshot.Close(); secondCheckpointSnapshot.Close(); thirdCheckpointSnapshot.Close(); }
public PrimitiveNodeStream(LongStream inner) : base(inner) { }
public static PrimitiveRelationshipStream Of(long[] array) { return(new PrimitiveRelationshipStream(LongStream.of(array))); }
public PrimitiveRelationshipStream(LongStream inner) : base(inner) { }
public PrimitiveEntityStream(LongStream inner) { this.Inner = inner; }
private StorageRelationshipTraversalCursor StoreCursor(params long[] ids) { //JAVA TO C# CONVERTER TODO TASK: Method reference constructor syntax is not converted by Java to C# Converter: return(StoreCursor(LongStream.of(ids).mapToObj(id => Rel(id, -1L, -1L, -1)).toArray(Rel[] ::new))); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void mustDeleteLogFilesThatCanBePruned() public virtual void MustDeleteLogFilesThatCanBePruned() { when(_factory.strategyFromConfigValue(eq(_fs), eq(_logFiles), eq(_clock), anyString())).thenReturn(upTo => LongStream.range(3, upTo)); LogPruning pruning = new LogPruningImpl(_fs, _logFiles, _logProvider, _factory, _clock, _config); pruning.PruneLogs(5); InOrder order = inOrder(_fs); order.verify(_fs).deleteFile(new File("3")); order.verify(_fs).deleteFile(new File("4")); // Log file 5 is not deleted; it's the lowest version expected to remain after pruning. verifyNoMoreInteractions(_fs); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void mustHaveLogFilesToPruneIfStrategyFindsFiles() public virtual void MustHaveLogFilesToPruneIfStrategyFindsFiles() { when(_factory.strategyFromConfigValue(eq(_fs), eq(_logFiles), eq(_clock), anyString())).thenReturn(upTo => LongStream.range(3, upTo)); when(_logFiles.HighestLogVersion).thenReturn(4L); LogPruning pruning = new LogPruningImpl(_fs, _logFiles, _logProvider, _factory, _clock, _config); assertTrue(pruning.MightHaveLogsToPrune()); }
//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET: //ORIGINAL LINE: public static java.util.Set<?> toSet(Object value) public static ISet <object> ToSet(object value) { if (value == null || value == NO_VALUE) { return(Collections.emptySet()); } else if (value is SequenceValue) { SequenceValue sequenceValue = ( SequenceValue )value; IEnumerator <AnyValue> iterator = sequenceValue.GetEnumerator(); ISet <AnyValue> set; if (sequenceValue.IterationPreference() == RANDOM_ACCESS) { // If we have a random access sequence value length() should be cheap and we can optimize the initial capacity int length = sequenceValue.Length(); set = new HashSet <AnyValue>(length); for (int i = 0; i < length; i++) { set.Add(sequenceValue.Value(i)); } } else { set = new HashSet <AnyValue>(); while (iterator.MoveNext()) { AnyValue element = iterator.Current; set.Add(element); } } return(set); } //JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET: //ORIGINAL LINE: else if (value instanceof java.util.Collection<?>) else if (value is ICollection <object> ) { //JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET: //ORIGINAL LINE: return new java.util.HashSet<>((java.util.Collection<?>) value); return(new HashSet <object>((ICollection <object>)value)); } else if (value is LongStream) { LongStream stream = ( LongStream )value; return(stream.boxed().collect(Collectors.toSet())); } else if (value is IntStream) { IntStream stream = ( IntStream )value; return(stream.boxed().collect(Collectors.toSet())); } else if (value is DoubleStream) { DoubleStream stream = ( DoubleStream )value; return(stream.boxed().collect(Collectors.toSet())); } else if (value.GetType().IsArray) { int len = Array.getLength(value); HashSet <object> collection = new HashSet <object>(len); for (int i = 0; i < len; i++) { collection.Add(Array.get(value, i)); } return(collection); } throw new CypherTypeException("Don't know how to create a set out of " + value.GetType().Name, null); }
public static PrimitiveNodeStream Of(long[] array) { return(new PrimitiveNodeStream(LongStream.of(array))); }
public override LongStream FindLogVersionsToDelete(long upToVersion) { lock (this) { if (upToVersion == INITIAL_LOG_VERSION) { return(LongStream.empty()); } _threshold.init(); long upper = upToVersion - 1; bool exceeded = false; while (upper >= 0) { File file = _files.getLogFileForVersion(upper); if (!_fileSystem.fileExists(file)) { // There aren't logs to prune anything. Just return return(LongStream.empty()); } if (_fileSystem.getFileSize(file) > LOG_HEADER_SIZE && _threshold.reached(file, upper, _logFileInformation)) { exceeded = true; break; } upper--; } if (!exceeded) { return(LongStream.empty()); } // Find out which log is the earliest existing (lower bound to prune) long lower = upper; while (_fileSystem.fileExists(_files.getLogFileForVersion(lower - 1))) { lower--; } /* * Here we make sure that at least one historical log remains behind, in addition of course to the * current one. This is in order to make sure that at least one transaction remains always available for * serving to whomever asks for it. * To illustrate, imagine that there is a threshold in place configured so that it enforces pruning of the * log file that was just rotated out (for example, a file size threshold that is misconfigured to be smaller * than the smallest log). In such a case, until the database commits a transaction there will be no * transactions present on disk, making impossible to serve any to whichever client might ask, leading to * errors on both sides of the conversation. * This if statement does nothing more complicated than checking if the next-to-last log would be pruned * and simply skipping it if so. */ if (upper == upToVersion - 1) { upper--; } // The reason we delete from lower to upper is that if it crashes in the middle we can be sure that no holes // are created. // We create a closed range because we want to include the 'upper' log version as well. The check above ensures // we don't accidentally leave the database without any logs. return(LongStream.rangeClosed(lower, upper)); } }
private Read TxState(params long[] ids) { //JAVA TO C# CONVERTER TODO TASK: Method reference constructor syntax is not converted by Java to C# Converter: return(TxState(LongStream.of(ids).mapToObj(id => Rel(id, _node, _node, _type)).toArray(Rel[] ::new))); }
public LongStream findLogVersionsToDelete(long upToLogVersion) { // Never delete anything. return(LongStream.empty()); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void mustNotHaveLogsFilesToPruneIfStrategyFindsNoFiles() public virtual void MustNotHaveLogsFilesToPruneIfStrategyFindsNoFiles() { when(_factory.strategyFromConfigValue(eq(_fs), eq(_logFiles), eq(_clock), anyString())).thenReturn(x => LongStream.empty()); LogPruning pruning = new LogPruningImpl(_fs, _logFiles, _logProvider, _factory, _clock, _config); assertFalse(pruning.MightHaveLogsToPrune()); }