improve concurrency when loading field data
This commit is contained in:
parent
7719dcd790
commit
4e6087ee2d
|
@ -26,7 +26,7 @@ import org.elasticsearch.index.field.data.FieldData;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author kimchy (Shay Banon)
|
* @author kimchy (shay.banon)
|
||||||
*/
|
*/
|
||||||
public interface FieldDataCache extends CloseableComponent {
|
public interface FieldDataCache extends CloseableComponent {
|
||||||
|
|
||||||
|
|
|
@ -32,7 +32,7 @@ import org.elasticsearch.index.settings.IndexSettings;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author kimchy (Shay Banon)
|
* @author kimchy (shay.banon)
|
||||||
*/
|
*/
|
||||||
public class NoneFieldDataCache extends AbstractIndexComponent implements FieldDataCache {
|
public class NoneFieldDataCache extends AbstractIndexComponent implements FieldDataCache {
|
||||||
|
|
||||||
|
|
|
@ -30,7 +30,7 @@ import org.elasticsearch.index.settings.IndexSettings;
|
||||||
import java.util.concurrent.ConcurrentMap;
|
import java.util.concurrent.ConcurrentMap;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author kimchy (Shay Banon)
|
* @author kimchy (shay.banon)
|
||||||
*/
|
*/
|
||||||
public class SoftFieldDataCache extends AbstractConcurrentMapFieldDataCache {
|
public class SoftFieldDataCache extends AbstractConcurrentMapFieldDataCache {
|
||||||
|
|
||||||
|
|
|
@ -33,7 +33,7 @@ import java.io.IOException;
|
||||||
import java.util.concurrent.ConcurrentMap;
|
import java.util.concurrent.ConcurrentMap;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author kimchy (Shay Banon)
|
* @author kimchy (shay.banon)
|
||||||
*/
|
*/
|
||||||
public abstract class AbstractConcurrentMapFieldDataCache extends AbstractIndexComponent implements FieldDataCache {
|
public abstract class AbstractConcurrentMapFieldDataCache extends AbstractIndexComponent implements FieldDataCache {
|
||||||
|
|
||||||
|
@ -76,23 +76,16 @@ public abstract class AbstractConcurrentMapFieldDataCache extends AbstractIndexC
|
||||||
fieldDataCache = ConcurrentCollections.newConcurrentMap();
|
fieldDataCache = ConcurrentCollections.newConcurrentMap();
|
||||||
cache.put(reader.getFieldCacheKey(), fieldDataCache);
|
cache.put(reader.getFieldCacheKey(), fieldDataCache);
|
||||||
}
|
}
|
||||||
T fieldData = (T) fieldDataCache.get(fieldName);
|
|
||||||
if (fieldData == null) {
|
|
||||||
fieldData = FieldData.load(type, reader, fieldName);
|
|
||||||
fieldDataCache.put(fieldName, fieldData);
|
|
||||||
}
|
|
||||||
return fieldData;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
T fieldData = (T) fieldDataCache.get(fieldName);
|
T fieldData = (T) fieldDataCache.get(fieldName);
|
||||||
if (fieldData == null) {
|
if (fieldData == null) {
|
||||||
synchronized (creationMutex) {
|
synchronized (fieldDataCache) {
|
||||||
fieldData = (T) fieldDataCache.get(fieldName);
|
fieldData = (T) fieldDataCache.get(fieldName);
|
||||||
if (fieldData == null) {
|
if (fieldData == null) {
|
||||||
fieldData = FieldData.load(type, reader, fieldName);
|
fieldData = FieldData.load(type, reader, fieldName);
|
||||||
fieldDataCache.put(fieldName, fieldData);
|
fieldDataCache.put(fieldName, fieldData);
|
||||||
}
|
}
|
||||||
return fieldData;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return fieldData;
|
return fieldData;
|
||||||
|
|
|
@ -30,7 +30,7 @@ import org.elasticsearch.index.settings.IndexSettings;
|
||||||
import java.util.concurrent.ConcurrentMap;
|
import java.util.concurrent.ConcurrentMap;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author kimchy (Shay Banon)
|
* @author kimchy (shay.banon)
|
||||||
*/
|
*/
|
||||||
public class WeakFieldDataCache extends AbstractConcurrentMapFieldDataCache {
|
public class WeakFieldDataCache extends AbstractConcurrentMapFieldDataCache {
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue