Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: BufferOverflowException when import data fix #3728 #3729

Merged
merged 3 commits into from
Feb 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,7 @@ public boolean build() {
result.putInt(totalSize); // Size
result.put(nullBitmap.getBuffer()); // BitMap
result.put(baseFieldBuf.array()); // Base data type
result.put(strAddrBuf.array()); // String addr
result.put(strAddrBuf.array(), 0, strAddrLen); // String addr
result.put(stringWriter.toByteArray()); // String value
return true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1018,5 +1018,41 @@ public void testSpecialCase() {
Assert.fail();
}
}

@Test
public void testLongString() {
try {
List<ColumnDesc> schema = new ArrayList<ColumnDesc>();
schema.add(ColumnDesc.newBuilder().setName("col1").setDataType(DataType.kInt).build());
schema.add(ColumnDesc.newBuilder().setName("col2").setDataType(DataType.kString).build());
schema.add(ColumnDesc.newBuilder().setName("col3").setDataType(DataType.kInt).build());
schema.add(ColumnDesc.newBuilder().setName("col4").setDataType(DataType.kString).build());
schema.add(ColumnDesc.newBuilder().setName("col5").setDataType(DataType.kString).build());
RowBuilder builder = new FlexibleRowBuilder(schema);
for (int i = 0; i < 20; i++) {
String str1 = genRandomString(100);
String str2 = i % 2 == 0 ? genRandomString(255) : genRandomString(20);
String str3 = i % 2 == 0 ? genRandomString(1000) : genRandomString(10);
Assert.assertTrue(builder.appendInt(1));
Assert.assertTrue(builder.appendString(str1));
Assert.assertTrue(builder.appendInt(10));
Assert.assertTrue(builder.appendString(str2));
Assert.assertTrue(builder.appendString(str3));
builder.build();

ByteBuffer buffer = builder.getValue();
RowView rowView = new RowView(schema, buffer, buffer.capacity());
Assert.assertEquals(rowView.getInt(0), new Integer(1));
Assert.assertEquals(rowView.getString(1), str1);
Assert.assertEquals(rowView.getString(3), str2);
Assert.assertEquals(rowView.getString(4), str3);

((FlexibleRowBuilder)builder).clear();
}
} catch (Exception e) {
e.printStackTrace();
Assert.assertTrue(false);
}
}
}

Loading