Skip to content

Commit

Permalink
Fix generics on LeadDocLookup (#23060)
Browse files Browse the repository at this point in the history
All the warnings were upsetting me. This doesn't change behavior.
  • Loading branch information
nik9000 authored Feb 8, 2017
1 parent 832952c commit f707132
Showing 1 changed file with 13 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@
import java.util.Map;
import java.util.Set;

public class LeafDocLookup implements Map {
public class LeafDocLookup implements Map<String, ScriptDocValues<?>> {

private final Map<String, ScriptDocValues> localCacheFieldData = new HashMap<>(4);
private final Map<String, ScriptDocValues<?>> localCacheFieldData = new HashMap<>(4);

private final MapperService mapperService;
private final IndexFieldDataService fieldDataService;
Expand Down Expand Up @@ -67,20 +67,20 @@ public void setDocument(int docId) {
}

@Override
public Object get(Object key) {
public ScriptDocValues<?> get(Object key) {
// assume its a string...
String fieldName = key.toString();
ScriptDocValues scriptValues = localCacheFieldData.get(fieldName);
ScriptDocValues<?> scriptValues = localCacheFieldData.get(fieldName);
if (scriptValues == null) {
final MappedFieldType fieldType = mapperService.fullName(fieldName);
if (fieldType == null) {
throw new IllegalArgumentException("No field found for [" + fieldName + "] in mapping with types " + Arrays.toString(types) + "");
}
// load fielddata on behalf of the script: otherwise it would need additional permissions
// to deal with pagedbytes/ramusagestimator/etc
scriptValues = AccessController.doPrivileged(new PrivilegedAction<ScriptDocValues>() {
scriptValues = AccessController.doPrivileged(new PrivilegedAction<ScriptDocValues<?>>() {
@Override
public ScriptDocValues run() {
public ScriptDocValues<?> run() {
return fieldDataService.getForField(fieldType).load(reader).getScriptValues();
}
});
Expand All @@ -94,7 +94,7 @@ public ScriptDocValues run() {
public boolean containsKey(Object key) {
// assume its a string...
String fieldName = key.toString();
ScriptDocValues scriptValues = localCacheFieldData.get(fieldName);
ScriptDocValues<?> scriptValues = localCacheFieldData.get(fieldName);
if (scriptValues == null) {
MappedFieldType fieldType = mapperService.fullName(fieldName);
if (fieldType == null) {
Expand All @@ -120,17 +120,17 @@ public boolean containsValue(Object value) {
}

@Override
public Object put(Object key, Object value) {
public ScriptDocValues<?> put(String key, ScriptDocValues<?> value) {
throw new UnsupportedOperationException();
}

@Override
public Object remove(Object key) {
public ScriptDocValues<?> remove(Object key) {
throw new UnsupportedOperationException();
}

@Override
public void putAll(Map m) {
public void putAll(Map<? extends String, ? extends ScriptDocValues<?>> m) {
throw new UnsupportedOperationException();
}

Expand All @@ -140,17 +140,17 @@ public void clear() {
}

@Override
public Set keySet() {
public Set<String> keySet() {
throw new UnsupportedOperationException();
}

@Override
public Collection values() {
public Collection<ScriptDocValues<?>> values() {
throw new UnsupportedOperationException();
}

@Override
public Set entrySet() {
public Set<Map.Entry<String, ScriptDocValues<?>>> entrySet() {
throw new UnsupportedOperationException();
}
}

0 comments on commit f707132

Please sign in to comment.