Package com.youtube.vitess.vtgate.cursor

Examples of com.youtube.vitess.vtgate.cursor.Cursor


      rows.add(row);
    }
    result.put("Rows", rows);

    QueryResult qr = Bsonify.bsonToQueryResult(result, null);
    Cursor cursor = new CursorImpl(qr);
    Assert.assertEquals(12L, cursor.getRowsAffected());
    Assert.assertEquals(12345L, cursor.getLastRowId());

    Row firstRow = cursor.next();
    Cell cell0 = firstRow.next();
    Assert.assertEquals("col_0", cell0.getName());
    Assert.assertEquals(BigDecimal.class, cell0.getType());
    Assert.assertEquals(new BigDecimal("0.0"), firstRow.getBigDecimal(cell0.getName()));
View Full Code Here


    Util.insertRows(testEnv, 1, 2000);
    VtGate vtgate = VtGate.connect("localhost:" + testEnv.port, 0);
    String selectSql = "select A.* from vtgate_test A join vtgate_test B";
    Query joinQuery = new QueryBuilder(selectSql, testEnv.keyspace, "master")
        .setKeyspaceIds(testEnv.getAllKeyspaceIds()).setStreaming(true).build();
    Cursor cursor = vtgate.execute(joinQuery);

    int count = 0;
    try {
      while (cursor.hasNext()) {
        count++;
        if (count == 1) {
          Util.setupTestEnv(testEnv, false);
        }
        cursor.next();
      }
      vtgate.close();
      Assert.fail("failed to raise exception");
    } catch (RuntimeException e) {
      Assert.assertTrue(e.getMessage().contains("vtgate exception: connection exception"));
View Full Code Here

  public void testStreamCursorType() throws Exception {
    VtGate vtgate = VtGate.connect("localhost:" + testEnv.port, 0);
    String selectSql = "select * from vtgate_test";
    Query allRowsQuery = new QueryBuilder(selectSql, testEnv.keyspace, "master")
        .setKeyspaceIds(testEnv.getAllKeyspaceIds()).setStreaming(true).build();
    Cursor cursor = vtgate.execute(allRowsQuery);
    Assert.assertEquals(StreamCursor.class, cursor.getClass());
    vtgate.close();
  }
View Full Code Here

    VtGate vtgate = VtGate.connect("localhost:" + testEnv.port, 0);
    for (String shardName : testEnv.shardKidMap.keySet()) {
      String selectSql = "select A.* from vtgate_test A join vtgate_test B join vtgate_test C";
      Query query = new QueryBuilder(selectSql, testEnv.keyspace, "master")
          .setKeyspaceIds(testEnv.getKeyspaceIds(shardName)).setStreaming(true).build();
      Cursor cursor = vtgate.execute(query);
      int count = 0;
      while (cursor.hasNext()) {
        cursor.next();
        count++;
      }
      Assert.assertEquals((int) Math.pow(rowCount, 3), count);
    }
    vtgate.close();
View Full Code Here

      List<KeyspaceId> kids = testEnv.getKeyspaceIds(shardName);
      KeyRange kr = new KeyRange(Collections.min(kids), Collections.max(kids));
      String selectSql = "select A.* from vtgate_test A join vtgate_test B join vtgate_test C";
      Query query = new QueryBuilder(selectSql, testEnv.keyspace, "master").addKeyRange(kr)
          .setStreaming(true).build();
      Cursor cursor = vtgate.execute(query);
      int count = 0;
      while (cursor.hasNext()) {
        cursor.next();
        count++;
      }
      Assert.assertEquals((int) Math.pow(rowCount, 3), count);
    }
    vtgate.close();
View Full Code Here

    }
    String selectSql = "select A.* from vtgate_test A join vtgate_test B join vtgate_test C";
    Query query = new QueryBuilder(selectSql, testEnv.keyspace, "master")
        .setKeyspaceIds(testEnv.getAllKeyspaceIds()).setStreaming(true).build();
    VtGate vtgate = VtGate.connect("localhost:" + testEnv.port, 0);
    Cursor cursor = vtgate.execute(query);
    int count = 0;
    for (Row row : cursor) {
      count++;
    }
    Assert.assertEquals(2 * (int) Math.pow(rowCount, 3), count);
View Full Code Here

    vtgate.commit();

    String selectSql = "select * from vtocc_ints where tiny = -128";
    Query selectQuery =
        new QueryBuilder(selectSql, testEnv.keyspace, "master").addKeyRange(KeyRange.ALL).build();
    Cursor cursor = vtgate.execute(selectQuery);
    Assert.assertEquals(1, cursor.getRowsAffected());
    Row row = cursor.next();
    Assert.assertTrue(row.getInt("tiny").equals(-128));
    Assert.assertTrue(row.getInt("tinyu").equals(255));
    Assert.assertTrue(row.getInt("small").equals(-32768));
    Assert.assertTrue(row.getInt("smallu").equals(65535));
    Assert.assertTrue(row.getInt("medium").equals(-8388608));
View Full Code Here

    vtgate.commit();

    String selectSql = "select * from vtocc_fracts where id = 1";
    Query selectQuery =
        new QueryBuilder(selectSql, testEnv.keyspace, "master").addKeyRange(KeyRange.ALL).build();
    Cursor cursor = vtgate.execute(selectQuery);
    Assert.assertEquals(1, cursor.getRowsAffected());
    Row row = cursor.next();
    Assert.assertTrue(row.getLong("id").equals(1L));
    Assert.assertTrue(row.getBigDecimal("deci").equals(new BigDecimal("1.99")));
    Assert.assertTrue(row.getBigDecimal("num").equals(new BigDecimal("2.99")));
    Assert.assertTrue(row.getFloat("f").equals(3.99F));
    Assert.assertTrue(row.getDouble("d").equals(4.99));
View Full Code Here

    vtgate.commit();

    String selectSql = "select * from vtocc_strings where vb = 'a'";
    Query selectQuery =
        new QueryBuilder(selectSql, testEnv.keyspace, "master").addKeyRange(KeyRange.ALL).build();
    Cursor cursor = vtgate.execute(selectQuery);
    Assert.assertEquals(1, cursor.getRowsAffected());
    Row row = cursor.next();
    Assert.assertTrue(Arrays.equals(row.getBytes("vb"), "a".getBytes()));
    Assert.assertTrue(Arrays.equals(row.getBytes("c"), "b".getBytes()));
    Assert.assertTrue(Arrays.equals(row.getBytes("vc"), "c".getBytes()));
    // binary(4) column will be suffixed with three 0 bytes
    Assert.assertTrue(
View Full Code Here

    vtgate.commit();

    String selectSql = "select * from vtocc_misc where id = 1";
    Query selectQuery =
        new QueryBuilder(selectSql, testEnv.keyspace, "master").addKeyRange(KeyRange.ALL).build();
    Cursor cursor = vtgate.execute(selectQuery);
    Assert.assertEquals(1, cursor.getRowsAffected());
    Row row = cursor.next();
    Assert.assertTrue(row.getLong("id").equals(1L));
    Assert.assertTrue(
        Arrays.equals(row.getBytes("b"), ByteBuffer.allocate(1).put((byte) 1).array()));
    Assert.assertTrue(row.getDateTime("d").equals(DateTime.parse("2012-01-01")));
    Assert.assertTrue(row.getDateTime("dt").equals(DateTime.parse("2012-01-01T15:45:45")));
View Full Code Here

TOP

Related Classes of com.youtube.vitess.vtgate.cursor.Cursor

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.