lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From r...@apache.org
Subject svn commit: r1001534 [2/2] - /lucene/dev/trunk/lucene/src/java/org/apache/lucene/search/cache/
Date Sun, 26 Sep 2010 22:00:59 GMT
Modified: lucene/dev/trunk/lucene/src/java/org/apache/lucene/search/cache/FloatValuesCreator.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/src/java/org/apache/lucene/search/cache/FloatValuesCreator.java?rev=1001534&r1=1001533&r2=1001534&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/src/java/org/apache/lucene/search/cache/FloatValuesCreator.java
(original)
+++ lucene/dev/trunk/lucene/src/java/org/apache/lucene/search/cache/FloatValuesCreator.java
Sun Sep 26 22:00:58 2010
@@ -1,150 +1,162 @@
-package org.apache.lucene.search.cache;
-
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-import java.io.IOException;
-
-import org.apache.lucene.index.DocsEnum;
-import org.apache.lucene.index.IndexReader;
-import org.apache.lucene.index.MultiFields;
-import org.apache.lucene.index.Terms;
-import org.apache.lucene.index.TermsEnum;
-import org.apache.lucene.search.DocIdSetIterator;
-import org.apache.lucene.search.FieldCache;
-import org.apache.lucene.search.FieldCache.FloatParser;
-import org.apache.lucene.search.cache.CachedArray.FloatValues;
-import org.apache.lucene.util.Bits;
-import org.apache.lucene.util.BytesRef;
-import org.apache.lucene.util.OpenBitSet;
-
-public class FloatValuesCreator extends CachedArrayCreator<FloatValues>
-{
-  protected FloatParser parser;
-
-  public FloatValuesCreator( String field, FloatParser parser, int options )
-  {
-    super( field, options );
-    this.parser = parser;
-  }
-
-  public FloatValuesCreator( String field, FloatParser parser )
-  {
-    super( field );
-    this.parser = parser;
-  }
-
-  @Override
-  public Class getArrayType() {
-    return Float.class;
-  }
-
-
-  //--------------------------------------------------------------------------------
-  //--------------------------------------------------------------------------------
-
-  @Override
-  public FloatValues create(IndexReader reader) throws IOException {
-    return validate( new FloatValues(), reader );
-  }
-
-  @Override
-  public FloatValues validate(FloatValues entry, IndexReader reader) throws IOException {
-    boolean ok = false;
-    if( hasOption(OPTION_CACHE_VALUES) ) {
-      ok = true;
-      if( entry.values == null ) {
-        fillFloatValues(entry, reader, field);
-      }
-    }
-    if( hasOption(OPTION_CACHE_BITS) ) {
-      ok = true;
-      if( entry.valid == null ) {
-        fillValidBits(entry, reader, field);
-      }
-    }
-    if( !ok ) {
-      throw new RuntimeException( "the config must cache values and/or bits" );
-    }
-    return entry;
-  }
-
-  protected void fillFloatValues( FloatValues vals, IndexReader reader, String field ) throws
IOException
-  {
-    if( parser == null ) {
-      try {
-        parser = FieldCache.DEFAULT_FLOAT_PARSER;
-        fillFloatValues( vals, reader, field );
-        return;
-      }
-      catch (NumberFormatException ne) {
-        vals.parserHashCode = null; // wipe the previous one
-        parser = FieldCache.NUMERIC_UTILS_FLOAT_PARSER;
-        fillFloatValues( vals, reader, field );
-        return;
-      }
-    }
-    assertSameParserAndResetCounts(vals, parser);
-
-    Terms terms = MultiFields.getTerms(reader, field);
-    int maxDoc = reader.maxDoc();
-    vals.values = null;
-    if (terms != null) {
-      final TermsEnum termsEnum = terms.iterator();
-      final Bits delDocs = MultiFields.getDeletedDocs(reader);
-      OpenBitSet validBits = (hasOption(OPTION_CACHE_BITS)) ? new OpenBitSet( maxDoc ) :
null;
-      DocsEnum docs = null;
-      try {
-        while(true) {
-          final BytesRef term = termsEnum.next();
-          if (term == null) {
-            break;
-          }
-          final float termval = parser.parseFloat(term);
-          docs = termsEnum.docs(delDocs, docs);
-          while (true) {
-            final int docID = docs.nextDoc();
-            if (docID == DocIdSetIterator.NO_MORE_DOCS) {
-              break;
-            }
-            if(vals.values == null) {
-              vals.values = new float[maxDoc];
-            }
-            vals.values[docID] = termval;
-            vals.numDocs++;
-            if( validBits != null ) {
-              validBits.set( docID );
-            }
-          }
-          vals.numTerms++;
-        }
-      } catch (FieldCache.StopFillCacheException stop) {}
-
-      if( vals.valid == null ) {
-        vals.valid = checkMatchAllBits( delDocs, validBits, vals.numDocs, maxDoc );
-      }
-    }
-
-    if(vals.values == null) {
-      vals.values = new float[maxDoc];
-    }
-
-    if( vals.valid == null && vals.numDocs < 1 ) {
-      vals.valid = new Bits.MatchNoBits( maxDoc );
-    }
-  }
+package org.apache.lucene.search.cache;
+
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import java.io.IOException;
+
+import org.apache.lucene.index.DocsEnum;
+import org.apache.lucene.index.IndexReader;
+import org.apache.lucene.index.MultiFields;
+import org.apache.lucene.index.Terms;
+import org.apache.lucene.index.TermsEnum;
+import org.apache.lucene.search.DocIdSetIterator;
+import org.apache.lucene.search.FieldCache;
+import org.apache.lucene.search.SortField;
+import org.apache.lucene.search.FieldCache.FloatParser;
+import org.apache.lucene.search.FieldCache.Parser;
+import org.apache.lucene.search.cache.CachedArray.FloatValues;
+import org.apache.lucene.util.Bits;
+import org.apache.lucene.util.BytesRef;
+import org.apache.lucene.util.OpenBitSet;
+
+public class FloatValuesCreator extends CachedArrayCreator<FloatValues>
+{
+  protected FloatParser parser;
+
+  public FloatValuesCreator( String field, FloatParser parser, int options )
+  {
+    super( field, options );
+    this.parser = parser;
+  }
+
+  public FloatValuesCreator( String field, FloatParser parser )
+  {
+    super( field );
+    this.parser = parser;
+  }
+
+  @Override
+  public Class getArrayType() {
+    return Float.class;
+  }
+
+  @Override
+  public Parser getParser() {
+    return parser;
+  }
+  
+  @Override
+  public int getSortTypeID() {
+    return SortField.FLOAT;
+  }
+
+
+  //--------------------------------------------------------------------------------
+  //--------------------------------------------------------------------------------
+
+  @Override
+  public FloatValues create(IndexReader reader) throws IOException {
+    return validate( new FloatValues(), reader );
+  }
+
+  @Override
+  public FloatValues validate(FloatValues entry, IndexReader reader) throws IOException {
+    boolean ok = false;
+    if( hasOption(OPTION_CACHE_VALUES) ) {
+      ok = true;
+      if( entry.values == null ) {
+        fillFloatValues(entry, reader, field);
+      }
+    }
+    if( hasOption(OPTION_CACHE_BITS) ) {
+      ok = true;
+      if( entry.valid == null ) {
+        fillValidBits(entry, reader, field);
+      }
+    }
+    if( !ok ) {
+      throw new RuntimeException( "the config must cache values and/or bits" );
+    }
+    return entry;
+  }
+
+  protected void fillFloatValues( FloatValues vals, IndexReader reader, String field ) throws
IOException
+  {
+    if( parser == null ) {
+      try {
+        parser = FieldCache.DEFAULT_FLOAT_PARSER;
+        fillFloatValues( vals, reader, field );
+        return;
+      }
+      catch (NumberFormatException ne) {
+        vals.parserHashCode = null; // wipe the previous one
+        parser = FieldCache.NUMERIC_UTILS_FLOAT_PARSER;
+        fillFloatValues( vals, reader, field );
+        return;
+      }
+    }
+    assertSameParserAndResetCounts(vals, parser);
+
+    Terms terms = MultiFields.getTerms(reader, field);
+    int maxDoc = reader.maxDoc();
+    vals.values = null;
+    if (terms != null) {
+      final TermsEnum termsEnum = terms.iterator();
+      final Bits delDocs = MultiFields.getDeletedDocs(reader);
+      OpenBitSet validBits = (hasOption(OPTION_CACHE_BITS)) ? new OpenBitSet( maxDoc ) :
null;
+      DocsEnum docs = null;
+      try {
+        while(true) {
+          final BytesRef term = termsEnum.next();
+          if (term == null) {
+            break;
+          }
+          final float termval = parser.parseFloat(term);
+          docs = termsEnum.docs(delDocs, docs);
+          while (true) {
+            final int docID = docs.nextDoc();
+            if (docID == DocIdSetIterator.NO_MORE_DOCS) {
+              break;
+            }
+            if(vals.values == null) {
+              vals.values = new float[maxDoc];
+            }
+            vals.values[docID] = termval;
+            vals.numDocs++;
+            if( validBits != null ) {
+              validBits.set( docID );
+            }
+          }
+          vals.numTerms++;
+        }
+      } catch (FieldCache.StopFillCacheException stop) {}
+
+      if( vals.valid == null ) {
+        vals.valid = checkMatchAllBits( delDocs, validBits, vals.numDocs, maxDoc );
+      }
+    }
+
+    if(vals.values == null) {
+      vals.values = new float[maxDoc];
+    }
+
+    if( vals.valid == null && vals.numDocs < 1 ) {
+      vals.valid = new Bits.MatchNoBits( maxDoc );
+    }
+  }
 }
\ No newline at end of file

Propchange: lucene/dev/trunk/lucene/src/java/org/apache/lucene/search/cache/FloatValuesCreator.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: lucene/dev/trunk/lucene/src/java/org/apache/lucene/search/cache/IntValuesCreator.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/src/java/org/apache/lucene/search/cache/IntValuesCreator.java?rev=1001534&r1=1001533&r2=1001534&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/src/java/org/apache/lucene/search/cache/IntValuesCreator.java
(original)
+++ lucene/dev/trunk/lucene/src/java/org/apache/lucene/search/cache/IntValuesCreator.java
Sun Sep 26 22:00:58 2010
@@ -1,150 +1,162 @@
-package org.apache.lucene.search.cache;
-
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-import java.io.IOException;
-
-import org.apache.lucene.index.DocsEnum;
-import org.apache.lucene.index.IndexReader;
-import org.apache.lucene.index.MultiFields;
-import org.apache.lucene.index.Terms;
-import org.apache.lucene.index.TermsEnum;
-import org.apache.lucene.search.DocIdSetIterator;
-import org.apache.lucene.search.FieldCache;
-import org.apache.lucene.search.FieldCache.IntParser;
-import org.apache.lucene.search.cache.CachedArray.IntValues;
-import org.apache.lucene.util.Bits;
-import org.apache.lucene.util.BytesRef;
-import org.apache.lucene.util.OpenBitSet;
-
-public class IntValuesCreator extends CachedArrayCreator<IntValues>
-{
-  protected IntParser parser;
-
-  public IntValuesCreator( String field, IntParser parser, int options )
-  {
-    super( field, options );
-    this.parser = parser;
-  }
-
-  public IntValuesCreator( String field, IntParser parser )
-  {
-    super( field );
-    this.parser = parser;
-  }
-
-  @Override
-  public Class getArrayType() {
-    return Integer.class;
-  }
-
-
-  //--------------------------------------------------------------------------------
-  //--------------------------------------------------------------------------------
-
-  @Override
-  public IntValues create(IndexReader reader) throws IOException {
-    return validate( new IntValues(), reader );
-  }
-
-  @Override
-  public IntValues validate(IntValues entry, IndexReader reader) throws IOException {
-    boolean ok = false;
-    if( hasOption(OPTION_CACHE_VALUES) ) {
-      ok = true;
-      if( entry.values == null ) {
-        fillIntValues(entry, reader, field);
-      }
-    }
-    if( hasOption(OPTION_CACHE_BITS) ) {
-      ok = true;
-      if( entry.valid == null ) {
-        fillValidBits(entry, reader, field);
-      }
-    }
-    if( !ok ) {
-      throw new RuntimeException( "the config must cache values and/or bits" );
-    }
-    return entry;
-  }
-
-  protected void fillIntValues( IntValues vals, IndexReader reader, String field ) throws
IOException
-  {
-    if( parser == null ) {
-      try {
-        parser = FieldCache.DEFAULT_INT_PARSER;
-        fillIntValues( vals, reader, field );
-        return;
-      }
-      catch (NumberFormatException ne) {
-        vals.parserHashCode = null;
-        parser = FieldCache.NUMERIC_UTILS_INT_PARSER;
-        fillIntValues( vals, reader, field );
-        return;
-      }
-    }
-    assertSameParserAndResetCounts(vals, parser);
-    
-    Terms terms = MultiFields.getTerms(reader, field);
-    int maxDoc = reader.maxDoc();
-    vals.values = null;
-    if (terms != null) {
-      final TermsEnum termsEnum = terms.iterator();
-      final Bits delDocs = MultiFields.getDeletedDocs(reader);
-      OpenBitSet validBits = (hasOption(OPTION_CACHE_BITS)) ? new OpenBitSet( maxDoc ) :
null;
-      DocsEnum docs = null;
-      try {
-        while(true) {
-          final BytesRef term = termsEnum.next();
-          if (term == null) {
-            break;
-          }
-          final int termval = parser.parseInt(term);
-          docs = termsEnum.docs(delDocs, docs);
-          while (true) {
-            final int docID = docs.nextDoc();
-            if (docID == DocIdSetIterator.NO_MORE_DOCS) {
-              break;
-            }
-            if(vals.values == null) {
-              vals.values = new int[maxDoc];
-            }
-            vals.values[docID] = termval;
-            vals.numDocs++;
-            if( validBits != null ) {
-              validBits.set( docID );
-            }
-          }
-          vals.numTerms++;
-        }
-      } catch (FieldCache.StopFillCacheException stop) {}
-
-      if( vals.valid == null ) {
-        vals.valid = checkMatchAllBits( delDocs, validBits, vals.numDocs, maxDoc );
-      }
-    }
-
-    if(vals.values == null) {
-      vals.values = new int[maxDoc];
-    }
-
-    if( vals.valid == null && vals.numDocs < 1 ) {
-      vals.valid = new Bits.MatchNoBits( maxDoc );
-    }
-  }
+package org.apache.lucene.search.cache;
+
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import java.io.IOException;
+
+import org.apache.lucene.index.DocsEnum;
+import org.apache.lucene.index.IndexReader;
+import org.apache.lucene.index.MultiFields;
+import org.apache.lucene.index.Terms;
+import org.apache.lucene.index.TermsEnum;
+import org.apache.lucene.search.DocIdSetIterator;
+import org.apache.lucene.search.FieldCache;
+import org.apache.lucene.search.SortField;
+import org.apache.lucene.search.FieldCache.IntParser;
+import org.apache.lucene.search.FieldCache.Parser;
+import org.apache.lucene.search.cache.CachedArray.IntValues;
+import org.apache.lucene.util.Bits;
+import org.apache.lucene.util.BytesRef;
+import org.apache.lucene.util.OpenBitSet;
+
+public class IntValuesCreator extends CachedArrayCreator<IntValues>
+{
+  protected IntParser parser;
+
+  public IntValuesCreator( String field, IntParser parser, int options )
+  {
+    super( field, options );
+    this.parser = parser;
+  }
+
+  public IntValuesCreator( String field, IntParser parser )
+  {
+    super( field );
+    this.parser = parser;
+  }
+
+  @Override
+  public Class getArrayType() {
+    return Integer.class;
+  }
+
+  @Override
+  public Parser getParser() {
+    return parser;
+  }
+  
+  @Override
+  public int getSortTypeID() {
+    return SortField.INT;
+  }
+
+
+  //--------------------------------------------------------------------------------
+  //--------------------------------------------------------------------------------
+
+  @Override
+  public IntValues create(IndexReader reader) throws IOException {
+    return validate( new IntValues(), reader );
+  }
+
+  @Override
+  public IntValues validate(IntValues entry, IndexReader reader) throws IOException {
+    boolean ok = false;
+    if( hasOption(OPTION_CACHE_VALUES) ) {
+      ok = true;
+      if( entry.values == null ) {
+        fillIntValues(entry, reader, field);
+      }
+    }
+    if( hasOption(OPTION_CACHE_BITS) ) {
+      ok = true;
+      if( entry.valid == null ) {
+        fillValidBits(entry, reader, field);
+      }
+    }
+    if( !ok ) {
+      throw new RuntimeException( "the config must cache values and/or bits" );
+    }
+    return entry;
+  }
+
+  protected void fillIntValues( IntValues vals, IndexReader reader, String field ) throws
IOException
+  {
+    if( parser == null ) {
+      try {
+        parser = FieldCache.DEFAULT_INT_PARSER;
+        fillIntValues( vals, reader, field );
+        return;
+      }
+      catch (NumberFormatException ne) {
+        vals.parserHashCode = null;
+        parser = FieldCache.NUMERIC_UTILS_INT_PARSER;
+        fillIntValues( vals, reader, field );
+        return;
+      }
+    }
+    assertSameParserAndResetCounts(vals, parser);
+    
+    Terms terms = MultiFields.getTerms(reader, field);
+    int maxDoc = reader.maxDoc();
+    vals.values = null;
+    if (terms != null) {
+      final TermsEnum termsEnum = terms.iterator();
+      final Bits delDocs = MultiFields.getDeletedDocs(reader);
+      OpenBitSet validBits = (hasOption(OPTION_CACHE_BITS)) ? new OpenBitSet( maxDoc ) :
null;
+      DocsEnum docs = null;
+      try {
+        while(true) {
+          final BytesRef term = termsEnum.next();
+          if (term == null) {
+            break;
+          }
+          final int termval = parser.parseInt(term);
+          docs = termsEnum.docs(delDocs, docs);
+          while (true) {
+            final int docID = docs.nextDoc();
+            if (docID == DocIdSetIterator.NO_MORE_DOCS) {
+              break;
+            }
+            if(vals.values == null) {
+              vals.values = new int[maxDoc];
+            }
+            vals.values[docID] = termval;
+            vals.numDocs++;
+            if( validBits != null ) {
+              validBits.set( docID );
+            }
+          }
+          vals.numTerms++;
+        }
+      } catch (FieldCache.StopFillCacheException stop) {}
+
+      if( vals.valid == null ) {
+        vals.valid = checkMatchAllBits( delDocs, validBits, vals.numDocs, maxDoc );
+      }
+    }
+
+    if(vals.values == null) {
+      vals.values = new int[maxDoc];
+    }
+
+    if( vals.valid == null && vals.numDocs < 1 ) {
+      vals.valid = new Bits.MatchNoBits( maxDoc );
+    }
+  }
 }
\ No newline at end of file

Propchange: lucene/dev/trunk/lucene/src/java/org/apache/lucene/search/cache/IntValuesCreator.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: lucene/dev/trunk/lucene/src/java/org/apache/lucene/search/cache/LongValuesCreator.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/src/java/org/apache/lucene/search/cache/LongValuesCreator.java?rev=1001534&r1=1001533&r2=1001534&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/src/java/org/apache/lucene/search/cache/LongValuesCreator.java
(original)
+++ lucene/dev/trunk/lucene/src/java/org/apache/lucene/search/cache/LongValuesCreator.java
Sun Sep 26 22:00:58 2010
@@ -1,150 +1,162 @@
-package org.apache.lucene.search.cache;
-
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-import java.io.IOException;
-
-import org.apache.lucene.index.DocsEnum;
-import org.apache.lucene.index.IndexReader;
-import org.apache.lucene.index.MultiFields;
-import org.apache.lucene.index.Terms;
-import org.apache.lucene.index.TermsEnum;
-import org.apache.lucene.search.DocIdSetIterator;
-import org.apache.lucene.search.FieldCache;
-import org.apache.lucene.search.FieldCache.LongParser;
-import org.apache.lucene.search.cache.CachedArray.LongValues;
-import org.apache.lucene.util.Bits;
-import org.apache.lucene.util.BytesRef;
-import org.apache.lucene.util.OpenBitSet;
-
-public class LongValuesCreator extends CachedArrayCreator<LongValues>
-{
-  protected LongParser parser;
-
-  public LongValuesCreator( String field, LongParser parser, int options )
-  {
-    super( field, options );
-    this.parser = parser;
-  }
-
-  public LongValuesCreator( String field, LongParser parser )
-  {
-    super( field );
-    this.parser = parser;
-  }
-
-  @Override
-  public Class getArrayType() {
-    return Long.class;
-  }
-
-
-  //--------------------------------------------------------------------------------
-  //--------------------------------------------------------------------------------
-
-  @Override
-  public LongValues create(IndexReader reader) throws IOException {
-    return validate( new LongValues(), reader );
-  }
-
-  @Override
-  public LongValues validate(LongValues entry, IndexReader reader) throws IOException {
-    boolean ok = false;
-    if( hasOption(OPTION_CACHE_VALUES) ) {
-      ok = true;
-      if( entry.values == null ) {
-        fillLongValues(entry, reader, field);
-      }
-    }
-    if( hasOption(OPTION_CACHE_BITS) ) {
-      ok = true;
-      if( entry.valid == null ) {
-        fillValidBits(entry, reader, field);
-      }
-    }
-    if( !ok ) {
-      throw new RuntimeException( "the config must cache values and/or bits" );
-    }
-    return entry;
-  }
-
-  protected void fillLongValues( LongValues vals, IndexReader reader, String field ) throws
IOException
-  {
-    if( parser == null ) {
-      try {
-        parser = FieldCache.DEFAULT_LONG_PARSER;
-        fillLongValues( vals, reader, field );
-        return;
-      }
-      catch (NumberFormatException ne) {
-        vals.parserHashCode = null; // wipe the previous one
-        parser = FieldCache.NUMERIC_UTILS_LONG_PARSER;
-        fillLongValues( vals, reader, field );
-        return;
-      }
-    }
-    assertSameParserAndResetCounts(vals, parser);
-
-    Terms terms = MultiFields.getTerms(reader, field);
-    int maxDoc = reader.maxDoc();
-    vals.values = null;
-    if (terms != null) {
-      final TermsEnum termsEnum = terms.iterator();
-      final Bits delDocs = MultiFields.getDeletedDocs(reader);
-      OpenBitSet validBits = (hasOption(OPTION_CACHE_BITS)) ? new OpenBitSet( maxDoc ) :
null;
-      DocsEnum docs = null;
-      try {
-        while(true) {
-          final BytesRef term = termsEnum.next();
-          if (term == null) {
-            break;
-          }
-          final long termval = parser.parseLong(term);
-          docs = termsEnum.docs(delDocs, docs);
-          while (true) {
-            final int docID = docs.nextDoc();
-            if (docID == DocIdSetIterator.NO_MORE_DOCS) {
-              break;
-            }
-            if(vals.values == null) {
-              vals.values = new long[maxDoc];
-            }
-            vals.values[docID] = termval;
-            vals.numDocs++;
-            if( validBits != null ) {
-              validBits.set( docID );
-            }
-          }
-          vals.numTerms++;
-        }
-      } catch (FieldCache.StopFillCacheException stop) {}
-
-      if( vals.valid == null ) {
-        vals.valid = checkMatchAllBits( delDocs, validBits, vals.numDocs, maxDoc );
-      }
-    }
-
-    if(vals.values == null) {
-      vals.values = new long[maxDoc];
-    }
-
-    if( vals.valid == null && vals.numDocs < 1 ) {
-      vals.valid = new Bits.MatchNoBits( maxDoc );
-    }
-  }
+package org.apache.lucene.search.cache;
+
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import java.io.IOException;
+
+import org.apache.lucene.index.DocsEnum;
+import org.apache.lucene.index.IndexReader;
+import org.apache.lucene.index.MultiFields;
+import org.apache.lucene.index.Terms;
+import org.apache.lucene.index.TermsEnum;
+import org.apache.lucene.search.DocIdSetIterator;
+import org.apache.lucene.search.FieldCache;
+import org.apache.lucene.search.SortField;
+import org.apache.lucene.search.FieldCache.LongParser;
+import org.apache.lucene.search.FieldCache.Parser;
+import org.apache.lucene.search.cache.CachedArray.LongValues;
+import org.apache.lucene.util.Bits;
+import org.apache.lucene.util.BytesRef;
+import org.apache.lucene.util.OpenBitSet;
+
+public class LongValuesCreator extends CachedArrayCreator<LongValues>
+{
+  protected LongParser parser;
+
+  public LongValuesCreator( String field, LongParser parser, int options )
+  {
+    super( field, options );
+    this.parser = parser;
+  }
+
+  public LongValuesCreator( String field, LongParser parser )
+  {
+    super( field );
+    this.parser = parser;
+  }
+
+  @Override
+  public Class getArrayType() {
+    return Long.class;
+  }
+
+  @Override
+  public Parser getParser() {
+    return parser;
+  }
+  
+  @Override
+  public int getSortTypeID() {
+    return SortField.LONG;
+  }
+
+
+  //--------------------------------------------------------------------------------
+  //--------------------------------------------------------------------------------
+
+  @Override
+  public LongValues create(IndexReader reader) throws IOException {
+    return validate( new LongValues(), reader );
+  }
+
+  @Override
+  public LongValues validate(LongValues entry, IndexReader reader) throws IOException {
+    boolean ok = false;
+    if( hasOption(OPTION_CACHE_VALUES) ) {
+      ok = true;
+      if( entry.values == null ) {
+        fillLongValues(entry, reader, field);
+      }
+    }
+    if( hasOption(OPTION_CACHE_BITS) ) {
+      ok = true;
+      if( entry.valid == null ) {
+        fillValidBits(entry, reader, field);
+      }
+    }
+    if( !ok ) {
+      throw new RuntimeException( "the config must cache values and/or bits" );
+    }
+    return entry;
+  }
+
+  protected void fillLongValues( LongValues vals, IndexReader reader, String field ) throws
IOException
+  {
+    if( parser == null ) {
+      try {
+        parser = FieldCache.DEFAULT_LONG_PARSER;
+        fillLongValues( vals, reader, field );
+        return;
+      }
+      catch (NumberFormatException ne) {
+        vals.parserHashCode = null; // wipe the previous one
+        parser = FieldCache.NUMERIC_UTILS_LONG_PARSER;
+        fillLongValues( vals, reader, field );
+        return;
+      }
+    }
+    assertSameParserAndResetCounts(vals, parser);
+
+    Terms terms = MultiFields.getTerms(reader, field);
+    int maxDoc = reader.maxDoc();
+    vals.values = null;
+    if (terms != null) {
+      final TermsEnum termsEnum = terms.iterator();
+      final Bits delDocs = MultiFields.getDeletedDocs(reader);
+      OpenBitSet validBits = (hasOption(OPTION_CACHE_BITS)) ? new OpenBitSet( maxDoc ) :
null;
+      DocsEnum docs = null;
+      try {
+        while(true) {
+          final BytesRef term = termsEnum.next();
+          if (term == null) {
+            break;
+          }
+          final long termval = parser.parseLong(term);
+          docs = termsEnum.docs(delDocs, docs);
+          while (true) {
+            final int docID = docs.nextDoc();
+            if (docID == DocIdSetIterator.NO_MORE_DOCS) {
+              break;
+            }
+            if(vals.values == null) {
+              vals.values = new long[maxDoc];
+            }
+            vals.values[docID] = termval;
+            vals.numDocs++;
+            if( validBits != null ) {
+              validBits.set( docID );
+            }
+          }
+          vals.numTerms++;
+        }
+      } catch (FieldCache.StopFillCacheException stop) {}
+
+      if( vals.valid == null ) {
+        vals.valid = checkMatchAllBits( delDocs, validBits, vals.numDocs, maxDoc );
+      }
+    }
+
+    if(vals.values == null) {
+      vals.values = new long[maxDoc];
+    }
+
+    if( vals.valid == null && vals.numDocs < 1 ) {
+      vals.valid = new Bits.MatchNoBits( maxDoc );
+    }
+  }
 }
\ No newline at end of file

Propchange: lucene/dev/trunk/lucene/src/java/org/apache/lucene/search/cache/LongValuesCreator.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: lucene/dev/trunk/lucene/src/java/org/apache/lucene/search/cache/ShortValuesCreator.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/src/java/org/apache/lucene/search/cache/ShortValuesCreator.java?rev=1001534&r1=1001533&r2=1001534&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/src/java/org/apache/lucene/search/cache/ShortValuesCreator.java
(original)
+++ lucene/dev/trunk/lucene/src/java/org/apache/lucene/search/cache/ShortValuesCreator.java
Sun Sep 26 22:00:58 2010
@@ -1,132 +1,144 @@
-package org.apache.lucene.search.cache;
-
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-import java.io.IOException;
-
-import org.apache.lucene.index.DocsEnum;
-import org.apache.lucene.index.IndexReader;
-import org.apache.lucene.index.MultiFields;
-import org.apache.lucene.index.Terms;
-import org.apache.lucene.index.TermsEnum;
-import org.apache.lucene.search.DocIdSetIterator;
-import org.apache.lucene.search.FieldCache;
-import org.apache.lucene.search.FieldCache.ShortParser;
-import org.apache.lucene.search.cache.CachedArray.ShortValues;
-import org.apache.lucene.util.Bits;
-import org.apache.lucene.util.BytesRef;
-import org.apache.lucene.util.OpenBitSet;
-
-public class ShortValuesCreator extends CachedArrayCreator<ShortValues>
-{
-  protected ShortParser parser;
-
-  public ShortValuesCreator( String field, ShortParser parser, int options )
-  {
-    super( field, options );
-    this.parser = parser;
-  }
-
-  public ShortValuesCreator( String field, ShortParser parser )
-  {
-    super( field );
-    this.parser = parser;
-  }
-
-  @Override
-  public Class getArrayType() {
-    return Short.class;
-  }
-
-
-  //--------------------------------------------------------------------------------
-  //--------------------------------------------------------------------------------
-
-  @Override
-  public ShortValues create(IndexReader reader) throws IOException {
-    return validate( new ShortValues(), reader );
-  }
-
-  @Override
-  public ShortValues validate(ShortValues entry, IndexReader reader) throws IOException {
-    boolean ok = false;
-    if( hasOption(OPTION_CACHE_VALUES) ) {
-      ok = true;
-      if( entry.values == null ) {
-        fillShortValues(entry, reader, field);
-      }
-    }
-    if( hasOption(OPTION_CACHE_BITS) ) {
-      ok = true;
-      if( entry.valid == null ) {
-        fillValidBits(entry, reader, field);
-      }
-    }
-    if( !ok ) {
-      throw new RuntimeException( "the config must cache values and/or bits" );
-    }
-    return entry;
-  }
-
-  protected void fillShortValues( ShortValues vals, IndexReader reader, String field ) throws
IOException
-  {
-    if( parser == null ) {
-      parser = FieldCache.DEFAULT_SHORT_PARSER;
-    }
-    assertSameParserAndResetCounts(vals, parser);
-
-    Terms terms = MultiFields.getTerms(reader, field);
-    int maxDoc = reader.maxDoc();
-    vals.values = new short[maxDoc];
-    if (terms != null) {
-      final TermsEnum termsEnum = terms.iterator();
-      final Bits delDocs = MultiFields.getDeletedDocs(reader);
-      OpenBitSet validBits = (hasOption(OPTION_CACHE_BITS)) ? new OpenBitSet( maxDoc ) :
null;
-      DocsEnum docs = null;
-      try {
-        while(true) {
-          final BytesRef term = termsEnum.next();
-          if (term == null) {
-            break;
-          }
-          final Short termval = parser.parseShort(term);
-          docs = termsEnum.docs(delDocs, docs);
-          while (true) {
-            final int docID = docs.nextDoc();
-            if (docID == DocIdSetIterator.NO_MORE_DOCS) {
-              break;
-            }
-            vals.values[docID] = termval;
-            vals.numDocs++;
-            if( validBits != null ) {
-              validBits.set( docID );
-            }
-          }
-          vals.numTerms++;
-        }
-      } catch (FieldCache.StopFillCacheException stop) {}
-
-      if( vals.valid == null ) {
-        vals.valid = checkMatchAllBits( delDocs, validBits, vals.numDocs, maxDoc );
-      }
-    }
-    if( vals.valid == null && vals.numDocs < 1 ) {
-      vals.valid = new Bits.MatchNoBits( maxDoc );
-    }
-  }
+package org.apache.lucene.search.cache;
+
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import java.io.IOException;
+
+import org.apache.lucene.index.DocsEnum;
+import org.apache.lucene.index.IndexReader;
+import org.apache.lucene.index.MultiFields;
+import org.apache.lucene.index.Terms;
+import org.apache.lucene.index.TermsEnum;
+import org.apache.lucene.search.DocIdSetIterator;
+import org.apache.lucene.search.FieldCache;
+import org.apache.lucene.search.SortField;
+import org.apache.lucene.search.FieldCache.Parser;
+import org.apache.lucene.search.FieldCache.ShortParser;
+import org.apache.lucene.search.cache.CachedArray.ShortValues;
+import org.apache.lucene.util.Bits;
+import org.apache.lucene.util.BytesRef;
+import org.apache.lucene.util.OpenBitSet;
+
+public class ShortValuesCreator extends CachedArrayCreator<ShortValues>
+{
+  protected ShortParser parser;
+
+  public ShortValuesCreator( String field, ShortParser parser, int options )
+  {
+    super( field, options );
+    this.parser = parser;
+  }
+
+  public ShortValuesCreator( String field, ShortParser parser )
+  {
+    super( field );
+    this.parser = parser;
+  }
+
+  @Override
+  public Class getArrayType() {
+    return Short.class;
+  }
+
+  @Override
+  public Parser getParser() {
+    return parser;
+  }
+  
+  @Override
+  public int getSortTypeID() {
+    return SortField.SHORT;
+  }
+
+
+  //--------------------------------------------------------------------------------
+  //--------------------------------------------------------------------------------
+
+  @Override
+  public ShortValues create(IndexReader reader) throws IOException {
+    return validate( new ShortValues(), reader );
+  }
+
+  @Override
+  public ShortValues validate(ShortValues entry, IndexReader reader) throws IOException {
+    boolean ok = false;
+    if( hasOption(OPTION_CACHE_VALUES) ) {
+      ok = true;
+      if( entry.values == null ) {
+        fillShortValues(entry, reader, field);
+      }
+    }
+    if( hasOption(OPTION_CACHE_BITS) ) {
+      ok = true;
+      if( entry.valid == null ) {
+        fillValidBits(entry, reader, field);
+      }
+    }
+    if( !ok ) {
+      throw new RuntimeException( "the config must cache values and/or bits" );
+    }
+    return entry;
+  }
+
+  protected void fillShortValues( ShortValues vals, IndexReader reader, String field ) throws
IOException
+  {
+    if( parser == null ) {
+      parser = FieldCache.DEFAULT_SHORT_PARSER;
+    }
+    assertSameParserAndResetCounts(vals, parser);
+
+    Terms terms = MultiFields.getTerms(reader, field);
+    int maxDoc = reader.maxDoc();
+    vals.values = new short[maxDoc];
+    if (terms != null) {
+      final TermsEnum termsEnum = terms.iterator();
+      final Bits delDocs = MultiFields.getDeletedDocs(reader);
+      OpenBitSet validBits = (hasOption(OPTION_CACHE_BITS)) ? new OpenBitSet( maxDoc ) :
null;
+      DocsEnum docs = null;
+      try {
+        while(true) {
+          final BytesRef term = termsEnum.next();
+          if (term == null) {
+            break;
+          }
+          final Short termval = parser.parseShort(term);
+          docs = termsEnum.docs(delDocs, docs);
+          while (true) {
+            final int docID = docs.nextDoc();
+            if (docID == DocIdSetIterator.NO_MORE_DOCS) {
+              break;
+            }
+            vals.values[docID] = termval;
+            vals.numDocs++;
+            if( validBits != null ) {
+              validBits.set( docID );
+            }
+          }
+          vals.numTerms++;
+        }
+      } catch (FieldCache.StopFillCacheException stop) {}
+
+      if( vals.valid == null ) {
+        vals.valid = checkMatchAllBits( delDocs, validBits, vals.numDocs, maxDoc );
+      }
+    }
+    if( vals.valid == null && vals.numDocs < 1 ) {
+      vals.valid = new Bits.MatchNoBits( maxDoc );
+    }
+  }
 }
\ No newline at end of file

Propchange: lucene/dev/trunk/lucene/src/java/org/apache/lucene/search/cache/ShortValuesCreator.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: lucene/dev/trunk/lucene/src/java/org/apache/lucene/search/cache/SimpleEntryKey.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/src/java/org/apache/lucene/search/cache/SimpleEntryKey.java?rev=1001534&r1=1001533&r2=1001534&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/src/java/org/apache/lucene/search/cache/SimpleEntryKey.java (original)
+++ lucene/dev/trunk/lucene/src/java/org/apache/lucene/search/cache/SimpleEntryKey.java Sun
Sep 26 22:00:58 2010
@@ -1,59 +1,77 @@
-package org.apache.lucene.search.cache;
-
-public class SimpleEntryKey extends EntryKey
-{
-  public final Class clazz;
-  public final Object[] args;
-  public final int hash;
-
-  public SimpleEntryKey( Class clazz, Object ... args ) {
-    this.clazz = clazz;
-    this.args = args;
-
-    int hash = clazz.hashCode();
-    if( args != null ) {
-      for( Object obj : args ) {
-        hash ^= obj.hashCode();
-      }
-    }
-    this.hash = hash;
-  }
-
-  @Override
-  public boolean equals(Object obj) {
-    if( obj instanceof SimpleEntryKey ) {
-      SimpleEntryKey key = (SimpleEntryKey)obj;
-      if( key.hash != hash ||
-          key.clazz != clazz ||
-          key.args.length != args.length ) {
-        return false;
-      }
-
-      // In the off chance that the hash etc is all the same
-      // we should actually check the values
-      for( int i=0; i<args.length; i++ ) {
-        if( !args[i].equals( key.args[i] ) ) {
-          return false;
-        }
-      }
-      return true;
-    }
-    return false;
-  }
-
-  @Override
-  public int hashCode() {
-    return hash;
-  }
-
-  @Override
-  public String toString() {
-    StringBuilder str = new StringBuilder();
-    str.append( '[' ).append( clazz.getName() ).append( ':' );
-    for( Object v : args ) {
-      str.append( v ).append( ':' );
-    }
-    str.append( hash ).append( ']' );
-    return str.toString();
-  }
-}
+package org.apache.lucene.search.cache;
+
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+public class SimpleEntryKey extends EntryKey
+{
+  public final Class clazz;
+  public final Object[] args;
+  public final int hash;
+
+  public SimpleEntryKey( Class clazz, Object ... args ) {
+    this.clazz = clazz;
+    this.args = args;
+
+    int hash = clazz.hashCode();
+    if( args != null ) {
+      for( Object obj : args ) {
+        hash ^= obj.hashCode();
+      }
+    }
+    this.hash = hash;
+  }
+
+  @Override
+  public boolean equals(Object obj) {
+    if( obj instanceof SimpleEntryKey ) {
+      SimpleEntryKey key = (SimpleEntryKey)obj;
+      if( key.hash != hash ||
+          key.clazz != clazz ||
+          key.args.length != args.length ) {
+        return false;
+      }
+
+      // In the off chance that the hash etc is all the same
+      // we should actually check the values
+      for( int i=0; i<args.length; i++ ) {
+        if( !args[i].equals( key.args[i] ) ) {
+          return false;
+        }
+      }
+      return true;
+    }
+    return false;
+  }
+
+  @Override
+  public int hashCode() {
+    return hash;
+  }
+
+  @Override
+  public String toString() {
+    StringBuilder str = new StringBuilder();
+    str.append( '[' ).append( clazz.getName() ).append( ':' );
+    for( Object v : args ) {
+      str.append( v ).append( ':' );
+    }
+    str.append( hash ).append( ']' );
+    return str.toString();
+  }
+}

Propchange: lucene/dev/trunk/lucene/src/java/org/apache/lucene/search/cache/SimpleEntryKey.java
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message