Package io.crate.action.sql

Examples of io.crate.action.sql.SQLBulkResponse$Result


        DefaultActionMapper defaultActionMapper = new DefaultActionMapper();
        defaultActionMapper.setContainer(container);
        ActionMapping actionMapping = defaultActionMapper.getMapping(request, configManager);

        Result result = actionMapping.getResult();
        assertNotNull(result);
        assertTrue(result instanceof ServletRedirectResult);

        Mock invMock = new Mock(ActionInvocation.class);
        ActionInvocation inv = (ActionInvocation) invMock.proxy();
        ActionContext ctx = ActionContext.getContext();
        ctx.put(ServletActionContext.HTTP_REQUEST, request);
        StrutsMockHttpServletResponse response = new StrutsMockHttpServletResponse();
        ctx.put(ServletActionContext.HTTP_RESPONSE, response);
        invMock.expectAndReturn("getInvocationContext", ctx);
        invMock.expectAndReturn("getStack", ctx.getValueStack());
        result.execute(inv);
        assertEquals("http://www.google.com", response.getRedirectURL());
        //TODO: need to test location but there's noaccess to the property/method, unless we use reflection
    }
View Full Code Here


        client.sql("refresh table test").actionGet();

        SQLBulkRequest bulkRequest = new SQLBulkRequest(
                "update test set a = ? where b = ?",
                new Object[][]{new Object[]{"bar", 1}, new Object[]{"baz", 1}});
        SQLBulkResponse bulkResponse = client.bulkSql(bulkRequest).actionGet();
        assertThat(bulkResponse.results().length, is(2));
        for (SQLBulkResponse.Result result : bulkResponse.results()) {
            assertThat(result.rowCount(), is(1L));
            assertThat(result.errorMessage(), is(nullValue()));
        }
    }
View Full Code Here

    }

    private void assertBulkResponseWithTypes(String stmt, Object[][] bulkArgs) {
        SQLBulkRequest request = new SQLBulkRequest(stmt, bulkArgs);
        request.includeTypesOnResponse(true);
        SQLBulkResponse sqlResponse = sqlExecutor.exec(request);
        assertThat(sqlResponse.columnTypes(), is(notNullValue()));
        assertThat(sqlResponse.columnTypes().length, is(sqlResponse.cols().length));
    }
View Full Code Here

    @Test
    public void testBulkOperations() throws Exception {
        execute("create table test (id integer primary key, name string) with (number_of_replicas = 0)");
        ensureGreen();
        SQLBulkResponse bulkResp = execute("insert into test (id, name) values (?, ?), (?, ?)",
                new Object[][] {
                        {1, "Earth", 2, "Saturn"},    // bulk row 1
                        {3, "Moon", 4, "Mars"}        // bulk row 2
                });
        assertThat(bulkResp.results().length, is(4));
        for (SQLBulkResponse.Result result : bulkResp.results()) {
            assertThat(result.rowCount(), is(1L));
        }
        refresh();

        bulkResp = execute("insert into test (id, name) values (?, ?), (?, ?)",
            new Object[][] {
                {1, "Earth", 2, "Saturn"},    // bulk row 1
                {3, "Moon", 4, "Mars"}        // bulk row 2
            });
        assertThat(bulkResp.results().length, is(4));
        for (SQLBulkResponse.Result result : bulkResp.results()) {
            assertThat(result.rowCount(), is(-2L));
        }

        execute("select name from test order by id asc");
        assertEquals("Earth\nSaturn\nMoon\nMars\n", TestingHelpers.printedTable(response.rows()));


        bulkResp = execute("update test set name = 'bulk_update' where id = ?", new Object[][]{
                new Object[]{2},
                new Object[]{3},
                new Object[]{4},
        });
        assertThat(bulkResp.results().length, is(3));
        for (SQLBulkResponse.Result result : bulkResp.results()) {
            assertThat(result.rowCount(), is(1L));
        }
        refresh();

        execute("select count(*) from test where name = 'bulk_update'");
        assertThat((Long) response.rows()[0][0], is(3L));

        bulkResp = execute("delete from test where id = ?", new Object[][] {
                new Object[] { 1 },
                new Object[] { 3 }
        });
        assertThat(bulkResp.results().length, is(2));
        for (SQLBulkResponse.Result result : bulkResp.results()) {
            assertThat(result.rowCount(), is(1L));
        }
        refresh();

        execute("select count(*) from test");
View Full Code Here

      setFaultCode(fCode);
    }
   
    setFaultString(getMessage());
   
    Result r = this.objectFactory.createResult();
    ErrInfo ei = this.objectFactory.createErrInfo();

    if (errCode != null) {
      ei.setErrCode(errCode);
    }

    ei.setValue(getMessage());

     r.setErrno(errno);

    if (ei != null) {
      r.setErrInfo(ei);
    }

    addResult(r);
  }
