Uploaded image for project: 'Cassandra'
  1. Cassandra
  2. CASSANDRA-7183

BackgroundActivityMonitor.readAndCompute only returns half of the values

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Low
    • Resolution: Fixed
    • Fix Version/s: 2.0.9, 2.1 rc1
    • Component/s: None
    • Labels:
      None
    • Severity:
      Low

      Description

      BackgroundActivityMonitor.readAndCompute does

              long[] returned = new long[tokenizer.countTokens()];
              for (int i = 0; i < tokenizer.countTokens(); i++)
                  returned[i] = Long.parseLong(tokenizer.nextToken());
      

      which is not only inefficient as it counts tokens each time thru the loop, it's wrong in that only the first half of the values are populated in the array, as each time thru the loop the number of tokens goes down by 1, since you've consumed one.

      switch the loop to

       for (int i = 0; i < returned.length; i++)
      

        Attachments

        1. 7183.txt
          0.7 kB
          David Brosius

          Activity

            People

            • Assignee:
              dbrosius David Brosius
              Reporter:
              dbrosius David Brosius
              Authors:
              David Brosius
              Reviewers:
              Jonathan Ellis
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: