//-------------------------------------------------------------------------
        /// <summary>
        /// Streams the set of dates included in the range.
        /// <para>
        /// This returns a stream consisting of each date in the range.
        /// The stream is ordered.
        ///
        /// </para>
        /// </summary>
        /// <param name="startInclusive">  the start date </param>
        /// <param name="endExclusive">  the end date </param>
        /// <returns> the stream of dates from the start to the end </returns>
        internal static Stream <LocalDate> stream(LocalDate startInclusive, LocalDate endExclusive)
        {
            IEnumerator <LocalDate> it = new IteratorAnonymousInnerClass(startInclusive, endExclusive);
            long count = endExclusive.toEpochDay() - startInclusive.toEpochDay() + 1;
            Spliterator <LocalDate> spliterator = Spliterators.spliterator(it, count, Spliterator.IMMUTABLE | Spliterator.NONNULL | Spliterator.DISTINCT | Spliterator.ORDERED | Spliterator.SORTED | Spliterator.SIZED | Spliterator.SUBSIZED);

            return(StreamSupport.stream(spliterator, false));
        }
Exemple #2
0
        public virtual Stream <NodeResult> GraphAlgosDijkstra(Node start, Node end, string relType, string weightProperty)
        {
            PathFinder <WeightedPath> pathFinder = GraphAlgoFactory.dijkstra(PathExpanders.forTypeAndDirection(RelationshipType.withName(relType), Direction.BOTH), weightProperty);

            WeightedPath path = pathFinder.FindSinglePath(start, end);

//JAVA TO C# CONVERTER TODO TASK: Method reference constructor syntax is not converted by Java to C# Converter:
            return(StreamSupport.stream(path.Nodes().spliterator(), false).map(NodeResult::new));
        }
        public virtual Stream <AvailableAnalyzer> ListAvailableAnalyzers()
        {
            Stream <AnalyzerProvider> stream = Accessor.listAvailableAnalyzers();

            return(stream.flatMap(provider =>
            {
                string description = provider.description();
                Spliterator <string> spliterator = provider.Keys.spliterator();
                return StreamSupport.stream(spliterator, false).map(name => new AvailableAnalyzer(name, description));
            }));
        }
Exemple #4
0
        /// <summary>
        /// Create a stream from the given iterator with given characteristics.
        /// <para>
        /// <b>Note:</b> returned stream needs to be closed via <seealso cref="Stream.close()"/> if the given iterator implements
        /// <seealso cref="Resource"/>.
        ///
        /// </para>
        /// </summary>
        /// <param name="iterator"> the iterator to convert to stream </param>
        /// <param name="characteristics"> the logical OR of characteristics for the underlying <seealso cref="Spliterator"/> </param>
        /// @param <T> the type of elements in the given iterator </param>
        /// <returns> stream over the iterator elements </returns>
        /// <exception cref="NullPointerException"> when the given iterator is {@code null} </exception>
        public static Stream <T> Stream <T>(IEnumerator <T> iterator, int characteristics)
        {
            Objects.requireNonNull(iterator);
            Spliterator <T> spliterator = Spliterators.spliteratorUnknownSize(iterator, characteristics);
            Stream <T>      stream      = StreamSupport.stream(spliterator, false);

            if (iterator is Resource)
            {
                return(stream.onClose((( Resource )iterator).close));
            }
            return(stream);
        }
Exemple #5
0
        // Service loader can't inject via the constructor
        public virtual void Inject(TopologyService topologyService, Config config, LogProvider logProvider, MemberId myself)
        {
            this.TopologyService = topologyService;
            this.Config          = config;
            this.Log             = logProvider.getLog(this.GetType());
            this.Myself          = myself;
            this.DbName          = config.Get(CausalClusteringSettings.database);

            ReadableName = StreamSupport.stream(Keys.spliterator(), false).collect(Collectors.joining(", "));
            Log.info("Using upstream selection strategy " + ReadableName);
            Init();
        }
        private byte[] ReadImageDataFromChunk(string chunkName, AspNetCore.ReportingServices.ReportProcessing.ReportProcessing.ReportChunkTypes chunkType)
        {
            byte[] array = null;
            string text  = default(string);
            Stream chunk = base.m_chunkFactory.GetChunk(chunkName, chunkType, ChunkMode.Open, out text);

            Global.Tracer.Assert(chunk != null, "Could not find expected image data chunk.  Name='{0}', Type={1}", chunkName, chunkType);
            using (chunk)
            {
                return(StreamSupport.ReadToEndUsingLength(chunk));
            }
        }
