You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by mi...@apache.org on 2015/12/11 22:13:43 UTC

svn commit: r1719562 [3/8] - in /lucene/dev/trunk: lucene/ lucene/analysis/common/src/test/org/apache/lucene/analysis/core/ lucene/backward-codecs/src/test/org/apache/lucene/index/ lucene/benchmark/src/java/org/apache/lucene/benchmark/byTask/feeds/ luc...

Added: lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/util/NumericUtils.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/util/NumericUtils.java?rev=1719562&view=auto
==============================================================================
--- lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/util/NumericUtils.java (added)
+++ lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/util/NumericUtils.java Fri Dec 11 21:13:41 2015
@@ -0,0 +1,258 @@
+package org.apache.lucene.util;
+
+/*
+ * 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.math.BigInteger;
+import java.util.Arrays;
+
+/**
+ * Helper APIs to encode numeric values as sortable bytes and vice-versa.
+ *
+ * @lucene.internal
+ */
+public final class NumericUtils {
+
+  private NumericUtils() {} // no instance!
+  
+  /**
+   * Converts a <code>double</code> value to a sortable signed <code>long</code>.
+   * The value is converted by getting their IEEE 754 floating-point &quot;double format&quot;
+   * bit layout and then some bits are swapped, to be able to compare the result as long.
+   * By this the precision is not reduced, but the value can easily used as a long.
+   * The sort order (including {@link Double#NaN}) is defined by
+   * {@link Double#compareTo}; {@code NaN} is greater than positive infinity.
+   * @see #sortableLongToDouble
+   */
+  public static long doubleToSortableLong(double val) {
+    return sortableDoubleBits(Double.doubleToLongBits(val));
+  }
+
+  /**
+   * Converts a sortable <code>long</code> back to a <code>double</code>.
+   * @see #doubleToSortableLong
+   */
+  public static double sortableLongToDouble(long val) {
+    return Double.longBitsToDouble(sortableDoubleBits(val));
+  }
+
+  /**
+   * Converts a <code>float</code> value to a sortable signed <code>int</code>.
+   * The value is converted by getting their IEEE 754 floating-point &quot;float format&quot;
+   * bit layout and then some bits are swapped, to be able to compare the result as int.
+   * By this the precision is not reduced, but the value can easily used as an int.
+   * The sort order (including {@link Float#NaN}) is defined by
+   * {@link Float#compareTo}; {@code NaN} is greater than positive infinity.
+   * @see #sortableIntToFloat
+   */
+  public static int floatToSortableInt(float val) {
+    return sortableFloatBits(Float.floatToIntBits(val));
+  }
+
+  /**
+   * Converts a sortable <code>int</code> back to a <code>float</code>.
+   * @see #floatToSortableInt
+   */
+  public static float sortableIntToFloat(int val) {
+    return Float.intBitsToFloat(sortableFloatBits(val));
+  }
+  
+  /** Converts IEEE 754 representation of a double to sortable order (or back to the original) */
+  public static long sortableDoubleBits(long bits) {
+    return bits ^ (bits >> 63) & 0x7fffffffffffffffL;
+  }
+  
+  /** Converts IEEE 754 representation of a float to sortable order (or back to the original) */
+  public static int sortableFloatBits(int bits) {
+    return bits ^ (bits >> 31) & 0x7fffffff;
+  }
+
+
+  /** Result = a - b, where a &gt;= b, else {@code IllegalArgumentException} is thrown.  */
+  public static void subtract(int bytesPerDim, int dim, byte[] a, byte[] b, byte[] result) {
+    int start = dim * bytesPerDim;
+    int end = start + bytesPerDim;
+    int borrow = 0;
+    for(int i=end-1;i>=start;i--) {
+      int diff = (a[i]&0xff) - (b[i]&0xff) - borrow;
+      if (diff < 0) {
+        diff += 256;
+        borrow = 1;
+      } else {
+        borrow = 0;
+      }
+      result[i-start] = (byte) diff;
+    }
+    if (borrow != 0) {
+      throw new IllegalArgumentException("a < b");
+    }
+  }
+
+  /** Result = a + b, where a and b are unsigned.  If there is an overflow, {@code IllegalArgumentException} is thrown. */
+  public static void add(int bytesPerDim, int dim, byte[] a, byte[] b, byte[] result) {
+    int start = dim * bytesPerDim;
+    int end = start + bytesPerDim;
+    int carry = 0;
+    for(int i=end-1;i>=start;i--) {
+      int digitSum = (a[i]&0xff) + (b[i]&0xff) + carry;
+      if (digitSum > 255) {
+        digitSum -= 256;
+        carry = 1;
+      } else {
+        carry = 0;
+      }
+      result[i-start] = (byte) digitSum;
+    }
+    if (carry != 0) {
+      throw new IllegalArgumentException("a + b overflows bytesPerDim=" + bytesPerDim);
+    }
+  }
+
+  /** Returns positive int if a &gt; b, negative int if a &lt; b and 0 if a == b */
+  public static int compare(int bytesPerDim, byte[] a, int aIndex, byte[] b, int bIndex) {
+    assert aIndex >= 0;
+    assert bIndex >= 0;
+    int aOffset = aIndex*bytesPerDim;
+    int bOffset = bIndex*bytesPerDim;
+    for(int i=0;i<bytesPerDim;i++) {
+      int cmp = (a[aOffset+i]&0xff) - (b[bOffset+i]&0xff);
+      if (cmp != 0) {
+        return cmp;
+      }
+    }
+
+    return 0;
+  }
+
+  /** Returns true if N-dim rect A contains N-dim rect B */
+  public static boolean contains(int bytesPerDim,
+                                 byte[] minPackedA, byte[] maxPackedA,
+                                 byte[] minPackedB, byte[] maxPackedB) {
+    int dims = minPackedA.length / bytesPerDim;
+    for(int dim=0;dim<dims;dim++) {
+      if (compare(bytesPerDim, minPackedA, dim, minPackedB, dim) > 0) {
+        return false;
+      }
+      if (compare(bytesPerDim, maxPackedA, dim, maxPackedB, dim) < 0) {
+        return false;
+      }
+    }
+
+    return true;
+  }
+
+  public static void intToBytes(int x, byte[] dest, int index) {
+    // Flip the sign bit, so negative ints sort before positive ints correctly:
+    x ^= 0x80000000;
+    intToBytesDirect(x, dest, index);
+  }
+
+  public static void intToBytesDirect(int x, byte[] dest, int index) {
+    // Flip the sign bit, so negative ints sort before positive ints correctly:
+    for(int i=0;i<4;i++) {
+      dest[4*index+i] = (byte) (x >> 24-i*8);
+    }
+  }
+
+  public static int bytesToInt(byte[] src, int index) {
+    int x = bytesToIntDirect(src, index);
+    // Re-flip the sign bit to restore the original value:
+    return x ^ 0x80000000;
+  }
+
+  public static int bytesToIntDirect(byte[] src, int index) {
+    int x = 0;
+    for(int i=0;i<4;i++) {
+      x |= (src[4*index+i] & 0xff) << (24-i*8);
+    }
+    return x;
+  }
+
+  public static void longToBytes(long v, byte[] bytes, int dim) {
+    // Flip the sign bit so negative longs sort before positive longs:
+    v ^= 0x8000000000000000L;
+    longToBytesDirect(v, bytes, dim);
+  }
+
+  public static void longToBytesDirect(long v, byte[] bytes, int dim) {
+    int offset = 8 * dim;
+    bytes[offset] = (byte) (v >> 56);
+    bytes[offset+1] = (byte) (v >> 48);
+    bytes[offset+2] = (byte) (v >> 40);
+    bytes[offset+3] = (byte) (v >> 32);
+    bytes[offset+4] = (byte) (v >> 24);
+    bytes[offset+5] = (byte) (v >> 16);
+    bytes[offset+6] = (byte) (v >> 8);
+    bytes[offset+7] = (byte) v;
+  }
+
+  public static long bytesToLong(byte[] bytes, int index) {
+    long v = bytesToLongDirect(bytes, index);
+    // Flip the sign bit back
+    v ^= 0x8000000000000000L;
+    return v;
+  }
+
+  public static long bytesToLongDirect(byte[] bytes, int index) {
+    int offset = 8 * index;
+    long v = ((bytes[offset] & 0xffL) << 56) |
+      ((bytes[offset+1] & 0xffL) << 48) |
+      ((bytes[offset+2] & 0xffL) << 40) |
+      ((bytes[offset+3] & 0xffL) << 32) |
+      ((bytes[offset+4] & 0xffL) << 24) |
+      ((bytes[offset+5] & 0xffL) << 16) |
+      ((bytes[offset+6] & 0xffL) << 8) |
+      (bytes[offset+7] & 0xffL);
+    return v;
+  }
+
+  public static void sortableBigIntBytes(byte[] bytes) {
+    bytes[0] ^= 0x80;
+    for(int i=1;i<bytes.length;i++)  {
+      bytes[i] ^= 0;
+    }
+  }
+
+  public static void bigIntToBytes(BigInteger bigInt, byte[] result, int dim, int numBytesPerDim) {
+    byte[] bigIntBytes = bigInt.toByteArray();
+    byte[] fullBigIntBytes;
+
+    if (bigIntBytes.length < numBytesPerDim) {
+      fullBigIntBytes = new byte[numBytesPerDim];
+      System.arraycopy(bigIntBytes, 0, fullBigIntBytes, numBytesPerDim-bigIntBytes.length, bigIntBytes.length);
+      if ((bigIntBytes[0] & 0x80) != 0) {
+        // sign extend
+        Arrays.fill(fullBigIntBytes, 0, numBytesPerDim-bigIntBytes.length, (byte) 0xff);
+      }
+    } else {
+      assert bigIntBytes.length == numBytesPerDim;
+      fullBigIntBytes = bigIntBytes;
+    }
+    sortableBigIntBytes(fullBigIntBytes);
+
+    System.arraycopy(fullBigIntBytes, 0, result, dim * numBytesPerDim, numBytesPerDim);
+
+    assert bytesToBigInt(result, dim, numBytesPerDim).equals(bigInt): "bigInt=" + bigInt + " converted=" + bytesToBigInt(result, dim, numBytesPerDim);
+  }
+
+  public static BigInteger bytesToBigInt(byte[] bytes, int dim, int numBytesPerDim) {
+    byte[] bigIntBytes = new byte[numBytesPerDim];
+    System.arraycopy(bytes, dim*numBytesPerDim, bigIntBytes, 0, numBytesPerDim);
+    sortableBigIntBytes(bigIntBytes);
+    return new BigInteger(bigIntBytes);
+  }
+}

Modified: lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/util/bkd/BKDReader.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/util/bkd/BKDReader.java?rev=1719562&r1=1719561&r2=1719562&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/util/bkd/BKDReader.java (original)
+++ lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/util/bkd/BKDReader.java Fri Dec 11 21:13:41 2015
@@ -26,6 +26,7 @@ import org.apache.lucene.index.Dimension
 import org.apache.lucene.store.IndexInput;
 import org.apache.lucene.util.Accountable;
 import org.apache.lucene.util.BytesRef;
+import org.apache.lucene.util.NumericUtils;
 import org.apache.lucene.util.RamUsageEstimator;
 import org.apache.lucene.util.StringHelper;
 
@@ -163,7 +164,7 @@ public class BKDReader implements Accoun
         // With only 1D, all values should always be in sorted order
         if (lastPackedValue == null) {
           lastPackedValue = Arrays.copyOf(packedValue, packedValue.length);
-        } else if (BKDUtil.compare(bytesPerDim, lastPackedValue, 0, packedValue, 0) > 0) {
+        } else if (NumericUtils.compare(bytesPerDim, lastPackedValue, 0, packedValue, 0) > 0) {
           throw new RuntimeException("value=" + new BytesRef(packedValue) + " for docID=" + docID + " dim=0" + " sorts before last value=" + new BytesRef(lastPackedValue));
         } else {
           System.arraycopy(packedValue, 0, lastPackedValue, 0, bytesPerDim);

Modified: lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/util/bkd/BKDWriter.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/util/bkd/BKDWriter.java?rev=1719562&r1=1719561&r2=1719562&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/util/bkd/BKDWriter.java (original)
+++ lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/util/bkd/BKDWriter.java Fri Dec 11 21:13:41 2015
@@ -38,8 +38,9 @@ import org.apache.lucene.util.BytesRefBu
 import org.apache.lucene.util.IOUtils;
 import org.apache.lucene.util.IntroSorter;
 import org.apache.lucene.util.LongBitSet;
-import org.apache.lucene.util.OfflineSorter.ByteSequencesWriter;
+import org.apache.lucene.util.NumericUtils;
 import org.apache.lucene.util.OfflineSorter;
+import org.apache.lucene.util.OfflineSorter.ByteSequencesWriter;
 import org.apache.lucene.util.PriorityQueue;
 import org.apache.lucene.util.RamUsageEstimator;
 import org.apache.lucene.util.StringHelper;
@@ -91,7 +92,7 @@ public class BKDWriter implements Closea
   public static final float DEFAULT_MAX_MB_SORT_IN_HEAP = 16.0f;
 
   /** Maximum number of dimensions */
-  public static final int MAX_DIMS = 255;
+  public static final int MAX_DIMS = 8;
 
   /** How many dimensions we are indexing */
   protected final int numDims;
@@ -534,7 +535,7 @@ public class BKDWriter implements Closea
         int block = j / writer.valuesPerBlock;
         int index = j % writer.valuesPerBlock;
         assert index >= 0: "index=" + index + " j=" + j;
-        int cmp = BKDUtil.compare(bytesPerDim, pivotPackedValue, 0, writer.blocks.get(block), index*numDims+dim);
+        int cmp = NumericUtils.compare(bytesPerDim, pivotPackedValue, 0, writer.blocks.get(block), index*numDims+dim);
         if (cmp != 0) {
           return cmp;
         }
@@ -578,7 +579,7 @@ public class BKDWriter implements Closea
         int dimI = i % writer.valuesPerBlock;
         int blockJ = j / writer.valuesPerBlock;
         int dimJ = j % writer.valuesPerBlock;
-        int cmp = BKDUtil.compare(bytesPerDim, writer.blocks.get(blockI), dimI*numDims+dim, writer.blocks.get(blockJ), dimJ*numDims+dim);
+        int cmp = NumericUtils.compare(bytesPerDim, writer.blocks.get(blockI), dimI*numDims+dim, writer.blocks.get(blockJ), dimJ*numDims+dim);
         if (cmp != 0) {
           return cmp;
         }
@@ -641,7 +642,7 @@ public class BKDWriter implements Closea
           final int docIDB = reader.readVInt();
           final long ordB = reader.readVLong();
 
-          int cmp = BKDUtil.compare(bytesPerDim, scratch1, dim, scratch2, dim);
+          int cmp = NumericUtils.compare(bytesPerDim, scratch1, dim, scratch2, dim);
 
           if (cmp != 0) {
             return cmp;
@@ -919,10 +920,10 @@ public class BKDWriter implements Closea
   /** Called only in assert */
   private boolean valueInBounds(byte[] packedValue, byte[] minPackedValue, byte[] maxPackedValue) {
     for(int dim=0;dim<numDims;dim++) {
-      if (BKDUtil.compare(bytesPerDim, packedValue, dim, minPackedValue, dim) < 0) {
+      if (NumericUtils.compare(bytesPerDim, packedValue, dim, minPackedValue, dim) < 0) {
         return false;
       }
-      if (BKDUtil.compare(bytesPerDim, packedValue, dim, maxPackedValue, dim) > 0) {
+      if (NumericUtils.compare(bytesPerDim, packedValue, dim, maxPackedValue, dim) > 0) {
         return false;
       }
     }
@@ -935,8 +936,8 @@ public class BKDWriter implements Closea
     // Find which dim has the largest span so we can split on it:
     int splitDim = -1;
     for(int dim=0;dim<numDims;dim++) {
-      BKDUtil.subtract(bytesPerDim, dim, maxPackedValue, minPackedValue, scratchDiff);
-      if (splitDim == -1 || BKDUtil.compare(bytesPerDim, scratchDiff, 0, scratch1, 0) > 0) {
+      NumericUtils.subtract(bytesPerDim, dim, maxPackedValue, minPackedValue, scratchDiff);
+      if (splitDim == -1 || NumericUtils.compare(bytesPerDim, scratchDiff, 0, scratch1, 0) > 0) {
         System.arraycopy(scratchDiff, 0, scratch1, 0, bytesPerDim);
         splitDim = dim;
       }
@@ -1145,7 +1146,7 @@ public class BKDWriter implements Closea
 
   // only called from assert
   private boolean valueInOrder(long ord, byte[] lastPackedValue, byte[] packedValue) {
-    if (ord > 0 && BKDUtil.compare(bytesPerDim, lastPackedValue, 0, packedValue, 0) > 0) {
+    if (ord > 0 && NumericUtils.compare(bytesPerDim, lastPackedValue, 0, packedValue, 0) > 0) {
       throw new AssertionError("values out of order: last value=" + new BytesRef(lastPackedValue) + " current value=" + new BytesRef(packedValue) + " ord=" + ord);
     }
     System.arraycopy(packedValue, 0, lastPackedValue, 0, bytesPerDim);

Modified: lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/TestSearch.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/TestSearch.java?rev=1719562&r1=1719561&r2=1719562&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/TestSearch.java (original)
+++ lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/TestSearch.java Fri Dec 11 21:13:41 2015
@@ -17,18 +17,18 @@ package org.apache.lucene;
  * limitations under the License.
  */
 
+import java.io.PrintWriter;
+import java.io.StringWriter;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.Random;
-import java.io.PrintWriter;
-import java.io.StringWriter;
 
-import org.apache.lucene.util.LuceneTestCase;
-import org.apache.lucene.store.*;
-import org.apache.lucene.document.*;
 import org.apache.lucene.analysis.*;
+import org.apache.lucene.document.*;
 import org.apache.lucene.index.*;
 import org.apache.lucene.search.*;
+import org.apache.lucene.store.*;
+import org.apache.lucene.util.LuceneTestCase;
 
 /** JUnit adaptation of an older test case SearchTest. */
 public class TestSearch extends LuceneTestCase {
@@ -125,7 +125,6 @@ public class TestSearch extends LuceneTe
       for (int j = 0; j < docs.length; j++) {
         Document d = new Document();
         d.add(newTextField("contents", docs[j], Field.Store.YES));
-        d.add(new IntField("id", j, Field.Store.NO));
         d.add(new NumericDocValuesField("id", j));
         writer.addDocument(d);
       }

Modified: lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/TestSearchForDuplicates.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/TestSearchForDuplicates.java?rev=1719562&r1=1719561&r2=1719562&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/TestSearchForDuplicates.java (original)
+++ lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/TestSearchForDuplicates.java Fri Dec 11 21:13:41 2015
@@ -26,8 +26,8 @@ import org.apache.lucene.analysis.Analyz
 import org.apache.lucene.analysis.MockAnalyzer;
 import org.apache.lucene.document.Document;
 import org.apache.lucene.document.Field;
-import org.apache.lucene.document.IntField;
 import org.apache.lucene.document.NumericDocValuesField;
+import org.apache.lucene.document.StoredField;
 import org.apache.lucene.index.DirectoryReader;
 import org.apache.lucene.index.IndexReader;
 import org.apache.lucene.index.IndexWriter;
@@ -98,7 +98,7 @@ public class TestSearchForDuplicates ext
       for (int j = 0; j < MAX_DOCS; j++) {
         Document d = new Document();
         d.add(newTextField(PRIORITY_FIELD, HIGH_PRIORITY, Field.Store.YES));
-        d.add(new IntField(ID_FIELD, j, Field.Store.YES));
+        d.add(new StoredField(ID_FIELD, j));
         d.add(new NumericDocValuesField(ID_FIELD, j));
         writer.addDocument(d);
       }

Modified: lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/analysis/TestNumericTokenStream.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/analysis/TestNumericTokenStream.java?rev=1719562&r1=1719561&r2=1719562&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/analysis/TestNumericTokenStream.java (original)
+++ lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/analysis/TestNumericTokenStream.java Fri Dec 11 21:13:41 2015
@@ -17,8 +17,8 @@ package org.apache.lucene.analysis;
  * limitations under the License.
  */
 
-import org.apache.lucene.util.NumericUtils;
-import org.apache.lucene.analysis.NumericTokenStream.NumericTermAttributeImpl;
+import org.apache.lucene.util.LegacyNumericUtils;
+import org.apache.lucene.analysis.LegacyNumericTokenStream.LegacyNumericTermAttributeImpl;
 import org.apache.lucene.analysis.tokenattributes.TermToBytesRefAttribute;
 import org.apache.lucene.analysis.tokenattributes.TestCharTermAttributeImpl;
 import org.apache.lucene.analysis.tokenattributes.TypeAttribute;
@@ -32,21 +32,21 @@ public class TestNumericTokenStream exte
 
   public void testLongStream() throws Exception {
     @SuppressWarnings("resource")
-    final NumericTokenStream stream=new NumericTokenStream().setLongValue(lvalue);
+    final LegacyNumericTokenStream stream=new LegacyNumericTokenStream().setLongValue(lvalue);
     final TermToBytesRefAttribute bytesAtt = stream.getAttribute(TermToBytesRefAttribute.class);
     assertNotNull(bytesAtt);
     final TypeAttribute typeAtt = stream.getAttribute(TypeAttribute.class);
     assertNotNull(typeAtt);
-    final NumericTokenStream.NumericTermAttribute numericAtt = stream.getAttribute(NumericTokenStream.NumericTermAttribute.class);
+    final LegacyNumericTokenStream.LegacyNumericTermAttribute numericAtt = stream.getAttribute(LegacyNumericTokenStream.LegacyNumericTermAttribute.class);
     assertNotNull(numericAtt);
     stream.reset();
     assertEquals(64, numericAtt.getValueSize());
-    for (int shift=0; shift<64; shift+=NumericUtils.PRECISION_STEP_DEFAULT) {
+    for (int shift=0; shift<64; shift+= LegacyNumericUtils.PRECISION_STEP_DEFAULT) {
       assertTrue("New token is available", stream.incrementToken());
       assertEquals("Shift value wrong", shift, numericAtt.getShift());
-      assertEquals("Term is incorrectly encoded", lvalue & ~((1L << shift) - 1L), NumericUtils.prefixCodedToLong(bytesAtt.getBytesRef()));
+      assertEquals("Term is incorrectly encoded", lvalue & ~((1L << shift) - 1L), LegacyNumericUtils.prefixCodedToLong(bytesAtt.getBytesRef()));
       assertEquals("Term raw value is incorrectly encoded", lvalue & ~((1L << shift) - 1L), numericAtt.getRawValue());
-      assertEquals("Type incorrect", (shift == 0) ? NumericTokenStream.TOKEN_TYPE_FULL_PREC : NumericTokenStream.TOKEN_TYPE_LOWER_PREC, typeAtt.type());
+      assertEquals("Type incorrect", (shift == 0) ? LegacyNumericTokenStream.TOKEN_TYPE_FULL_PREC : LegacyNumericTokenStream.TOKEN_TYPE_LOWER_PREC, typeAtt.type());
     }
     assertFalse("More tokens available", stream.incrementToken());
     stream.end();
@@ -55,21 +55,21 @@ public class TestNumericTokenStream exte
 
   public void testIntStream() throws Exception {
     @SuppressWarnings("resource")
-    final NumericTokenStream stream=new NumericTokenStream().setIntValue(ivalue);
+    final LegacyNumericTokenStream stream=new LegacyNumericTokenStream().setIntValue(ivalue);
     final TermToBytesRefAttribute bytesAtt = stream.getAttribute(TermToBytesRefAttribute.class);
     assertNotNull(bytesAtt);
     final TypeAttribute typeAtt = stream.getAttribute(TypeAttribute.class);
     assertNotNull(typeAtt);
-    final NumericTokenStream.NumericTermAttribute numericAtt = stream.getAttribute(NumericTokenStream.NumericTermAttribute.class);
+    final LegacyNumericTokenStream.LegacyNumericTermAttribute numericAtt = stream.getAttribute(LegacyNumericTokenStream.LegacyNumericTermAttribute.class);
     assertNotNull(numericAtt);
     stream.reset();
     assertEquals(32, numericAtt.getValueSize());
-    for (int shift=0; shift<32; shift+=NumericUtils.PRECISION_STEP_DEFAULT) {
+    for (int shift=0; shift<32; shift+= LegacyNumericUtils.PRECISION_STEP_DEFAULT) {
       assertTrue("New token is available", stream.incrementToken());
       assertEquals("Shift value wrong", shift, numericAtt.getShift());
-      assertEquals("Term is incorrectly encoded", ivalue & ~((1 << shift) - 1), NumericUtils.prefixCodedToInt(bytesAtt.getBytesRef()));
+      assertEquals("Term is incorrectly encoded", ivalue & ~((1 << shift) - 1), LegacyNumericUtils.prefixCodedToInt(bytesAtt.getBytesRef()));
       assertEquals("Term raw value is incorrectly encoded", ((long) ivalue) & ~((1L << shift) - 1L), numericAtt.getRawValue());
-      assertEquals("Type incorrect", (shift == 0) ? NumericTokenStream.TOKEN_TYPE_FULL_PREC : NumericTokenStream.TOKEN_TYPE_LOWER_PREC, typeAtt.type());
+      assertEquals("Type incorrect", (shift == 0) ? LegacyNumericTokenStream.TOKEN_TYPE_FULL_PREC : LegacyNumericTokenStream.TOKEN_TYPE_LOWER_PREC, typeAtt.type());
     }
     assertFalse("More tokens available", stream.incrementToken());
     stream.end();
@@ -77,7 +77,7 @@ public class TestNumericTokenStream exte
   }
   
   public void testNotInitialized() throws Exception {
-    final NumericTokenStream stream=new NumericTokenStream();
+    final LegacyNumericTokenStream stream=new LegacyNumericTokenStream();
     
     try {
       stream.reset();
@@ -100,28 +100,28 @@ public class TestNumericTokenStream exte
   public static class TestAttributeImpl extends CharTermAttributeImpl implements TestAttribute {}
   
   public void testCTA() throws Exception {
-    final NumericTokenStream stream=new NumericTokenStream();
+    final LegacyNumericTokenStream stream=new LegacyNumericTokenStream();
     try {
       stream.addAttribute(CharTermAttribute.class);
       fail("Succeeded to add CharTermAttribute.");
     } catch (IllegalArgumentException iae) {
-      assertTrue(iae.getMessage().startsWith("NumericTokenStream does not support"));
+      assertTrue(iae.getMessage().startsWith("LegacyNumericTokenStream does not support"));
     }
     try {
       stream.addAttribute(TestAttribute.class);
       fail("Succeeded to add TestAttribute.");
     } catch (IllegalArgumentException iae) {
-      assertTrue(iae.getMessage().startsWith("NumericTokenStream does not support"));
+      assertTrue(iae.getMessage().startsWith("LegacyNumericTokenStream does not support"));
     }
     stream.close();
   }
   
   public void testAttributeClone() throws Exception {
-    NumericTermAttributeImpl att = new NumericTermAttributeImpl();
+    LegacyNumericTermAttributeImpl att = new LegacyNumericTermAttributeImpl();
     att.init(1234L, 64, 8, 0); // set some value, to make getBytesRef() work
-    NumericTermAttributeImpl copy = TestCharTermAttributeImpl.assertCloneIsEqual(att);
+    LegacyNumericTermAttributeImpl copy = TestCharTermAttributeImpl.assertCloneIsEqual(att);
     assertNotSame(att.getBytesRef(), copy.getBytesRef());
-    NumericTermAttributeImpl copy2 = TestCharTermAttributeImpl.assertCopyIsEqual(att);
+    LegacyNumericTermAttributeImpl copy2 = TestCharTermAttributeImpl.assertCopyIsEqual(att);
     assertNotSame(att.getBytesRef(), copy2.getBytesRef());
   }
   

Modified: lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/document/TestDocument.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/document/TestDocument.java?rev=1719562&r1=1719561&r2=1719562&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/document/TestDocument.java (original)
+++ lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/document/TestDocument.java Fri Dec 11 21:13:41 2015
@@ -360,10 +360,10 @@ public class TestDocument extends Lucene
   
   public void testNumericFieldAsString() throws Exception {
     Document doc = new Document();
-    doc.add(new IntField("int", 5, Field.Store.YES));
+    doc.add(new LegacyIntField("int", 5, Field.Store.YES));
     assertEquals("5", doc.get("int"));
     assertNull(doc.get("somethingElse"));
-    doc.add(new IntField("int", 4, Field.Store.YES));
+    doc.add(new LegacyIntField("int", 4, Field.Store.YES));
     assertArrayEquals(new String[] { "5", "4" }, doc.getValues("int"));
     
     Directory dir = newDirectory();

Modified: lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/document/TestField.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/document/TestField.java?rev=1719562&r1=1719561&r2=1719562&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/document/TestField.java (original)
+++ lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/document/TestField.java Fri Dec 11 21:13:41 2015
@@ -38,8 +38,8 @@ public class TestField extends LuceneTes
   
   public void testDoubleField() throws Exception {
     Field fields[] = new Field[] {
-        new DoubleField("foo", 5d, Field.Store.NO),
-        new DoubleField("foo", 5d, Field.Store.YES)
+        new LegacyDoubleField("foo", 5d, Field.Store.NO),
+        new LegacyDoubleField("foo", 5d, Field.Store.YES)
     };
 
     for (Field field : fields) {
@@ -100,8 +100,8 @@ public class TestField extends LuceneTes
   
   public void testFloatField() throws Exception {
     Field fields[] = new Field[] {
-        new FloatField("foo", 5f, Field.Store.NO),
-        new FloatField("foo", 5f, Field.Store.YES)
+        new LegacyFloatField("foo", 5f, Field.Store.NO),
+        new LegacyFloatField("foo", 5f, Field.Store.YES)
     };
 
     for (Field field : fields) {
@@ -124,8 +124,8 @@ public class TestField extends LuceneTes
   
   public void testIntField() throws Exception {
     Field fields[] = new Field[] {
-        new IntField("foo", 5, Field.Store.NO),
-        new IntField("foo", 5, Field.Store.YES)
+        new LegacyIntField("foo", 5, Field.Store.NO),
+        new LegacyIntField("foo", 5, Field.Store.YES)
     };
 
     for (Field field : fields) {
@@ -167,8 +167,8 @@ public class TestField extends LuceneTes
   
   public void testLongField() throws Exception {
     Field fields[] = new Field[] {
-        new LongField("foo", 5L, Field.Store.NO),
-        new LongField("foo", 5L, Field.Store.YES)
+        new LegacyLongField("foo", 5L, Field.Store.NO),
+        new LegacyLongField("foo", 5L, Field.Store.YES)
     };
 
     for (Field field : fields) {

Modified: lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/document/TestFieldType.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/document/TestFieldType.java?rev=1719562&r1=1719561&r2=1719562&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/document/TestFieldType.java (original)
+++ lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/document/TestFieldType.java Fri Dec 11 21:13:41 2015
@@ -20,7 +20,7 @@ package org.apache.lucene.document;
 import java.lang.reflect.Method;
 import java.lang.reflect.Modifier;
 
-import org.apache.lucene.document.FieldType.NumericType;
+import org.apache.lucene.document.FieldType.LegacyNumericType;
 import org.apache.lucene.index.DocValuesType;
 import org.apache.lucene.index.IndexOptions;
 import org.apache.lucene.util.LuceneTestCase;
@@ -60,7 +60,7 @@ public class TestFieldType extends Lucen
     assertFalse(ft7.equals(ft));
     
     FieldType ft8 = new FieldType();
-    ft8.setNumericType(NumericType.DOUBLE);
+    ft8.setNumericType(LegacyNumericType.DOUBLE);
     assertFalse(ft8.equals(ft));
     
     FieldType ft9 = new FieldType();

Modified: lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/index/TestDemoParallelLeafReader.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/index/TestDemoParallelLeafReader.java?rev=1719562&r1=1719561&r2=1719562&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/index/TestDemoParallelLeafReader.java (original)
+++ lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/index/TestDemoParallelLeafReader.java Fri Dec 11 21:13:41 2015
@@ -32,13 +32,13 @@ import java.util.concurrent.ConcurrentHa
 import java.util.concurrent.atomic.AtomicLong;
 import java.util.regex.Pattern;
 
+import org.apache.lucene.document.DimensionalLongField;
 import org.apache.lucene.document.Document;
 import org.apache.lucene.document.Field;
-import org.apache.lucene.document.LongField;
 import org.apache.lucene.document.NumericDocValuesField;
+import org.apache.lucene.search.DimensionalRangeQuery;
 import org.apache.lucene.search.IndexSearcher;
 import org.apache.lucene.search.MatchAllDocsQuery;
-import org.apache.lucene.search.NumericRangeQuery;
 import org.apache.lucene.search.ScoreDoc;
 import org.apache.lucene.search.Sort;
 import org.apache.lucene.search.SortField;
@@ -681,7 +681,7 @@ public class TestDemoParallelLeafReader
           Document newDoc = new Document();
           long value = Long.parseLong(oldDoc.get("text").split(" ")[1]);
           newDoc.add(new NumericDocValuesField("number", value));
-          newDoc.add(new LongField("number", value, Field.Store.NO));
+          newDoc.add(new DimensionalLongField("number", value));
           w.addDocument(newDoc);
         }
 
@@ -737,7 +737,7 @@ public class TestDemoParallelLeafReader
             Document newDoc = new Document();
             long value = Long.parseLong(oldDoc.get("text").split(" ")[1]);
             newDoc.add(new NumericDocValuesField("number_" + newSchemaGen, value));
-            newDoc.add(new LongField("number", value, Field.Store.NO));
+            newDoc.add(new DimensionalLongField("number", value));
             w.addDocument(newDoc);
           }
         } else {
@@ -832,7 +832,7 @@ public class TestDemoParallelLeafReader
             Document newDoc = new Document();
             long value = Long.parseLong(oldDoc.get("text").split(" ")[1]);
             newDoc.add(new NumericDocValuesField("number", newSchemaGen*value));
-            newDoc.add(new LongField("number", value, Field.Store.NO));
+            newDoc.add(new DimensionalLongField("number", value));
             w.addDocument(newDoc);
           }
         } else {
@@ -1168,7 +1168,7 @@ public class TestDemoParallelLeafReader
       checkAllNumberDVs(r);
       IndexSearcher s = newSearcher(r);
       testNumericDVSort(s);
-      testNumericRangeQuery(s);
+      testDimensionalRangeQuery(s);
     } finally {
       reindexer.mgr.release(r);
     }
@@ -1190,7 +1190,7 @@ public class TestDemoParallelLeafReader
       checkAllNumberDVs(r);
       IndexSearcher s = newSearcher(r);
       testNumericDVSort(s);
-      testNumericRangeQuery(s);
+      testDimensionalRangeQuery(s);
     } finally {
       reindexer.mgr.release(r);
     }
@@ -1209,7 +1209,7 @@ public class TestDemoParallelLeafReader
       checkAllNumberDVs(r);
       IndexSearcher s = newSearcher(r);
       testNumericDVSort(s);
-      testNumericRangeQuery(s);
+      testDimensionalRangeQuery(s);
     } finally {
       reindexer.mgr.release(r);
     }
@@ -1261,7 +1261,7 @@ public class TestDemoParallelLeafReader
           checkAllNumberDVs(r);
           IndexSearcher s = newSearcher(r);
           testNumericDVSort(s);
-          testNumericRangeQuery(s);
+          testDimensionalRangeQuery(s);
         } finally {
           reindexer.mgr.release(r);
         }
@@ -1340,7 +1340,7 @@ public class TestDemoParallelLeafReader
     }
   }
 
-  private static void testNumericRangeQuery(IndexSearcher s) throws IOException {
+  private static void testDimensionalRangeQuery(IndexSearcher s) throws IOException {
     NumericDocValues numbers = MultiDocValues.getNumericValues(s.getIndexReader(), "number");
     for(int i=0;i<100;i++) {
       // Confirm we can range search by the new indexed (numeric) field:
@@ -1352,7 +1352,7 @@ public class TestDemoParallelLeafReader
         max = x;
       }
 
-      TopDocs hits = s.search(NumericRangeQuery.newLongRange("number", min, max, true, true), 100);
+      TopDocs hits = s.search(DimensionalRangeQuery.new1DLongRange("number", min, true, max, true), 100);
       for(ScoreDoc scoreDoc : hits.scoreDocs) {
         long value = Long.parseLong(s.doc(scoreDoc.doc).get("text").split(" ")[1]);
         assertTrue(value >= min);

Modified: lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/index/TestDimensionalValues.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/index/TestDimensionalValues.java?rev=1719562&r1=1719561&r2=1719562&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/index/TestDimensionalValues.java (original)
+++ lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/index/TestDimensionalValues.java Fri Dec 11 21:13:41 2015
@@ -31,7 +31,8 @@ import org.apache.lucene.codecs.Dimensio
 import org.apache.lucene.codecs.FilterCodec;
 import org.apache.lucene.codecs.lucene60.Lucene60DimensionalReader;
 import org.apache.lucene.codecs.lucene60.Lucene60DimensionalWriter;
-import org.apache.lucene.document.DimensionalField;
+import org.apache.lucene.document.DimensionalBinaryField;
+import org.apache.lucene.document.DimensionalIntField;
 import org.apache.lucene.document.Document;
 import org.apache.lucene.document.Field;
 import org.apache.lucene.document.NumericDocValuesField;
@@ -44,9 +45,8 @@ import org.apache.lucene.util.Bits;
 import org.apache.lucene.util.BytesRef;
 import org.apache.lucene.util.IOUtils;
 import org.apache.lucene.util.LuceneTestCase;
+import org.apache.lucene.util.NumericUtils;
 import org.apache.lucene.util.TestUtil;
-import org.apache.lucene.util.bkd.BKDUtil;
-import org.apache.lucene.util.bkd.BKDWriter;
 
 // TODO: factor out a BaseTestDimensionFormat
 
@@ -60,8 +60,8 @@ public class TestDimensionalValues exten
     byte[] point = new byte[4];
     for(int i=0;i<20;i++) {
       Document doc = new Document();
-      BKDUtil.intToBytes(i, point, 0);
-      doc.add(new DimensionalField("dim", point));
+      NumericUtils.intToBytes(i, point, 0);
+      doc.add(new DimensionalBinaryField("dim", point));
       w.addDocument(doc);
     }
     w.forceMerge(1);
@@ -84,7 +84,7 @@ public class TestDimensionalValues exten
                        }
                        public void visit(int docID, byte[] packedValue) {
                          seen.set(docID);
-                         assertEquals(docID, BKDUtil.bytesToInt(packedValue, 0));
+                         assertEquals(docID, NumericUtils.bytesToInt(packedValue, 0));
                        }
                      });
     assertEquals(20, seen.cardinality());
@@ -99,8 +99,8 @@ public class TestDimensionalValues exten
     byte[] point = new byte[4];
     for(int i=0;i<20;i++) {
       Document doc = new Document();
-      BKDUtil.intToBytes(i, point, 0);
-      doc.add(new DimensionalField("dim", point));
+      NumericUtils.intToBytes(i, point, 0);
+      doc.add(new DimensionalBinaryField("dim", point));
       w.addDocument(doc);
       if (i == 10) {
         w.commit();
@@ -126,7 +126,7 @@ public class TestDimensionalValues exten
                        }
                        public void visit(int docID, byte[] packedValue) {
                          seen.set(docID);
-                         assertEquals(docID, BKDUtil.bytesToInt(packedValue, 0));
+                         assertEquals(docID, NumericUtils.bytesToInt(packedValue, 0));
                        }
                      });
     assertEquals(20, seen.cardinality());
@@ -140,8 +140,8 @@ public class TestDimensionalValues exten
     byte[] point = new byte[4];
     for(int i=0;i<10;i++) {
       Document doc = new Document();
-      BKDUtil.intToBytes(i, point, 0);
-      doc.add(new DimensionalField("dim", point));
+      NumericUtils.intToBytes(i, point, 0);
+      doc.add(new DimensionalBinaryField("dim", point));
       doc.add(new NumericDocValuesField("id", i));
       doc.add(newStringField("x", "x", Field.Store.NO));
       w.addDocument(doc);
@@ -173,7 +173,7 @@ public class TestDimensionalValues exten
                            if (liveDocs.get(docID)) {
                              seen.set(docID);
                            }
-                           assertEquals(idValues.get(docID), BKDUtil.bytesToInt(packedValue, 0));
+                           assertEquals(idValues.get(docID), NumericUtils.bytesToInt(packedValue, 0));
                          }
                        });
       assertEquals(0, seen.cardinality());
@@ -184,8 +184,8 @@ public class TestDimensionalValues exten
   /** Make sure we close open files, delete temp files, etc., on exception */
   public void testWithExceptions() throws Exception {
     int numDocs = atLeast(10000);
-    int numBytesPerDim = TestUtil.nextInt(random(), 2, 30);
-    int numDims = TestUtil.nextInt(random(), 1, 5);
+    int numBytesPerDim = TestUtil.nextInt(random(), 2, DimensionalValues.MAX_NUM_BYTES);
+    int numDims = TestUtil.nextInt(random(), 1, DimensionalValues.MAX_DIMENSIONS);
 
     byte[][][] docValues = new byte[numDocs][][];
 
@@ -244,8 +244,8 @@ public class TestDimensionalValues exten
   }
 
   public void testMultiValued() throws Exception {
-    int numBytesPerDim = TestUtil.nextInt(random(), 2, 30);
-    int numDims = TestUtil.nextInt(random(), 1, 5);
+    int numBytesPerDim = TestUtil.nextInt(random(), 2, DimensionalValues.MAX_NUM_BYTES);
+    int numDims = TestUtil.nextInt(random(), 1, DimensionalValues.MAX_DIMENSIONS);
 
     int numDocs = atLeast(1000);
     List<byte[][]> docValues = new ArrayList<>();
@@ -274,8 +274,8 @@ public class TestDimensionalValues exten
   }
 
   public void testAllEqual() throws Exception {
-    int numBytesPerDim = TestUtil.nextInt(random(), 2, 30);
-    int numDims = TestUtil.nextInt(random(), 1, 5);
+    int numBytesPerDim = TestUtil.nextInt(random(), 2, DimensionalValues.MAX_NUM_BYTES);
+    int numDims = TestUtil.nextInt(random(), 1, DimensionalValues.MAX_DIMENSIONS);
 
     int numDocs = atLeast(1000);
     byte[][][] docValues = new byte[numDocs][][];
@@ -297,8 +297,8 @@ public class TestDimensionalValues exten
   }
 
   public void testOneDimEqual() throws Exception {
-    int numBytesPerDim = TestUtil.nextInt(random(), 2, 30);
-    int numDims = TestUtil.nextInt(random(), 1, 5);
+    int numBytesPerDim = TestUtil.nextInt(random(), 2, DimensionalValues.MAX_NUM_BYTES);
+    int numDims = TestUtil.nextInt(random(), 1, DimensionalValues.MAX_DIMENSIONS);
 
     int numDocs = atLeast(1000);
     int theEqualDim = random().nextInt(numDims);
@@ -324,8 +324,8 @@ public class TestDimensionalValues exten
 
     int numDocs = atLeast(1000);
     try (Directory dir = getDirectory(numDocs)) {
-      int numBytesPerDim = TestUtil.nextInt(random(), 2, 30);
-      int numDims = TestUtil.nextInt(random(), 1, 5);
+      int numBytesPerDim = TestUtil.nextInt(random(), 2, DimensionalValues.MAX_NUM_BYTES);
+      int numDims = TestUtil.nextInt(random(), 1, DimensionalValues.MAX_DIMENSIONS);
       IndexWriterConfig iwc = newIndexWriterConfig(new MockAnalyzer(random()));
       // We rely on docIDs not changing:
       iwc.setMergePolicy(newLogMergePolicy());
@@ -341,14 +341,14 @@ public class TestDimensionalValues exten
         for(int dim=0;dim<numDims;dim++) {
           values[dim] = randomBigInt(numBytesPerDim);
           bytes[dim] = new byte[numBytesPerDim];
-          BKDUtil.bigIntToBytes(values[dim], bytes[dim], 0, numBytesPerDim);
+          NumericUtils.bigIntToBytes(values[dim], bytes[dim], 0, numBytesPerDim);
           if (VERBOSE) {
             System.out.println("    " + dim + " -> " + values[dim]);
           }
         }
         docs[docID] = values;
         Document doc = new Document();
-        doc.add(new DimensionalField("field", bytes));
+        doc.add(new DimensionalBinaryField("field", bytes));
         w.addDocument(doc);
       }
 
@@ -391,7 +391,7 @@ public class TestDimensionalValues exten
             public void visit(int docID, byte[] packedValue) {
               //System.out.println("visit check docID=" + docID);
               for(int dim=0;dim<numDims;dim++) {
-                BigInteger x = BKDUtil.bytesToBigInt(packedValue, dim, numBytesPerDim);
+                BigInteger x = NumericUtils.bytesToBigInt(packedValue, dim, numBytesPerDim);
                 if (x.compareTo(queryMin[dim]) < 0 || x.compareTo(queryMax[dim]) > 0) {
                   //System.out.println("  no");
                   return;
@@ -406,8 +406,8 @@ public class TestDimensionalValues exten
             public Relation compare(byte[] minPacked, byte[] maxPacked) {
               boolean crosses = false;
               for(int dim=0;dim<numDims;dim++) {
-                BigInteger min = BKDUtil.bytesToBigInt(minPacked, dim, numBytesPerDim);
-                BigInteger max = BKDUtil.bytesToBigInt(maxPacked, dim, numBytesPerDim);
+                BigInteger min = NumericUtils.bytesToBigInt(minPacked, dim, numBytesPerDim);
+                BigInteger max = NumericUtils.bytesToBigInt(maxPacked, dim, numBytesPerDim);
                 assert max.compareTo(min) >= 0;
 
                 if (max.compareTo(queryMin[dim]) < 0 || min.compareTo(queryMax[dim]) > 0) {
@@ -469,7 +469,7 @@ public class TestDimensionalValues exten
     
     iwc = newIndexWriterConfig();
     w = new IndexWriter(dir, iwc);
-    doc.add(new DimensionalField("dim", new byte[4]));
+    doc.add(new DimensionalBinaryField("dim", new byte[4]));
     w.close();
     dir.close();
   }
@@ -481,8 +481,8 @@ public class TestDimensionalValues exten
     IndexWriterConfig iwc = new IndexWriterConfig(new MockAnalyzer(random()));
     IndexWriter w = new IndexWriter(dir, iwc);
     Document doc = new Document();
-    doc.add(new DimensionalField("dim", new byte[4]));
-    doc.add(new DimensionalField("dim", new byte[4], new byte[4]));
+    doc.add(new DimensionalBinaryField("dim", new byte[4]));
+    doc.add(new DimensionalBinaryField("dim", new byte[4], new byte[4]));
     try {
       w.addDocument(doc);
     } catch (IllegalArgumentException iae) {
@@ -498,10 +498,10 @@ public class TestDimensionalValues exten
     IndexWriterConfig iwc = new IndexWriterConfig(new MockAnalyzer(random()));
     IndexWriter w = new IndexWriter(dir, iwc);
     Document doc = new Document();
-    doc.add(new DimensionalField("dim", new byte[4]));
+    doc.add(new DimensionalBinaryField("dim", new byte[4]));
     w.addDocument(doc);
     doc = new Document();
-    doc.add(new DimensionalField("dim", new byte[4], new byte[4]));
+    doc.add(new DimensionalBinaryField("dim", new byte[4], new byte[4]));
     try {
       w.addDocument(doc);
     } catch (IllegalArgumentException iae) {
@@ -517,11 +517,11 @@ public class TestDimensionalValues exten
     IndexWriterConfig iwc = new IndexWriterConfig(new MockAnalyzer(random()));
     IndexWriter w = new IndexWriter(dir, iwc);
     Document doc = new Document();
-    doc.add(new DimensionalField("dim", new byte[4]));
+    doc.add(new DimensionalBinaryField("dim", new byte[4]));
     w.addDocument(doc);
     w.commit();
     doc = new Document();
-    doc.add(new DimensionalField("dim", new byte[4], new byte[4]));
+    doc.add(new DimensionalBinaryField("dim", new byte[4], new byte[4]));
     try {
       w.addDocument(doc);
     } catch (IllegalArgumentException iae) {
@@ -537,13 +537,13 @@ public class TestDimensionalValues exten
     IndexWriterConfig iwc = new IndexWriterConfig(new MockAnalyzer(random()));
     IndexWriter w = new IndexWriter(dir, iwc);
     Document doc = new Document();
-    doc.add(new DimensionalField("dim", new byte[4]));
+    doc.add(new DimensionalBinaryField("dim", new byte[4]));
     w.addDocument(doc);
     w.close();
     iwc = new IndexWriterConfig(new MockAnalyzer(random()));
     w = new IndexWriter(dir, iwc);
     doc = new Document();
-    doc.add(new DimensionalField("dim", new byte[4], new byte[4]));
+    doc.add(new DimensionalBinaryField("dim", new byte[4], new byte[4]));
     try {
       w.addDocument(doc);
     } catch (IllegalArgumentException iae) {
@@ -559,7 +559,7 @@ public class TestDimensionalValues exten
     IndexWriterConfig iwc = new IndexWriterConfig(new MockAnalyzer(random()));
     IndexWriter w = new IndexWriter(dir, iwc);
     Document doc = new Document();
-    doc.add(new DimensionalField("dim", new byte[4]));
+    doc.add(new DimensionalBinaryField("dim", new byte[4]));
     w.addDocument(doc);
     w.close();
 
@@ -567,7 +567,7 @@ public class TestDimensionalValues exten
     iwc = new IndexWriterConfig(new MockAnalyzer(random()));
     w = new IndexWriter(dir2, iwc);
     doc = new Document();
-    doc.add(new DimensionalField("dim", new byte[4], new byte[4]));
+    doc.add(new DimensionalBinaryField("dim", new byte[4], new byte[4]));
     w.addDocument(doc);
     try {
       w.addIndexes(new Directory[] {dir});
@@ -582,7 +582,7 @@ public class TestDimensionalValues exten
     IndexWriterConfig iwc = new IndexWriterConfig(new MockAnalyzer(random()));
     IndexWriter w = new IndexWriter(dir, iwc);
     Document doc = new Document();
-    doc.add(new DimensionalField("dim", new byte[4]));
+    doc.add(new DimensionalBinaryField("dim", new byte[4]));
     w.addDocument(doc);
     w.close();
 
@@ -590,7 +590,7 @@ public class TestDimensionalValues exten
     iwc = new IndexWriterConfig(new MockAnalyzer(random()));
     w = new IndexWriter(dir2, iwc);
     doc = new Document();
-    doc.add(new DimensionalField("dim", new byte[4], new byte[4]));
+    doc.add(new DimensionalBinaryField("dim", new byte[4], new byte[4]));
     w.addDocument(doc);
     DirectoryReader r = DirectoryReader.open(dir);
     try {
@@ -606,7 +606,7 @@ public class TestDimensionalValues exten
     IndexWriterConfig iwc = new IndexWriterConfig(new MockAnalyzer(random()));
     IndexWriter w = new IndexWriter(dir, iwc);
     Document doc = new Document();
-    doc.add(new DimensionalField("dim", new byte[4]));
+    doc.add(new DimensionalBinaryField("dim", new byte[4]));
     w.addDocument(doc);
     w.close();
 
@@ -614,7 +614,7 @@ public class TestDimensionalValues exten
     iwc = new IndexWriterConfig(new MockAnalyzer(random()));
     w = new IndexWriter(dir2, iwc);
     doc = new Document();
-    doc.add(new DimensionalField("dim", new byte[4], new byte[4]));
+    doc.add(new DimensionalBinaryField("dim", new byte[4], new byte[4]));
     w.addDocument(doc);
     DirectoryReader r = DirectoryReader.open(dir);
     try {
@@ -625,33 +625,13 @@ public class TestDimensionalValues exten
     IOUtils.close(r, w, dir, dir2);
   }
 
-  public void testIllegalTooManyDimensions() throws Exception {
-    Directory dir = getDirectory(1);
-    IndexWriterConfig iwc = new IndexWriterConfig(new MockAnalyzer(random()));
-    IndexWriter w = new IndexWriter(dir, iwc);
-    Document doc = new Document();
-    byte[][] values = new byte[BKDWriter.MAX_DIMS+1][];
-    for(int i=0;i<values.length;i++) {
-      values[i] = new byte[4];
-    }
-    doc.add(new DimensionalField("dim", values));
-    w.addDocument(doc);
-    try {
-      w.close();
-    } catch (IllegalArgumentException iae) {
-      // expected
-      assertEquals("numDims must be 1 .. 255 (got: 256)", iae.getMessage());
-    }
-    dir.close();
-  }
-
   public void testIllegalNumBytesChangeOneDoc() throws Exception {
     Directory dir = getDirectory(1);
     IndexWriterConfig iwc = new IndexWriterConfig(new MockAnalyzer(random()));
     IndexWriter w = new IndexWriter(dir, iwc);
     Document doc = new Document();
-    doc.add(new DimensionalField("dim", new byte[4]));
-    doc.add(new DimensionalField("dim", new byte[6]));
+    doc.add(new DimensionalBinaryField("dim", new byte[4]));
+    doc.add(new DimensionalBinaryField("dim", new byte[6]));
     try {
       w.addDocument(doc);
     } catch (IllegalArgumentException iae) {
@@ -667,10 +647,10 @@ public class TestDimensionalValues exten
     IndexWriterConfig iwc = new IndexWriterConfig(new MockAnalyzer(random()));
     IndexWriter w = new IndexWriter(dir, iwc);
     Document doc = new Document();
-    doc.add(new DimensionalField("dim", new byte[4]));
+    doc.add(new DimensionalBinaryField("dim", new byte[4]));
     w.addDocument(doc);
     doc = new Document();
-    doc.add(new DimensionalField("dim", new byte[6]));
+    doc.add(new DimensionalBinaryField("dim", new byte[6]));
     try {
       w.addDocument(doc);
     } catch (IllegalArgumentException iae) {
@@ -686,11 +666,11 @@ public class TestDimensionalValues exten
     IndexWriterConfig iwc = new IndexWriterConfig(new MockAnalyzer(random()));
     IndexWriter w = new IndexWriter(dir, iwc);
     Document doc = new Document();
-    doc.add(new DimensionalField("dim", new byte[4]));
+    doc.add(new DimensionalBinaryField("dim", new byte[4]));
     w.addDocument(doc);
     w.commit();
     doc = new Document();
-    doc.add(new DimensionalField("dim", new byte[6]));
+    doc.add(new DimensionalBinaryField("dim", new byte[6]));
     try {
       w.addDocument(doc);
     } catch (IllegalArgumentException iae) {
@@ -706,13 +686,13 @@ public class TestDimensionalValues exten
     IndexWriterConfig iwc = new IndexWriterConfig(new MockAnalyzer(random()));
     IndexWriter w = new IndexWriter(dir, iwc);
     Document doc = new Document();
-    doc.add(new DimensionalField("dim", new byte[4]));
+    doc.add(new DimensionalBinaryField("dim", new byte[4]));
     w.addDocument(doc);
     w.close();
     iwc = new IndexWriterConfig(new MockAnalyzer(random()));
     w = new IndexWriter(dir, iwc);
     doc = new Document();
-    doc.add(new DimensionalField("dim", new byte[6]));
+    doc.add(new DimensionalBinaryField("dim", new byte[6]));
     try {
       w.addDocument(doc);
     } catch (IllegalArgumentException iae) {
@@ -728,7 +708,7 @@ public class TestDimensionalValues exten
     IndexWriterConfig iwc = new IndexWriterConfig(new MockAnalyzer(random()));
     IndexWriter w = new IndexWriter(dir, iwc);
     Document doc = new Document();
-    doc.add(new DimensionalField("dim", new byte[4]));
+    doc.add(new DimensionalBinaryField("dim", new byte[4]));
     w.addDocument(doc);
     w.close();
 
@@ -736,7 +716,7 @@ public class TestDimensionalValues exten
     iwc = new IndexWriterConfig(new MockAnalyzer(random()));
     w = new IndexWriter(dir2, iwc);
     doc = new Document();
-    doc.add(new DimensionalField("dim", new byte[6]));
+    doc.add(new DimensionalBinaryField("dim", new byte[6]));
     w.addDocument(doc);
     try {
       w.addIndexes(new Directory[] {dir});
@@ -751,7 +731,7 @@ public class TestDimensionalValues exten
     IndexWriterConfig iwc = new IndexWriterConfig(new MockAnalyzer(random()));
     IndexWriter w = new IndexWriter(dir, iwc);
     Document doc = new Document();
-    doc.add(new DimensionalField("dim", new byte[4]));
+    doc.add(new DimensionalBinaryField("dim", new byte[4]));
     w.addDocument(doc);
     w.close();
 
@@ -759,7 +739,7 @@ public class TestDimensionalValues exten
     iwc = new IndexWriterConfig(new MockAnalyzer(random()));
     w = new IndexWriter(dir2, iwc);
     doc = new Document();
-    doc.add(new DimensionalField("dim", new byte[6]));
+    doc.add(new DimensionalBinaryField("dim", new byte[6]));
     w.addDocument(doc);
     DirectoryReader r = DirectoryReader.open(dir);
     try {
@@ -775,7 +755,7 @@ public class TestDimensionalValues exten
     IndexWriterConfig iwc = new IndexWriterConfig(new MockAnalyzer(random()));
     IndexWriter w = new IndexWriter(dir, iwc);
     Document doc = new Document();
-    doc.add(new DimensionalField("dim", new byte[4]));
+    doc.add(new DimensionalBinaryField("dim", new byte[4]));
     w.addDocument(doc);
     w.close();
 
@@ -783,7 +763,7 @@ public class TestDimensionalValues exten
     iwc = new IndexWriterConfig(new MockAnalyzer(random()));
     w = new IndexWriter(dir2, iwc);
     doc = new Document();
-    doc.add(new DimensionalField("dim", new byte[6]));
+    doc.add(new DimensionalBinaryField("dim", new byte[6]));
     w.addDocument(doc);
     DirectoryReader r = DirectoryReader.open(dir);
     try {
@@ -794,10 +774,52 @@ public class TestDimensionalValues exten
     IOUtils.close(r, w, dir, dir2);
   }
 
+  public void testIllegalTooManyBytes() throws Exception {
+    Directory dir = getDirectory(1);
+    IndexWriterConfig iwc = new IndexWriterConfig(new MockAnalyzer(random()));
+    IndexWriter w = new IndexWriter(dir, iwc);
+    Document doc = new Document();
+    doc.add(new DimensionalBinaryField("dim", new byte[DimensionalValues.MAX_NUM_BYTES+1]));
+    try {
+      w.addDocument(doc);
+      fail("did not hit exception");
+    } catch (IllegalArgumentException iae) {
+      // expected
+    }
+    doc = new Document();
+    doc.add(new DimensionalIntField("dim", 17));
+    w.addDocument(doc);
+    w.close();
+    dir.close();
+  }
+
+  public void testIllegalTooManyDimensions() throws Exception {
+    Directory dir = getDirectory(1);
+    IndexWriterConfig iwc = new IndexWriterConfig(new MockAnalyzer(random()));
+    IndexWriter w = new IndexWriter(dir, iwc);
+    Document doc = new Document();
+    byte[][] values = new byte[DimensionalValues.MAX_DIMENSIONS+1][];
+    for(int i=0;i<values.length;i++) {
+      values[i] = new byte[4];
+    }
+    doc.add(new DimensionalBinaryField("dim", values));
+    try {
+      w.addDocument(doc);
+      fail("did not hit exception");
+    } catch (IllegalArgumentException iae) {
+      // expected
+    }
+    doc = new Document();
+    doc.add(new DimensionalIntField("dim", 17));
+    w.addDocument(doc);
+    w.close();
+    dir.close();
+  }
+
   private void doTestRandomBinary(int count) throws Exception {
     int numDocs = TestUtil.nextInt(random(), count, count*2);
-    int numBytesPerDim = TestUtil.nextInt(random(), 2, 30);
-    int numDims = TestUtil.nextInt(random(), 1, 5);
+    int numBytesPerDim = TestUtil.nextInt(random(), 2, DimensionalValues.MAX_NUM_BYTES);
+    int numDims = TestUtil.nextInt(random(), 1, DimensionalValues.MAX_DIMENSIONS);
 
     byte[][][] docValues = new byte[numDocs][][];
 
@@ -935,7 +957,7 @@ public class TestDimensionalValues exten
           doc = new Document();
           doc.add(new NumericDocValuesField("id", id));
         }
-        doc.add(new DimensionalField("field", docValues[ord]));
+        doc.add(new DimensionalBinaryField("field", docValues[ord]));
         lastID = id;
 
         if (random().nextInt(30) == 17) {
@@ -953,7 +975,7 @@ public class TestDimensionalValues exten
         if (random().nextInt(30) == 17) {
           // randomly index some documents with this field, but we will delete them:
           Document xdoc = new Document();
-          xdoc.add(new DimensionalField("field", docValues[ord]));
+          xdoc.add(new DimensionalBinaryField("field", docValues[ord]));
           xdoc.add(new StringField("nukeme", "yes", Field.Store.NO));
           if (useRealWriter) {
             w.w.addDocument(xdoc);
@@ -1028,7 +1050,7 @@ public class TestDimensionalValues exten
           random().nextBytes(queryMin[dim]);
           queryMax[dim] = new byte[numBytesPerDim];
           random().nextBytes(queryMax[dim]);
-          if (BKDUtil.compare(numBytesPerDim, queryMin[dim], 0, queryMax[dim], 0) > 0) {
+          if (NumericUtils.compare(numBytesPerDim, queryMin[dim], 0, queryMax[dim], 0) > 0) {
             byte[] x = queryMin[dim];
             queryMin[dim] = queryMax[dim];
             queryMax[dim] = x;
@@ -1060,8 +1082,8 @@ public class TestDimensionalValues exten
               //System.out.println("visit check docID=" + docID + " id=" + idValues.get(docID));
               for(int dim=0;dim<numDims;dim++) {
                 //System.out.println("  dim=" + dim + " value=" + new BytesRef(packedValue, dim*numBytesPerDim, numBytesPerDim));
-                if (BKDUtil.compare(numBytesPerDim, packedValue, dim, queryMin[dim], 0) < 0 ||
-                    BKDUtil.compare(numBytesPerDim, packedValue, dim, queryMax[dim], 0) > 0) {
+                if (NumericUtils.compare(numBytesPerDim, packedValue, dim, queryMin[dim], 0) < 0 ||
+                    NumericUtils.compare(numBytesPerDim, packedValue, dim, queryMax[dim], 0) > 0) {
                   //System.out.println("  no");
                   return;
                 }
@@ -1076,12 +1098,12 @@ public class TestDimensionalValues exten
               boolean crosses = false;
               //System.out.println("compare");
               for(int dim=0;dim<numDims;dim++) {
-                if (BKDUtil.compare(numBytesPerDim, maxPacked, dim, queryMin[dim], 0) < 0 ||
-                    BKDUtil.compare(numBytesPerDim, minPacked, dim, queryMax[dim], 0) > 0) {
+                if (NumericUtils.compare(numBytesPerDim, maxPacked, dim, queryMin[dim], 0) < 0 ||
+                    NumericUtils.compare(numBytesPerDim, minPacked, dim, queryMax[dim], 0) > 0) {
                   //System.out.println("  query_outside_cell");
                   return Relation.CELL_OUTSIDE_QUERY;
-                } else if (BKDUtil.compare(numBytesPerDim, minPacked, dim, queryMin[dim], 0) < 0 ||
-                           BKDUtil.compare(numBytesPerDim, maxPacked, dim, queryMax[dim], 0) > 0) {
+                } else if (NumericUtils.compare(numBytesPerDim, minPacked, dim, queryMin[dim], 0) < 0 ||
+                           NumericUtils.compare(numBytesPerDim, maxPacked, dim, queryMax[dim], 0) > 0) {
                   crosses = true;
                 }
               }
@@ -1101,8 +1123,8 @@ public class TestDimensionalValues exten
           boolean matches = true;
           for(int dim=0;dim<numDims;dim++) {
             byte[] x = docValues[ord][dim];
-            if (BKDUtil.compare(numBytesPerDim, x, 0, queryMin[dim], 0) < 0 ||
-                BKDUtil.compare(numBytesPerDim, x, 0, queryMax[dim], 0) > 0) {
+            if (NumericUtils.compare(numBytesPerDim, x, 0, queryMin[dim], 0) < 0 ||
+                NumericUtils.compare(numBytesPerDim, x, 0, queryMax[dim], 0) > 0) {
               matches = false;
               break;
             }

Modified: lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/index/TestFieldReuse.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/index/TestFieldReuse.java?rev=1719562&r1=1719561&r2=1719562&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/index/TestFieldReuse.java (original)
+++ lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/index/TestFieldReuse.java Fri Dec 11 21:13:41 2015
@@ -23,15 +23,15 @@ import java.util.Collections;
 import org.apache.lucene.analysis.Analyzer;
 import org.apache.lucene.analysis.BaseTokenStreamTestCase;
 import org.apache.lucene.analysis.CannedTokenStream;
-import org.apache.lucene.analysis.NumericTokenStream;
-import org.apache.lucene.analysis.NumericTokenStream.NumericTermAttribute;
+import org.apache.lucene.analysis.LegacyNumericTokenStream;
+import org.apache.lucene.analysis.LegacyNumericTokenStream.LegacyNumericTermAttribute;
 import org.apache.lucene.analysis.Token;
 import org.apache.lucene.analysis.TokenStream;
 import org.apache.lucene.document.Field;
-import org.apache.lucene.document.IntField;
+import org.apache.lucene.document.LegacyIntField;
 import org.apache.lucene.document.StringField;
 import org.apache.lucene.store.Directory;
-import org.apache.lucene.util.NumericUtils;
+import org.apache.lucene.util.LegacyNumericUtils;
 
 /** test tokenstream reuse by DefaultIndexingChain */
 public class TestFieldReuse extends BaseTokenStreamTestCase {
@@ -59,7 +59,7 @@ public class TestFieldReuse extends Base
     
     // pass a bogus stream and ensure it's still ok
     stringField = new StringField("foo", "beer", Field.Store.NO);
-    TokenStream bogus = new NumericTokenStream();
+    TokenStream bogus = new LegacyNumericTokenStream();
     ts = stringField.tokenStream(null, bogus);
     assertNotSame(ts, bogus);
     assertTokenStreamContents(ts, 
@@ -70,32 +70,32 @@ public class TestFieldReuse extends Base
   }
   
   public void testNumericReuse() throws IOException {
-    IntField intField = new IntField("foo", 5, Field.Store.NO);
+    LegacyIntField legacyIntField = new LegacyIntField("foo", 5, Field.Store.NO);
     
     // passing null
-    TokenStream ts = intField.tokenStream(null, null);
-    assertTrue(ts instanceof NumericTokenStream);
-    assertEquals(NumericUtils.PRECISION_STEP_DEFAULT_32, ((NumericTokenStream)ts).getPrecisionStep());
+    TokenStream ts = legacyIntField.tokenStream(null, null);
+    assertTrue(ts instanceof LegacyNumericTokenStream);
+    assertEquals(LegacyNumericUtils.PRECISION_STEP_DEFAULT_32, ((LegacyNumericTokenStream)ts).getPrecisionStep());
     assertNumericContents(5, ts);
 
     // now reuse previous stream
-    intField = new IntField("foo", 20, Field.Store.NO);
-    TokenStream ts2 = intField.tokenStream(null, ts);
+    legacyIntField = new LegacyIntField("foo", 20, Field.Store.NO);
+    TokenStream ts2 = legacyIntField.tokenStream(null, ts);
     assertSame(ts, ts2);
     assertNumericContents(20, ts);
     
     // pass a bogus stream and ensure it's still ok
-    intField = new IntField("foo", 2343, Field.Store.NO);
+    legacyIntField = new LegacyIntField("foo", 2343, Field.Store.NO);
     TokenStream bogus = new CannedTokenStream(new Token("bogus", 0, 5));
-    ts = intField.tokenStream(null, bogus);
+    ts = legacyIntField.tokenStream(null, bogus);
     assertNotSame(bogus, ts);
     assertNumericContents(2343, ts);
     
     // pass another bogus stream (numeric, but different precision step!)
-    intField = new IntField("foo", 42, Field.Store.NO);
-    assert 3 != NumericUtils.PRECISION_STEP_DEFAULT;
-    bogus = new NumericTokenStream(3);
-    ts = intField.tokenStream(null, bogus);
+    legacyIntField = new LegacyIntField("foo", 42, Field.Store.NO);
+    assert 3 != LegacyNumericUtils.PRECISION_STEP_DEFAULT;
+    bogus = new LegacyNumericTokenStream(3);
+    ts = legacyIntField.tokenStream(null, bogus);
     assertNotSame(bogus, ts);
     assertNumericContents(42, ts);
   }
@@ -161,8 +161,8 @@ public class TestFieldReuse extends Base
   }
   
   private void assertNumericContents(int value, TokenStream ts) throws IOException {
-    assertTrue(ts instanceof NumericTokenStream);
-    NumericTermAttribute numericAtt = ts.getAttribute(NumericTermAttribute.class);
+    assertTrue(ts instanceof LegacyNumericTokenStream);
+    LegacyNumericTermAttribute numericAtt = ts.getAttribute(LegacyNumericTermAttribute.class);
     ts.reset();
     boolean seen = false;
     while (ts.incrementToken()) {

Modified: lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/index/TestPostingsOffsets.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/index/TestPostingsOffsets.java?rev=1719562&r1=1719561&r2=1719562&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/index/TestPostingsOffsets.java (original)
+++ lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/index/TestPostingsOffsets.java Fri Dec 11 21:13:41 2015
@@ -33,7 +33,6 @@ import org.apache.lucene.analysis.TokenS
 import org.apache.lucene.document.Document;
 import org.apache.lucene.document.Field;
 import org.apache.lucene.document.FieldType;
-import org.apache.lucene.document.IntField;
 import org.apache.lucene.document.NumericDocValuesField;
 import org.apache.lucene.document.StringField;
 import org.apache.lucene.document.TextField;
@@ -239,7 +238,6 @@ public class TestPostingsOffsets extends
 
     for(int docCount=0;docCount<numDocs;docCount++) {
       Document doc = new Document();
-      doc.add(new IntField("id", docCount, Field.Store.YES));
       doc.add(new NumericDocValuesField("id", docCount));
       List<Token> tokens = new ArrayList<>();
       final int numTokens = atLeast(100);

Modified: lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/index/TestTerms.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/index/TestTerms.java?rev=1719562&r1=1719561&r2=1719562&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/index/TestTerms.java (original)
+++ lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/index/TestTerms.java Fri Dec 11 21:13:41 2015
@@ -17,20 +17,18 @@ package org.apache.lucene.index;
  * limitations under the License.
  */
 
-import java.util.*;
-
 import org.apache.lucene.analysis.CannedBinaryTokenStream;
 import org.apache.lucene.document.Document;
-import org.apache.lucene.document.DoubleField;
+import org.apache.lucene.document.LegacyDoubleField;
 import org.apache.lucene.document.Field;
-import org.apache.lucene.document.FloatField;
-import org.apache.lucene.document.IntField;
-import org.apache.lucene.document.LongField;
+import org.apache.lucene.document.LegacyFloatField;
+import org.apache.lucene.document.LegacyIntField;
+import org.apache.lucene.document.LegacyLongField;
 import org.apache.lucene.document.TextField;
 import org.apache.lucene.store.Directory;
 import org.apache.lucene.util.BytesRef;
+import org.apache.lucene.util.LegacyNumericUtils;
 import org.apache.lucene.util.LuceneTestCase;
-import org.apache.lucene.util.NumericUtils;
 import org.apache.lucene.util.TestUtil;
 
 public class TestTerms extends LuceneTestCase {
@@ -92,8 +90,8 @@ public class TestTerms extends LuceneTes
   }
 
   public void testEmptyIntFieldMinMax() throws Exception {
-    assertNull(NumericUtils.getMinInt(EMPTY_TERMS));
-    assertNull(NumericUtils.getMaxInt(EMPTY_TERMS));
+    assertNull(LegacyNumericUtils.getMinInt(EMPTY_TERMS));
+    assertNull(LegacyNumericUtils.getMaxInt(EMPTY_TERMS));
   }
   
   public void testIntFieldMinMax() throws Exception {
@@ -107,14 +105,14 @@ public class TestTerms extends LuceneTes
       int num = random().nextInt();
       minValue = Math.min(num, minValue);
       maxValue = Math.max(num, maxValue);
-      doc.add(new IntField("field", num, Field.Store.NO));
+      doc.add(new LegacyIntField("field", num, Field.Store.NO));
       w.addDocument(doc);
     }
     
     IndexReader r = w.getReader();
     Terms terms = MultiFields.getTerms(r, "field");
-    assertEquals(new Integer(minValue), NumericUtils.getMinInt(terms));
-    assertEquals(new Integer(maxValue), NumericUtils.getMaxInt(terms));
+    assertEquals(new Integer(minValue), LegacyNumericUtils.getMinInt(terms));
+    assertEquals(new Integer(maxValue), LegacyNumericUtils.getMaxInt(terms));
 
     r.close();
     w.close();
@@ -122,8 +120,8 @@ public class TestTerms extends LuceneTes
   }
 
   public void testEmptyLongFieldMinMax() throws Exception {
-    assertNull(NumericUtils.getMinLong(EMPTY_TERMS));
-    assertNull(NumericUtils.getMaxLong(EMPTY_TERMS));
+    assertNull(LegacyNumericUtils.getMinLong(EMPTY_TERMS));
+    assertNull(LegacyNumericUtils.getMaxLong(EMPTY_TERMS));
   }
   
   public void testLongFieldMinMax() throws Exception {
@@ -137,15 +135,15 @@ public class TestTerms extends LuceneTes
       long num = random().nextLong();
       minValue = Math.min(num, minValue);
       maxValue = Math.max(num, maxValue);
-      doc.add(new LongField("field", num, Field.Store.NO));
+      doc.add(new LegacyLongField("field", num, Field.Store.NO));
       w.addDocument(doc);
     }
     
     IndexReader r = w.getReader();
 
     Terms terms = MultiFields.getTerms(r, "field");
-    assertEquals(new Long(minValue), NumericUtils.getMinLong(terms));
-    assertEquals(new Long(maxValue), NumericUtils.getMaxLong(terms));
+    assertEquals(new Long(minValue), LegacyNumericUtils.getMinLong(terms));
+    assertEquals(new Long(maxValue), LegacyNumericUtils.getMaxLong(terms));
 
     r.close();
     w.close();
@@ -163,14 +161,14 @@ public class TestTerms extends LuceneTes
       float num = random().nextFloat();
       minValue = Math.min(num, minValue);
       maxValue = Math.max(num, maxValue);
-      doc.add(new FloatField("field", num, Field.Store.NO));
+      doc.add(new LegacyFloatField("field", num, Field.Store.NO));
       w.addDocument(doc);
     }
     
     IndexReader r = w.getReader();
     Terms terms = MultiFields.getTerms(r, "field");
-    assertEquals(minValue, NumericUtils.sortableIntToFloat(NumericUtils.getMinInt(terms)), 0.0f);
-    assertEquals(maxValue, NumericUtils.sortableIntToFloat(NumericUtils.getMaxInt(terms)), 0.0f);
+    assertEquals(minValue, LegacyNumericUtils.sortableIntToFloat(LegacyNumericUtils.getMinInt(terms)), 0.0f);
+    assertEquals(maxValue, LegacyNumericUtils.sortableIntToFloat(LegacyNumericUtils.getMaxInt(terms)), 0.0f);
 
     r.close();
     w.close();
@@ -188,7 +186,7 @@ public class TestTerms extends LuceneTes
       double num = random().nextDouble();
       minValue = Math.min(num, minValue);
       maxValue = Math.max(num, maxValue);
-      doc.add(new DoubleField("field", num, Field.Store.NO));
+      doc.add(new LegacyDoubleField("field", num, Field.Store.NO));
       w.addDocument(doc);
     }
     
@@ -196,8 +194,8 @@ public class TestTerms extends LuceneTes
 
     Terms terms = MultiFields.getTerms(r, "field");
 
-    assertEquals(minValue, NumericUtils.sortableLongToDouble(NumericUtils.getMinLong(terms)), 0.0);
-    assertEquals(maxValue, NumericUtils.sortableLongToDouble(NumericUtils.getMaxLong(terms)), 0.0);
+    assertEquals(minValue, LegacyNumericUtils.sortableLongToDouble(LegacyNumericUtils.getMinLong(terms)), 0.0);
+    assertEquals(maxValue, LegacyNumericUtils.sortableLongToDouble(LegacyNumericUtils.getMaxLong(terms)), 0.0);
 
     r.close();
     w.close();

Modified: lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/index/TestTermsEnum.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/index/TestTermsEnum.java?rev=1719562&r1=1719561&r2=1719562&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/index/TestTermsEnum.java (original)
+++ lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/index/TestTermsEnum.java Fri Dec 11 21:13:41 2015
@@ -23,7 +23,6 @@ import java.util.*;
 import org.apache.lucene.analysis.MockAnalyzer;
 import org.apache.lucene.document.Document;
 import org.apache.lucene.document.Field;
-import org.apache.lucene.document.IntField;
 import org.apache.lucene.document.NumericDocValuesField;
 import org.apache.lucene.search.DocIdSetIterator;
 import org.apache.lucene.store.Directory;
@@ -158,7 +157,6 @@ public class TestTermsEnum extends Lucen
 
   private void addDoc(RandomIndexWriter w, Collection<String> terms, Map<BytesRef,Integer> termToID, int id) throws IOException {
     Document doc = new Document();
-    doc.add(new IntField("id", id, Field.Store.YES));
     doc.add(new NumericDocValuesField("id", id));
     if (VERBOSE) {
       System.out.println("TEST: addDoc id:" + id + " terms=" + terms);

Modified: lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/search/BaseTestRangeFilter.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/search/BaseTestRangeFilter.java?rev=1719562&r1=1719561&r2=1719562&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/search/BaseTestRangeFilter.java (original)
+++ lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/search/BaseTestRangeFilter.java Fri Dec 11 21:13:41 2015
@@ -21,13 +21,16 @@ import java.io.IOException;
 import java.util.Random;
 
 import org.apache.lucene.analysis.MockAnalyzer;
+import org.apache.lucene.document.DimensionalDoubleField;
+import org.apache.lucene.document.DimensionalFloatField;
+import org.apache.lucene.document.DimensionalIntField;
+import org.apache.lucene.document.DimensionalLongField;
 import org.apache.lucene.document.Document;
-import org.apache.lucene.document.DoubleField;
 import org.apache.lucene.document.Field;
-import org.apache.lucene.document.Field.Store;
-import org.apache.lucene.document.FloatField;
-import org.apache.lucene.document.IntField;
-import org.apache.lucene.document.LongField;
+import org.apache.lucene.document.LegacyDoubleField;
+import org.apache.lucene.document.LegacyFloatField;
+import org.apache.lucene.document.LegacyIntField;
+import org.apache.lucene.document.LegacyLongField;
 import org.apache.lucene.document.NumericDocValuesField;
 import org.apache.lucene.document.SortedDocValuesField;
 import org.apache.lucene.index.IndexReader;
@@ -124,13 +127,13 @@ public class BaseTestRangeFilter extends
     Document doc = new Document();
     Field idField = newStringField(random, "id", "", Field.Store.YES);
     Field idDVField = new SortedDocValuesField("id", new BytesRef());
-    Field intIdField = new IntField("id_int", 0, Store.YES);
+    Field intIdField = new DimensionalIntField("id_int", 0);
     Field intDVField = new NumericDocValuesField("id_int", 0);
-    Field floatIdField = new FloatField("id_float", 0, Store.YES);
+    Field floatIdField = new DimensionalFloatField("id_float", 0);
     Field floatDVField = new NumericDocValuesField("id_float", 0);
-    Field longIdField = new LongField("id_long", 0, Store.YES);
+    Field longIdField = new DimensionalLongField("id_long", 0);
     Field longDVField = new NumericDocValuesField("id_long", 0);
-    Field doubleIdField = new DoubleField("id_double", 0, Store.YES);
+    Field doubleIdField = new DimensionalDoubleField("id_double", 0);
     Field doubleDVField = new NumericDocValuesField("id_double", 0);
     Field randField = newStringField(random, "rand", "", Field.Store.YES);
     Field randDVField = new SortedDocValuesField("rand", new BytesRef());