Class JsonIterator<T>
- java.lang.Object
-
- org.apache.druid.data.input.impl.prefetch.JsonIterator<T>
-
- Type Parameters:
T
- the type of object returned by this iterator
- All Implemented Interfaces:
Closeable
,AutoCloseable
,Iterator<T>
,CloseableIterator<T>
public class JsonIterator<T> extends Object implements CloseableIterator<T>
An iterator over an array of JSON objects. UsesObjectCodec
to deserialize regular Java objects.
-
-
Constructor Summary
Constructors Constructor Description JsonIterator(com.fasterxml.jackson.core.type.TypeReference<T> typeRef, InputStream inputStream, Closeable resourceCloser, com.fasterxml.jackson.databind.ObjectMapper objectMapper)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
boolean
hasNext()
Returnstrue
if there are more objects to be read.T
next()
Retrieves the next deserialized object from the stream of JSON objects.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.apache.druid.java.util.common.parsers.CloseableIterator
flatMap, map
-
Methods inherited from interface java.util.Iterator
forEachRemaining, remove
-
-
-
-
Constructor Detail
-
JsonIterator
public JsonIterator(com.fasterxml.jackson.core.type.TypeReference<T> typeRef, InputStream inputStream, Closeable resourceCloser, com.fasterxml.jackson.databind.ObjectMapper objectMapper)
- Parameters:
typeRef
- the object type that the JSON object should be deserialized intoinputStream
- stream containing an array of JSON objectsresourceCloser
- aCloseable
implementation to release resources that the object is holdingobjectMapper
- object mapper, used for deserialization
-
-
Method Detail
-
hasNext
public boolean hasNext()
Returnstrue
if there are more objects to be read.
-
next
public T next()
Retrieves the next deserialized object from the stream of JSON objects.
-
close
public void close() throws IOException
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Throws:
IOException
-
-