Class CompositeDocumentSequence
- java.lang.Object
-
- it.unimi.di.big.mg4j.document.AbstractDocumentSequence
-
- it.unimi.di.big.mg4j.document.CompositeDocumentSequence
-
- All Implemented Interfaces:
DocumentSequence,SafelyCloseable,Closeable,AutoCloseable
public class CompositeDocumentSequence extends AbstractDocumentSequence
A document sequence composing a list of underlying sequences.An instance of this class exposes documents formed by juxtaposition of the content of the underlying document sequences. In particular, it instantiates a
CompositeDocumentFactoryusing the provided optional array of field names.For instance, by composing a document sequence whose documents have a single text field and a document sequence whose documents have a single integer field we obtain a new sequence whose documents have two fields.
The title and uri of composed documents are those of the documents returned by the first underlying sequence.
-
-
Constructor Summary
Constructors Constructor Description CompositeDocumentSequence(DocumentSequence... sequence)Creates a new composite document sequence using the provided underlying document sequences, which must possess distinct field names.CompositeDocumentSequence(DocumentSequence[] sequence, String[] fieldName)Creates a new composite document sequence using the provided underlying document sequences.
-
Method Summary
Modifier and Type Method Description voidclose()Closes this document sequence, releasing all resources.DocumentFactoryfactory()Returns the factory used by this sequence.DocumentIteratoriterator()Returns an iterator over the sequence of documents.-
Methods inherited from class it.unimi.di.big.mg4j.document.AbstractDocumentSequence
filename, finalize, load
-
-
-
-
Constructor Detail
-
CompositeDocumentSequence
public CompositeDocumentSequence(DocumentSequence... sequence)
Creates a new composite document sequence using the provided underlying document sequences, which must possess distinct field names.- Parameters:
sequence- an array of underlying document sequences (they must return the same number of documents).
-
CompositeDocumentSequence
public CompositeDocumentSequence(DocumentSequence[] sequence, String[] fieldName)
Creates a new composite document sequence using the provided underlying document sequences.- Parameters:
sequence- an array of underlying document sequences (they must return the same number of documents).fieldName- an array of field names for all fields resulting from the composition of the document factories of the underlying sequences: it will be passed toCompositeDocumentFactory(DocumentFactory[], String[])(so in particular it may benullif all fields have distinct names).
-
-
Method Detail
-
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- Overrides:
closein classAbstractDocumentSequence- Throws:
IOException
-
factory
public DocumentFactory factory()
Description copied from interface:DocumentSequenceReturns the factory used by this sequence.Every document sequence is based on a document factory that transforms raw bytes into a sequence of characters. The factory contains useful information such as the number of fields.
- Returns:
- the factory used by this sequence.
-
iterator
public DocumentIterator iterator() throws IOException
Description copied from interface:DocumentSequenceReturns an iterator over the sequence of documents.Warning: this method can be safely called just one time. For instance, implementations based on standard input will usually throw an exception if this method is called twice.
Implementations may decide to override this restriction (in particular, if they implement
DocumentCollection). Usually, however, it is not possible to obtain two iterators at the same time on a collection.- Returns:
- an iterator over the sequence of documents.
- Throws:
IOException- See Also:
DocumentCollection
-
-