doris中一个bitmap里面包含小于2147483648(2的31次方)的INT数字,也包含大于2147483648 的LONG数字,在JDBC读取后转换为Roaring64NavigableMap会出现,大于2147483648的数字无法正常识别,丢失精度变成负数。
有没有JAVA中JDBC读取doris bitamp的正确示例
doris中一个bitmap里面包含小于2147483648(2的31次方)的INT数字,也包含大于2147483648 的LONG数字,在JDBC读取后转换为Roaring64NavigableMap会出现,大于2147483648的数字无法正常识别,丢失精度变成负数。
有没有JAVA中JDBC读取doris bitamp的正确示例
可以参考如下代码块:
// Initialize connection
try (Connection conn = DriverManager.getConnection(url, user, password);
Statement stmt = conn.createStatement();
ResultSet rs = stmt.executeQuery("SELECT bitmap_column FROM your_table WHERE conditions")) {
// Iterate through the result set
while (rs.next()) {
// Retrieve the bitmap as a Base64 String
String base64Bitmap = rs.getString("bitmap_column");
// Convert the Base64 String to a Roaring64NavigableMap
Roaring64NavigableMap bitmap = Roaring64NavigableMap.bitmapOf();
// Assuming you have a method to convert base64 to Roaring64NavigableMap
// This conversion method is not provided here and needs to be implemented
// according to the specific details of your environment and requirements.
bitmap = convertBase64ToRoaring64NavigableMap(base64Bitmap);
// Now you can work with the bitmap
// For example, print out the content
System.out.println(bitmap.toString());
}
} catch (Exception e) {
e.printStackTrace();
}