Uploaded image for project: 'Lucene - Core'
  1. Lucene - Core
  2. LUCENE-8575

Improve toString() in SegmentInfo

Details

    • Improvement
    • Status: Closed
    • Major
    • Resolution: Fixed
    • None
    • 7.7, 8.0
    • core/index
    • None
    • New

    Description

      I saw the following code in SegmentInfo class.

      // TODO: we could append toString of attributes() here?
      

      Of course, we can.

       

      So I wrote a code for that part.

      public String toString(int delCount) {
        StringBuilder s = new StringBuilder();
        s.append(name).append('(').append(version == null ? "?" : version).append(')').append(':');
        char cfs = getUseCompoundFile() ? 'c' : 'C';
        s.append(cfs);
      
        s.append(maxDoc);
      
        if (delCount != 0) {
          s.append('/').append(delCount);
        }
      
        if (indexSort != null) {
          s.append(":[indexSort=");
          s.append(indexSort);
          s.append(']');
        }
      
        // New Code
        if (!diagnostics.isEmpty()) {
          s.append(":[diagnostics=");
          for (Map.Entry<String, String> entry : diagnostics.entrySet())
            s.append("<").append(entry.getKey()).append(",").append(entry.getValue()).append(">,");
          s.setLength(s.length() - 1);
          s.append(']');
        }
      
        // New Code
        if (!attributes.isEmpty()) {
          s.append(":[attributes=");
          for (Map.Entry<String, String> entry : attributes.entrySet())
            s.append("<").append(entry.getKey()).append(",").append(entry.getValue()).append(">,");
          s.setLength(s.length() - 1);
          s.append(']');
        }
      
        return s.toString();
      }
      

       

      Attachments

        1. LUCENE-8575.patch
          4 kB
          Namgyu Kim
        2. LUCENE-8575.patch
          4 kB
          Namgyu Kim

        Issue Links

          Activity

            People

              Unassigned Unassigned
              danmuzi Namgyu Kim
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: