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

    byte[] testArray = new byte[] {1, 2, 3, 4, 5, 6 ,7, 8, 9};

    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.addBinary("key", String.format("key_%02d", i).getBytes(UTF_8));
      row.addString("c1", "✁✂✃✄✆");
      row.addDouble("c2", i);
      if (i % 2 == 1) {
        row.addBinary("c3", testArray);
      }
      session.apply(insert);
      if (i % 50 == 0) {
        session.flush();
      }
    }
    session.flush();

    List<String> rowStrings = scanTableToStrings(table);
    assertEquals(100, rowStrings.size());
    for (int i = 0; i < rowStrings.size(); i++) {
      StringBuilder expectedRow = new StringBuilder();
      expectedRow.append(String.format("BINARY key=\"key_%02d\", STRING c1=✁✂✃✄✆, DOUBLE c2=%.1f,"
          + " BINARY c3=", i, (double) i));
      if (i % 2 == 1) {
        expectedRow.append(Bytes.pretty(testArray));
      } else {
        expectedRow.append("NULL");
      }
      assertEquals(expectedRow.toString(), rowStrings.get(i));
    }
  }
/**
   * Test inserting and retrieving binary columns.
   */
Test inserting and retrieving binary columns.
Test inserting and retrieving binary columns .
@Test(timeout = 100000)
  public void testBinaryColumns() throws Exception {
    Schema schema = createSchemaWithBinaryColumns();
    syncClient.createTable(tableName, schema, getBasicCreateTableOptions());
    byte[] testArray = new byte[] {1, 2, 3, 4, 5, 6 ,7, 8, 9};
    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.addBinary("key", String.format("key_%02d", i).getBytes(UTF_8));
      row.addString("c1", "✁✂✃✄✆");
      row.addDouble("c2", i);
      if (i % 2 == 1) {
        row.addBinary("c3", testArray);
      }
      session.apply(insert);
      if (i % 50 == 0) {
        session.flush();
      }
    }
    session.flush();
    List<String> rowStrings = scanTableToStrings(table);
    assertEquals(100, rowStrings.size());
    for (int i = 0; i < rowStrings.size(); i++) {
      StringBuilder expectedRow = new StringBuilder();
      expectedRow.append(String.format("BINARY key=\"key_%02d\", STRING c1=✁✂✃✄✆, DOUBLE c2=%.1f,"
          + " BINARY c3=", i, (double) i));
      if (i % 2 == 1) {
        expectedRow.append(Bytes.pretty(testArray));
      } else {
        expectedRow.append("NULL");
      }
      assertEquals(expectedRow.toString(), rowStrings.get(i));
    }
  }
@ Test ( timeout = 100000 ) public void testBinaryColumns ( ) throws Exception { Schema schema = createSchemaWithBinaryColumns ( ) ; syncClient . createTable ( tableName , schema , getBasicCreateTableOptions ( ) ) ; byte [ ] testArray = new byte [ ] { 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 } ; 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 . addBinary ( "key" , String . format ( "key_%02d" , i ) . getBytes ( UTF_8 ) ) ; row . addString ( "c1" , "✁✂✃✄✆"); row . addDouble ( "c2" , i ) ; if ( i % 2 == 1 ) { row . addBinary ( "c3" , testArray ) ; } session . apply ( insert ) ; if ( i % 50 == 0 ) { session . flush ( ) ; } } session . flush ( ) ; List < String > rowStrings = scanTableToStrings ( table ) ; assertEquals ( 100 , rowStrings . size ( ) ) ; for ( int i = 0 ; i < rowStrings . size ( ) ; i ++ ) { StringBuilder expectedRow = new StringBuilder ( ) ; expectedRow . append ( String . format ( "BINARY key=\"key_%02d\", STRING c1=✁✂✃✄✆, DOUBLE c2=%.1f," + " BINARY c3=" , i , ( double ) i ) ) ; if ( i % 2 == 1 ) { expectedRow . append ( Bytes . pretty ( testArray ) ) ; } else { expectedRow . append ( "NULL" ) ; } assertEquals ( expectedRow . toString ( ) , rowStrings . get ( i ) ) ; } }
Test inserting and retrieving binary columns.
Test inserting and retrieving binary columns .