Object[] keyValues;
if (mainIsTableName) {
String mainSql = "select "+mainKeyColumnInfo.getName()+" from "+mainTableOrSql;
if ((condition != null) && (! condition.isEmpty()))
mainSql += " where " + condition;
QueryResultSet qrs = flashDatabase.executeQuery(mainSql, conditionParams != null ? conditionParams : new Object[0]);
keyValues = new Object[qrs.getRowCount()];
for (int i=0; i < keyValues.length; i++) {
keyValues[i] = qrs.getValue(i, 0);
}
Arrays.sort(keyValues);
}
else {
QueryResultSet qrs = flashDatabase.executeQuery(mainTableOrSql, conditionParams != null ? conditionParams : new Object[0]);
keyValues = new Object[qrs.getRowCount()];
for (int i=0; i < keyValues.length; i++) {
keyValues[i] = qrs.getRow(i);
}
}
// 根据主键分段
int partCount = (keyValues.length + partSize - 1) / partSize;