Package it.unimi.di.big.mg4j.io
Class HadoopFileSystemIOFactory
- java.lang.Object
-
- it.unimi.di.big.mg4j.io.HadoopFileSystemIOFactory
-
- All Implemented Interfaces:
IOFactory
public class HadoopFileSystemIOFactory extends Object implements IOFactory
An I/O factory using a Hadoop file system.The factory provides some constructors (
HadoopFileSystemIOFactory()
andHadoopFileSystemIOFactory(String)
) that are suitable for use with anObjectParser
. For instance, the object specification it.unimi.di.mg4j.io.HadoopFileSystemIOFactory(hdfs://127.0.0.1:9000/) could be used withScan
orIndexBuilder
to make them use a local HDFS file system.Note that if you use the constructors based on the default configuration you must set up your configuration files suitably. If you use an unconfigured Hadoop file system, you will get a Hadoop
LocalFileSystem
.
-
-
Field Summary
-
Fields inherited from interface it.unimi.di.big.mg4j.io.IOFactory
FILESYSTEM_FACTORY
-
-
Constructor Summary
Constructors Constructor Description HadoopFileSystemIOFactory()
Creates a factory using a file system with a default configuration.HadoopFileSystemIOFactory(String uri)
Creates a factory using a file system specified by a givenURI
with a default configurationHadoopFileSystemIOFactory(URI uri)
Creates a factory using a file system specified by a givenURI
with a default configuration.HadoopFileSystemIOFactory(FileSystem fileSystem)
Creates a factory using a given Hadoop file system.
-
Method Summary
Modifier and Type Method Description void
createNewFile(String name)
boolean
delete(String name)
boolean
exists(String name)
FSDataInputStream
getInputStream(String name)
FSDataOutputStream
getOutputStream(String name)
ReadableByteChannel
getReadableByteChannel(String name)
WritableByteChannel
getWritableByteChannel(String name)
long
length(String name)
-
-
-
Constructor Detail
-
HadoopFileSystemIOFactory
public HadoopFileSystemIOFactory() throws IOException
Creates a factory using a file system with a default configuration.- Throws:
IOException
-
HadoopFileSystemIOFactory
public HadoopFileSystemIOFactory(URI uri) throws IOException
Creates a factory using a file system specified by a givenURI
with a default configuration.- Parameters:
uri
- a URI that will be passed toFileSystem.get(URI, Configuration)
.- Throws:
IOException
-
HadoopFileSystemIOFactory
public HadoopFileSystemIOFactory(String uri) throws IOException
Creates a factory using a file system specified by a givenURI
with a default configurationThis constructor is essentially identical to
HadoopFileSystemIOFactory(URI)
, but it can be used with anObjectParser
.- Parameters:
uri
- a URI, specified as a string, that will be passed toFileSystem.get(URI, Configuration)
.- Throws:
IOException
-
HadoopFileSystemIOFactory
public HadoopFileSystemIOFactory(FileSystem fileSystem)
Creates a factory using a given Hadoop file system.- Parameters:
fileSystem
- a Hadoop file system.
-
-
Method Detail
-
getInputStream
public FSDataInputStream getInputStream(String name) throws IOException
- Specified by:
getInputStream
in interfaceIOFactory
- Throws:
IOException
-
getOutputStream
public FSDataOutputStream getOutputStream(String name) throws IOException
- Specified by:
getOutputStream
in interfaceIOFactory
- Throws:
IOException
-
getWritableByteChannel
public WritableByteChannel getWritableByteChannel(String name) throws IOException
- Specified by:
getWritableByteChannel
in interfaceIOFactory
- Throws:
IOException
-
getReadableByteChannel
public ReadableByteChannel getReadableByteChannel(String name) throws IOException
- Specified by:
getReadableByteChannel
in interfaceIOFactory
- Throws:
IOException
-
exists
public boolean exists(String name) throws IOException
- Specified by:
exists
in interfaceIOFactory
- Throws:
IOException
-
delete
public boolean delete(String name) throws IOException
- Specified by:
delete
in interfaceIOFactory
- Throws:
IOException
-
createNewFile
public void createNewFile(String name) throws IOException
- Specified by:
createNewFile
in interfaceIOFactory
- Throws:
IOException
-
length
public long length(String name) throws IOException
- Specified by:
length
in interfaceIOFactory
- Throws:
IOException
-
-