Exemple #7
0
        public virtual Stream <Output> TestFailingResourceProcedure(long failCount)
        {
            IEnumerator <Output> failingIterator = new IteratorAnonymousInnerClass(this, failCount);
            IEnumerable <Output> failingIterable = () => failingIterator;
            Stream <Output>      stream          = StreamSupport.stream(failingIterable.spliterator(), false);

            stream.onClose(() =>
            {
                Counters.closeCountTestFailingResourceProcedure++;
            });
            Counters.openCountTestFailingResourceProcedure++;
            return(stream);
        }
        public virtual void TestSpliteratorInSequence()
        {
            List <int> x = new List <int>();

            for (int i = 0; i < 1000; ++i)
            {
                x.Add(i);
            }
            IterableIterator <int> iter        = new IterableIterator <int>(x.GetEnumerator());
            ISpliterator <int>     spliterator = iter.Spliterator();
            IStream <int>          stream      = StreamSupport.Stream(spliterator, false);

            int[] next = new int[] { 0 };
            stream.ForEach(null);
        }
Exemple #9
0
 public void CopyDataChunksTo(IChunkFactory chunkFactory, out bool hasDataChunks)
 {
     hasDataChunks = false;
     foreach (Chunk allChunk in this.m_allChunks)
     {
         if (allChunk.Header.ChunkType == 5)
         {
             hasDataChunks = true;
             using (Stream to = chunkFactory.CreateChunk(allChunk.Header.ChunkName, AspNetCore.ReportingServices.ReportProcessing.ReportProcessing.ReportChunkTypes.Data, null))
             {
                 allChunk.Stream.Position = 0L;
                 StreamSupport.CopyStreamUsingBuffer(allChunk.Stream, to, 4096);
             }
         }
     }
 }
Exemple #10
0
        public override bool?TernaryEquals(AnyValue other)
        {
            if (other == null || other == NO_VALUE)
            {
                return(null);
            }
            else if (!(other is MapValue))
            {
                return(false);
            }
            MapValue otherMap = ( MapValue )other;
            int      size     = size();

            if (size != otherMap.Size())
            {
                return(false);
            }
//JAVA TO C# CONVERTER TODO TASK: Method reference constructor syntax is not converted by Java to C# Converter:
            string[] thisKeys = StreamSupport.stream(KeySet().spliterator(), false).toArray(string[] ::new);
            Arrays.sort(thisKeys, string.compareTo);
//JAVA TO C# CONVERTER TODO TASK: Method reference constructor syntax is not converted by Java to C# Converter:
            string[] thatKeys = StreamSupport.stream(otherMap.Keys.spliterator(), false).toArray(string[] ::new);
            Arrays.sort(thatKeys, string.compareTo);
            for (int i = 0; i < size; i++)
            {
                if (thisKeys[i].CompareTo(thatKeys[i]) != 0)
                {
                    return(false);
                }
            }
            bool?equalityResult = true;

            for (int i = 0; i < size; i++)
            {
                string key = thisKeys[i];
                bool?  s   = Get(key).ternaryEquals(otherMap.Get(key));
                if (s == null)
                {
                    equalityResult = null;
                }
                else if (!s.Value)
                {
                    return(false);
                }
            }
            return(equalityResult);
        }
Exemple #11
0
        /// <summary>A helper function for dumping the accuracy of the trained classifier.</summary>
        /// <param name="classifier">The classifier to evaluate.</param>
        /// <param name="dataset">The dataset to evaluate the classifier on.</param>
        public static void DumpAccuracy(IClassifier <ClauseSplitter.ClauseClassifierLabel, string> classifier, GeneralDataset <ClauseSplitter.ClauseClassifierLabel, string> dataset)
        {
            DecimalFormat df = new DecimalFormat("0.00%");

            Redwood.Log("size:         " + dataset.Size());
            Redwood.Log("split count:  " + StreamSupport.Stream(dataset.Spliterator(), false).Filter(null).Collect(Collectors.ToList()).Count);
            Redwood.Log("interm count: " + StreamSupport.Stream(dataset.Spliterator(), false).Filter(null).Collect(Collectors.ToList()).Count);
            Pair <double, double> pr = classifier.EvaluatePrecisionAndRecall(dataset, ClauseSplitter.ClauseClassifierLabel.ClauseSplit);

            Redwood.Log("p  (split):   " + df.Format(pr.first));
            Redwood.Log("r  (split):   " + df.Format(pr.second));
            Redwood.Log("f1 (split):   " + df.Format(2 * pr.first * pr.second / (pr.first + pr.second)));
            pr = classifier.EvaluatePrecisionAndRecall(dataset, ClauseSplitter.ClauseClassifierLabel.ClauseInterm);
            Redwood.Log("p  (interm):  " + df.Format(pr.first));
            Redwood.Log("r  (interm):  " + df.Format(pr.second));
            Redwood.Log("f1 (interm):  " + df.Format(2 * pr.first * pr.second / (pr.first + pr.second)));
        }
        public virtual void TestSpliteratorInParallel()
        {
            List <int> x = new List <int>();

            for (int i = 0; i < 1000; ++i)
            {
                x.Add(i);
            }
            IterableIterator <int> iter        = new IterableIterator <int>(x.GetEnumerator());
            ISpliterator <int>     spliterator = iter.Spliterator();
            IStream <int>          stream      = StreamSupport.Stream(spliterator, true);

            bool[] seen = new bool[1000];
            stream.ForEach(null);
            for (int i_1 = 0; i_1 < 1000; ++i_1)
            {
                NUnit.Framework.Assert.IsTrue(seen[i_1]);
            }
        }
Exemple #13
0
        public override int CompareTo(VirtualValue other, IComparer <AnyValue> comparator)
        {
            if (!(other is MapValue))
            {
                throw new System.ArgumentException("Cannot compare different virtual values");
            }
            MapValue otherMap = ( MapValue )other;
            int      size     = size();
            int      compare  = Integer.compare(size, otherMap.Size());

            if (compare == 0)
            {
//JAVA TO C# CONVERTER TODO TASK: Method reference constructor syntax is not converted by Java to C# Converter:
                string[] thisKeys = StreamSupport.stream(KeySet().spliterator(), false).toArray(string[] ::new);
                Arrays.sort(thisKeys, string.compareTo);
//JAVA TO C# CONVERTER TODO TASK: Method reference constructor syntax is not converted by Java to C# Converter:
                string[] thatKeys = StreamSupport.stream(otherMap.Keys.spliterator(), false).toArray(string[] ::new);
                Arrays.sort(thatKeys, string.compareTo);
                for (int i = 0; i < size; i++)
                {
                    compare = thisKeys[i].CompareTo(thatKeys[i]);
                    if (compare != 0)
                    {
                        return(compare);
                    }
                }

                for (int i = 0; i < size; i++)
                {
                    string key = thisKeys[i];
                    compare = comparator.Compare(Get(key), otherMap.Get(key));
                    if (compare != 0)
                    {
                        return(compare);
                    }
                }
            }
            return(compare);
        }
Exemple #14
0
 public virtual Stream <ScoreEntry> Stream()
 {
     return(StreamSupport.stream(Spliterators.spliteratorUnknownSize(this, Spliterator.ORDERED), false));
 }
Exemple #15
0
        /// <summary>
        /// Returns a {@code Stream}, the elements of which are lines read from
        /// this {@code BufferedReader}.  The <seealso cref="Stream"/> is lazily populated,
        /// i.e., read only occurs during the
        /// <a href="../util/stream/package-summary.html#StreamOps">terminal
        /// stream operation</a>.
        ///
        /// <para> The reader must not be operated on during the execution of the
        /// terminal stream operation. Otherwise, the result of the terminal stream
        /// operation is undefined.
        ///
        /// </para>
        /// <para> After execution of the terminal stream operation there are no
        /// guarantees that the reader will be at a specific position from which to
        /// read the next character or line.
        ///
        /// </para>
        /// <para> If an <seealso cref="IOException"/> is thrown when accessing the underlying
        /// {@code BufferedReader}, it is wrapped in an {@link
        /// UncheckedIOException} which will be thrown from the {@code Stream}
        /// method that caused the read to take place. This method will return a
        /// Stream if invoked on a BufferedReader that is closed. Any operation on
        /// that stream that requires reading from the BufferedReader after it is
        /// closed, will cause an UncheckedIOException to be thrown.
        ///
        /// </para>
        /// </summary>
        /// <returns> a {@code Stream<String>} providing the lines of text
        ///         described by this {@code BufferedReader}
        ///
        /// @since 1.8 </returns>
        public virtual Stream <String> Lines()
        {
            IEnumerator <String> iter = new IteratorAnonymousInnerClassHelper(this);

            return(StreamSupport.Stream(Spliterators.SpliteratorUnknownSize(iter, java.util.Spliterator_Fields.ORDERED | java.util.Spliterator_Fields.NONNULL), false));
        }
Exemple #16
0
 internal virtual Stream <NeighbourOutput> FindNeighbours(Node node)
 {
     return(StreamSupport.stream(node.GetRelationships(Direction.OUTGOING).spliterator(), false).map(relationship => new NeighbourOutput(relationship, relationship.getOtherNode(node))));
 }
