Exemple #1
0
            internal virtual string BuildProcedureQuery()
            {
                StringJoiner stringJoiner = new StringJoiner(",", "CALL " + Name + "(", ")");

                foreach (object parameter in Params)
                {
                    stringJoiner.add(parameter.ToString());
                }
                if (!string.ReferenceEquals(SetupQuery, null) && !string.ReferenceEquals(PostQuery, null))
                {
                    return(SetupQuery + " " + stringJoiner.ToString() + " " + PostQuery);
                }
                else
                {
                    return(stringJoiner.ToString());
                }
            }
Exemple #2
0
        public void TestJoinerClearClearsString()
        {
            var joiner = new StringJoiner("");

            joiner.Append("a");
            joiner.Clear();
            Assert.AreEqual(string.Empty, joiner.ToString());
        }
Exemple #3
0
        public void TestJoinerToStringGivesExpectedString(string seperator, string expected)
        {
            var joiner = new StringJoiner(seperator);

            joiner.Append("a");
            joiner.Append("b");
            joiner.Append("c");
            Assert.AreEqual(expected, joiner.ToString());
        }
Exemple #4
0
        public override void RecoveryCleanupFinished(long numberOfPagesVisited, long numberOfCleanedCrashPointers, long durationMillis)
        {
            StringJoiner joiner = new StringJoiner(", ", "Label index cleanup job finished: ", "");

            joiner.add("Number of pages visited: " + numberOfPagesVisited);
            joiner.add("Number of cleaned crashed pointers: " + numberOfCleanedCrashPointers);
            joiner.add("Time spent: " + duration(durationMillis));
            _log.info(joiner.ToString());
        }
Exemple #5
0
        public override string ToString()
        {
            StringJoiner joiner = new StringJoiner(", ", "CleanupJob(", ")");

            joiner.add("file=" + _indexFile.AbsolutePath);
            joiner.add("needed=" + _needed);
            joiner.add("failure=" + (_failure == null ? null : _failure.ToString()));
            return(joiner.ToString());
        }
Exemple #6
0
        public override void RecoveryCleanupFinished(File indexFile, IndexDescriptor indexDescriptor, long numberOfPagesVisited, long numberOfCleanedCrashPointers, long durationMillis)
        {
            StringJoiner joiner = new StringJoiner(", ", "Schema index cleanup job finished: " + IndexDescription(indexFile, indexDescriptor) + " ", "");

            joiner.add("Number of pages visited: " + numberOfPagesVisited);
            joiner.add("Number of cleaned crashed pointers: " + numberOfCleanedCrashPointers);
            joiner.add("Time spent: " + duration(durationMillis));
            _log.info(joiner.ToString());
        }
        private string MainReportString(string title)
        {
            StringJoiner joiner = new StringJoiner(", ", title + ": ", "");

            _times.Values.forEach(logger =>
            {
                ReportToJoiner(joiner, logger);
            });
            return(joiner.ToString());
        }
Exemple #8
0
        private string IndexPattern(string label, params string[] properties)
        {
            StringJoiner pattern = new StringJoiner(",", ":" + label + "(", ")");

            foreach (string property in properties)
            {
                pattern.add(property);
            }
            return(pattern.ToString());
        }
Exemple #9
0
        internal override string ToDetailedStringInternal()
        {
            StringJoiner joiner = new StringJoiner(",");

            foreach (GenericKey state in _states)
            {
                joiner.add(state.ToDetailedStringInternal());
            }
            return(joiner.ToString());
        }
 public override void Init()
 {
     _started = false;
     if (!_jobs.Empty)
     {
         StringJoiner joiner = new StringJoiner(string.Format("%n  "), "Did not expect there to be any cleanup jobs still here. Jobs[", "]");
         ConsumeAndCloseJobs(cj => joiner.add(_jobs.ToString()));
         throw new System.InvalidOperationException(joiner.ToString());
     }
     ScheduleJobs();
 }
Exemple #11
0
        private string Join(ICollection <object> collection)
        {
            var joiner = new StringJoiner(",");

            foreach (var value in collection)
            {
                joiner.Add(value.ToString());
            }

            return(joiner.ToString());
        }
        private string PeriodReportString(long millisSinceLastPeriodReport)
        {
            long         secondsSinceLastPeriodReport = TimeUnit.MILLISECONDS.toSeconds(millisSinceLastPeriodReport);
            StringJoiner joiner = new StringJoiner(", ", "Last " + secondsSinceLastPeriodReport + " sec: ", "");

//JAVA TO C# CONVERTER TODO TASK: Method reference arbitrary object instance method syntax is not converted by Java to C# Converter:
            _times.Values.Select(Logger::period).ForEach(period =>
            {
                ReportToJoiner(joiner, period);
                period.reset();
            });
            return(joiner.ToString());
        }
Exemple #13
0
        public static string SortGetExpectedPoints(
            BoundingBox bb,
            IList<SupportSpatialPoint> points)
        {
            var joiner = new StringJoiner(",");
            foreach (var point in points) {
                if (bb.ContainsPoint(point.Px.Value, point.Py.Value)) {
                    joiner.Add(point.Id);
                }
            }

            return joiner.ToString();
        }
