Example HTTP Connector
The Example HTTP connector can be found in the directory in the root of the Presto source tree.
The plugin implementation in the Example HTTP connector looks very similar to other plugin implementations. Most of the implementation is devoted to handling optional configuration and the only function of interest is the following:
Note that the ImmutableList
class is a utility class from Guava.
In Presto, the primary object that handles the connection between Presto and a particular type of data source is the Connector
object, which are created using .
This implementation is available in the class ExampleConnectorFactory
. The first thing the connector factory implementation does is specify the name of this connector. This is the same string used to reference this connector in Presto configuration.
The real work in a connector factory happens in the create()
method. In the ExampleConnectorFactory
class, the create()
method configures the connector and then asks Guice to create the object. This is the meat of the method without parameter validation and exception handling:
This class is responsible for reporting table names, table metadata, column names, column metadata and other information about the schemas that are provided by this connector. ConnectorMetadata
is also called by Presto to ensure that a particular connector can understand and handle a given table name.
The ExampleMetadata
implementation delegates many of these calls to ExampleClient
, a class that implements much of the core functionality of the connector.
The split manager partitions the data for a table into the individual chunks that Presto will distribute to workers for processing. In the case of the Example HTTP connector, each table contains one or more URIs pointing at the actual data. One split is created per URI.