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. Uses ObjectCodec to deserialize regular Java objects.
  • Constructor Details

    • 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 into
      inputStream - stream containing an array of JSON objects
      resourceCloser - a Closeable implementation to release resources that the object is holding
      objectMapper - object mapper, used for deserialization
  • Method Details

    • hasNext

      public boolean hasNext()
      Returns true if there are more objects to be read.
      Specified by:
      hasNext in interface Iterator<T>
      Returns:
      true if there are more objects to be read, else return false
    • next

      public T next()
      Retrieves the next deserialized object from the stream of JSON objects.
      Specified by:
      next in interface Iterator<T>
      Returns:
      the next deserialized object from the stream of JSON ovbjects
    • close

      public void close() throws IOException
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
      Throws:
      IOException