continuum 0.1.0.0 → 0.1.0.1
raw patch · 3 files changed
+38/−3 lines, 3 files
Files
- continuum.cabal +1/−1
- src/Continuum/Client/Base.hs +1/−1
- src/Continuum/Common/Types.hs +36/−1
continuum.cabal view
@@ -1,7 +1,7 @@ name: continuum stability: experimental description: Continuum Database Client-version: 0.1.0.0+version: 0.1.0.1 license: MIT license-file: LICENSE author: Alex Petrov
src/Continuum/Client/Base.hs view
@@ -18,11 +18,11 @@ connect :: String -> String -> IO ContinuumClient+ connect host port = do socket <- N.socket N.Bus _ <- N.connect socket ("tcp://" ++ host ++ ":" ++ port) return ContinuumClient { clientSocket = socket }- executeQuery :: ContinuumClient -> Query
src/Continuum/Common/Types.hs view
@@ -7,13 +7,22 @@ import qualified Data.Serialize as S import qualified Data.Map as Map +-- |+-- | INTERNAL DB TYPES+-- |+ data DbType = DbtInt+ | DbtDouble | DbtString deriving(Show, Generic) instance S.Serialize DbType +-- |+-- | DB Error+-- |+ data DbError = IndexesDecodeError String | FieldDecodeError String ByteString@@ -32,6 +41,11 @@ type DbErrorMonad = Either DbError ++-- |+-- | DB VALUE+-- |+ data DbValue = EmptyValue | DbInt Integer@@ -52,6 +66,11 @@ instance S.Serialize DbRecord +-- | Creates a DbRecord from Timestamp and Key/Value pairs+--+makeRecord :: Integer -> [(ByteString, DbValue)] -> DbRecord+makeRecord timestamp vals = DbRecord timestamp (Map.fromList vals)+ -- | -- | DB RESULT -- |@@ -82,6 +101,7 @@ | TsKeyRange Integer Integer | EntireKeyspace deriving(Show)+ -- | -- | AGGREGATES -- |@@ -95,7 +115,7 @@ instance S.Serialize Decoding -- |--- |+-- | DB SCHEMA -- | data DbSchema = DbSchema@@ -107,6 +127,21 @@ } deriving (Generic, Show) instance S.Serialize DbSchema++-- | Creates a DbSchema out of Schema Definition (name/type pairs)+--+makeSchema :: [(ByteString, DbType)] -> DbSchema+makeSchema stringTypeList =+ DbSchema { fieldMappings = fMappings+ , fields = fields'+ , schemaMappings = Map.fromList stringTypeList+ , indexMappings = iMappings+ , schemaTypes = schemaTypes'}+ where fields' = fmap fst stringTypeList+ schemaTypes' = fmap snd stringTypeList+ fMappings = Map.fromList $ zip fields' iterateFrom0+ iMappings = Map.fromList $ zip iterateFrom0 fields'+ iterateFrom0 = (iterate (1+) 0) -- | -- | QUERIES