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 9b36c421..4d0eca04 100644 --- a/hbs2-storage-ncq/lib/HBS2/Storage/NCQ3/Internal/Index.hs +++ b/hbs2-storage-ncq/lib/HBS2/Storage/NCQ3/Internal/Index.hs @@ -25,7 +25,7 @@ unpackIndexEntry entryBs = do let (fks,rest1) = BS.splitAt 4 entryBs let (offs,rest2) = BS.splitAt 8 rest1 let ss = BS.take 4 rest2 - let fk = FileKey (N.word32 fks) + let fk = FileKey (N.word64 fks) let off = N.word64 offs let size = N.word32 ss IndexEntry fk off size @@ -34,11 +34,9 @@ unpackIndexEntry entryBs = do emptyKey :: ByteString emptyKey = BS.replicate 32 0 +-- FIXME: better-hashtable-params ncqIndexAlloc :: NWayHashAlloc -ncqIndexAlloc = nwayAllocDef 1.10 32 8 16 - -ncqIndexAllocForMerge :: NWayHashAlloc -ncqIndexAllocForMerge = nwayAllocDef 0.8 32 8 16 +ncqIndexAlloc = nwayAllocDef 1.15 32 8 32 ncqLookupIndex :: MonadUnliftIO m => HashRef @@ -80,10 +78,11 @@ ncqIndexFile n fk = runMaybeT do _ -> do -- we need size in order to return block size faster -- w/o search in fossil - let fks = N.bytestring32 (coerce fk) + let fks = N.bytestring64 (coerce fk) let rs = (w + ncqSLen) & fromIntegral @_ @Word32 & N.bytestring32 let os = fromIntegral @_ @Word64 offset & N.bytestring64 - let record = fks <> os <> rs + let padding = BS.replicate 12 0 + let record = fks <> os <> rs <> padding -- debug $ "WRITE INDEX ENTRY" <+> pretty (BS.length record) S.yield (coerce key, record) diff --git a/hbs2-storage-ncq/lib/HBS2/Storage/NCQ3/Internal/Types.hs b/hbs2-storage-ncq/lib/HBS2/Storage/NCQ3/Internal/Types.hs index 882d7f27..0c70346c 100644 --- a/hbs2-storage-ncq/lib/HBS2/Storage/NCQ3/Internal/Types.hs +++ b/hbs2-storage-ncq/lib/HBS2/Storage/NCQ3/Internal/Types.hs @@ -22,7 +22,7 @@ type Shard = TVar (HashMap HashRef NCQEntry) type StateVersion = Word64 -newtype FileKey = FileKey Word32 +newtype FileKey = FileKey Word64 deriving newtype (Eq,Ord,Show,Num,Enum,Real,Integral,Pretty,Hashable) deriving stock (Data,Generic) @@ -119,10 +119,10 @@ instance ToFileName (DataFile FileKey) where toFileName (DataFile fk) = ncqMakeFossilName fk instance ToFileName (IndexFile FileKey) where - toFileName (IndexFile fk) = printf "i-%08x.cq" (coerce @_ @Word32 fk) + toFileName (IndexFile fk) = printf "i-%016x.cq" (coerce @_ @Word64 fk) instance ToFileName (StateFile FileKey) where - toFileName (StateFile fk) = printf "s-%08x" (coerce @_ @Word32 fk) + toFileName (StateFile fk) = printf "s-%016x" (coerce @_ @Word64 fk) instance Monoid NCQState where @@ -144,7 +144,7 @@ instance Pretty Location where InMemory _ -> "in-memory" ncqMakeFossilName :: FileKey -> FilePath -ncqMakeFossilName = printf "f-%08x.data" . coerce @_ @Word32 +ncqMakeFossilName = printf "f-%016x.data" . coerce @_ @Word64 withSem :: forall a m . MonadUnliftIO m => TSem -> m a -> m a withSem sem action =