JSON Dumping
Summary
Let users de-serialize the data in Concourse to a JSON object.
Motivation
Having the data de-serialized into a JSON object will let users to transfer data between different systems more conveniently and it can also be kept as a data backup option.
Use Cases
- I want to have the data stored in Concourse saved offline in a JSON formatted file.
- I want to be able to move the data somewhere else and in JSON syntax.
Effects on Public API
The following methods will be added to the Public API and will therefore have a client-side implementation:
- public String jsonify(Long record, boolean flag)
- public String jsonify(Collection<Long> records, boolean flag)
Effects on Thrift API
The following methods will be added to the Thrift API and will therefore have a server-side implementation.
- string jsonify(1:list<i64 record>, 2:bool flag)
Important Questions and Semantics
Does the Primary Key need to be included for every record dumped in JSON?
An optional second parameter is provided in the API command. It acts as a configurable flag to give users the options of whether or not they want to keep the primary key in the export.
- What if the flag to keep primary key is not set?
- The flag will be set true by default and keep the primary key in the JSON string returned by the jsonify method.
Implementation Plan
Task | Description | Notes |
---|---|---|
Convert a collection of records into Json string. | Use the Gson library and create a javaToJson method in the Convert class (Concourse.util) that returns a JSON string | |
Update Thrift API | Add new jsonify method to Thrift API. | |
Server-side implementation | Implement the logic of calling the javaToJson method for a collection of records and building corresponding JSON mapping of key and set of values. The jsonify method should take a flag that sets whether the primary key should be included or not. | |
Update Public API | Add an atomic operation and compound operation jsonify method to Public API | |
Client-side implementation | Implement the logic of calling the new Thrift | |
Create JsonImporter class for concourse.importer | Implement handleFileImporter - For each JSON object in the JSON text file, call the Concourse.insert method(Json). |