Skip to content

Commit

Permalink
Upgrade to lucene-6.1.0-snapshot-3a57bea.
Browse files Browse the repository at this point in the history
  • Loading branch information
jpountz committed Jun 10, 2016
1 parent a25b8ee commit 44c653f
Show file tree
Hide file tree
Showing 102 changed files with 384 additions and 417 deletions.
2 changes: 0 additions & 2 deletions buildSrc/src/main/resources/forbidden/es-all-signatures.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,3 @@ org.apache.lucene.index.IndexReader#getCombinedCoreAndDeletesKey()

@defaultMessage Soon to be removed
org.apache.lucene.document.FieldType#numericType()

org.apache.lucene.document.InetAddressPoint#newPrefixQuery(java.lang.String, java.net.InetAddress, int) @LUCENE-7232
2 changes: 1 addition & 1 deletion buildSrc/version.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
elasticsearch = 5.0.0
lucene = 6.0.1
lucene = 6.1.0-snapshot-3a57bea

# optional dependencies
spatial4j = 0.6
Expand Down
117 changes: 0 additions & 117 deletions core/src/main/java/org/apache/lucene/document/XInetAddressPoint.java

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -283,15 +283,15 @@ private Term[] equalsTerms() {
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (!super.equals(o)) return false;
if (sameClassAs(o) == false) return false;

BlendedTermQuery that = (BlendedTermQuery) o;
return Arrays.equals(equalsTerms(), that.equalsTerms());
}

@Override
public int hashCode() {
return Objects.hash(super.hashCode(), Arrays.hashCode(equalsTerms()));
return Objects.hash(classHash(), Arrays.hashCode(equalsTerms()));
}

