Package org.apache.druid.data.input
Class BytesCountingInputEntity
- java.lang.Object
-
- org.apache.druid.data.input.BytesCountingInputEntity
-
- All Implemented Interfaces:
InputEntity
public class BytesCountingInputEntity extends Object implements InputEntity
Wrapper around anInputEntity
that counts the number of bytes read.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.apache.druid.data.input.InputEntity
InputEntity.CleanableFile
-
-
Field Summary
-
Fields inherited from interface org.apache.druid.data.input.InputEntity
DEFAULT_FETCH_BUFFER_SIZE, DEFAULT_MAX_NUM_FETCH_TRIES, LOG
-
-
Constructor Summary
Constructors Constructor Description BytesCountingInputEntity(InputEntity baseInputEntity, InputStats inputStats)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description InputEntity.CleanableFile
fetch(File temporaryDirectory, byte[] fetchBuffer)
Fetches the input entity into the local storage.InputEntity
getBaseInputEntity()
com.google.common.base.Predicate<Throwable>
getRetryCondition()
Returns a retry condition that the caller should retry on.URI
getUri()
Returns an URI to identify the input entity.InputStream
open()
Opens anInputStream
on the input entity directly.
-
-
-
Constructor Detail
-
BytesCountingInputEntity
public BytesCountingInputEntity(InputEntity baseInputEntity, InputStats inputStats)
-
-
Method Detail
-
getUri
@Nullable public URI getUri()
Description copied from interface:InputEntity
Returns an URI to identify the input entity. Implementations can return null if they don't have an unique URI.- Specified by:
getUri
in interfaceInputEntity
-
open
public InputStream open() throws IOException
Description copied from interface:InputEntity
Opens anInputStream
on the input entity directly. This is the basic way to read the given entity. The behavior of this method is only defined fort the first call to open(). The behavior of subsequent calls is undefined and may vary between implementations.- Specified by:
open
in interfaceInputEntity
- Throws:
IOException
- See Also:
InputEntity.fetch(java.io.File, byte[])
-
getBaseInputEntity
public InputEntity getBaseInputEntity()
-
fetch
public InputEntity.CleanableFile fetch(File temporaryDirectory, byte[] fetchBuffer) throws IOException
Description copied from interface:InputEntity
Fetches the input entity into the local storage. This method might be preferred instead ofInputEntity.open()
, for example -InputFormat
requires expensive random access on remote storage. - Holding a connection until you consume the entire InputStream is expensive.- Specified by:
fetch
in interfaceInputEntity
- Parameters:
temporaryDirectory
- to store temp data. This directory will be removed automatically once the task finishes.fetchBuffer
- is used to fetch remote entity into local storage.- Throws:
IOException
- See Also:
FileUtils.copyLarge(T, org.apache.druid.data.input.impl.prefetch.ObjectOpenFunction<T>, java.io.File, byte[], com.google.common.base.Predicate<java.lang.Throwable>, int, java.lang.String)
-
getRetryCondition
public com.google.common.base.Predicate<Throwable> getRetryCondition()
Description copied from interface:InputEntity
Returns a retry condition that the caller should retry on. The returned condition should be used when reading data from this InputEntity such as inInputEntity.fetch(java.io.File, byte[])
orRetryingInputEntity
.- Specified by:
getRetryCondition
in interfaceInputEntity
-
-