Lucene - Core
  1. Lucene - Core
  2. LUCENE-2849

StringIndexOutOfBoundsException on searchtime

    Details

    • Type: Bug Bug
    • Status: Open
    • Priority: Minor Minor
    • Resolution: Unresolved
    • Affects Version/s: 3.0.2
    • Fix Version/s: None
    • Component/s: modules/benchmark
    • Labels:
      None
    • Environment:

      Windows XP

    • Lucene Fields:
      New

      Description

      I've been trying to run the example PrecisionRecall.java code from Lucene in Action II (downloaded the code, so its just as in the book). It gives a StringIndexOutOfBoundsException on my machine.

      Figured it out. I copied QualityBenchmark and QualityStats from the Lucene source and inserted a debugline to get a view of the argument values in the function that throws the exception.

      private String fracFormat(String frac)

      { int k = frac.indexOf('.'); String s1 = padd+frac.substring(0,k); int n = Math.max(k,6); s1 = s1.substring(s1.length()-n); return s1 + frac.substring(k); }

      This function assumes that a decimal '.' is being used. However, the PC's we use over here at uni have a different locale using a ',' for decimals. Think you might be able to catch that by using (new DecimalFormatSymbols().getDecimalSeparator()) instead of ('.')?

      1. LUCENE-2849.patch
        1 kB
        Jeroen Vuurens

        Activity

        Jeroen Vuurens created issue -
        Jeroen Vuurens made changes -
        Field Original Value New Value
        Description I've been trying to run the example PrecisionRecall.java code from Lucene in Action II (downloaded the code, so its just as in the book). It gives a StringIndexOutOfBoundsException on my machine.

        From what i can tell it uses a searchtime in milliseconds / 1000, and QualityStats.fracFormat() uses k = frac.indexOf('.') that returns -1 (maybe time = 0 milliseconds?) and returns the exception when performing frac.substring(0,k). Any tips on how to overcome this?
        I've been trying to run the example PrecisionRecall.java code from Lucene in Action II (downloaded the code, so its just as in the book). It gives a StringIndexOutOfBoundsException on my machine.

        Figured it out. I copied QualityBenchmark and QualityStats from the Lucene source and inserted a debugline to get a view of the argument values in the function that throws the exception.

        private String fracFormat(String frac) {
        int k = frac.indexOf('.');
        String s1 = padd+frac.substring(0,k);
        int n = Math.max(k,6);
        s1 = s1.substring(s1.length()-n);
        return s1 + frac.substring(k);
        }

        This function assumes that a decimal . is being used. However, the PC's we use over here at uni have a different locale using a , for decimals. Think you might be able to catch that by using DecimalFormatSymbols().getDecimalSeperator() instead of '.'?
        Jeroen Vuurens made changes -
        Description I've been trying to run the example PrecisionRecall.java code from Lucene in Action II (downloaded the code, so its just as in the book). It gives a StringIndexOutOfBoundsException on my machine.

        Figured it out. I copied QualityBenchmark and QualityStats from the Lucene source and inserted a debugline to get a view of the argument values in the function that throws the exception.

        private String fracFormat(String frac) {
        int k = frac.indexOf('.');
        String s1 = padd+frac.substring(0,k);
        int n = Math.max(k,6);
        s1 = s1.substring(s1.length()-n);
        return s1 + frac.substring(k);
        }

        This function assumes that a decimal . is being used. However, the PC's we use over here at uni have a different locale using a , for decimals. Think you might be able to catch that by using DecimalFormatSymbols().getDecimalSeperator() instead of '.'?
        I've been trying to run the example PrecisionRecall.java code from Lucene in Action II (downloaded the code, so its just as in the book). It gives a StringIndexOutOfBoundsException on my machine.

        Figured it out. I copied QualityBenchmark and QualityStats from the Lucene source and inserted a debugline to get a view of the argument values in the function that throws the exception.

        private String fracFormat(String frac) {
        int k = frac.indexOf('.');
        String s1 = padd+frac.substring(0,k);
        int n = Math.max(k,6);
        s1 = s1.substring(s1.length()-n);
        return s1 + frac.substring(k);
        }

        This function assumes that a decimal '.' is being used. However, the PC's we use over here at uni have a different locale using a ',' for decimals. Think you might be able to catch that by using (new DecimalFormatSymbols().getDecimalSeparator()) instead of ('.')?
        Hide
        Robert Muir added a comment -

        However, the PC's we use over here at uni have a different locale using a , for decimals. Think you might be able to catch that by using DecimalFormatSymbols().getDecimalSeperator() instead of '.'?

        Hi Jeroen, I agree this sounds like a localization bug. do you want to contribute a patch?
        see http://wiki.apache.org/lucene-java/HowToContribute

        Show
        Robert Muir added a comment - However, the PC's we use over here at uni have a different locale using a , for decimals. Think you might be able to catch that by using DecimalFormatSymbols().getDecimalSeperator() instead of '.'? Hi Jeroen, I agree this sounds like a localization bug. do you want to contribute a patch? see http://wiki.apache.org/lucene-java/HowToContribute
        Hide
        Jeroen Vuurens added a comment -

        Hi Robert,

        Well I've never contributed a patch to open source b4, but I'll have a look on the page you refer to, to see if I can figure it out.

        regards, Jeroen

        Show
        Jeroen Vuurens added a comment - Hi Robert, Well I've never contributed a patch to open source b4, but I'll have a look on the page you refer to, to see if I can figure it out. regards, Jeroen
        Hide
        Robert Muir added a comment -

        Jeroen, let us know either way! (we can try to improve the guide).

        One thing to keep in mind, is that lucene/contrib/benchmark is now under modules/benchmark in our trunk code:
        http://svn.apache.org/repos/asf/lucene/dev/trunk/

        Show
        Robert Muir added a comment - Jeroen, let us know either way! (we can try to improve the guide). One thing to keep in mind, is that lucene/contrib/benchmark is now under modules/benchmark in our trunk code: http://svn.apache.org/repos/asf/lucene/dev/trunk/
        Hide
        Jeroen Vuurens added a comment -

        Really made an attempt here. Just starting to use Lucene, but am going for a few years of researching information retrieval at least, so figured knowing how SVN works (is new for me too) enables me to contribute more. But after getting eclipse with svn-plugins to work, it hangs at importing 52% giving a java-heap error. Can't find any good tutorial on how to get SVN to work. Unless you have a doable tutorial on this I think I better leave it into your capable hands.

        Show
        Jeroen Vuurens added a comment - Really made an attempt here. Just starting to use Lucene, but am going for a few years of researching information retrieval at least, so figured knowing how SVN works (is new for me too) enables me to contribute more. But after getting eclipse with svn-plugins to work, it hangs at importing 52% giving a java-heap error. Can't find any good tutorial on how to get SVN to work. Unless you have a doable tutorial on this I think I better leave it into your capable hands.
        Hide
        Jeroen Vuurens added a comment - - edited

        Hi Robert,

        Quite a hassle for someone thats new to SVN. I wast able to create a test. Problem is that the whole export doesnt build in Netbeans. I made the changes to the file, it does test out ok like this in my own environment. First attempt at posting a patch, so would appreciate some feedback if the patch is usable as created or if I did something wrong.

        gl Jeroen

        Show
        Jeroen Vuurens added a comment - - edited Hi Robert, Quite a hassle for someone thats new to SVN. I wast able to create a test. Problem is that the whole export doesnt build in Netbeans. I made the changes to the file, it does test out ok like this in my own environment. First attempt at posting a patch, so would appreciate some feedback if the patch is usable as created or if I did something wrong. gl Jeroen
        Jeroen Vuurens made changes -
        Attachment LUCENE-2849.patch [ 12467716 ]
        Mark Thomas made changes -
        Workflow jira [ 12541738 ] Default workflow, editable Closed status [ 12563797 ]
        Mark Thomas made changes -
        Workflow Default workflow, editable Closed status [ 12563797 ] jira [ 12584455 ]

          People

          • Assignee:
            Unassigned
            Reporter:
            Jeroen Vuurens
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:

              Time Tracking

              Estimated:
              Original Estimate - 1h
              1h
              Remaining:
              Remaining Estimate - 1h
              1h
              Logged:
              Time Spent - Not Specified
              Not Specified

                Development