Search in sources :

Example 1 with Iface

use of org.apache.hive.service.rpc.thrift.TCLIService.Iface in project hive by apache.

the class EmbeddedCLIServicePortal method get.

public static Iface get(Map<String, String> hiveConfs) {
    TCLIService.Iface embeddedClient;
    try {
        Class<TCLIService.Iface> clazz = (Class<Iface>) Class.forName("org.apache.hive.service.cli.thrift.EmbeddedThriftBinaryCLIService");
        embeddedClient = clazz.newInstance();
        ((Service) embeddedClient).init(buildOverlayedConf(hiveConfs));
    } catch (ClassNotFoundException e) {
        throw new RuntimeException("Please Load hive-service jar to the classpath to enable embedded mode");
    } catch (Exception e) {
        throw new RuntimeException("Error initializing embedded mode", e);
    }
    return embeddedClient;
}
Also used : Iface(org.apache.hive.service.rpc.thrift.TCLIService.Iface) Service(org.apache.hive.service.Service) TCLIService(org.apache.hive.service.rpc.thrift.TCLIService) Iface(org.apache.hive.service.rpc.thrift.TCLIService.Iface) TCLIService(org.apache.hive.service.rpc.thrift.TCLIService)

Example 2 with Iface

use of org.apache.hive.service.rpc.thrift.TCLIService.Iface in project hive by apache.

the class TestHiveStatement method testSetFetchSizeZeroWithDefault.

/**
 * Gives the JDBC driver a hint as to the number of rows that should be
 * fetched from the database when more rows are needed for ResultSet objects
 * generated by this Statement. If the value specified is zero, then the hint
 * is ignored. Test for a value of zero (hint is ignored) and a default is
 * specified.
 */
@Test
public void testSetFetchSizeZeroWithDefault() throws SQLException {
    final HiveConnection connection = mock(HiveConnection.class);
    final Iface iface = mock(Iface.class);
    final TSessionHandle handle = mock(TSessionHandle.class);
    // so it falls-back to a value 1000
    try (HiveStatement stmt = new HiveStatement(connection, iface, handle, false, 0, 10)) {
        stmt.setFetchSize(0);
        assertEquals(10, stmt.getFetchSize());
    }
}
Also used : TSessionHandle(org.apache.hive.service.rpc.thrift.TSessionHandle) Iface(org.apache.hive.service.rpc.thrift.TCLIService.Iface) Test(org.junit.Test)

Example 3 with Iface

use of org.apache.hive.service.rpc.thrift.TCLIService.Iface in project hive by apache.

the class TestHiveStatement method testSetFetchSizeNegativeValue.

/**
 * Gives the JDBC driver a hint as to the number of rows that should be
 * fetched from the database when more rows are needed for ResultSet objects
 * generated by this Statement. If the value specified is zero, then the hint
 * is ignored. If the hint is less than zero, an error is thrown.
 *
 * @see Statement#setFetchSize(int)
 */
@Test(expected = SQLException.class)
public void testSetFetchSizeNegativeValue() throws SQLException {
    final HiveConnection connection = mock(HiveConnection.class);
    final Iface iface = mock(Iface.class);
    final TSessionHandle handle = mock(TSessionHandle.class);
    try (HiveStatement stmt = new HiveStatement(connection, iface, handle)) {
        stmt.setFetchSize(-1);
    }
}
Also used : TSessionHandle(org.apache.hive.service.rpc.thrift.TSessionHandle) Iface(org.apache.hive.service.rpc.thrift.TCLIService.Iface) Test(org.junit.Test)

Example 4 with Iface

use of org.apache.hive.service.rpc.thrift.TCLIService.Iface in project hive by apache.

the class TestHiveStatement method testSetFetchSizeJdbcProperty.

/**
 * Gives the JDBC driver a hint as to the number of rows that should be
 * fetched from the database when more rows are needed for ResultSet objects
 * generated by this Statement. The fetch size can be passed in through the
 * JDBC connection string whereby every created {@code Statement} will start
 * with the fetch size specified if no explicit calls are made.
 *
 * @see Utils.JdbcConnectionParams#FETCH_SIZE
 */
@Test
public void testSetFetchSizeJdbcProperty() throws SQLException {
    final HiveConnection connection = mock(HiveConnection.class);
    final Iface iface = mock(Iface.class);
    final TSessionHandle handle = mock(TSessionHandle.class);
    try (HiveStatement stmt = new HiveStatement(connection, iface, handle, false, 4, 1000)) {
        assertEquals(4, stmt.getFetchSize());
    }
}
Also used : TSessionHandle(org.apache.hive.service.rpc.thrift.TSessionHandle) Iface(org.apache.hive.service.rpc.thrift.TCLIService.Iface) Test(org.junit.Test)

Example 5 with Iface

use of org.apache.hive.service.rpc.thrift.TCLIService.Iface in project hive by apache.

the class TestHiveStatement method testaddBatch.

@Test(expected = SQLFeatureNotSupportedException.class)
public void testaddBatch() throws SQLException {
    final HiveConnection connection = mock(HiveConnection.class);
    final Iface iface = mock(Iface.class);
    final TSessionHandle handle = mock(TSessionHandle.class);
    try (HiveStatement stmt = new HiveStatement(connection, iface, handle)) {
        stmt.addBatch(null);
    }
}
Also used : TSessionHandle(org.apache.hive.service.rpc.thrift.TSessionHandle) Iface(org.apache.hive.service.rpc.thrift.TCLIService.Iface) Test(org.junit.Test)

Aggregations

Iface (org.apache.hive.service.rpc.thrift.TCLIService.Iface)7 TSessionHandle (org.apache.hive.service.rpc.thrift.TSessionHandle)6 Test (org.junit.Test)6 Service (org.apache.hive.service.Service)1 TCLIService (org.apache.hive.service.rpc.thrift.TCLIService)1