Exemple #14
0
        internal virtual string ToDetailedString(GenericKey state)
        {
            StringJoiner joiner = new StringJoiner(", ");

            joiner.add(ToString(state));

            // Mutable, meta-state
            joiner.add("type=" + state.TypeConflict.GetType().Name);
            joiner.add("inclusion=" + state.Inclusion);
            joiner.add("isArray=" + state.IsArray);

            AddTypeSpecificDetails(joiner, state);
            return(joiner.ToString());
        }
Exemple #15
0
        private string Describe(ISet <KernelTransactionHandle> allBlockers)
        {
            if (allBlockers.Count == 0)
            {
                return(StringUtils.EMPTY);
            }
            StringJoiner stringJoiner = new StringJoiner(", ", "[", "]");

            foreach (KernelTransactionHandle blocker in allBlockers)
            {
                stringJoiner.add(blocker.UserTransactionName);
            }
            return(stringJoiner.ToString());
        }
Exemple #16
0
        private static void AssertCompare(
            MXCIFQuadTree tree,
            String expected,
            IDictionary <int, String> received)
        {
            StringJoiner joiner = new StringJoiner(",");

            foreach (string value in received.Values)
            {
                joiner.Add(value);
            }

            Assert.AreEqual(expected, joiner.ToString());
            Assert.IsTrue((expected.Length == 0 ? 0 : expected.SplitCsv().Length) <= MXCIFQuadTreeFilterIndexCount.Count(tree));
        }
Exemple #17
0
        /**
         * Makes the warning for when the registry responds with an image digest that is not the expected
         * digest of the image.
         *
         * @param expectedDigest the expected image digest
         * @param receivedDigests the received image digests
         * @return the warning message
         */
        private static string MakeUnexpectedImageDigestWarning(
            DescriptorDigest expectedDigest, IList <string> receivedDigests)
        {
            if (receivedDigests.Count == 0)
            {
                return("Expected image digest " + expectedDigest + ", but received none");
            }

            StringJoiner message =
                new StringJoiner(", ", "Expected image digest " + expectedDigest + ", but received: ", "");

            foreach (string receivedDigest in receivedDigests)
            {
                message.Add(receivedDigest);
            }
            return(message.ToString());
        }
Exemple #18
0
        public static string SortGetExpectedRectangles(
            BoundingBox bb,
            IList<SupportSpatialEventRectangle> rectangles)
        {
            var joiner = new StringJoiner(",");
            foreach (var rect in rectangles) {
                if (bb.IntersectsBoxIncludingEnd(
                    rect.X.Value,
                    rect.Y.Value,
                    rect.Width.Value,
                    rect.Height.Value)) {
                    joiner.Add(rect.Id);
                }
            }

            return joiner.ToString();
        }
Exemple #19
0
        public static string ToDelimitedString(this IEnumerable source, string delimiter = ",", string quote = "\"", Func <object, string> convertToString = null)
        {
            if (convertToString == null)
            {
                convertToString = x => (x == null ? "" : x.ToString());
            }

            var data = (
                from object a in source
                let s = convertToString(a)
                        select s.Contains(delimiter) || s.Contains("\r") || s.Contains("\n") || s.Contains(quote) ? String.Format("{0}{1}{0}", quote, s) : s
                );

            StringJoiner sj = new StringJoiner(delimiter);

            data.ForEach(e => sj.Add(e));

            return(sj.ToString());
        }
Exemple #20
0
        public static string SortJoinProperty(
            EventBean[] events,
            string propertyName)
        {
            var sorted = new SortedDictionary<int, string>();
            if (events != null) {
                foreach (var @event in events) {
                    var value = @event.Get(propertyName).ToString();
                    var num = int.Parse(value.Substring(1));
                    sorted.Put(num, value);
                }
            }

            var joiner = new StringJoiner(",");
            foreach (var data in sorted.Values) {
                joiner.Add(data);
            }

            return joiner.ToString();
        }
        static void OnQueryEnded(object sender, EventArgs eventArgs)
        {
            PanelManager.GetOutputPanel(PanelName).QueryEnded -= OnQueryEnded;

            var document = new StringJoiner(
                LinqPadUtilResources.DumpExtendedHead,
                LinqPadUtilResources.DumpExtendedFoot);


            foreach (var renderer in Renderers)
            {
                document.AppendFunc(renderer);
            }

            document.Document.Replace("{script}", LinqPadUtilResources.jquery_1_11_1_min)
            .Replace("{tablesorter}", LinqPadUtilResources.jquery_tablesorter_min)
            .Replace("{firebug}", LinqPadUtilResources.firebug_lite_compressed);

            webBrowser.NavigateToString(document.ToString());

            Renderers.Clear();
            webBrowser = null;
        }
            public override string ToString()
            {
                StringJoiner joiner = new StringJoiner(", ", Phase.ToString() + "[", "]");

                if (NbrOfReports == 0)
                {
                    AddToString("nbrOfReports", NbrOfReports, joiner, false);
                }
                else if (NbrOfReports == 1)
                {
                    AddToString("totalTime", TotalTime, joiner, true);
                }
                else
                {
                    long avgTime = TotalTime / NbrOfReports;
                    AddToString("totalTime", TotalTime, joiner, true);
                    AddToString("avgTime", avgTime, joiner, true);
                    AddToString("minTime", MinTime, joiner, true);
                    AddToString("maxTime", MaxTime, joiner, true);
                    AddToString("nbrOfReports", NbrOfReports, joiner, false);
                }
                return(joiner.ToString());
            }
        /// <summary>
        /// This test target a bug around minimal splitter in gbpTree and unique index populator. It goes like this:
        /// Given a set of updates (value,entityId):
        /// - ("A01",1), ("A90",3), ("A9",2)
        /// If ("A01",1) and ("A90",3) would cause a split to occur they would produce a minimal splitter ("A9",3).
        /// Note that the value in this minimal splitter is equal to our last update ("A9",2).
        /// When making insertions with the unique populator we don't compare entityId which would means ("A9",2)
        /// ends up to the right of ("A9",3), even though it belongs to the left because of entityId being smaller.
        /// At this point the tree is in an inconsistent (key on wrong side of splitter).
        ///
        /// To work around this problem the entityId is only kept in minimal splitter if strictly necessary to divide
        /// left from right. This means the minimal splitter between ("A01",1) and ("A90",3) is ("A9",-1) and ("A9",2)
        /// will correctly be placed on the right side of this splitter.
        ///
        /// To trigger this scenario this test first insert a bunch of values that are all unique and that will cause a
        /// split to happen. This is the firstBatch.
        /// The second batch are constructed so that at least one of them will have a value equal to the splitter key
        /// constructed during the firstBatch.
        /// It's important that the secondBatch has ids that are lower than the first batch to align with example described above.
        /// </summary>
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldPopulateAndRemoveEntriesWithSimilarMinimalSplitter() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldPopulateAndRemoveEntriesWithSimilarMinimalSplitter()
        {
            string prefix     = "Work out your own salvation. Do not depend on others. ";
            int    nbrOfNodes = 200;
            long   nodeId     = 0;

            // Second batch has lower ids
            IList <NodeAndValue> secondBatch = new List <NodeAndValue>();

            for (int i = 0; i < nbrOfNodes; i++)
            {
                secondBatch.Add(new NodeAndValue(nodeId++, stringValue(prefix + i)));
            }

            // First batch has higher ids and minimal splitter among values in first batch will be found among second batch
            IList <NodeAndValue> firstBatch = new List <NodeAndValue>();

            for (int i = 0; i < nbrOfNodes; i++)
            {
                firstBatch.Add(new NodeAndValue(nodeId++, stringValue(prefix + i + " " + i)));
            }

            WithPopulator(IndexProvider.getPopulator(Descriptor, IndexSamplingConfig, heapBufferFactory(1024)), p =>
            {
                p.add(Updates(firstBatch));
                p.add(Updates(secondBatch));

                // Index should be consistent
            });

            IList <NodeAndValue> toRemove = new List <NodeAndValue>();

            ((IList <NodeAndValue>)toRemove).AddRange(firstBatch);
            ((IList <NodeAndValue>)toRemove).AddRange(secondBatch);
            Collections.shuffle(toRemove);

            // And we should be able to remove the entries in any order
            using (IndexAccessor accessor = IndexProvider.getOnlineAccessor(Descriptor, IndexSamplingConfig))
            {
                // WHEN
                using (IndexUpdater updater = accessor.NewUpdater(IndexUpdateMode.ONLINE))
                {
                    foreach (NodeAndValue nodeAndValue in toRemove)
                    {
                        updater.Process(IndexEntryUpdate.Remove(nodeAndValue.NodeId, Descriptor, nodeAndValue.Value));
                    }
                }

                // THEN
                using (IndexReader reader = new QueryResultComparingIndexReader(accessor.NewReader()))
                {
                    int propertyKeyId = Descriptor.schema().PropertyId;
                    foreach (NodeAndValue nodeAndValue in toRemove)
                    {
                        NodeValueIterator nodes = new NodeValueIterator();
                        reader.Query(nodes, IndexOrder.NONE, false, IndexQuery.exact(propertyKeyId, nodeAndValue.Value));
                        bool anyHits = false;

                        StringJoiner nodesStillLeft = new StringJoiner(", ", "[", "]");
                        while (nodes.HasNext())
                        {
                            anyHits = true;
                            nodesStillLeft.add(Convert.ToString(nodes.Next()));
                        }
                        assertFalse("Expected this query to have zero hits but found " + nodesStillLeft.ToString(), anyHits);
                    }
                }
            }
        }
Exemple #24
0
        public void TestJoinerDoesntThrowsOnToStringIfDefaultCtor()
        {
            var joiner = new StringJoiner();

            Assert.DoesNotThrow(() => joiner.ToString());
        }