[C Data] Format.asString emits locale dependent digits in format strings
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 2/5
- Thời gian dự kiến
- 1-3 giờ
- Mức phù hợp với người mới
- 78/100
Hướng nghiên cứu
Bắt đầu tại c/src/main/java/org/apache/arrow/c/Format.java, ở các lệnh gọi String.format được liên kết trong issue, sau đó chạy bản tái hiện được cung cấp với locale ar-EG. Được xem là hoàn tất khi Format.asString xuất ra các chữ số ASCII cho các tham số FixedSizeList, FixedSizeBinary và Decimal, trong khi hành vi import Java hiện có vẫn tương thích.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Describe the bug, including details regarding any error messages, version, and platform.
Format.asString builds the parameterised format strings with String.format("+w:%d", ...) and no explicit Locale. java.util.Formatter localises the digits of %d with Locale.getDefault(Locale.Category.FORMAT), so on a JVM whose default locale uses digits outside ASCII (ar-EG, fa-IR, bn-BD, mr-IN, 98 of the 1069 locales available on JDK 21) a FixedSizeList(8) is exported as +w:٨ instead of +w:8. The same applies to FixedSizeBinary and Decimal.
https://github.com/apache/arrow-java/blob/b410fb26d01c7cefc4c6e3443a53562164001371/c/src/main/java/org/apache/arrow/c/Format.java#L66
https://github.com/apache/arrow-java/blob/b410fb26d01c7cefc4c6e3443a53562164001371/c/src/main/java/org/apache/arrow/c/Format.java#L68-L69
https://github.com/apache/arrow-java/blob/b410fb26d01c7cefc4c6e3443a53562164001371/c/src/main/java/org/apache/arrow/c/Format.java#L96
https://github.com/apache/arrow-java/blob/b410fb26d01c7cefc4c6e3443a53562164001371/c/src/main/java/org/apache/arrow/c/Format.java#L91
Other implementations parse the parameter as an ASCII integer and reject the string. arrow-rs fails at https://github.com/apache/arrow-rs/blob/58.0.0/arrow-schema/src/ffi.rs#L494-L503 with C Data interface error: The FixedSizeList type requires an integer parameter representing number of elements per list. The Java importer reads the parameter with Integer.parseInt (https://github.com/apache/arrow-java/blob/v19.0.0/c/src/main/java/org/apache/arrow/c/Format.java#L352-L354), which accepts Unicode digits, so a Java to Java round trip does not expose the problem.
Reproduction (arrow-java 19.0.0 and 18.1.0, Temurin 21.0.6, run with --add-opens=java.base/java.nio=ALL-UNNAMED):
import java.nio.charset.StandardCharsets;
import java.util.HexFormat;
import java.util.List;
import java.util.Locale;
import org.apache.arrow.c.ArrowSchema;
import org.apache.arrow.c.Data;
import org.apache.arrow.c.NativeUtil;
import org.apache.arrow.memory.BufferAllocator;
import org.apache.arrow.memory.RootAllocator;
import org.apache.arrow.vector.types.FloatingPointPrecision;
import org.apache.arrow.vector.types.pojo.ArrowType;
import org.apache.arrow.vector.types.pojo.Field;
import org.apache.arrow.vector.types.pojo.FieldType;
public class FormatLocale {
public static void main(String[] args) {
Locale.setDefault(Locale.forLanguageTag("ar-EG"));
Field item = new Field("item",
FieldType.nullable(new ArrowType.FloatingPoint(FloatingPointPrecision.SINGLE)), null);
Field vec = new Field("vec", FieldType.nullable(new ArrowType.FixedSizeList(8)), List.of(item));
try (BufferAllocator allocator = new RootAllocator()) {
ArrowSchema schema = ArrowSchema.allocateNew(allocator);
Data.exportField(allocator, vec, null, schema);
String format = NativeUtil.toJavaString(schema.snapshot().format);
System.out.println(format + " "
+ HexFormat.ofDelimiter(" ").formatHex(format.getBytes(StandardCharsets.UTF_8)));
System.out.println("Java import: " + Data.importField(allocator, schema, null).getType());
}
}
}
+w:٨ 2b 77 3a d9 a8
Java import: FixedSizeList(8)
With Locale.US the first line is +w:8 2b 77 3a 38.
- Ngôn ngữ chính
- Java
- Star
- 95
- Fork
- 154
- Merge trung bình
- 2 ngày 16 giờ
- Pull request đã merge (30 ngày)
- 9
Hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của apache/arrow-java
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 74/100
apache/arrow-java#1261 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
apache/arrow-java#1236 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
apache/arrow-java#1230 ·
-
Type: bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 85/100
apache/arrow-java#1205 ·
-
Type: bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
apache/arrow-java#1196 · 1 bình luận ·
Tất cả issue của apache/arrow-java
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
infinispan/infinispan#18150 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100
-
untriaged
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
opensearch-project/k-NN#3597 ·
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100