Exemple #17
0
 private static Stream <T> EnumerationAsStream <T>(IEnumerator <T> e)
 {
     return(StreamSupport.stream(Spliterators.spliteratorUnknownSize(new IteratorAnonymousInnerClass(e)
                                                                     , Spliterator.ORDERED), false));
 }
        /// <summary>
        /// Finds which format, if any, succeeded the specified format. Only formats in the same family are considered.
        /// </summary>
        /// <param name="format"> to find successor to. </param>
        /// <returns> the format with the lowest generation > format.generation, or None if no such format is known. </returns>
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Nonnull public static java.util.Optional<RecordFormats> findSuccessor(@Nonnull final RecordFormats format)
//JAVA TO C# CONVERTER WARNING: 'final' parameters are ignored unless the option to convert to C# 7.2 'in' parameters is selected:
        public static Optional <RecordFormats> FindSuccessor(RecordFormats format)
        {
            return(StreamSupport.stream(RecordFormatSelector.AllFormats().spliterator(), false).filter(candidate => FormatFamily.IsSameFamily(format, candidate)).filter(candidate => candidate.generation() > format.Generation()).reduce((a, b) => a.generation() < b.generation() ? a : b));
        }
Exemple #19
0
 private static string NicelyCommaSeparatedList(IEnumerable <string> keys)
 {
     return(StreamSupport.stream(keys.spliterator(), false).collect(Collectors.joining(", ")));
 }
Exemple #20
0
        public static IList <R> Records <R, A>(IEnumerable <Org.Neo4j.Kernel.impl.transaction.state.RecordAccess_RecordProxy <R, A> > changes) where R : Org.Neo4j.Kernel.impl.store.record.AbstractBaseRecord
        {
//JAVA TO C# CONVERTER TODO TASK: Method reference arbitrary object instance method syntax is not converted by Java to C# Converter:
            return(StreamSupport.stream(changes.spliterator(), false).map(Org.Neo4j.Kernel.impl.transaction.state.RecordAccess_RecordProxy::forChangingData).collect(Collectors.toList()));
        }
        public override Stream <AnalyzerProvider> ListAvailableAnalyzers()
        {
            IEnumerable <AnalyzerProvider> providers = AnalyzerProvider.load(typeof(AnalyzerProvider));

            return(StreamSupport.stream(providers.spliterator(), false));
        }
Exemple #22
0
 /// <param name="resources"> <seealso cref="System.Collections.IEnumerable"/> over resources to close. </param>
 public static void CloseAll <T>(IEnumerable <T> resources) where T : Resource
 {
     CloseAll(StreamSupport.stream(resources.spliterator(), false));
 }
        /// <summary>
        /// Returns a stream that wraps this iterator.
        /// <para>
        /// The stream will process any remaining rows in the CSV file.
        /// As such, it is recommended that callers should use this method or the iterator methods and not both.
        ///
        /// </para>
        /// </summary>
        /// <returns> the stream wrapping this iterator </returns>
        public Stream <CsvRow> asStream()
        {
            Spliterator <CsvRow> spliterator = Spliterators.spliteratorUnknownSize(this, Spliterator.ORDERED | Spliterator.NONNULL);

            return(StreamSupport.stream(spliterator, false));
        }
Exemple #24
0
 /// <exception cref="System.IO.IOException"/>
 private static IStream <SimpleSentiment.SentimentDatum> Unlabelled(string path)
 {
     return(StreamSupport.Stream(IOUtils.IterFilesRecursive(new File(path)).Spliterator(), true).FlatMap(null));
 }
Exemple #25
0
 public virtual IEnumerable <File> AllFiles()
 {
     return(StreamSupport.stream(RotationStrategy.candidateFiles().spliterator(), false).filter(_fs.fileExists).collect(Collectors.toList()));
 }
Exemple #26
0
 private static IStream <SimpleSentiment.SentimentDatum> Imdb(string path, SentimentClass label)
 {
     return(StreamSupport.Stream(IOUtils.IterFilesRecursive(new File(path)).Spliterator(), true).Map(null));
 }
Exemple #27
0
 private static IStream <SimpleSentiment.SentimentDatum> Twitter(string path)
 {
     return(StreamSupport.Stream(IOUtils.ReadLines(path).Spliterator(), true).Map(null));
 }
Exemple #28
0
 private static IEnumerable <SimpleSentiment.SentimentDatum> Stanford(string path)
 {
     return(StreamSupport.Stream(IOUtils.ReadLines(path).Spliterator(), true).Map(null));
 }
Exemple #29
0
 protected internal virtual Stream <T> Stream <T>(IEnumerable <T> iterable)
 {
     return(StreamSupport.stream(iterable.spliterator(), false));
 }