From 219a20a9454d4426ea555e6851ce7c0ac5dbe3e5 Mon Sep 17 00:00:00 2001 From: Karl-Johan Wettin Date: Thu, 11 Dec 2008 22:08:45 +0000 Subject: [PATCH] LUCENE-1462 InstantiatedIndexWriter did not reset pre analyzed TokenStreams the same way IndexWriter does. Parts of InstantiatedIndex was not Serializable. git-svn-id: https://svn.apache.org/repos/asf/lucene/java/trunk@725837 13f79535-47bb-0310-9956-ffa450edef68 --- contrib/CHANGES.txt | 4 ++++ .../org/apache/lucene/store/instantiated/FieldSetting.java | 4 +++- .../org/apache/lucene/store/instantiated/FieldSettings.java | 3 ++- .../lucene/store/instantiated/InstantiatedIndexWriter.java | 3 +++ 4 files changed, 12 insertions(+), 2 deletions(-) diff --git a/contrib/CHANGES.txt b/contrib/CHANGES.txt index 00138b71770..57fa8f7de98 100644 --- a/contrib/CHANGES.txt +++ b/contrib/CHANGES.txt @@ -15,6 +15,10 @@ Bug fixes 1. LUCENE-1423: InstantiatedTermEnum#skipTo(Term) throws ArrayIndexOutOfBounds on empty index. (Karl Wettin) + 2. LUCENE-1462: InstantiatedIndexWriter did not reset pre analyzed TokenStreams the + same way IndexWriter does. Parts of InstantiatedIndex was not Serializable. + (Karl Wettin) + New features 1. LUCENE-1470: Added TrieRangeQuery, a much faster implementation of diff --git a/contrib/instantiated/src/java/org/apache/lucene/store/instantiated/FieldSetting.java b/contrib/instantiated/src/java/org/apache/lucene/store/instantiated/FieldSetting.java index 34d96bf710c..f2af6767d9f 100644 --- a/contrib/instantiated/src/java/org/apache/lucene/store/instantiated/FieldSetting.java +++ b/contrib/instantiated/src/java/org/apache/lucene/store/instantiated/FieldSetting.java @@ -1,5 +1,7 @@ package org.apache.lucene.store.instantiated; +import java.io.Serializable; + /** * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with @@ -20,7 +22,7 @@ package org.apache.lucene.store.instantiated; /** * For non package access see {@link org.apache.lucene.index.IndexReader#getFieldNames(org.apache.lucene.index.IndexReader.FieldOption)} */ -class FieldSetting { +class FieldSetting implements Serializable { String fieldName; boolean storeTermVector = false; diff --git a/contrib/instantiated/src/java/org/apache/lucene/store/instantiated/FieldSettings.java b/contrib/instantiated/src/java/org/apache/lucene/store/instantiated/FieldSettings.java index 99b4ace7ad6..5659d3afca1 100644 --- a/contrib/instantiated/src/java/org/apache/lucene/store/instantiated/FieldSettings.java +++ b/contrib/instantiated/src/java/org/apache/lucene/store/instantiated/FieldSettings.java @@ -3,6 +3,7 @@ package org.apache.lucene.store.instantiated; import java.util.HashMap; import java.util.Map; import java.util.Collection; +import java.io.Serializable; /** * Licensed to the Apache Software Foundation (ASF) under one or more @@ -24,7 +25,7 @@ import java.util.Collection; /** * Essetially a Map */ -class FieldSettings { +class FieldSettings implements Serializable { FieldSettings() { diff --git a/contrib/instantiated/src/java/org/apache/lucene/store/instantiated/InstantiatedIndexWriter.java b/contrib/instantiated/src/java/org/apache/lucene/store/instantiated/InstantiatedIndexWriter.java index 307c16e9e76..4279163d547 100644 --- a/contrib/instantiated/src/java/org/apache/lucene/store/instantiated/InstantiatedIndexWriter.java +++ b/contrib/instantiated/src/java/org/apache/lucene/store/instantiated/InstantiatedIndexWriter.java @@ -522,6 +522,9 @@ public class InstantiatedIndexWriter { tokenStream = analyzer.tokenStream(field.name(), new StringReader(field.stringValue())); } + // reset the TokenStream to the first token + tokenStream.reset(); + final Token reusableToken = new Token(); for (Token nextToken = tokenStream.next(reusableToken); nextToken != null; nextToken = tokenStream.next(reusableToken)) { tokens.add((Token) nextToken.clone()); // the vector will be built on commit.