|
|
|
@ -32,8 +32,8 @@ public class TestMax32K {
|
|
|
|
|
/**
|
|
|
|
|
* 分割过大的单表数据
|
|
|
|
|
*/
|
|
|
|
|
private static List<String> splitLargeTable(String tableName, Set<String> fieldNames,
|
|
|
|
|
List<Record> allTableData, int maxSize) {
|
|
|
|
|
private static List<String> splitLargeTable(Set<String> fieldNames,
|
|
|
|
|
List<Record> allTableData, int maxSize) {
|
|
|
|
|
List<String> chunks = new ArrayList<>();
|
|
|
|
|
StringBuilder currentTableChunk = new StringBuilder();
|
|
|
|
|
|
|
|
|
@ -57,7 +57,7 @@ public class TestMax32K {
|
|
|
|
|
|
|
|
|
|
// 检查是否超过限制
|
|
|
|
|
if (currentTableChunk.length() + rowData.length() > maxSize) {
|
|
|
|
|
if (currentTableChunk.length() > 0) {
|
|
|
|
|
if (!currentTableChunk.isEmpty()) {
|
|
|
|
|
chunks.add(currentTableChunk.toString());
|
|
|
|
|
currentTableChunk = new StringBuilder();
|
|
|
|
|
}
|
|
|
|
@ -65,22 +65,13 @@ public class TestMax32K {
|
|
|
|
|
currentTableChunk.append(rowData);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (currentTableChunk.length() > 0) {
|
|
|
|
|
if (!currentTableChunk.isEmpty()) {
|
|
|
|
|
chunks.add(currentTableChunk.toString());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return chunks;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 获取分块数据的方法(可供其他类调用)
|
|
|
|
|
*/
|
|
|
|
|
public static String[] getDataChunks() {
|
|
|
|
|
// 这里可以将main方法中的逻辑提取出来,返回分块数据
|
|
|
|
|
// 为了简化,这里只是示例
|
|
|
|
|
return new String[]{"示例数据块1", "示例数据块2"};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static String generateComprehensiveReport() {
|
|
|
|
|
LocalMysqlConnectUtil.Init();
|
|
|
|
|
|
|
|
|
@ -254,7 +245,7 @@ public class TestMax32K {
|
|
|
|
|
|
|
|
|
|
// 如果单个表数据超过限制,需要进一步分割
|
|
|
|
|
if (tableDataStr.length() > MAX_CHUNK_SIZE - header.length()) {
|
|
|
|
|
List<String> tableChunks = splitLargeTable(tableName, fieldNames, allTableData, MAX_CHUNK_SIZE - header.length());
|
|
|
|
|
List<String> tableChunks = splitLargeTable(fieldNames, allTableData, MAX_CHUNK_SIZE - header.length());
|
|
|
|
|
for (int i = 0; i < tableChunks.size(); i++) {
|
|
|
|
|
StringBuilder chunkBuilder = new StringBuilder();
|
|
|
|
|
chunkBuilder.append(header);
|
|
|
|
|