mirror of https://github.com/apache/druid.git
remove maxRows
This commit is contained in:
parent
bdf67180cb
commit
4d4de51f4f
|
@ -59,7 +59,7 @@ public class KttmNestedComponentSupplier extends StandardComponentSupplier
|
||||||
public static class Micro extends KttmNestedComponentSupplier {
|
public static class Micro extends KttmNestedComponentSupplier {
|
||||||
public Micro(TempDirProducer tempDirProducer)
|
public Micro(TempDirProducer tempDirProducer)
|
||||||
{
|
{
|
||||||
super(tempDirProducer, Fraction.getFraction(1, 10000), Integer.MAX_VALUE);
|
super(tempDirProducer, Fraction.getFraction(1, 10000));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -68,14 +68,13 @@ public class KttmNestedComponentSupplier extends StandardComponentSupplier
|
||||||
|
|
||||||
public KttmNestedComponentSupplier(TempDirProducer tempDirProducer)
|
public KttmNestedComponentSupplier(TempDirProducer tempDirProducer)
|
||||||
{
|
{
|
||||||
this(tempDirProducer, Fraction.ONE, Integer.MAX_VALUE);
|
this(tempDirProducer, Fraction.ONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
public KttmNestedComponentSupplier(TempDirProducer tempDirProducer, Fraction fraction, int maxRows)
|
public KttmNestedComponentSupplier(TempDirProducer tempDirProducer, Fraction fraction)
|
||||||
{
|
{
|
||||||
super(tempDirProducer);
|
super(tempDirProducer);
|
||||||
this.fraction = fraction;
|
this.fraction = fraction;
|
||||||
this.maxRows = maxRows;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -41,12 +41,10 @@ public class ScaledResoureInputDataSource extends AbstractInputSource
|
||||||
{
|
{
|
||||||
private final ResourceInputSource resourceInputSource;
|
private final ResourceInputSource resourceInputSource;
|
||||||
private final Fraction fraction;
|
private final Fraction fraction;
|
||||||
private final int maxRows;
|
|
||||||
|
|
||||||
public ScaledResoureInputDataSource(Fraction fraction, int maxRows, ResourceInputSource resourceInputSource)
|
public ScaledResoureInputDataSource(Fraction fraction, ResourceInputSource resourceInputSource)
|
||||||
{
|
{
|
||||||
this.fraction = fraction;
|
this.fraction = fraction;
|
||||||
this.maxRows = maxRows;
|
|
||||||
this.resourceInputSource = resourceInputSource;
|
this.resourceInputSource = resourceInputSource;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -66,7 +64,7 @@ public class ScaledResoureInputDataSource extends AbstractInputSource
|
||||||
public InputSourceReader reader(InputRowSchema inputRowSchema, InputFormat inputFormat, File temporaryDirectory)
|
public InputSourceReader reader(InputRowSchema inputRowSchema, InputFormat inputFormat, File temporaryDirectory)
|
||||||
{
|
{
|
||||||
InputSourceReader reader = resourceInputSource.reader(inputRowSchema, inputFormat, temporaryDirectory);
|
InputSourceReader reader = resourceInputSource.reader(inputRowSchema, inputFormat, temporaryDirectory);
|
||||||
return new FilteredReader(reader, this::filterPredicate, maxRows);
|
return new FilteredReader(reader, this::filterPredicate);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean filterPredicate(InputRow inputRow)
|
public boolean filterPredicate(InputRow inputRow)
|
||||||
|
@ -76,27 +74,24 @@ public class ScaledResoureInputDataSource extends AbstractInputSource
|
||||||
|
|
||||||
static class FilteredReader implements InputSourceReader
|
static class FilteredReader implements InputSourceReader
|
||||||
{
|
{
|
||||||
private InputSourceReader reader;
|
private final InputSourceReader reader;
|
||||||
private Predicate<InputRow> filterPredicate;
|
private final Predicate<InputRow> filterPredicate;
|
||||||
private int maxRows;
|
|
||||||
|
|
||||||
public FilteredReader(InputSourceReader reader, Predicate<InputRow> filterPredicate, int maxRows)
|
public FilteredReader(InputSourceReader reader, Predicate<InputRow> filterPredicate)
|
||||||
{
|
{
|
||||||
this.reader = reader;
|
this.reader = reader;
|
||||||
this.filterPredicate = filterPredicate;
|
this.filterPredicate = filterPredicate;
|
||||||
this.maxRows = maxRows;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CloseableIterator<InputRow> read(InputStats inputStats) throws IOException
|
public CloseableIterator<InputRow> read(InputStats inputStats) throws IOException
|
||||||
{
|
{
|
||||||
FilteringCloseableInputRowIterator filteredIterator = new FilteringCloseableInputRowIterator(
|
return new FilteringCloseableInputRowIterator(
|
||||||
reader.read(inputStats),
|
reader.read(inputStats),
|
||||||
filterPredicate,
|
filterPredicate,
|
||||||
NoopRowIngestionMeters.INSTANCE,
|
NoopRowIngestionMeters.INSTANCE,
|
||||||
new ParseExceptionHandler(NoopRowIngestionMeters.INSTANCE, false, 0, 0)
|
new ParseExceptionHandler(NoopRowIngestionMeters.INSTANCE, false, 0, 0)
|
||||||
);
|
);
|
||||||
return new LimitedCloseableIterator<>(filteredIterator, maxRows);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -105,39 +100,4 @@ public class ScaledResoureInputDataSource extends AbstractInputSource
|
||||||
return reader.sample();
|
return reader.sample();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static class LimitedCloseableIterator<InputRow> implements CloseableIterator<InputRow>
|
|
||||||
{
|
|
||||||
private final CloseableIterator<InputRow> delegate;
|
|
||||||
private final int maxRows;
|
|
||||||
private int count = 0;
|
|
||||||
|
|
||||||
public LimitedCloseableIterator(CloseableIterator<InputRow> delegate, int maxRows)
|
|
||||||
{
|
|
||||||
this.delegate = delegate;
|
|
||||||
this.maxRows = maxRows;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean hasNext()
|
|
||||||
{
|
|
||||||
return count < maxRows && delegate.hasNext();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public InputRow next()
|
|
||||||
{
|
|
||||||
if (count >= maxRows) {
|
|
||||||
throw new IllegalStateException("Exceeded maxRows");
|
|
||||||
}
|
|
||||||
count++;
|
|
||||||
return delegate.next();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void close() throws IOException
|
|
||||||
{
|
|
||||||
delegate.close();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue