Java源码示例:org.ojai.store.DriverManager

示例1
private void indexJSONTableDocuments(TransportClient client, String indexName, String typeName, String tablePath, String... fields) {

        loginTestUser(TEST_USER_NAME, TEST_USER_GROUP);

        // Create an OJAI connection to MapR cluster
        Connection connection = DriverManager.getConnection(CONNECTION_URL);

        // Get an instance of OJAI DocumentStore
        final DocumentStore store = connection.getStore(tablePath);

        DocumentStream documentStream = store.find(fields);
        for (Document document : documentStream) {

            IndexResponse response = client.prepareIndex(indexName, typeName, document.getId().getString())
                    .setSource(document.asJsonString(), XContentType.JSON)
                    .get();

            log.info("Elasticsearch Index Response: '{}'", response);
        }

        // Close this instance of OJAI DocumentStore
        store.close();

        // Close the OJAI connection and release any resources held by the connection
        connection.close();
    }
 
示例2
@Test
public void testDummyDriver() {
  Driver driver = DriverManager.getDriver(JsonConsts.BASE_URL);
  assertNotNull(driver);
  assertTrue(driver instanceof JsonDriver);
  assertEquals(JsonConsts.DRIVER_NAME, driver.getName());
}
 
示例3
private void startConnection() {
  connection = DriverManager.getConnection("ojai:mapr:");
}