Package org.apache.solr.common.util
Class JsonRecordReader
- java.lang.Object
-
- org.apache.solr.common.util.JsonRecordReader
-
public class JsonRecordReader extends Object
A Streaming parser for json to emit one record at a time.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
JsonRecordReader.Handler
Implement this interface to stream records as and when one is found.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static void
consumeTillMatchingEnd(JSONParser parser, int obj, int arr)
List<Map<String,Object>>
getAllRecords(Reader r)
UsesstreamRecords
to getInst the JSON source but with a handler that collects all the emitted records into a single List which is returned upon completion.static JsonRecordReader
getInst(String split, List<String> fieldMappings)
static List<Object>
parseArrayFieldValue(int ev, JSONParser parser, org.apache.solr.common.util.JsonRecordReader.MethodFrameWrapper runnable)
static Object
parseSingleFieldValue(int ev, JSONParser parser, org.apache.solr.common.util.JsonRecordReader.MethodFrameWrapper runnable)
void
streamRecords(Reader r, JsonRecordReader.Handler handler)
Creates an JSONParser on top of whatever reader has been configured.void
streamRecords(JSONParser parser, JsonRecordReader.Handler handler)
-
-
-
Field Detail
-
DELIM
public static final String DELIM
- See Also:
- Constant Field Values
-
-
Method Detail
-
getInst
public static JsonRecordReader getInst(String split, List<String> fieldMappings)
-
getAllRecords
public List<Map<String,Object>> getAllRecords(Reader r) throws IOException
UsesstreamRecords
to getInst the JSON source but with a handler that collects all the emitted records into a single List which is returned upon completion.- Parameters:
r
- the stream reader- Returns:
- results a List of emitted records
- Throws:
IOException
-
streamRecords
public void streamRecords(Reader r, JsonRecordReader.Handler handler) throws IOException
Creates an JSONParser on top of whatever reader has been configured. Then calls getInst() with a handler which is invoked forEach record emitted.- Parameters:
r
- the stream readerhandler
- The callback instance- Throws:
IOException
-
streamRecords
public void streamRecords(JSONParser parser, JsonRecordReader.Handler handler) throws IOException
- Throws:
IOException
-
parseSingleFieldValue
public static Object parseSingleFieldValue(int ev, JSONParser parser, org.apache.solr.common.util.JsonRecordReader.MethodFrameWrapper runnable) throws IOException
- Throws:
IOException
-
parseArrayFieldValue
public static List<Object> parseArrayFieldValue(int ev, JSONParser parser, org.apache.solr.common.util.JsonRecordReader.MethodFrameWrapper runnable) throws IOException
- Throws:
IOException
-
consumeTillMatchingEnd
public static void consumeTillMatchingEnd(JSONParser parser, int obj, int arr) throws IOException
- Throws:
IOException
-
-