Getting started - new connectors
1. Create a new XXXDataContext class that extends QueryPostProcessDataContext (to get functionalities for free) that holds a reference to a native API object. Taking existing examples:
2. Implement materializeMainSchemaTable to fetch the data that is going to represent the table, using the native API. Existing examples:
CouchDbDataContext fetches a view will all docs through Ektorp's CouchDbInstance
HBaseDataContext creates a Scan of a table through HBaseTablePool
CsvDataContext reads the whole file using our file handle
3. Return a new XXXDataSet instance with the native result passed as a parameter. XXXDataSet class takes the native result object and translates it to the MetaModel's Row objects.
CouchDbDataSet will parse the JSON document and instantiate MetaModel's Row object with this data
HBaseDataSet extracts the values from the Scan and instantiates MetaModel's Row object with the values
CsvDataSet translates a line from a CSV file into MetaModel's Row object
This is the minimum that needs to be implemented. While we have the native result translated to MetaModel's Row objects, selecting specific columns, filtering and so on we get for free from QueryPostProcessDataContext class that we subclassed. Of course, it is not the most performant way of querying, for example doing a full scan to get a single row by its primary key is optimized in many databases. Delegating primary key lookups, count queries, queries with simple WHERE clauses to the native API instead of post-processing it in Java is the next step for a developer of a new MetaModel connector.