Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fork devgrok's changes #1

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions zebra-cli/ambiata-zebra-cli.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ library
, bytestring >= 0.10
, containers == 0.5.*
, exceptions >= 0.10
, monad-control
, mmorph >= 1.0
, pretty-show == 1.6.*
, resourcet >= 1.1
Expand Down
3 changes: 2 additions & 1 deletion zebra-cli/main/zebra.hs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import Zebra.Command.Import
import Zebra.Command.Merge
import Zebra.Command.Summary
import Zebra.Serial.Binary (BinaryVersion(..))
import Zebra.X.WrappedResourceT (usingResourceT)


main :: IO ()
Expand Down Expand Up @@ -324,7 +325,7 @@ run = \case
zebraExport export

ZebraMerge merge ->
orDie renderMergeError . hoist runResourceT $
orDie renderMergeError . hoist (runResourceT . usingResourceT) $
zebraMerge merge

ZebraAdapt adapt ->
Expand Down
17 changes: 6 additions & 11 deletions zebra-cli/src/Zebra/Command/Merge.hs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
{-# LANGUAGE DoAndIfThenElse #-}
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE PatternSynonyms #-}
{-# LANGUAGE ScopedTypeVariables #-}
Expand All @@ -15,6 +16,7 @@ module Zebra.Command.Merge (
, renderMergeError
) where

import Control.Monad.Trans.Control (MonadBaseControl (..))
import Control.Monad.Catch (MonadCatch)
import Control.Monad.IO.Class (liftIO)
import Control.Monad.Morph (hoist)
Expand All @@ -36,7 +38,7 @@ import qualified Viking.ByteStream as ByteStream
import qualified X.Data.Vector.Cons as Cons

import Zebra.Command.Util
import Zebra.Merge.Table (UnionTableError)
import Zebra.Merge.Table (UnionTableError, MergeRowsPerBlock(..))
import qualified Zebra.Merge.Table as Merge
import Zebra.Serial.Binary (BinaryStripedEncodeError, BinaryStripedDecodeError)
import Zebra.Serial.Binary (BinaryVersion(..))
Expand All @@ -58,11 +60,6 @@ data Merge =
, mergeMaximumRowSize :: !(Maybe MergeMaximumRowSize)
} deriving (Eq, Ord, Show)

newtype MergeRowsPerBlock =
MergeRowsPerBlock {
unMergeRowsPerBlock :: Int
} deriving (Eq, Ord, Show)

newtype MergeMaximumRowSize =
MergeMaximumRowSize {
unMergeMaximumRowSize :: Int64
Expand Down Expand Up @@ -109,7 +106,7 @@ readSchema = \case
fmap Just . firstT MergeTextSchemaDecodeError . hoistEither $
Text.decodeSchema schema

zebraMerge :: (MonadResource m, MonadCatch m) => Merge -> EitherT MergeError m ()
zebraMerge :: (MonadResource m, MonadCatch m, MonadBaseControl IO m) => Merge -> EitherT MergeError m ()
zebraMerge x = do
mschema <- readSchema (mergeSchema x)

Expand All @@ -127,8 +124,6 @@ zebraMerge x = do
writeFileOrStdout (mergeOutput x) .
hoist (firstJoin MergeBinaryStripedEncodeError) .
Binary.encodeStripedWith (mergeVersion x) .
hoist (firstJoin MergeStripedError) .
Striped.rechunk (unMergeRowsPerBlock $ mergeRowsPerChunk x) .
hoist (firstJoin MergeUnionTableError) $
union msize inputs
{-# SPECIALIZE zebraMerge :: Merge -> EitherT MergeError (ResourceT IO) () #-}
union msize (mergeRowsPerChunk x) inputs

5 changes: 5 additions & 0 deletions zebra-core/ambiata-zebra-core.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ library
, ambiata-x-vector
, aeson >= 1.0 && < 1.5
, aeson-pretty == 0.8.*
, lifted-async
, attoparsec >= 0.13 && < 0.14
, base64-bytestring == 1.0.*
, bifunctors >= 4.2 && < 5.6
Expand All @@ -40,6 +41,7 @@ library
, exceptions >= 0.10 && < 0.11
, ghc-prim >= 0.4 && < 0.6
, lens >= 4.7
, monad-control
, mmorph >= 1.1
, mtl >= 2.2
, old-locale == 1.0.*
Expand All @@ -53,6 +55,7 @@ library
, text == 1.2.*
, thyme == 0.3.*
, transformers == 0.5.*
, transformers-base
, transformers-either
, unordered-containers == 0.2.*
, vector >= 0.11 && < 0.13
Expand Down Expand Up @@ -120,9 +123,11 @@ library
Zebra.Time

Zebra.X.Either
Zebra.X.Stream
Zebra.X.Vector.Generic
Zebra.X.Vector.Segment
Zebra.X.Vector.Storable
Zebra.X.WrappedResourceT

include-dirs:
csrc
Expand Down
Loading