Search in sources :

Example 6 with LegacyNumericTokenStream

use of org.apache.solr.legacy.LegacyNumericTokenStream in project lucene-solr by apache.

the class TestNumericTokenStream method testCTA.

public void testCTA() throws Exception {
    final LegacyNumericTokenStream stream = new LegacyNumericTokenStream();
    IllegalArgumentException e = expectThrows(IllegalArgumentException.class, () -> {
        stream.addAttribute(CharTermAttribute.class);
    });
    assertTrue(e.getMessage().startsWith("LegacyNumericTokenStream does not support"));
    e = expectThrows(IllegalArgumentException.class, () -> {
        stream.addAttribute(TestAttribute.class);
    });
    assertTrue(e.getMessage().startsWith("LegacyNumericTokenStream does not support"));
    stream.close();
}
Also used : LegacyNumericTokenStream(org.apache.solr.legacy.LegacyNumericTokenStream)

Example 7 with LegacyNumericTokenStream

use of org.apache.solr.legacy.LegacyNumericTokenStream in project lucene-solr by apache.

the class TestNumericTokenStream method testCaptureStateAfterExhausted.

/** LUCENE-7027 */
public void testCaptureStateAfterExhausted() throws Exception {
    // default precstep
    try (LegacyNumericTokenStream stream = new LegacyNumericTokenStream()) {
        // int
        stream.setIntValue(ivalue);
        stream.reset();
        while (stream.incrementToken()) ;
        stream.captureState();
        stream.end();
        stream.captureState();
        // long
        stream.setLongValue(lvalue);
        stream.reset();
        while (stream.incrementToken()) ;
        stream.captureState();
        stream.end();
        stream.captureState();
    }
    // huge precstep
    try (LegacyNumericTokenStream stream = new LegacyNumericTokenStream(Integer.MAX_VALUE)) {
        // int
        stream.setIntValue(ivalue);
        stream.reset();
        while (stream.incrementToken()) ;
        stream.captureState();
        stream.end();
        stream.captureState();
        // long
        stream.setLongValue(lvalue);
        stream.reset();
        while (stream.incrementToken()) ;
        stream.captureState();
        stream.end();
        stream.captureState();
    }
}
Also used : LegacyNumericTokenStream(org.apache.solr.legacy.LegacyNumericTokenStream)

Aggregations

LegacyNumericTokenStream (org.apache.solr.legacy.LegacyNumericTokenStream)7 TermToBytesRefAttribute (org.apache.lucene.analysis.tokenattributes.TermToBytesRefAttribute)2 TypeAttribute (org.apache.lucene.analysis.tokenattributes.TypeAttribute)2 CannedTokenStream (org.apache.lucene.analysis.CannedTokenStream)1 Token (org.apache.lucene.analysis.Token)1 TokenStream (org.apache.lucene.analysis.TokenStream)1 LegacyIntField (org.apache.solr.legacy.LegacyIntField)1 LegacyNumericTermAttribute (org.apache.solr.legacy.LegacyNumericTokenStream.LegacyNumericTermAttribute)1