Package it.unimi.di.big.mg4j.document
Class AbstractDocumentSequence
- java.lang.Object
-
- it.unimi.di.big.mg4j.document.AbstractDocumentSequence
-
- All Implemented Interfaces:
DocumentSequence,SafelyCloseable,Closeable,AutoCloseable
- Direct Known Subclasses:
AbstractDocumentCollection,CompositeDocumentSequence,ConcatenatedDocumentSequence,CSVDocumentCollection,SubsetDocumentSequence,WarcDocumentSequence,WikipediaDocumentSequence
public abstract class AbstractDocumentSequence extends Object implements DocumentSequence, SafelyCloseable
An abstract,safely closeableimplementation of a document sequence.Note that even if your
DocumentSequenceimplementation does not allocate any specific resource, it is nonetheless a good idea to inherit from this class, as tracking missing calls toclose()will be easier to detect.
-
-
Constructor Summary
Constructors Constructor Description AbstractDocumentSequence()
-
Method Summary
Modifier and Type Method Description voidclose()Closes this document sequence, releasing all resources.voidfilename(CharSequence filename)Does nothing.protected voidfinalize()static DocumentSequenceload(CharSequence filename)Loads a sequence.-
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface it.unimi.di.big.mg4j.document.DocumentSequence
factory, iterator
-
-
-
-
Method Detail
-
load
public static DocumentSequence load(CharSequence filename) throws IOException, ClassNotFoundException, IllegalArgumentException, SecurityException
Loads a sequence.This method first deserialises the object specified by the given filename, and then invokes
DocumentSequence.filename(CharSequence)to ensure proper relativisation of serialised filenames.- Parameters:
filename- a filename that will be used to load a serialised sequence.- Throws:
IOExceptionClassNotFoundExceptionIllegalArgumentExceptionSecurityException
-
filename
public void filename(CharSequence filename) throws IOException
Does nothing.- Specified by:
filenamein interfaceDocumentSequence- Parameters:
filename- the filename of this document sequence.- Throws:
IOException
-
finalize
protected void finalize() throws Throwable
-
close
public void close() throws IOExceptionDescription copied from interface:DocumentSequenceCloses this document sequence, releasing all resources.You should always call this method after having finished with this document sequence. Implementations are invited to call this method in a finaliser as a safety net (even better, implement
SafelyCloseable), but since there is no guarantee as to when finalisers are invoked, you should not depend on this behaviour.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Specified by:
closein interfaceDocumentSequence- Throws:
IOException
-
-