Package com.youtube.vitess.vtgate

Examples of com.youtube.vitess.vtgate.VtGate.splitQuery()


      if (!columns.contains(KeyspaceId.COL_NAME)) {
        columns.add(KeyspaceId.COL_NAME);
      }
      String sql = "select " + StringUtils.join(columns, ',') + " from " + conf.getInputTable();
      Map<Query, Long> queries =
          vtgate.splitQuery(conf.getKeyspace(), sql, conf.getSplitsPerShard());
      List<InputSplit> splits = new LinkedList<>();
      for (Query query : queries.keySet()) {
        Long size = queries.get(query);
        InputSplit split = new VitessInputSplit(query, size);
        splits.add(split);
View Full Code Here


      Util.insertRowsInShard(testEnv, shardName, 20);
    }
    Util.waitForTablet("rdonly", 40, 3, testEnv);
    VtGate vtgate = VtGate.connect("localhost:" + testEnv.port, 0);
    Map<Query, Long> queries =
        vtgate.splitQuery("test_keyspace", "select id,keyspace_id from vtgate_test", 1);
    vtgate.close();

    // Verify 2 splits, one per shard
    assertEquals(2, queries.size());
    Set<String> shardsInSplits = new HashSet<>();
View Full Code Here

            "select id, keyspace_id from vtgate_test where id >= 19",
            "select id, keyspace_id from vtgate_test where id >= 19");
    Util.waitForTablet("rdonly", rowCount, 3, testEnv);
    VtGate vtgate = VtGate.connect("localhost:" + testEnv.port, 0);
    int splitsPerShard = 3;
    Map<Query, Long> queries = vtgate.splitQuery("test_keyspace",
        "select id,keyspace_id from vtgate_test", splitsPerShard);
    vtgate.close();

    // Verify 6 splits, 3 per shard
    assertEquals(2 * splitsPerShard, queries.size());
View Full Code Here

  @Test
  public void testSplitQueryInvalidTable() throws Exception {
    VtGate vtgate = VtGate.connect("localhost:" + testEnv.port, 0);
    try {
      vtgate.splitQuery("test_keyspace", "select id from invalid_table", 1);
      fail("failed to raise connection exception");
    } catch (ConnectionException e) {
      assertTrue(e.getMessage().contains("query validation error: can't find table in schema"));
    } finally {
      vtgate.close();
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.