attoparsec parsers for all new-format uuid-based logs
There should be some speed gains here, especially for chunk and remote state logs, which are queried once per key. Now only old-format uuid-based logs still need to be converted to attoparsec.
This commit is contained in:
parent
7e54c215b4
commit
66603d6f75
10 changed files with 88 additions and 56 deletions
|
@ -17,6 +17,8 @@ import qualified Annex.Branch
|
|||
import qualified Annex
|
||||
|
||||
import qualified Data.Map as M
|
||||
import qualified Data.ByteString.Lazy as L
|
||||
import qualified Data.Attoparsec.ByteString.Lazy as A
|
||||
import Data.ByteString.Builder
|
||||
|
||||
type RemoteState = String
|
||||
|
@ -26,7 +28,7 @@ setRemoteState u k s = do
|
|||
c <- liftIO currentVectorClock
|
||||
config <- Annex.getGitConfig
|
||||
Annex.Branch.change (remoteStateLogFile config k) $
|
||||
buildRemoteState . changeLog c u s . parseLogNew Just . decodeBL
|
||||
buildRemoteState . changeLog c u s . parseRemoteState
|
||||
|
||||
buildRemoteState :: Log RemoteState -> Builder
|
||||
buildRemoteState = buildLogNew (byteString . encodeBS)
|
||||
|
@ -34,7 +36,10 @@ buildRemoteState = buildLogNew (byteString . encodeBS)
|
|||
getRemoteState :: UUID -> Key -> Annex (Maybe RemoteState)
|
||||
getRemoteState u k = do
|
||||
config <- Annex.getGitConfig
|
||||
extract . parseLogNew Just . decodeBL
|
||||
extract . parseRemoteState
|
||||
<$> Annex.Branch.get (remoteStateLogFile config k)
|
||||
where
|
||||
extract m = value <$> M.lookup u m
|
||||
|
||||
parseRemoteState :: L.ByteString -> Log RemoteState
|
||||
parseRemoteState = parseLogNew (decodeBS <$> A.takeByteString)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue