Remove makeObjectColumnSelector() from DimensionIndexer (#4679)

This commit is contained in:
Jonathan Wei 2017-08-11 14:39:00 -07:00 committed by GitHub
parent d775347b06
commit e91d4d1b80
5 changed files with 1 additions and 149 deletions

View File

@ -249,19 +249,12 @@ public interface DimensionIndexer
/**
* Return an object used to read values from this indexer's column as Objects.
* Return an object used to read values from this indexer's column as Doubles.
*
* @param spec Specifies the output name of a dimension and any extraction functions to be applied.
* @param currEntry Provides access to the current TimeAndDims object in the Cursor
* @param desc Descriptor object for this dimension within an IncrementalIndex
* @return A new object that reads rows from currEntry
*/
ObjectColumnSelector makeObjectColumnSelector(
DimensionSpec spec,
IncrementalIndexStorageAdapter.EntryHolder currEntry,
IncrementalIndex.DimensionDesc desc
);
DoubleColumnSelector makeDoubleColumnSelector(
IncrementalIndexStorageAdapter.EntryHolder currEntry,
IncrementalIndex.DimensionDesc desc

View File

@ -157,36 +157,6 @@ public class DoubleDimensionIndexer implements DimensionIndexer<Double, Double,
return new IndexerFloatColumnSelector();
}
@Override
public ObjectColumnSelector makeObjectColumnSelector(
DimensionSpec spec, IncrementalIndexStorageAdapter.EntryHolder currEntry, IncrementalIndex.DimensionDesc desc
)
{
final int dimIndex = desc.getIndex();
class IndexerObjectColumnSelector implements ObjectColumnSelector
{
@Override
public Class classOfObject()
{
return Double.class;
}
@Override
public Object get()
{
final Object[] dims = currEntry.getKey().getDims();
if (dimIndex >= dims.length) {
return DimensionHandlerUtils.ZERO_DOUBLE;
}
return dims[dimIndex];
}
}
return new IndexerObjectColumnSelector();
}
@Override
public DoubleColumnSelector makeDoubleColumnSelector(
IncrementalIndexStorageAdapter.EntryHolder currEntry, IncrementalIndex.DimensionDesc desc

View File

@ -159,38 +159,6 @@ public class FloatDimensionIndexer implements DimensionIndexer<Float, Float, Flo
return new IndexerFloatColumnSelector();
}
@Override
public ObjectColumnSelector makeObjectColumnSelector(
final DimensionSpec spec,
final IncrementalIndexStorageAdapter.EntryHolder currEntry,
final IncrementalIndex.DimensionDesc desc
)
{
final int dimIndex = desc.getIndex();
class IndexerObjectColumnSelector implements ObjectColumnSelector
{
@Override
public Class classOfObject()
{
return Float.class;
}
@Override
public Object get()
{
final Object[] dims = currEntry.getKey().getDims();
if (dimIndex >= dims.length) {
return DimensionHandlerUtils.ZERO_FLOAT;
}
return dims[dimIndex];
}
}
return new IndexerObjectColumnSelector();
}
@Override
public DoubleColumnSelector makeDoubleColumnSelector(
IncrementalIndexStorageAdapter.EntryHolder currEntry, IncrementalIndex.DimensionDesc desc

View File

@ -159,38 +159,6 @@ public class LongDimensionIndexer implements DimensionIndexer<Long, Long, Long>
return new IndexerFloatColumnSelector();
}
@Override
public ObjectColumnSelector makeObjectColumnSelector(
final DimensionSpec spec,
final IncrementalIndexStorageAdapter.EntryHolder currEntry,
final IncrementalIndex.DimensionDesc desc
)
{
final int dimIndex = desc.getIndex();
class IndexerObjectColumnSelector implements ObjectColumnSelector
{
@Override
public Class classOfObject()
{
return Long.class;
}
@Override
public Object get()
{
final Object[] dims = currEntry.getKey().getDims();
if (dimIndex >= dims.length) {
return DimensionHandlerUtils.ZERO_LONG;
}
return dims[dimIndex];
}
}
return new IndexerObjectColumnSelector();
}
@Override
public DoubleColumnSelector makeDoubleColumnSelector(
IncrementalIndexStorageAdapter.EntryHolder currEntry, IncrementalIndex.DimensionDesc desc

View File

@ -576,53 +576,6 @@ public class StringDimensionIndexer implements DimensionIndexer<Integer, int[],
return ZeroDoubleColumnSelector.instance();
}
@Override
public ObjectColumnSelector makeObjectColumnSelector(
final DimensionSpec spec,
final IncrementalIndexStorageAdapter.EntryHolder currEntry,
final IncrementalIndex.DimensionDesc desc
)
{
final ExtractionFn extractionFn = spec.getExtractionFn();
final int dimIndex = desc.getIndex();
class StringIndexerObjectColumnSelector implements ObjectColumnSelector<String>
{
@Override
public Class<String> classOfObject()
{
return String.class;
}
@Override
public String get()
{
final Object[] dims = currEntry.getKey().getDims();
int[] indices;
if (dimIndex < dims.length) {
indices = (int[]) dims[dimIndex];
if (indices.length > 1) {
throw new UnsupportedOperationException(
"makeObjectColumnSelector does not support multi-value columns."
);
}
} else {
indices = null;
}
if (indices == null || indices.length == 0) {
return extractionFn.apply(null);
}
final String strValue = getActualValue(indices[0], false);
return extractionFn == null ? strValue : extractionFn.apply(strValue);
}
}
return new StringIndexerObjectColumnSelector();
}
@Override
public Object convertUnsortedEncodedKeyComponentToActualArrayOrList(int[] key, boolean asList)
{