private void splitOn ( String ... columnNames ) { List < Column < ? > > columns = getSourceTable ( ) . columns ( columnNames ) ; int byteSize = getByteSize ( columns ) ; byte [ ] currentKey = null ; String currentStringKey = null ; TableSlice view ; Selection selection = new BitmapBackedSelection ( ) ; for ( int row = 0 ; row < getSourceTable ( ) . rowCount ( ) ; row ++ ) { ByteBuffer byteBuffer = ByteBuffer . allocate ( byteSize ) ; String newStringKey = "" ; for ( int col = 0 ; col < columnNames . length ; col ++ ) { if ( col > 0 ) { newStringKey = newStringKey + SPLIT_STRING ; } Column < ? > c = getSourceTable ( ) . column ( columnNames [ col ] ) ; String groupKey = getSourceTable ( ) . getUnformatted ( row , getSourceTable ( ) . columnIndex ( c ) ) ; newStringKey = newStringKey + groupKey ; byteBuffer . put ( c . asBytes ( row ) ) ; } byte [ ] newKey = byteBuffer . array ( ) ; if ( row == 0 ) { currentKey = newKey ; currentStringKey = newStringKey ; } if ( ! Arrays . equals ( newKey , currentKey ) ) { currentKey = newKey ; view = new TableSlice ( getSourceTable ( ) , selection ) ; view . setName ( currentStringKey ) ; currentStringKey = newStringKey ; addSlice ( view ) ; selection = new BitmapBackedSelection ( ) ; selection . add ( row ) ; } else { selection . add ( row ) ; } } if ( ! selection . isEmpty ( ) ) { view = new TableSlice ( getSourceTable ( ) , selection ) ; view . setName ( currentStringKey ) ; addSlice ( view ) ; } }
Splits the sourceTable table into sub - tables grouping on the columns whose names are given in splitColumnNames