@@ -24,7 +24,7 @@ import Control.Applicative ((<$>), (<|>), (<*>), (<*), (*>), many)
2424import Control.Monad (forM_ , zipWithM_ , unless , when , void , replicateM_ )
2525import Data.Attoparsec.Text
2626import Data.Char
27- import DataFrame.Internal.Column (Column (.. ), freezeColumn' , writeColumn , columnLength )
27+ import DataFrame.Internal.Column (Column (.. ), MutableColumn ( .. ), freezeColumn' , writeColumn , columnLength )
2828import DataFrame.Internal.DataFrame (DataFrame (.. ))
2929import DataFrame.Internal.Parsing
3030import DataFrame.Operations.Typing
@@ -122,13 +122,13 @@ readSeparated c opts path = do
122122 }, (pos, unconsumed, r + 1 ))
123123{-# INLINE readSeparated #-}
124124
125- getInitialDataVectors :: Int -> VM. IOVector Column -> [T. Text ] -> IO ()
125+ getInitialDataVectors :: Int -> VM. IOVector MutableColumn -> [T. Text ] -> IO ()
126126getInitialDataVectors n mCol xs = do
127127 forM_ (zip [0 .. ] xs) $ \ (i, x) -> do
128128 col <- case inferValueType x of
129- " Int" -> MutableUnboxedColumn <$> ((VUM. unsafeNew n :: IO (VUM. IOVector Int )) >>= \ c -> VUM. unsafeWrite c 0 (fromMaybe 0 $ readInt x) >> return c)
130- " Double" -> MutableUnboxedColumn <$> ((VUM. unsafeNew n :: IO (VUM. IOVector Double )) >>= \ c -> VUM. unsafeWrite c 0 (fromMaybe 0 $ readDouble x) >> return c)
131- _ -> MutableBoxedColumn <$> ((VM. unsafeNew n :: IO (VM. IOVector T. Text )) >>= \ c -> VM. unsafeWrite c 0 x >> return c)
129+ " Int" -> MUnboxedColumn <$> ((VUM. unsafeNew n :: IO (VUM. IOVector Int )) >>= \ c -> VUM. unsafeWrite c 0 (fromMaybe 0 $ readInt x) >> return c)
130+ " Double" -> MUnboxedColumn <$> ((VUM. unsafeNew n :: IO (VUM. IOVector Double )) >>= \ c -> VUM. unsafeWrite c 0 (fromMaybe 0 $ readDouble x) >> return c)
131+ _ -> MBoxedColumn <$> ((VM. unsafeNew n :: IO (VM. IOVector T. Text )) >>= \ c -> VM. unsafeWrite c 0 x >> return c)
132132 VM. unsafeWrite mCol i col
133133{-# INLINE getInitialDataVectors #-}
134134
@@ -154,7 +154,7 @@ readSingleLine c unused handle = parseWith (TIO.hGetChunk handle) (parseRow c) u
154154 return (row, unconsumed)
155155
156156-- | Reads rows from the handle and stores values in mutable vectors.
157- fillColumns :: Int -> Char -> VM. IOVector Column -> VM. IOVector [(Int , T. Text )] -> T. Text -> Handle -> IO (T. Text , Int )
157+ fillColumns :: Int -> Char -> VM. IOVector MutableColumn -> VM. IOVector [(Int , T. Text )] -> T. Text -> Handle -> IO (T. Text , Int )
158158fillColumns n c mutableCols nullIndices unused handle = do
159159 input <- newIORef unused
160160 rowsRead <- newIORef (0 :: Int )
@@ -179,7 +179,7 @@ fillColumns n c mutableCols nullIndices unused handle = do
179179{-# INLINE fillColumns #-}
180180
181181-- | Writes a value into the appropriate column, resizing the vector if necessary.
182- writeValue :: VM. IOVector Column -> VM. IOVector [(Int , T. Text )] -> Int -> Int -> T. Text -> IO ()
182+ writeValue :: VM. IOVector MutableColumn -> VM. IOVector [(Int , T. Text )] -> Int -> Int -> T. Text -> IO ()
183183writeValue mutableCols nullIndices count colIndex value = do
184184 col <- VM. unsafeRead mutableCols colIndex
185185 res <- writeColumn count value col
@@ -188,7 +188,7 @@ writeValue mutableCols nullIndices count colIndex value = do
188188{-# INLINE writeValue #-}
189189
190190-- | Freezes a mutable vector into an immutable one, trimming it to the actual row count.
191- freezeColumn :: VM. IOVector Column -> V. Vector [(Int , T. Text )] -> ReadOptions -> Int -> IO Column
191+ freezeColumn :: VM. IOVector MutableColumn -> V. Vector [(Int , T. Text )] -> ReadOptions -> Int -> IO Column
192192freezeColumn mutableCols nulls opts colIndex = do
193193 col <- VM. unsafeRead mutableCols colIndex
194194 freezeColumn' (nulls V. ! colIndex) col
0 commit comments