예제 #1
0
  protected static KuduTable createFourTabletsTableWithNineRows(String tableName) throws Exception {
    CreateTableBuilder builder = new CreateTableBuilder();
    PartialRow splitRow = basicSchema.newPartialRow();
    for (int i : KEYS) {
      splitRow.addInt(0, i);
      builder.addSplitRow(splitRow);
    }
    KuduTable table = createTable(tableName, basicSchema, builder);
    AsyncKuduSession session = client.newSession();

    // create a table with on empty tablet and 3 tablets of 3 rows each
    for (int key1 : KEYS) {
      for (int key2 = 1; key2 <= 3; key2++) {
        Insert insert = table.newInsert();
        PartialRow row = insert.getRow();
        row.addInt(0, key1 + key2);
        row.addInt(1, key1);
        row.addInt(2, key2);
        row.addString(3, "a string");
        row.addBoolean(4, true);
        session.apply(insert).join(DEFAULT_SLEEP);
      }
    }
    session.close().join(DEFAULT_SLEEP);
    return table;
  }
예제 #2
0
 /**
  * Blocking call that flushes the buffers (see {@link #flush()} and closes the sessions.
  *
  * @return List of OperationResponse, one per operation that was flushed
  * @throws Exception if anything went wrong. If it's an issue with some or all batches, it will be
  *     of type DeferredGroupException.
  */
 public List<OperationResponse> close() throws Exception {
   return session.close().join(getTimeoutMillis());
 }