forked from elastic/elasticsearch
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
geo_point runtime field implementation (elastic#63164)
Run time field that emits geo points from lat/lon values.
- Loading branch information
Showing
21 changed files
with
1,255 additions
and
128 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 49 additions & 0 deletions
49
...rc/main/java/org/elasticsearch/xpack/runtimefields/fielddata/GeoPointScriptDocValues.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
package org.elasticsearch.xpack.runtimefields.fielddata; | ||
|
||
import org.apache.lucene.geo.GeoEncodingUtils; | ||
import org.elasticsearch.common.geo.GeoPoint; | ||
import org.elasticsearch.index.fielddata.MultiGeoPointValues; | ||
import org.elasticsearch.xpack.runtimefields.mapper.GeoPointFieldScript; | ||
|
||
import java.util.Arrays; | ||
|
||
public final class GeoPointScriptDocValues extends MultiGeoPointValues { | ||
private final GeoPointFieldScript script; | ||
private final GeoPoint point; | ||
private int cursor; | ||
|
||
GeoPointScriptDocValues(GeoPointFieldScript script) { | ||
this.script = script; | ||
this.point = new GeoPoint(); | ||
} | ||
|
||
@Override | ||
public boolean advanceExact(int docId) { | ||
script.runForDoc(docId); | ||
if (script.count() == 0) { | ||
return false; | ||
} | ||
Arrays.sort(script.values(), 0, script.count()); | ||
cursor = 0; | ||
return true; | ||
} | ||
|
||
@Override | ||
public int docValueCount() { | ||
return script.count(); | ||
} | ||
|
||
@Override | ||
public GeoPoint nextValue() { | ||
final long value = script.values()[cursor++]; | ||
final int lat = (int) (value >>> 32); | ||
final int lon = (int) (value & 0xFFFFFFFF); | ||
return point.reset(GeoEncodingUtils.decodeLatitude(lat), GeoEncodingUtils.decodeLongitude(lon)); | ||
} | ||
} |
Oops, something went wrong.