Skip to content

Commit

Permalink
Whitelist some ScriptDocValues in painless (#22600)
Browse files Browse the repository at this point in the history
Without this whitelist painless can't use ip or binary doc values.

Closes #22584
  • Loading branch information
nik9000 authored Jan 12, 2017
1 parent 58daf5f commit baed02b
Show file tree
Hide file tree
Showing 4 changed files with 392 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@

package org.elasticsearch.index.mapper;

import org.apache.lucene.document.Field;
import org.apache.lucene.document.InetAddressPoint;
import org.apache.lucene.document.SortedSetDocValuesField;
import org.apache.lucene.document.StoredField;
Expand All @@ -32,7 +31,6 @@
import org.apache.lucene.search.MatchNoDocsQuery;
import org.apache.lucene.search.Query;
import org.apache.lucene.util.BytesRef;
import org.elasticsearch.Version;
import org.elasticsearch.action.fieldstats.FieldStats;
import org.elasticsearch.common.Explicit;
import org.elasticsearch.common.Nullable;
Expand All @@ -41,7 +39,6 @@
import org.elasticsearch.common.xcontent.XContentBuilder;
import org.elasticsearch.index.fielddata.IndexFieldData;
import org.elasticsearch.index.fielddata.ScriptDocValues;
import org.elasticsearch.index.fielddata.SortedBinaryDocValues;
import org.elasticsearch.index.fielddata.plain.DocValuesIndexFieldData;
import org.elasticsearch.index.query.QueryShardContext;
import org.elasticsearch.search.DocValueFormat;
Expand All @@ -51,11 +48,9 @@
import java.net.InetAddress;
import java.util.AbstractList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import java.util.ListIterator;
import java.util.Map;

/** A {@link FieldMapper} for ip addresses. */
Expand Down Expand Up @@ -238,7 +233,7 @@ public FieldStats.Ip stats(IndexReader reader) throws IOException {
InetAddressPoint.decode(min), InetAddressPoint.decode(max));
}

private static class IpScriptDocValues extends AbstractList<String> implements ScriptDocValues<String> {
public static final class IpScriptDocValues extends AbstractList<String> implements ScriptDocValues<String> {

private final RandomAccessOrds values;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -566,11 +566,11 @@ private Map<String,List<String>> addStructs() {
}
if (line.startsWith("class ")) {
String elements[] = line.split("\u0020");
assert elements[2].equals("->");
assert elements[2].equals("->") : "Invalid struct definition [" + String.join(" ", elements) +"]";
if (elements.length == 7) {
hierarchy.put(elements[1], Arrays.asList(elements[5].split(",")));
} else {
assert elements.length == 5;
assert elements.length == 5 : "Invalid struct definition [" + String.join(" ", elements) + "]";
}
String className = elements[1];
String javaPeer = elements[3];
Expand Down Expand Up @@ -612,7 +612,7 @@ private Map<String,List<String>> addStructs() {
}
}
} catch (Exception e) {
throw new RuntimeException("syntax error in " + file + ", line: " + currentLine, e);
throw new RuntimeException("error in " + file + ", line: " + currentLine, e);
}
}
return hierarchy;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,26 @@ class org.elasticsearch.index.fielddata.ScriptDocValues.Booleans -> org.elastics
List getValues()
}

class org.elasticsearch.index.fielddata.ScriptDocValues.BytesRefs -> org.elasticsearch.index.fielddata.ScriptDocValues$BytesRefs extends List,Collection,Iterable,Object {
BytesRef get(int)
BytesRef getValue()
List getValues()
}

class BytesRef -> org.apache.lucene.util.BytesRef extends Object {
byte[] bytes
int offset
int length
boolean bytesEquals(BytesRef)
String utf8ToString()
}

class org.elasticsearch.index.mapper.IpFieldMapper.IpFieldType.IpScriptDocValues -> org.elasticsearch.index.mapper.IpFieldMapper$IpFieldType$IpScriptDocValues extends List,Collection,Iterable,Object {
String get(int)
String getValue()
List getValues()
}

# for testing.
# currently FeatureTest exposes overloaded constructor, field load store, and overloaded static methods
class org.elasticsearch.painless.FeatureTest -> org.elasticsearch.painless.FeatureTest extends Object {
Expand Down
Loading

0 comments on commit baed02b

Please sign in to comment.