Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Adding partial implementation for IndexDelete

  • Loading branch information...
commit 0106cc4552da75c29537abc86029a4e5a20018c1 1 parent 7392f5f
@zmoazeni authored
Showing with 6 additions and 4 deletions.
  1. +6 −4 src/Storage.hs
View
10 src/Storage.hs
@@ -21,15 +21,17 @@ import Data.Text.Encoding (encodeUtf8, decodeUtf8)
import Data.Text (pack, unpack)
import Data.Map (toList)
-data IndexAction = IndexCreate
+data IndexAction = IndexCreate | IndexDelete
deriving (Eq, Ord, Show)
instance Serialize IndexAction where
put IndexCreate = S.put . encodeUtf8 $ pack "create"
+ put _ = error "Unimplemented"
+
get = do string <- S.get
case unpack $ decodeUtf8 string of
"create" -> return IndexCreate
- e -> error $ "Unknown Index Action " ++ e
+ e -> error $ "Unknown Index Action " ++ e
withDB :: FilePath -> (DB -> IO a) -> IO a
withDB filePath f = withLevelDB filePath [CreateIfMissing, CacheSize 1024] f
@@ -77,8 +79,8 @@ flush stageDB gramDB = withIterator stageDB [] $ \iter -> iterFirst iter >> flus
value <- iterValue iter
case decode value of
Right (IndexCreate, rawJson) -> saveGram rawJson
- -- Right (_, _) -> error "Unknown action"
- Left message -> error message
+ Left message -> error message
+ _ -> error "Unknown action"
delete stageDB [] key
iterNext iter
flush' iter
Please sign in to comment.
Something went wrong with that request. Please try again.