public static BlendedTermQuery booleanBlendedQuery(Term[] terms, final boolean disableCoord) {
Expand Down
4 changes: 2 additions & 2 deletions core/src/main/java/org/apache/lucene/queries/MinDocQuery.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,12 @@ public MinDocQuery(int minDoc) {

@Override
public int hashCode() {
return Objects.hash(super.hashCode(), minDoc);
return Objects.hash(classHash(), minDoc);
}

@Override
public boolean equals(Object obj) {
if (super.equals(obj) == false) {
if (sameClassAs(obj) == false) {
return false;
}
MinDocQuery that = (MinDocQuery) obj;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,6 @@
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
Expand Down Expand Up @@ -622,22 +619,26 @@ public void build(InputIterator iterator) throws IOException {
Set<BytesRef> seenSurfaceForms = new HashSet<>();

int dedup = 0;
while (reader.read(scratch)) {
input.reset(scratch.bytes(), 0, scratch.length());
while (true) {
BytesRef bytes = reader.next();
if (bytes == null) {
break;
}
input.reset(bytes.bytes, bytes.offset, bytes.length);
short analyzedLength = input.readShort();
analyzed.grow(analyzedLength+2);
input.readBytes(analyzed.bytes(), 0, analyzedLength);
analyzed.setLength(analyzedLength);

long cost = input.readInt();

surface.bytes = scratch.bytes();
surface.bytes = bytes.bytes;
if (hasPayloads) {
surface.length = input.readShort();
surface.offset = input.getPosition();
} else {
surface.offset = input.getPosition();
surface.length = scratch.length() - surface.offset;
surface.length = bytes.length - surface.offset;
}

if (previousAnalyzed == null) {
Expand Down Expand Up @@ -679,11 +680,11 @@ public void build(InputIterator iterator) throws IOException {
builder.add(scratchInts.get(), outputs.newPair(cost, BytesRef.deepCopyOf(surface)));
} else {
int payloadOffset = input.getPosition() + surface.length;
int payloadLength = scratch.length() - payloadOffset;
int payloadLength = bytes.length - payloadOffset;
BytesRef br = new BytesRef(surface.length + 1 + payloadLength);
System.arraycopy(surface.bytes, surface.offset, br.bytes, 0, surface.length);
br.bytes[surface.length] = (byte) payloadSep;
System.arraycopy(scratch.bytes(), payloadOffset, br.bytes, surface.length+1, payloadLength);
System.arraycopy(bytes.bytes, payloadOffset, br.bytes, surface.length+1, payloadLength);
br.length = br.bytes.length;
builder.add(scratchInts.get(), outputs.newPair(cost, br));
}
Expand Down
2 changes: 1 addition & 1 deletion core/src/main/java/org/elasticsearch/Version.java
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public class Version {
public static final int V_5_0_0_alpha3_ID = 5000003;
public static final Version V_5_0_0_alpha3 = new Version(V_5_0_0_alpha3_ID, org.apache.lucene.util.Version.LUCENE_6_0_0);
public static final int V_5_0_0_ID = 5000099;
public static final Version V_5_0_0 = new Version(V_5_0_0_ID, org.apache.lucene.util.Version.LUCENE_6_0_1);
public static final Version V_5_0_0 = new Version(V_5_0_0_ID, org.apache.lucene.util.Version.LUCENE_6_1_0);
public static final Version CURRENT = V_5_0_0;

static {
Expand Down
20 changes: 20 additions & 0 deletions core/src/main/java/org/elasticsearch/bootstrap/JavaVersion.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,13 @@ public List<Integer> getVersion() {
}

private JavaVersion(List<Integer> version) {
if (version.size() >= 2
&& version.get(0).intValue() == 1
&& version.get(1).intValue() == 8) {
// for Java 8 there is ambiguity since both 1.8 and 8 are supported,
// so we rewrite the former to the latter
version = new ArrayList<>(version.subList(1, version.size()));
}
this.version = Collections.unmodifiableList(version);
}

Expand Down Expand Up @@ -75,6 +82,19 @@ public int compareTo(JavaVersion o) {
return 0;
}

@Override
public boolean equals(Object o) {
if (o == null || o.getClass() != getClass()) {
return false;
}
return compareTo((JavaVersion) o) == 0;
}

@Override
public int hashCode() {
return version.hashCode();
}

@Override
public String toString() {
return version.stream().map(v -> Integer.toString(v)).collect(Collectors.joining("."));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import java.util.ArrayList;
import java.util.Collection;

import org.apache.lucene.spatial.util.GeoEncodingUtils;
import org.apache.lucene.spatial.geopoint.document.GeoPointField;
import org.apache.lucene.util.BitUtil;

/**
Expand All @@ -39,7 +39,7 @@ public class GeoHashUtils {

/** maximum precision for geohash strings */
public static final int PRECISION = 12;
private static final short MORTON_OFFSET = (GeoEncodingUtils.BITS<<1) - (PRECISION*5);
private static final short MORTON_OFFSET = (GeoPointField.BITS<<1) - (PRECISION*5);

// No instance:
private GeoHashUtils() {
Expand All @@ -51,7 +51,7 @@ private GeoHashUtils() {
public static final long longEncode(final double lon, final double lat, final int level) {
// shift to appropriate level
final short msf = (short)(((12 - level) * 5) + MORTON_OFFSET);
return ((BitUtil.flipFlop(GeoEncodingUtils.mortonHash(lat, lon)) >>> msf) << 4) | level;
return ((BitUtil.flipFlop(GeoPointField.encodeLatLon(lat, lon)) >>> msf) << 4) | level;
}

/**
Expand Down Expand Up @@ -117,7 +117,7 @@ public static final String stringEncode(final double lon, final double lat) {
*/
public static final String stringEncode(final double lon, final double lat, final int level) {
// convert to geohashlong
final long ghLong = fromMorton(GeoEncodingUtils.mortonHash(lat, lon), level);
final long ghLong = fromMorton(GeoPointField.encodeLatLon(lat, lon), level);
return stringEncode(ghLong);

}
Expand All @@ -138,7 +138,7 @@ public static final String stringEncodeFromMortonLong(long hashedVal, final int

StringBuilder geoHash = new StringBuilder();
short precision = 0;
final short msf = (GeoEncodingUtils.BITS<<1)-5;
final short msf = (GeoPointField.BITS<<1)-5;
long mask = 31L<<msf;
do {
geoHash.append(BASE_32[(int)((mask & hashedVal)>>>(msf-(precision*5)))]);
Expand Down
13 changes: 4 additions & 9 deletions core/src/main/java/org/elasticsearch/common/geo/GeoPoint.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,11 @@

package org.elasticsearch.common.geo;

import org.apache.lucene.spatial.geopoint.document.GeoPointField;
import org.apache.lucene.util.BitUtil;

import static org.elasticsearch.common.geo.GeoHashUtils.mortonEncode;
import static org.elasticsearch.common.geo.GeoHashUtils.stringEncode;
import static org.apache.lucene.spatial.util.GeoEncodingUtils.mortonUnhashLat;
import static org.apache.lucene.spatial.util.GeoEncodingUtils.mortonUnhashLon;

/**
*
Expand Down Expand Up @@ -84,14 +83,14 @@ public GeoPoint resetFromString(String value) {
}

public GeoPoint resetFromIndexHash(long hash) {
lon = mortonUnhashLon(hash);
lat = mortonUnhashLat(hash);
lon = GeoPointField.decodeLongitude(hash);
lat = GeoPointField.decodeLatitude(hash);
return this;
}

public GeoPoint resetFromGeoHash(String geohash) {
final long hash = mortonEncode(geohash);
return this.reset(mortonUnhashLat(hash), mortonUnhashLon(hash));
return this.reset(GeoPointField.decodeLatitude(hash), GeoPointField.decodeLongitude(hash));
}

public GeoPoint resetFromGeoHash(long geohashLong) {
Expand Down Expand Up @@ -164,8 +163,4 @@ public static GeoPoint fromGeohash(String geohash) {
public static GeoPoint fromGeohash(long geohashLong) {
return new GeoPoint().resetFromGeoHash(geohashLong);
}

public static GeoPoint fromIndexLong(long indexLong) {
return new GeoPoint().resetFromIndexHash(indexLong);
}
}
12 changes: 11 additions & 1 deletion core/src/main/java/org/elasticsearch/common/geo/GeoUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
import org.elasticsearch.common.xcontent.XContentParser.Token;
import org.elasticsearch.index.mapper.geo.GeoPointFieldMapper;

import static org.apache.lucene.spatial.util.GeoDistanceUtils.maxRadialDistanceMeters;

import java.io.IOException;

Expand Down Expand Up @@ -67,6 +66,9 @@ public class GeoUtils {
/** Earth ellipsoid polar distance in meters */
public static final double EARTH_POLAR_DISTANCE = Math.PI * EARTH_SEMI_MINOR_AXIS;

/** rounding error for quantized latitude and longitude values */
public static final double TOLERANCE = 1E-6;

/** Returns the minimum between the provided distance 'initialRadius' and the
* maximum distance/radius from the point 'center' before overlapping
**/
Expand Down Expand Up @@ -468,6 +470,14 @@ public static GeoPoint parseGeoPoint(String data, GeoPoint point) {
}
}

/** Returns the maximum distance/radius (in meters) from the point 'center' before overlapping */
public static double maxRadialDistanceMeters(final double centerLat, final double centerLon) {
if (Math.abs(centerLat) == MAX_LAT) {
return SloppyMath.haversinMeters(centerLat, centerLon, 0, centerLon);
}
return SloppyMath.haversinMeters(centerLat, centerLon, centerLat, (MAX_LON + centerLon) % 360);
}

private GeoUtils() {
}
}
Loading

0 comments on commit 44c653f

Please sign in to comment.