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 withScanorIndexBuilderto 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 givenURIwith a default configurationHadoopFileSystemIOFactory(URI uri)Creates a factory using a file system specified by a givenURIwith a default configuration.HadoopFileSystemIOFactory(FileSystem fileSystem)Creates a factory using a given Hadoop file system.
-
Method Summary
Modifier and Type Method Description voidcreateNewFile(String name)booleandelete(String name)booleanexists(String name)FSDataInputStreamgetInputStream(String name)FSDataOutputStreamgetOutputStream(String name)ReadableByteChannelgetReadableByteChannel(String name)WritableByteChannelgetWritableByteChannel(String name)longlength(String name)
-
-
-
Constructor Detail
-
HadoopFileSystemIOFactory
public HadoopFileSystemIOFactory() throws IOExceptionCreates 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 givenURIwith 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 givenURIwith 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:
getInputStreamin interfaceIOFactory- Throws:
IOException
-
getOutputStream
public FSDataOutputStream getOutputStream(String name) throws IOException
- Specified by:
getOutputStreamin interfaceIOFactory- Throws:
IOException
-
getWritableByteChannel
public WritableByteChannel getWritableByteChannel(String name) throws IOException
- Specified by:
getWritableByteChannelin interfaceIOFactory- Throws:
IOException
-
getReadableByteChannel
public ReadableByteChannel getReadableByteChannel(String name) throws IOException
- Specified by:
getReadableByteChannelin interfaceIOFactory- Throws:
IOException
-
exists
public boolean exists(String name) throws IOException
- Specified by:
existsin interfaceIOFactory- Throws:
IOException
-
delete
public boolean delete(String name) throws IOException
- Specified by:
deletein interfaceIOFactory- Throws:
IOException
-
createNewFile
public void createNewFile(String name) throws IOException
- Specified by:
createNewFilein interfaceIOFactory- Throws:
IOException
-
length
public long length(String name) throws IOException
- Specified by:
lengthin interfaceIOFactory- Throws:
IOException
-
-