Fix ShingleFilter reuse, some minor changes to testcase for speed and consistency

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/branches/lucene3969@1311724 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Uwe Schindler 2012-04-10 13:50:03 +00:00
parent a764c0d021
commit 3706fbc5b0
2 changed files with 9 additions and 8 deletions

View File

@ -439,6 +439,8 @@ public final class ShingleFilter extends TokenFilter {
super.reset(); super.reset();
gramSize.reset(); gramSize.reset();
inputWindow.clear(); inputWindow.clear();
nextInputStreamToken = null;
isNextInputStreamToken = false;
numFillerTokensToInsert = 0; numFillerTokensToInsert = 0;
isOutputHere = false; isOutputHere = false;
noShingleOutput = true; noShingleOutput = true;

View File

@ -130,17 +130,17 @@ public class TestRandomChains extends BaseTokenStreamTestCase {
if ( if (
// don't waste time with abstract classes or deprecated known-buggy ones // don't waste time with abstract classes or deprecated known-buggy ones
Modifier.isAbstract(modifiers) || !Modifier.isPublic(modifiers) Modifier.isAbstract(modifiers) || !Modifier.isPublic(modifiers)
|| c.isAnnotationPresent(Deprecated.class)
|| c.isSynthetic() || c.isAnonymousClass() || c.isMemberClass() || c.isInterface() || c.isSynthetic() || c.isAnonymousClass() || c.isMemberClass() || c.isInterface()
|| !(Tokenizer.class.isAssignableFrom(c) || TokenFilter.class.isAssignableFrom(c) || CharStream.class.isAssignableFrom(c))
|| brokenComponents.contains(c) || brokenComponents.contains(c)
|| c.isAnnotationPresent(Deprecated.class)
|| !(Tokenizer.class.isAssignableFrom(c) || TokenFilter.class.isAssignableFrom(c) || CharStream.class.isAssignableFrom(c))
) { ) {
continue; continue;
} }
for (final Constructor<?> ctor : c.getConstructors()) { for (final Constructor<?> ctor : c.getConstructors()) {
// don't test deprecated ctors, they likely have known bugs: // don't test synthetic or deprecated ctors, they likely have known bugs:
if (ctor.isAnnotationPresent(Deprecated.class) || ctor.isSynthetic()) { if (ctor.isSynthetic() || ctor.isAnnotationPresent(Deprecated.class)) {
continue; continue;
} }
if (Tokenizer.class.isAssignableFrom(c)) { if (Tokenizer.class.isAssignableFrom(c)) {
@ -258,9 +258,8 @@ public class TestRandomChains extends BaseTokenStreamTestCase {
}); });
put(byte.class, new ArgProducer() { put(byte.class, new ArgProducer() {
@Override public Object create(Random random) { @Override public Object create(Random random) {
byte bytes[] = new byte[1]; // this wraps to negative when casting to byte
random.nextBytes(bytes); return Byte.valueOf((byte) random.nextInt(256));
return Byte.valueOf(bytes[0]);
} }
}); });
put(byte[].class, new ArgProducer() { put(byte[].class, new ArgProducer() {
@ -671,7 +670,7 @@ public class TestRandomChains extends BaseTokenStreamTestCase {
} }
static final class CheckThatYouDidntReadAnythingReaderWrapper extends CharFilter { static final class CheckThatYouDidntReadAnythingReaderWrapper extends CharFilter {
boolean readSomething; boolean readSomething = false;
CheckThatYouDidntReadAnythingReaderWrapper(Reader in) { CheckThatYouDidntReadAnythingReaderWrapper(Reader in) {
super(CharReader.get(in)); super(CharReader.get(in));