Changeset 11831 for third-party
- Timestamp:
- 07/31/06 08:11:22 (2 years ago)
- Location:
- third-party/HsJudy
- Files:
-
- 4 modified
-
Judy/Map2.hs (modified) (5 diffs)
-
TODO (modified) (3 diffs)
-
tests/CheckDup.results (modified) (1 diff)
-
tests/TestMap2.hs (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
third-party/HsJudy/Judy/Map2.hs
r11716 r11831 3 3 module Judy.Map2 ( 4 4 Map2 (..), 5 swapMaps, freeze 5 swapMaps, freeze, toRevList 6 6 ) where 7 7 … … 160 160 -- return $ r 161 161 162 163 internalMap' :: (Ptr Value -> Ptr Value -> IO b) -> Map2 k a -> IO [b] 164 internalMap' f (Map2 j) = do 165 jj <- withForeignPtr j peek 166 alloca $ \vp -> do 167 poke vp (0 :: Value) 168 let loop act xs = do 169 r <- act jj vp judyError 170 if r == nullPtr 171 then return xs 172 else do x <- f r vp 173 loop judyLNext (x:xs) 174 loop judyLFirst [] 175 162 176 internalMap :: (Ptr Value -> Ptr Value -> IO b) -> Map2 k a -> IO [b] 163 177 internalMap f (Map2 j) = do … … 171 185 else do x <- f r vp 172 186 loop judyLPrev (x:xs) 173 loop judyLLast [] 187 loop judyLLast [] -- Because of list concat we go backwards 188 -- to get ordered list right. 174 189 175 190 mapToList_ :: (ReversibleHashIO k, Refeable a) => (k -> a -> b) -> Map2 k a -> IO [b] … … 181 196 return $ f k' v' 182 197 198 mapToRevList_ :: (ReversibleHashIO k, Refeable a) => (k -> a -> b) -> Map2 k a -> IO [b] 199 mapToRevList_ f = internalMap' $ \r vp -> do 200 k <- peek vp 201 k' <- unHashIO k 202 v <- peek r 203 v' <- fromRef v 204 return $ f k' v' 205 183 206 toList_ :: (ReversibleHashIO k, Refeable a) => Map2 k a -> IO [(k,a)] 184 207 toList_ = mapToList_ $ \k a -> (k,a) 208 209 toRevList :: (ReversibleHashIO k, Refeable a) => Map2 k a -> IO [(k,a)] 210 toRevList = mapToRevList_ $ \k a -> (k,a) 185 211 186 212 keys_ :: ReversibleHashIO k => Map2 k a -> IO [k] … … 201 227 poke p1 v2 202 228 poke p2 v1 203 204 205 206 207 -
third-party/HsJudy/TODO
r11716 r11831 1 1 # TODO 2 - Use Judy to implement Pugs IHash substitute. (First patch done, but it's old by now) 2 - Use Judy for Hash and Array in Pugs. Maybe creating some special 3 operators for Judy.Map2 to be used for Array (think shift and pop). 3 4 - CollectionsM: complete the subset of MapM and uncomment/complete CollectionM. 4 5 - See if needGC hack can be improved. It seems its eating CPU time. 5 6 6 7 - First RBR test: 1/3 running time when using MapL (via Map2). Not sure 7 if the results are correct (they seem to be). 8 - Should I call MapSL and Map2 just Map? 8 if the results are correct (they seem to be). Check with Ketil about usage 9 of Map2, if its enough. 10 11 - Names names names 12 - Idea: Map2 -> IntMap 13 - Should I call MapSL just Map too? 14 9 15 - Other missing malloc error checking 10 16 - Tests that stress MiniGC (w/ two maps at same time would be nice too) 17 11 18 - Check how GHC do interning 19 - Check how's sparse array implementation of Parrot. 12 20 13 # "CRAZY" BUGS 14 - Dummy/Refeable Bug: need to ask in #haskell and reply Simon's email. 15 X Bug on HSIter stuff when use a lot of memory. (One of them is solved. Need to GC now.) 21 # "CRAZY" BUGS (X means "solved") 22 X Dummy/Refeable Bug: need to ask in #haskell and reply Simon's email. 23 It dissapeared recently. Dunno the reason. 24 X Bug on HSIter stuff when use a lot of memory. 16 25 X Finalizer may be not working right => test with sequencing a lot of operations 17 causes error in GHC runtime. (seems to be fixed by having ONLY ONE gc for everyone) 26 causes error in GHC runtime. (seems to be fixed by having ONLY ONE gc 27 for everyone) 18 28 19 29 … … 25 35 on the page (are they updated?). 26 36 - Implementations specific to unboxed values like Int and Double: Int seems to 27 be ok now, but Double and other unbox edstill need to check37 be ok now, but Double and other unboxable still need to check 28 38 29 39 - Discuss APIs 30 -- Unbounded arrays: see Bulat work on this 40 -- Unbounded arrays: see Bulat work on this. 31 41 32 42 - Refeable vs. HashIO => unify? … … 70 80 Bulat says "sorry, i don't think so. especially for Arrays ;)" 71 81 82 Judy is useful for applications for (very-)sparse Arrays, which is Pugs' case. 83 -
third-party/HsJudy/tests/CheckDup.results
r11694 r11831 17 17 6 Judy.MapSL ByteString Int 0.642 18 18 7 Data.HashTable String Int 2.790 19 8 Data.HashTable String Int3.80919 8 Data.HashTable ByteString Int 3.809 20 20 -
third-party/HsJudy/tests/TestMap2.hs
r11694 r11831 20 20 testSwapMaps 21 21 testAlter 22 testRevList 22 23 23 24 testSimple = do … … 62 63 say "Elems" 63 64 s <- new :: IO (Map2 Int Int) 64 elems s . -=[]65 elems s .=> [] 65 66 insert 3 42 s 66 67 insert 37 1 s 67 68 insert 0 2 s 68 elems s . -= [1,2,42]69 elems s .=> [2,42,1] 69 70 70 71 testKeys = do … … 75 76 insert 37 1 s 76 77 insert 0 2 s 77 keys s . -=[0,3,37]78 keys s .=> [0,3,37] 78 79 delete 37 s 79 80 delete 15 s 80 keys s . -=[0,3]81 keys s .=> [0,3] 81 82 82 83 testStringValue = do … … 87 88 insert 22 "string" s 88 89 insert 59 "i am not a number" s 89 toList s . -=[(22, "string"), (59,"i am not a number")]90 toList s .=> [(22, "string"), (59,"i am not a number")] 90 91 member 22 s .=> True 91 92 … … 102 103 insert 23 "string" s 103 104 insert 59 "i am not a number" s 104 toList s .-=[(22, "string"), (23, "string"), (59,"i am not a number")]105 toList s .=> [(22, "string"), (23, "string"), (59,"i am not a number")] 105 106 member 22 s .=> True 106 107 … … 138 139 lookup 1 m .=> Nothing 139 140 141 testRevList = do 142 say "RevList" 143 let l = [(1,2), (2,3), (4,5)] 144 m <- fromList l :: IO (J.Map2 Int Int) 145 J.toRevList m .=> reverse l 146 147 insert 3 10 m 148 J.toRevList m .=> reverse (sort $ (3,10):l) 149 140 150 -- TODO: test some crazy haskell type as value (to check stableptrs) 141 151
