Created
March 19, 2012 17:19
-
-
Save anonymous/2119955 to your computer and use it in GitHub Desktop.
A Haskell API wrapping libhdfs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module System.Hdfs where | |
import Data.ByteString (ByteString) | |
import qualified Data.ByteString as B | |
import Data.Int | |
import Data.Vector (Vector) | |
import Data.Word | |
import Foreign.Ptr | |
type Size = Int32 | |
type Time = () -- TODO | |
-- TODO: tOffset is sometimes used a size/length. Do we want a | |
-- separate type alias for that? | |
type Offset = Int64 | |
type Port = Word16 | |
data ObjectKind = File | Directory | |
-- Type aliases not present in C header file. | |
type Host = ByteString | |
type Path = ByteString | |
data FS -- To prevent mixup of pointer in the implementation | |
newtype FileSystem = FileSystem (Ptr FS) | |
data HdfsFile -- To prevent mixup of pointer in the implementation | |
newtype File = F (Ptr HdfsFile) | |
connectAsUser :: Maybe Host -> Port -> Maybe ByteString -> IO FileSystem | |
connectAsUser = undefined | |
connect :: Maybe Host -> Port -> IO FileSystem | |
connect = undefined | |
disconnect :: FileSystem -> IO () | |
disconnect = undefined | |
-- TODO: What to do with short? | |
type Flags = () -- TODO | |
openFile :: FileSystem -> Path -> Flags -> Int -> Int -> Size -> IO File | |
openFile = undefined | |
closeFile :: FileSystem -> File -> IO () | |
closeFile = undefined | |
exists :: FileSystem -> Path -> IO Bool | |
exists = undefined | |
seek :: FileSystem -> File -> Offset -> IO () | |
seek = undefined | |
tell :: FileSystem -> File -> IO Offset | |
tell = undefined | |
read :: FileSystem -> File -> Size -> IO ByteString | |
read = undefined | |
-- Uses user supplied buffer. | |
readInto :: FileSystem -> File -> Ptr Word8 -> Size -> IO Size | |
readInto = undefined | |
pread :: FileSystem -> File -> Offset -> Size -> IO ByteString | |
pread = undefined | |
preadInto :: FileSystem -> File -> Offset -> Ptr Word8 -> Size -> IO Size | |
preadInto = undefined | |
write :: FileSystem -> File -> ByteString -> IO Size | |
write = undefined | |
flush :: FileSystem -> File -> IO () | |
flush = undefined | |
hflush :: FileSystem -> File -> IO () | |
hflush = undefined | |
available :: FileSystem -> File -> IO Int | |
available = undefined | |
copy :: FileSystem -> Path -> FileSystem -> Path -> IO () | |
copy = undefined | |
move :: FileSystem -> Path -> FileSystem -> Path -> IO () | |
move = undefined | |
delete :: FileSystem -> Path -> Bool -> IO () | |
delete = undefined | |
rename :: FileSystem -> Path -> Path -> IO () | |
rename = undefined | |
getWorkingDirectory :: FileSystem -> IO Path | |
getWorkingDirectory = undefined | |
setWorkingDirectory :: FileSystem -> Path -> IO () | |
setWorkingDirectory = undefined | |
createDirectory :: FileSystem -> Path -> IO () | |
createDirectory = undefined | |
setReplication :: FileSystem -> Path -> Int16 -> IO () | |
setReplication = undefined | |
data FileInfo = FileInfo | |
{ kind :: ObjectKind | |
, name :: Path | |
, lastMod :: Time | |
, size :: Offset | |
, replication :: Int -- TODO: What to do with short? | |
, blockSize :: Offset | |
, owner :: ByteString | |
, group :: ByteString | |
, permissions :: Int -- TODO: What to do with short? | |
, lastAccess :: Time | |
} | |
listDirectory :: FileSystem -> Path -> IO (Vector FileInfo) | |
listDirectory = undefined | |
getPathInfo :: FileSystem -> Path -> IO FileInfo | |
getPathInfo = undefined | |
-- TODO: What's the correct return type here? | |
getHosts :: FileSystem -> Path -> Offset -> Offset -> IO (Vector ByteString) | |
getHosts = undefined | |
getDefaultBlockSize :: FileSystem -> IO Offset | |
getDefaultBlockSize = undefined | |
getCapacity :: FileSystem -> IO Offset | |
getCapacity = undefined | |
getUsed :: FileSystem -> IO Offset | |
getUsed = undefined | |
chown :: FileSystem -> Path -> ByteString -> ByteString -> IO () | |
chown = undefined | |
type Mode = () -- TODO | |
chmod :: FileSystem -> Path -> Mode -> IO () | |
chmod = undefined | |
utime :: FileSystem -> Path -> Time -> Time -> IO () | |
utime = undefined |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment