Search in sources :

Example 6 with PartitionBatch

use of com.thinkbiganalytics.util.PartitionBatch in project kylo by Teradata.

the class TableMergeSyncSupport method toPartitionBatches.

/*
    Generates batches of partitions in the source table
     */
protected List<PartitionBatch> toPartitionBatches(PartitionSpec spec, ResultSet rs) throws SQLException {
    Vector<PartitionBatch> v = new Vector<>();
    int count = rs.getMetaData().getColumnCount();
    while (rs.next()) {
        String[] values = new String[count];
        for (int i = 1; i <= count; i++) {
            Object oVal = rs.getObject(i);
            String sVal = (oVal == null ? "" : oVal.toString());
            values[i - 1] = StringUtils.defaultString(sVal, "");
        }
        Long numRecords = rs.getLong(count);
        v.add(new PartitionBatch(numRecords, spec, values));
    }
    logger.info("Number of partitions [" + v.size() + "]");
    return v;
}
Also used : PartitionBatch(com.thinkbiganalytics.util.PartitionBatch) Vector(java.util.Vector)

Aggregations

PartitionBatch (com.thinkbiganalytics.util.PartitionBatch)6 Vector (java.util.Vector)3 PartitionSpec (com.thinkbiganalytics.util.PartitionSpec)2 ResultSet (java.sql.ResultSet)2 SQLException (java.sql.SQLException)2 Statement (java.sql.Statement)2