View Full Code Here

  {
    if (this.dispReport==null) {
      this.dispReport = this.objectFactory.createDispositionReport();
    }

    Result jaxbResult = this.objectFactory.createResult();
    this.dispReport.getResult().add(jaxbResult);
   
    if (result.getErrInfo() != null) jaxbResult.setErrInfo(result.getErrInfo());
    if (result.getKeyType() != null) jaxbResult.setKeyType(result.getKeyType());
    jaxbResult.setErrno(result.getErrno());
  }
View Full Code Here

            keyResultArr = new Result[resultList.size()];
            resultList.toArray(keyResultArr);
           
            log.debug("After deleting Business. Obtained vector size:" + keyResultArr != null ? keyResultArr.length : 0);
            for (int i = 0; keyResultArr != null && i < keyResultArr.length; i++) {
                Result result = (Result) keyResultArr[i];
                int errno = result.getErrno();
                if (errno == 0) {
                    coll.addAll(keys);
                }
                else {
                    ErrInfo errinfo = result.getErrInfo();
                    DeleteException de = new DeleteException(errinfo.getErrCode() + ":" + errinfo.getValue());
                    bulk.setStatus(JAXRResponse.STATUS_FAILURE);
                    exceptions.add(de);
                }
            }
View Full Code Here

        private DispositionReport getSuccessMessage() {
                DispositionReport r = new DispositionReport();
                r.setGeneric("2.0");
                r.setTruncated(Truncated.FALSE);
                Result x = new Result();
                r.setOperator(getNodeID());
                r.getResult().add(x);
                return r;
        }
View Full Code Here

                List<Result> r = new ArrayList<Result>();
                if (result == null) {
                        return r;
                }
                for (int i = 0; i < result.size(); i++) {
                        Result x = new Result();
                        x.setErrno(result.get(i).getErrno());
                        x.setErrno(result.get(i).getErrno());
                        if (result.get(i).getKeyType() != null) {
                                switch (result.get(i).getKeyType()) {
                                        case BINDING_KEY:
                                                x.setKeyType(KeyType.BINDING_KEY);
                                                break;
                                        case BUSINESS_KEY:
                                                x.setKeyType(KeyType.BUSINESS_KEY);
                                                break;
                                        case SERVICE_KEY:
                                                x.setKeyType(KeyType.SERVICE_KEY);
                                                break;
                                        case T_MODEL_KEY:
                                                x.setKeyType(KeyType.T_MODEL_KEY);
                                                break;
                                }
                        }
                        x.setErrInfo(new ErrInfo());
                        x.getErrInfo().setErrCode(result.get(i).getErrInfo().getErrCode());
                        x.getErrInfo().setValue(result.get(i).getErrInfo().getValue());
                        r.add(x);
                }
               
                return r;
        }
View Full Code Here

   
   
    new ValidateSubscriptionListener().validateNotification(body);
     
    DispositionReport dr = new DispositionReport();
    Result res = new Result();
    dr.getResult().add(res);
    return dr;
  }
View Full Code Here

TOP

Related Classes of io.crate.action.sql.SQLBulkResponse$Result

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.