From b57919aa851dd29b9f507d58a4eb0b92a9d6f41b Mon Sep 17 00:00:00 2001 From: voidlizard Date: Wed, 30 Jul 2025 16:54:17 +0300 Subject: [PATCH] wip, fix --- .../lib/HBS2/Storage/NCQ3/Internal/Fossil.hs | 2 +- .../lib/HBS2/Storage/NCQ3/Internal/Index.hs | 14 ++++++++++---- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/hbs2-storage-ncq/lib/HBS2/Storage/NCQ3/Internal/Fossil.hs b/hbs2-storage-ncq/lib/HBS2/Storage/NCQ3/Internal/Fossil.hs index 1108be91..f72cc5fe 100644 --- a/hbs2-storage-ncq/lib/HBS2/Storage/NCQ3/Internal/Fossil.hs +++ b/hbs2-storage-ncq/lib/HBS2/Storage/NCQ3/Internal/Fossil.hs @@ -72,7 +72,7 @@ ncqFossilMergeStep me@NCQStorage3{..} = withSem ncqServiceSem $ flip runContT p for_ [f1, f2] $ \fi -> do let fik = coerce fi writeFiltered me (ncqGetFileName me fi) fd $ \_ _ k _ -> do - ncqLocate me k >>= \case + ncqLocate_ False me k >>= \case Nothing -> pure True Just (InMemory{}) -> pure False Just (InFossil fk _ _) -> do diff --git a/hbs2-storage-ncq/lib/HBS2/Storage/NCQ3/Internal/Index.hs b/hbs2-storage-ncq/lib/HBS2/Storage/NCQ3/Internal/Index.hs index 2c693e84..c152d55e 100644 --- a/hbs2-storage-ncq/lib/HBS2/Storage/NCQ3/Internal/Index.hs +++ b/hbs2-storage-ncq/lib/HBS2/Storage/NCQ3/Internal/Index.hs @@ -49,16 +49,21 @@ ncqLookupIndex hx (mmaped, nway) = do {-# INLINE ncqLookupIndex #-} -ncqLocate :: MonadUnliftIO m => NCQStorage3 -> HashRef -> m (Maybe Location) -ncqLocate me@NCQStorage3{..} href = ncqOperation me (pure Nothing) do + +ncqLocate_ :: MonadUnliftIO m => Bool -> NCQStorage3 -> HashRef -> m (Maybe Location) +ncqLocate_ f me@NCQStorage3{..} href = ncqOperation me (pure Nothing) do answ <- newEmptyTMVarIO atomically do - -- modifyTVar ncqWrites succ + when f $ modifyTVar ncqWrites succ writeTQueue ncqReadReq (href, answ) atomically $ takeTMVar answ +ncqLocate :: MonadUnliftIO m => NCQStorage3 -> HashRef -> m (Maybe Location) +ncqLocate me href = ncqOperation me (pure Nothing) do + ncqLocate_ True me href + ncqIndexFile :: MonadUnliftIO m => NCQStorage3 -> DataFile FileKey -> m (Maybe FilePath) ncqIndexFile n fk = runMaybeT do @@ -154,7 +159,8 @@ ncqIndexCompactStep me@NCQStorage3{..} = withSem ncqServiceSem $ flip runContT p ts <- liftIO (PFS.getFileStatus idx1Name) <&> PFS.modificationTimeHiRes - result <- lift $ nwayWriteBatch ncqIndexAllocForMerge dir "merged-.cq$" e + -- result <- lift $ nwayWriteBatch ncqIndexAllocForMerge dir "merged-.cq$" e + result <- lift $ nwayWriteBatch ncqIndexAlloc dir "merged-.cq$" e liftIO $ PFS.setFileTimesHiRes result ts ts