Skip to content

Commit 780560a

Browse files
authored
Update Aggregation.hs
1 parent 0489035 commit 780560a

1 file changed

Lines changed: 6 additions & 5 deletions

File tree

src/DataFrame/Operations/Aggregation.hs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ groupBy names df
7373
mkRowRep :: [Int] -> DataFrame -> Int -> Int
7474
mkRowRep groupColumnIndices df i = hash (map mkHash groupColumnIndices)
7575
where
76+
getHashedElem :: Column -> Int -> Int
7677
getHashedElem (BoxedColumn (c :: V.Vector a)) j = hash' @a (c V.! j)
7778
getHashedElem (UnboxedColumn (c :: VU.Vector a)) j = hash' @a (c VU.! j)
7879
getHashedElem (OptionalColumn (c :: V.Vector a)) j = hash' @a (c V.! j)
@@ -81,14 +82,14 @@ mkRowRep groupColumnIndices df i = hash (map mkHash groupColumnIndices)
8182

8283
-- | This hash function returns the hash when given a non numeric type but
8384
-- the value when given a numeric.
84-
hash' :: Columnable a => a -> Double
85+
hash' :: Columnable a => a -> Int
8586
hash' value = case testEquality (typeOf value) (typeRep @Double) of
86-
Just Refl -> value
87+
Just Refl -> round $ value * 1000
8788
Nothing -> case testEquality (typeOf value) (typeRep @Int) of
88-
Just Refl -> fromIntegral value
89+
Just Refl -> value
8990
Nothing -> case testEquality (typeOf value) (typeRep @T.Text) of
90-
Just Refl -> fromIntegral $ hash value
91-
Nothing -> fromIntegral $ hash (show value)
91+
Just Refl -> hash value
92+
Nothing -> hash (show value)
9293

9394
mkGroupedColumns :: VU.Vector Int -> DataFrame -> DataFrame -> T.Text -> DataFrame
9495
mkGroupedColumns indices df acc name =

0 commit comments

Comments
 (0)