Search in sources :

Example 1 with SERVER

use of org.apache.ignite.client.Config.SERVER in project ignite by apache.

the class ArrayIndexTest method checkTableExpression.

/**
 */
private void checkTableExpression(boolean useTypedArrays) throws Exception {
    System.setProperty(IGNITE_USE_BINARY_ARRAYS, Boolean.toString(useTypedArrays));
    BinaryArray.initUseBinaryArrays();
    try (IgniteEx ex = startGrid(0);
        IgniteEx cli = startClientGrid(1);
        IgniteClient thinCli = Ignition.startClient(new ClientConfiguration().setAddresses(SERVER))) {
        ex.cluster().active(true);
        executeSql(cli, "CREATE TABLE T1 (id int not null, name varchar(1), PRIMARY KEY(id))");
        String insertQry = "INSERT INTO T1(id, name) VALUES (?, ?)";
        executeSql(cli, insertQry, 1, "A");
        executeSql(cli, insertQry, 2, "B");
        executeSql(cli, insertQry, 3, "C");
        String select = "SELECT T1.ID, T1.NAME FROM T1 INNER JOIN TABLE (id2 int = ?) T2 on (T1.id = T2.id2) ORDER BY id";
        Object arg = new Integer[] { 1, 2 };
        Consumer<List<List<?>>> checker = res -> {
            assertNotNull(res);
            assertEquals(2, res.size());
            assertEquals(1, res.get(0).get(0));
            assertEquals("A", res.get(0).get(1));
            assertEquals(2, res.get(1).get(0));
            assertEquals("B", res.get(1).get(1));
        };
        checker.accept(executeSql(ex, select, arg));
        checker.accept(executeSql(cli, select, arg));
        checker.accept(thinCli.query(new SqlFieldsQuery(select).setArgs(arg)).getAll());
    } finally {
        System.clearProperty(IGNITE_USE_BINARY_ARRAYS);
        BinaryArray.initUseBinaryArrays();
    }
}
Also used : SqlFieldsQuery(org.apache.ignite.cache.query.SqlFieldsQuery) IgniteEx(org.apache.ignite.internal.IgniteEx) Test(org.junit.Test) Hex(org.apache.commons.codec.binary.Hex) IgniteCache(org.apache.ignite.IgniteCache) Objects(java.util.Objects) Consumer(java.util.function.Consumer) List(java.util.List) IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) Ignition(org.apache.ignite.Ignition) ClientConfiguration(org.apache.ignite.configuration.ClientConfiguration) IgniteClient(org.apache.ignite.client.IgniteClient) CacheConfiguration(org.apache.ignite.configuration.CacheConfiguration) CacheWriteSynchronizationMode(org.apache.ignite.cache.CacheWriteSynchronizationMode) BinaryArray(org.apache.ignite.internal.binary.BinaryArray) After(org.junit.After) SERVER(org.apache.ignite.client.Config.SERVER) DataStorageConfiguration(org.apache.ignite.configuration.DataStorageConfiguration) IGNITE_USE_BINARY_ARRAYS(org.apache.ignite.IgniteSystemProperties.IGNITE_USE_BINARY_ARRAYS) QueryEntity(org.apache.ignite.cache.QueryEntity) Collections(java.util.Collections) DataRegionConfiguration(org.apache.ignite.configuration.DataRegionConfiguration) GridQueryProcessor(org.apache.ignite.internal.processors.query.GridQueryProcessor) Before(org.junit.Before) IgniteClient(org.apache.ignite.client.IgniteClient) IgniteEx(org.apache.ignite.internal.IgniteEx) List(java.util.List) ClientConfiguration(org.apache.ignite.configuration.ClientConfiguration) SqlFieldsQuery(org.apache.ignite.cache.query.SqlFieldsQuery)

Aggregations

Collections (java.util.Collections)1 List (java.util.List)1 Objects (java.util.Objects)1 Consumer (java.util.function.Consumer)1 Hex (org.apache.commons.codec.binary.Hex)1 IgniteCache (org.apache.ignite.IgniteCache)1 IGNITE_USE_BINARY_ARRAYS (org.apache.ignite.IgniteSystemProperties.IGNITE_USE_BINARY_ARRAYS)1 Ignition (org.apache.ignite.Ignition)1 CacheWriteSynchronizationMode (org.apache.ignite.cache.CacheWriteSynchronizationMode)1 QueryEntity (org.apache.ignite.cache.QueryEntity)1 SqlFieldsQuery (org.apache.ignite.cache.query.SqlFieldsQuery)1 SERVER (org.apache.ignite.client.Config.SERVER)1 IgniteClient (org.apache.ignite.client.IgniteClient)1 CacheConfiguration (org.apache.ignite.configuration.CacheConfiguration)1 ClientConfiguration (org.apache.ignite.configuration.ClientConfiguration)1 DataRegionConfiguration (org.apache.ignite.configuration.DataRegionConfiguration)1 DataStorageConfiguration (org.apache.ignite.configuration.DataStorageConfiguration)1 IgniteConfiguration (org.apache.ignite.configuration.IgniteConfiguration)1 IgniteEx (org.apache.ignite.internal.IgniteEx)1 BinaryArray (org.apache.ignite.internal.binary.BinaryArray)1