T
- The type of the handle used for each split payloadpublic class JSONSplitter<T extends JSONWriteHandle> extends java.lang.Object implements Splitter<T>
Modifier and Type | Class and Description |
---|---|
static class |
JSONSplitter.ArrayVisitor
The basic visitor only splits objects or arrays under top array.
|
static interface |
JSONSplitter.UriMaker
UriMaker which generates URI for each split file
|
static class |
JSONSplitter.Visitor<T extends AbstractWriteHandle>
The Visitor class is used to accumulate and inspect state during the depth-first traversal of the JSON tree
and make the decision of how to split the JSON file.
|
Constructor and Description |
---|
JSONSplitter(JSONSplitter.Visitor<T> visitor)
Construct a JSONSplitter which splits the JSON file according to the visitor.
|
Modifier and Type | Method and Description |
---|---|
long |
getCount()
Returns the number of splits.
|
JSONSplitter.UriMaker |
getUriMaker()
Get the UriMaker of the splitter
|
JSONSplitter.Visitor<T> |
getVisitor()
Get the visitor used in JSONSplitter class.
|
static JSONSplitter<StringHandle> |
makeArraySplitter()
Construct a simple JSONSplitter which split objects or arrays under an array.
|
void |
setUriMaker(JSONSplitter.UriMaker uriMaker)
Set the UriMaker to the splitter
|
void |
setVisitor(JSONSplitter.Visitor<T> visitor)
Set the visitor to select objects or arrays to split in JSONSplitter.
|
java.util.stream.Stream<T> |
split(java.io.InputStream input)
Takes an InputStream of a JSON file and split it into a steam of handles.
|
java.util.stream.Stream<T> |
split(com.fasterxml.jackson.core.JsonParser input)
Take an input of JsonParser created from the JSON file and split it into a stream of handles to write to database.
|
java.util.stream.Stream<DocumentWriteOperation> |
splitWriteOperations(java.io.InputStream input)
Takes an InputStream of a JSON file and split it into a steam of DocumentWriteOperation to write to database.
|
java.util.stream.Stream<DocumentWriteOperation> |
splitWriteOperations(java.io.InputStream input,
java.lang.String splitFilename)
Takes an InputStream of a JSON file and file name and split it into a steam of DocumentWriteOperation
to write to database.
|
java.util.stream.Stream<DocumentWriteOperation> |
splitWriteOperations(com.fasterxml.jackson.core.JsonParser input,
java.lang.String splitFilename)
Take an input of JsonParser created from the JSON file and split it into a stream of DocumentWriteOperations
to write to database.
|
public JSONSplitter(JSONSplitter.Visitor<T> visitor)
visitor
- describes how to spit the filepublic static JSONSplitter<StringHandle> makeArraySplitter()
public JSONSplitter.Visitor<T> getVisitor()
public void setVisitor(JSONSplitter.Visitor<T> visitor)
visitor
- the visitor describes the rule to split the JSON filepublic long getCount()
getCount
in interface Splitter<T extends JSONWriteHandle>
public java.util.stream.Stream<T> split(java.io.InputStream input) throws java.io.IOException
split
in interface Splitter<T extends JSONWriteHandle>
input
- is the incoming InputStream of a JSON file.java.io.IOException
- if the input cannot be splitpublic java.util.stream.Stream<DocumentWriteOperation> splitWriteOperations(java.io.InputStream input) throws java.lang.Exception
splitWriteOperations
in interface Splitter<T extends JSONWriteHandle>
input
- is the incoming input stream of a JSON filejava.lang.Exception
- if the input cannot be splitpublic java.util.stream.Stream<DocumentWriteOperation> splitWriteOperations(java.io.InputStream input, java.lang.String splitFilename) throws java.lang.Exception
splitWriteOperations
in interface Splitter<T extends JSONWriteHandle>
input
- is the incoming input stream of a JSON filesplitFilename
- is the name of input file, including name and extension. It is used to generate URLs for split
files.The splitFilename could either be provided here or in user-defined UriMaker.java.lang.Exception
- if the input cannot be splitpublic java.util.stream.Stream<T> split(com.fasterxml.jackson.core.JsonParser input) throws java.io.IOException
input
- JsonParser created from the JSON filejava.io.IOException
- if the input cannot be splitpublic java.util.stream.Stream<DocumentWriteOperation> splitWriteOperations(com.fasterxml.jackson.core.JsonParser input, java.lang.String splitFilename)
input
- JsonParser created from the JSON filesplitFilename
- is the name of input file, including name and extension. It is used to generate URLs for split
files.The splitFilename could either be provided here or in user-defined UriMaker.public JSONSplitter.UriMaker getUriMaker()
public void setUriMaker(JSONSplitter.UriMaker uriMaker)
uriMaker
- the uriMaker to generate URI of each split file.Copyright © 2013-2020 MarkLogic Corporation.