make IndexedInts closeable + add fill method

This commit is contained in:
Xavier Léauté 2015-04-13 21:51:46 -07:00
parent ed0d49933e
commit 1abb9cce7c
13 changed files with 157 additions and 1 deletions

View File

@ -23,6 +23,7 @@ import com.google.common.base.Strings;
import com.google.common.collect.Iterators;
import io.druid.segment.data.IndexedInts;
import java.io.IOException;
import java.util.Iterator;
public class NullDimensionSelector implements DimensionSelector
@ -43,6 +44,18 @@ public class NullDimensionSelector implements DimensionSelector
public Iterator<Integer> iterator() {
return Iterators.singletonIterator(0);
}
@Override
public void fill(int index, int[] toFill)
{
throw new UnsupportedOperationException("NullDimensionSelector does not support fill");
}
@Override
public void close() throws IOException
{
}
};
@Override

View File

@ -356,6 +356,18 @@ public class QueryableIndexStorageAdapter implements StorageAdapter
{
return Iterators.singletonIterator(column.getSingleValueRow(cursorOffset.getOffset()));
}
@Override
public void fill(int index, int[] toFill)
{
throw new UnsupportedOperationException("fill not supported");
}
@Override
public void close() throws IOException
{
}
};
}

View File

@ -24,6 +24,7 @@ import com.google.common.collect.Maps;
import io.druid.query.extraction.ExtractionFn;
import io.druid.segment.data.IndexedInts;
import java.io.IOException;
import java.util.Iterator;
import java.util.Map;
@ -109,6 +110,18 @@ public class SingleScanTimeDimSelector implements DimensionSelector
{
return Iterators.singletonIterator(dimensionValueIndex);
}
@Override
public void fill(int index, int[] toFill)
{
throw new UnsupportedOperationException("fill not supported");
}
@Override
public void close() throws IOException
{
}
};
}

View File

@ -17,6 +17,7 @@
package io.druid.segment.data;
import java.io.IOException;
import java.util.Iterator;
/**
@ -44,4 +45,16 @@ public class ArrayBasedIndexedInts implements IndexedInts
{
return new IndexedIntsIterator(this);
}
@Override
public void fill(int index, int[] toFill)
{
throw new UnsupportedOperationException("fill not supported");
}
@Override
public void close() throws IOException
{
}
}

View File

@ -22,6 +22,7 @@ import com.metamx.collections.bitmap.ImmutableBitmap;
import org.roaringbitmap.IntIterator;
import javax.annotation.Nullable;
import java.io.IOException;
import java.util.Iterator;
/**
@ -104,4 +105,16 @@ public class BitmapCompressedIndexedInts implements IndexedInts, Comparable<Immu
}
};
}
@Override
public void fill(int index, int[] toFill)
{
throw new UnsupportedOperationException("fill not supported");
}
@Override
public void close() throws IOException
{
}
}

View File

@ -19,6 +19,7 @@ package io.druid.segment.data;
import com.google.common.collect.ImmutableList;
import java.io.IOException;
import java.util.Iterator;
/**
@ -44,4 +45,16 @@ public class EmptyIndexedInts implements IndexedInts
{
return ImmutableList.<Integer>of().iterator();
}
@Override
public void fill(int index, int[] toFill)
{
throw new UnsupportedOperationException("fill not supported");
}
@Override
public void close() throws IOException
{
}
}

View File

@ -17,11 +17,14 @@
package io.druid.segment.data;
import java.io.Closeable;
/**
* Get a int an index (array or list lookup abstraction without boxing).
*/
public interface IndexedInts extends Iterable<Integer>
public interface IndexedInts extends Iterable<Integer>, Closeable
{
int size();
int get(int index);
void fill(int index, int[] toFill);
}

View File

@ -21,6 +21,7 @@ import com.google.common.collect.Ordering;
import com.google.common.primitives.Ints;
import io.druid.collections.IntList;
import java.io.IOException;
import java.nio.ByteBuffer;
import java.nio.IntBuffer;
import java.util.Iterator;
@ -120,4 +121,16 @@ public class IntBufferIndexedInts implements IndexedInts, Comparable<IntBufferIn
return Ordering.natural().nullsFirst().compare(o1, o2);
}
}
@Override
public void fill(int index, int[] toFill)
{
throw new UnsupportedOperationException("fill not supported");
}
@Override
public void close() throws IOException
{
}
}

View File

@ -190,4 +190,15 @@ public class VSizeIndexedInts implements IndexedInts, Comparable<VSizeIndexedInt
throw new IAE("Unknown version[%s]", versionFromBuffer);
}
@Override
public void fill(int index, int[] toFill)
{
throw new UnsupportedOperationException("fill not supported");
}
@Override
public void close() throws IOException
{
}
}

View File

@ -53,6 +53,7 @@ import org.joda.time.Interval;
import javax.annotation.Nullable;
import java.io.Closeable;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;
@ -198,6 +199,18 @@ public abstract class IncrementalIndex<AggregatorType> implements Iterable<Row>,
{
return vals.iterator();
}
@Override
public void close() throws IOException
{
}
@Override
public void fill(int index, int[] toFill)
{
throw new UnsupportedOperationException("fill not supported");
}
};
}

View File

@ -35,6 +35,7 @@ import org.joda.time.Interval;
import org.roaringbitmap.IntIterator;
import javax.annotation.Nullable;
import java.io.IOException;
import java.util.Iterator;
import java.util.Map;
@ -272,6 +273,18 @@ public class IncrementalIndexAdapter implements IndexableAdapter
}
};
}
@Override
public void fill(int index, int[] toFill)
{
throw new UnsupportedOperationException("fill not supported");
}
@Override
public void close() throws IOException
{
}
};
}

View File

@ -52,6 +52,7 @@ import org.joda.time.DateTime;
import org.joda.time.Interval;
import javax.annotation.Nullable;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
@ -328,6 +329,18 @@ public class IncrementalIndexStorageAdapter implements StorageAdapter
{
return vals.iterator();
}
@Override
public void fill(int index, int[] toFill)
{
throw new UnsupportedOperationException("fill not supported");
}
@Override
public void close() throws IOException
{
}
};
}

View File

@ -34,6 +34,7 @@ import org.junit.Assert;
import org.junit.Test;
import javax.annotation.Nullable;
import java.io.IOException;
import java.nio.ByteBuffer;
import java.util.Iterator;
import java.util.List;
@ -125,6 +126,18 @@ public class CardinalityAggregatorTest
{
return Iterators.forArray(column.get(p));
}
@Override
public void fill(int index, int[] toFill)
{
throw new UnsupportedOperationException("fill not supported");
}
@Override
public void close() throws IOException
{
}
};
}