Package io.crate.action.sql

Examples of io.crate.action.sql.SQLResponse


    public void prepare() throws Exception {
        if (ids.isEmpty() || countryCodes.isEmpty()) {
            doLoadData();
            // setupOnce non-static
            SQLRequest request = new SQLRequest("SELECT \"_id\", \"countryCode\" FROM countries");
            SQLResponse response = getClient(false).execute(SQLAction.INSTANCE, request).actionGet();
            for (int i=0; i<response.rows().length;i++ ) {
                ids.add((String) response.rows()[i][0]);
                countryCodes.add((String) response.rows()[i][1]);
            }
        }
    }
View Full Code Here


    @BenchmarkOptions(benchmarkRounds = BENCHMARK_ROUNDS, warmupRounds = 1)
    @Test
    public void testDeleteSqlById() throws Exception {
        for (int i=0; i<NUM_REQUESTS_PER_TEST; i++) {
            SQLResponse response = getClient(false).execute(SQLAction.INSTANCE, getDeleteSqlByIdRequest()).actionGet();
        }
    }
View Full Code Here

    @BenchmarkOptions(benchmarkRounds = BENCHMARK_ROUNDS, warmupRounds = 1)
    @Test
    public void testDeleteSQLByQuery() throws Exception {
        for (int i=0; i<NUM_REQUESTS_PER_TEST; i++) {
            SQLResponse response = getClient(false).execute(SQLAction.INSTANCE, getDeleteSqlByQueryRequest()).actionGet();
        }
    }
View Full Code Here

    @Test
    public void testCopyToFile() throws Exception {
        this.setup.groupBySetup();

        String uriTemplate = Paths.get(folder.getRoot().toURI()).resolve("testCopyToFile%s.json").toAbsolutePath().toString();
        SQLResponse response = execute("copy characters to format(?, sys.shards.id)", new Object[]{uriTemplate});
        assertThat(response.rowCount(), is(7L));
        List<String> lines = new ArrayList<>(7);
        DirectoryStream<Path> stream = Files.newDirectoryStream(Paths.get(folder.getRoot().toURI()), "*.json");
        for (Path entry: stream) {
            lines.addAll(Files.readAllLines(entry, StandardCharsets.UTF_8));
        }
View Full Code Here

    @Test
    public void testCopyColumnsToDirectory() throws Exception {
        this.setup.groupBySetup();

        String uriTemplate = Paths.get(folder.getRoot().toURI()).toAbsolutePath().toString();
        SQLResponse response = execute("copy characters (name, details['job']) to DIRECTORY ?", new Object[]{uriTemplate});
        assertThat(response.rowCount(), is(7L));
        List<String> lines = new ArrayList<>(7);
        DirectoryStream<Path> stream = Files.newDirectoryStream(Paths.get(folder.getRoot().toURI()), "*.json");
        for (Path entry: stream) {
            lines.addAll(Files.readAllLines(entry, StandardCharsets.UTF_8));
        }
View Full Code Here

    @Test
    public void testCopyToDirectory() throws Exception {
        this.setup.groupBySetup();

        String uriTemplate = Paths.get(folder.getRoot().toURI()).toAbsolutePath().toString();
        SQLResponse response = execute("copy characters to DIRECTORY ?", new Object[]{uriTemplate});
        assertThat(response.rowCount(), is(7L));
        List<String> lines = new ArrayList<>(7);
        DirectoryStream<Path> stream = Files.newDirectoryStream(Paths.get(folder.getRoot().toURI()), "*.json");
        for (Path entry: stream) {
            lines.addAll(Files.readAllLines(entry, StandardCharsets.UTF_8));
        }
View Full Code Here

    @Test
    public void testAllFieldsDisabled() throws Exception {
        execute("create table test (col1 string)");
        ensureGreen();

        SQLResponse sqlResponse = execute("insert into test (col1) values ('foo')");
        assertEquals(1, sqlResponse.rowCount());
        refresh();


        byte[] searchSource = XContentFactory.jsonBuilder()
                .startObject()
View Full Code Here

        e.exec("set global stats.enabled = true");
        String stmt = "select * from sys.jobs";

        // the response contains all current jobs, if the tests are executed in parallel
        // this might be more then only the "select * from sys.jobs" statement.
        SQLResponse response = e.exec(stmt);
        List<String> statements = new ArrayList<>();

        for (Object[] objects : response.rows()) {
            assertNotNull(objects[0]);
            statements.add((String)objects[1]);
        }
        assertTrue(statements.contains(stmt));
        e.exec("set global stats.enabled = false");
View Full Code Here

        });
        execute("insert into test (id, name, content) values (?, ?, ?)", new Object[]{
                2, "another phrase", "Don't panic!"
        });
        refresh();
        SQLResponse response = execute("select id from test where match(content, 'brown jump')");
        assertEquals(1L, response.rowCount());
        assertEquals(1, response.rows()[0][0]);    }
View Full Code Here

        }
    }

    @Test
    public void testSysNodesMem() throws Exception {
        SQLResponse response = executor.exec("select mem['free'], mem['used'], mem['free_percent'], mem['used_percent'] from sys.nodes limit 1");
        long free = (long)response.rows()[0][0];
        long used = (long)response.rows()[0][1];

        double free_percent = ((Number) response.rows()[0][2]).intValue() * 0.01;
        double used_percent = ((Number) response.rows()[0][3]).intValue() * 0.01;

        double calculated_free_percent = free / (double)(free + used) ;
        double calculated_used_percent = used/ (double)(free + used) ;

        double max_delta = 0.02; // result should not differ from calculated result more than 2%
View Full Code Here

TOP

Related Classes of io.crate.action.sql.SQLResponse

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.