This commit is contained in:
voidlizard 2024-12-30 23:14:59 +03:00
parent 6ad858d175
commit 5e374b68cd
1 changed files with 12 additions and 6 deletions

View File

@ -908,6 +908,8 @@ theDict = do
>>= orThrow SomeReadLogError >>= orThrow SomeReadLogError
<&> GitHash . LBS.toStrict <&> GitHash . LBS.toStrict
void $ readBytesMaybe 32
lift $ S.yield hash lift $ S.yield hash
go (succ n) go (succ n)
@ -915,7 +917,7 @@ theDict = do
for_ hashes $ \h -> do for_ hashes $ \h -> do
-- found <- binSearchBS 24 (BS.take 20 . BS.drop 4) ( show . pretty . GitHash ) (coerce h) file -- found <- binSearchBS 24 (BS.take 20 . BS.drop 4) ( show . pretty . GitHash ) (coerce h) file
found <- liftIO $ binarySearchBS 24 (BS.take 20 . BS.drop 4) (coerce h) file found <- liftIO $ binarySearchBS 56 (BS.take 20 . BS.drop 4) (coerce h) file
liftIO $ print $ pretty h <+> pretty (isJust found) liftIO $ print $ pretty h <+> pretty (isJust found)
_ -> throwIO (BadFormException @C nil) _ -> throwIO (BadFormException @C nil)
@ -933,7 +935,7 @@ theDict = do
& orThrowUser "no index specified" & orThrowUser "no index specified"
file <- liftIO $ mmapFileByteString idxName Nothing file <- liftIO $ mmapFileByteString idxName Nothing
r <- liftIO $ binarySearchBS 24 (BS.take 20 . BS.drop 4) (coerce hash) file r <- liftIO $ binarySearchBS 56 (BS.take 20 . BS.drop 4) (coerce hash) file
liftIO $ print $ pretty r liftIO $ print $ pretty r
@ -1122,11 +1124,13 @@ theDict = do
[ StringLike f ] -> lift do [ StringLike f ] -> lift do
bs <- liftIO $ mmapFileByteString f Nothing bs <- liftIO $ mmapFileByteString f Nothing
scanBS bs $ \segment -> do scanBS bs $ \segment -> do
let (sha1,blake) = BS.splitAt 20 segment none
& over _1 (coerce @_ @GitHash) -- let (sha1,blake) = BS.splitAt 20 segment
& over _2 (coerce @_ @HashRef) -- & over _1 (coerce @_ @GitHash)
-- & over _2 (coerce @_ @HashRef)
liftIO $ hPrint stdout $ pretty sha1 <+> pretty blake -- notice $ pretty sha1 <+> pretty blake
liftIO $ print $ pretty "okay"
_ -> throwIO (BadFormException @C nil) _ -> throwIO (BadFormException @C nil)
@ -1600,6 +1604,8 @@ linearSearchLBS hash lbs = do
>>= orThrow SomeReadLogError >>= orThrow SomeReadLogError
<&> LBS.toStrict <&> LBS.toStrict
void $ readBytesMaybe 32
case (compare hash1 (coerce hash)) of case (compare hash1 (coerce hash)) of
EQ -> lift $ S.yield n EQ -> lift $ S.yield n
_ -> go (succ n) _ -> go (succ n)