Skip to content
This repository has been archived by the owner on Jan 17, 2020. It is now read-only.

Commit

Permalink
Merge pull request #18 from garyb/hdfs
Browse files Browse the repository at this point in the history
Spark HDFS mount type
  • Loading branch information
natefaubion authored Nov 28, 2016
2 parents 5c0698c + 71c25f2 commit e910f63
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 14 deletions.
8 changes: 4 additions & 4 deletions src/Quasar/FS/Mount.purs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ data Mount
| MongoDB DirPath
| Couchbase DirPath
| MarkLogic DirPath
| Spark DirPath
| SparkHDFS DirPath

derive instance eqMountEq Mount

Expand All @@ -39,7 +39,7 @@ instance showMount ∷ Show Mount where
show (MongoDB p) = "(MongoDB " <> show p <> ")"
show (Couchbase p) = "(Couchbase " <> show p <> ")"
show (MarkLogic p) = "(MarkLogic " <> show p <> ")"
show (Spark p) = "(Spark " <> show p <> ")"
show (SparkHDFS p) = "(SparkHDFS " <> show p <> ")"

-- | Attempts to decode a mount listing value from Quasar's filesystem metadata,
-- | for a mount in the specified parent directory.
Expand All @@ -53,7 +53,7 @@ fromJSON parent = decodeJson >=> \obj → do
"directory", "mongodb"Right $ MongoDB (parent </> dir name)
"directory", "couchbase"Right $ Couchbase (parent </> dir name)
"directory", "marklogic"Right $ MarkLogic (parent </> dir name)
"directory", "spark"Right $ Spark (parent </> dir name)
"directory", "spark"Right $ SparkHDFS (parent </> dir name)
_, _ → Left $
"Unknown mount type '" <> mount <> "' for resource type '" <> typ <> "'"

Expand All @@ -62,7 +62,7 @@ getPath (View p) = Right p
getPath (MongoDB p) = Left p
getPath (Couchbase p) = Left p
getPath (MarkLogic p) = Left p
getPath (Spark p) = Left p
getPath (SparkHDFS p) = Left p

getName Mount Either (Maybe DirName) FileName
getName = pathName <<< getPath
12 changes: 6 additions & 6 deletions src/Quasar/Mount.purs
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,15 @@ import Data.Either (Either(..))
import Quasar.Mount.Couchbase as Couchbase
import Quasar.Mount.MarkLogic as MarkLogic
import Quasar.Mount.MongoDB as MongoDB
import Quasar.Mount.Spark as Spark
import Quasar.Mount.SparkHDFS as SparkHDFS
import Quasar.Mount.View as View

data MountConfig
= ViewConfig View.Config
| MongoDBConfig MongoDB.Config
| CouchbaseConfig Couchbase.Config
| MarkLogicConfig MarkLogic.Config
| SparkConfig Spark.Config
| SparkHDFSConfig SparkHDFS.Config

instance showMountConfigShow MountConfig where
show (ViewConfig { query, vars })
Expand All @@ -55,8 +55,8 @@ instance showMountConfig ∷ Show MountConfig where
<> ", path: " <> show path
<> ", user: " <> show user
<> ", password: " <> show password <> " })"
show (SparkConfig { sparkHost, hdfsHost, path })
= "(SparkConfig { sparkHost: " <> show sparkHost
show (SparkHDFSConfig { sparkHost, hdfsHost, path })
= "(SparkHDFSConfig { sparkHost: " <> show sparkHost
<> ", hdfsHost: " <> show hdfsHost
<> ", path: " <> show path <> " })"

Expand All @@ -66,12 +66,12 @@ fromJSON json
<|> MongoDBConfig <$> MongoDB.fromJSON json
<|> CouchbaseConfig <$> Couchbase.fromJSON json
<|> MarkLogicConfig <$> MarkLogic.fromJSON json
<|> SparkConfig <$> Spark.fromJSON json
<|> SparkHDFSConfig <$> SparkHDFS.fromJSON json
<|> Left "Could not decode mount config"

toJSON MountConfig Json
toJSON (ViewConfig config) = View.toJSON config
toJSON (MongoDBConfig config) = MongoDB.toJSON config
toJSON (CouchbaseConfig config) = Couchbase.toJSON config
toJSON (MarkLogicConfig config) = MarkLogic.toJSON config
toJSON (SparkConfig config) = Spark.toJSON config
toJSON (SparkHDFSConfig config) = SparkHDFS.toJSON config
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
-}

module Quasar.Mount.Spark
module Quasar.Mount.SparkHDFS
( Config
, toJSON
, fromJSON
Expand Down Expand Up @@ -48,7 +48,7 @@ type Config =
toJSON Config Json
toJSON config =
let uri = toString config
in "spark" := ("connectionUri" := uri ~> jsonEmptyObject) ~> jsonEmptyObject
in "spark-hdfs" := ("connectionUri" := uri ~> jsonEmptyObject) ~> jsonEmptyObject

fromJSON Json Either String Config
fromJSON
Expand Down
4 changes: 2 additions & 2 deletions src/Quasar/Mount/View.purs
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,9 @@ fromURI ∷ URI.AbsoluteURI → Either String Config
fromURI (URI.AbsoluteURI scheme _ query) = do
unless (scheme == Just uriScheme) $ Left "Expected 'sql2' URL scheme"
let queryMap = maybe List.Nil (\(URI.Query q) → q) query
query ← maybe (Left "Expected 'q' query variable") pure (extractQuery queryMap)
query' ← maybe (Left "Expected 'q' query variable") pure (extractQuery queryMap)
let vars = SM.fromFoldable $ foldMap extractVar queryMap
pure { query, vars }
pure { query: query', vars }

uriScheme URI.URIScheme
uriScheme = URI.URIScheme "sql2"
Expand Down

0 comments on commit e910f63

Please sign in to comment.