0lai0 commented on code in PR #1407:
URL: https://github.com/apache/mahout/pull/1407#discussion_r3452118337


##########
qdp/qdp-core/src/pipeline_runner.rs:
##########
@@ -389,28 +428,67 @@ fn path_extension_lower(path: &Path) -> Option<String> {
         .map(|s| s.to_lowercase())
 }
 
-/// Dispatches by path extension to the appropriate io reader. Returns (data, 
num_samples, sample_size).
-/// Unsupported or missing extension returns Err with message listing 
supported formats.
+/// f64→f32 narrowing cast: values outside f32 range silently become ±Inf.
+fn cast_f64_to_batch_data(
+    data: Vec<f64>,
+    n: usize,
+    s: usize,
+    dtype: Precision,
+    fmt: &str,
+) -> (BatchData, usize, usize) {
+    if matches!(dtype, Precision::Float32) {
+        log::warn!(
+            "{fmt} file loaded as f64, casting to f32: values outside f32 
range become ±Inf."
+        );
+        (
+            BatchData::F32(data.iter().map(|&x| x as f32).collect()),
+            n,
+            s,
+        )
+    } else {
+        (BatchData::F64(data), n, s)
+    }
+}
+
 fn read_file_by_extension(
     path: &Path,
     null_handling: NullHandling,
-) -> Result<(Vec<f64>, usize, usize)> {
+    dtype: Precision,
+) -> Result<(BatchData, usize, usize)> {
+    use crate::reader::DataReader;
     let ext_lower = path_extension_lower(path);
     let ext = ext_lower.as_deref();
     match ext {
         Some("parquet") => {
-            use crate::reader::DataReader;
-            let mut reader = crate::readers::ParquetReader::new(path, None, 
null_handling)?;
-            reader.read_batch()
+            if matches!(dtype, Precision::Float32) {

Review Comment:
   Thanks @ryankert01 and @rich7420 for review. Sure, I'll keep basis file 
input in f64 and reject an explicit dtype=f32 request in next commit.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to