java/kudu-client/src/test/java/org/apache/kudu/client/TestKuduClient.java
@Test(timeout = 100000)
  public void testStrings() throws Exception {
    Schema schema = createManyStringsSchema();
    syncClient.createTable(tableName, schema, getBasicCreateTableOptions());

    KuduSession session = syncClient.newSession();
    KuduTable table = syncClient.openTable(tableName);
    for (int i = 0; i < 100; i++) {
      Insert insert = table.newInsert();
      PartialRow row = insert.getRow();
      row.addString("key", String.format("key_%02d", i));
      row.addString("c2", "c2_" + i);
      if (i % 2 == 1) {
        row.addString("c3", "c3_" + i);
      }
      row.addString("c4", "c4_" + i);
      // NOTE: we purposefully add the strings in a non-left-to-right
      // order to verify that we still place them in the right position in
      // the row.
      row.addString("c1", "c1_" + i);
      session.apply(insert);
      if (i % 50 == 0) {
        session.flush();
      }
    }
    session.flush();

    List<String> rowStrings = scanTableToStrings(table);
    assertEquals(100, rowStrings.size());
    assertEquals(
        "STRING key=key_03, STRING c1=c1_3, STRING c2=c2_3, STRING c3=c3_3, STRING c4=c4_3",
        rowStrings.get(3));
    assertEquals(
        "STRING key=key_04, STRING c1=c1_4, STRING c2=c2_4, STRING c3=NULL, STRING c4=c4_4",
        rowStrings.get(4));

    KuduScanner scanner = syncClient.newScannerBuilder(table).build();

    assertTrue("Scanner should have returned row", scanner.hasMoreRows());

    RowResultIterator rows = scanner.nextRows();
    final RowResult next = rows.next();

    // Do negative testing on string type.
    try {
      next.getInt("c2");
      fail("IllegalArgumentException was not thrown when accessing " +
              "a string column with getInt");
    } catch (IllegalArgumentException ignored) {}
  }
/**
   * Test inserting and retrieving string columns.
   */
Test inserting and retrieving string columns.
Test inserting and retrieving string columns .
@Test(timeout = 100000)
  public void testStrings() throws Exception {
    Schema schema = createManyStringsSchema();
    syncClient.createTable(tableName, schema, getBasicCreateTableOptions());
    KuduSession session = syncClient.newSession();
    KuduTable table = syncClient.openTable(tableName);
    for (int i = 0; i < 100; i++) {
      Insert insert = table.newInsert();
      PartialRow row = insert.getRow();
      row.addString("key", String.format("key_%02d", i));
      row.addString("c2", "c2_" + i);
      if (i % 2 == 1) {
        row.addString("c3", "c3_" + i);
      }
      row.addString("c4", "c4_" + i);
      row.addString("c1", "c1_" + i);
      session.apply(insert);
      if (i % 50 == 0) {
        session.flush();
      }
    }
    session.flush();
    List<String> rowStrings = scanTableToStrings(table);
    assertEquals(100, rowStrings.size());
    assertEquals(
        "STRING key=key_03, STRING c1=c1_3, STRING c2=c2_3, STRING c3=c3_3, STRING c4=c4_3",
        rowStrings.get(3));
    assertEquals(
        "STRING key=key_04, STRING c1=c1_4, STRING c2=c2_4, STRING c3=NULL, STRING c4=c4_4",
        rowStrings.get(4));
    KuduScanner scanner = syncClient.newScannerBuilder(table).build();
    assertTrue("Scanner should have returned row", scanner.hasMoreRows());
    RowResultIterator rows = scanner.nextRows();
    final RowResult next = rows.next();
    try {
      next.getInt("c2");
      fail("IllegalArgumentException was not thrown when accessing " +
              "a string column with getInt");
    } catch (IllegalArgumentException ignored) {}
  }
@ Test ( timeout = 100000 ) public void testStrings ( ) throws Exception { Schema schema = createManyStringsSchema ( ) ; syncClient . createTable ( tableName , schema , getBasicCreateTableOptions ( ) ) ; KuduSession session = syncClient . newSession ( ) ; KuduTable table = syncClient . openTable ( tableName ) ; for ( int i = 0 ; i < 100 ; i ++ ) { Insert insert = table . newInsert ( ) ; PartialRow row = insert . getRow ( ) ; row . addString ( "key" , String . format ( "key_%02d" , i ) ) ; row . addString ( "c2" , "c2_" + i ) ; if ( i % 2 == 1 ) { row . addString ( "c3" , "c3_" + i ) ; } row . addString ( "c4" , "c4_" + i ) ; row . addString ( "c1" , "c1_" + i ) ; session . apply ( insert ) ; if ( i % 50 == 0 ) { session . flush ( ) ; } } session . flush ( ) ; List < String > rowStrings = scanTableToStrings ( table ) ; assertEquals ( 100 , rowStrings . size ( ) ) ; assertEquals ( "STRING key=key_03, STRING c1=c1_3, STRING c2=c2_3, STRING c3=c3_3, STRING c4=c4_3" , rowStrings . get ( 3 ) ) ; assertEquals ( "STRING key=key_04, STRING c1=c1_4, STRING c2=c2_4, STRING c3=NULL, STRING c4=c4_4" , rowStrings . get ( 4 ) ) ; KuduScanner scanner = syncClient . newScannerBuilder ( table ) . build ( ) ; assertTrue ( "Scanner should have returned row" , scanner . hasMoreRows ( ) ) ; RowResultIterator rows = scanner . nextRows ( ) ; final RowResult next = rows . next ( ) ; try { next . getInt ( "c2" ) ; fail ( "IllegalArgumentException was not thrown when accessing " + "a string column with getInt" ) ; } catch ( IllegalArgumentException ignored ) { } }
Test inserting and retrieving string columns.
Test inserting and retrieving string columns .
// NOTE: we purposefully add the strings in a non-left-to-right // order to verify that we still place them in the right position in // the row. // Do negative testing on string type.