public class JsonImporter extends Importer
Importer that uses Concourse's bulk JSON insert functionality for more efficient imports.
This class can be used as a standalone importer for JSON files and it can be extended to provide efficient inserts of other file formats. For example, an extension can parse line based files into a JSON intermediate format that is handled by the logic defined in this class.
| Modifier and Type | Field and Description |
|---|---|
protected Logger |
log |
ANNOTATE_DATA_SOURCE_OPTION_NAME, concourse, DATA_SOURCE_ANNOTATION_KEY, params| Modifier | Constructor and Description |
|---|---|
|
JsonImporter(Concourse concourse)
Construct a new instance.
|
protected |
JsonImporter(Concourse concourse,
Logger log)
Construct a new instance.
|
| Modifier and Type | Method and Description |
|---|---|
Set<Long> |
importFile(String file)
Import the data from
file into Concourse and return the
record ids where the data was imported. |
protected Set<Long> |
importJsonString(String json)
Given a string of JSON data, insert it into Concourse.
|
Set<Long> |
importString(String json)
Import
data directly from a String, for instance input
from stdin. |
protected Set<Long> |
upsertJsonString(String json)
Given a string of JSON data, upsert it into Concourse.
|
public JsonImporter(Concourse concourse)
concourse - protected JsonImporter(Concourse concourse,
Logger log)
concourse - public Set<Long> importFile(String file)
Importerfile into Concourse and return the
record ids where the data was imported.importFile in class Importerfile - the path of the file to import; relative paths will be
resolved against the user.dir system property. When
using the ImportCli, prior
to passing the path to this method, relative paths are
converted to absolute paths by resolving against the directory
from which the CLI process is launchedSet that contains the ids of the records affected by
the importprotected Set<Long> importJsonString(String json)
json - protected Set<Long> upsertJsonString(String json)
json - public Set<Long> importString(String json)
Importerdata directly from a String, for instance input
from stdin.importString in class Importerjson - a string with data to importSet that contains the ids of the records affected by
the import