Package elki.datasource.bundle
Class BundleReader
- java.lang.Object
-
- elki.datasource.bundle.BundleReader
-
- All Implemented Interfaces:
BundleStreamSource
public class BundleReader extends java.lang.Object implements BundleStreamSource
Read an ELKI bundle file into a data stream.TODO: resize buffer when necessary?
- Since:
- 0.5.5
- Author:
- Erich Schubert
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface elki.datasource.bundle.BundleStreamSource
BundleStreamSource.Event
-
-
Field Summary
Fields Modifier and Type Field Description (package private) java.nio.MappedByteBufferbufferThe stream buffer.(package private) java.lang.Object[]dataCurrent object.(package private) booleanhasidsWhether or not we have DBIDs.(package private) java.nio.channels.FileChannelinputInput channel.static intMAGICMagic number, shared withBundleReader.(package private) BundleMetametaBundle metadata.(package private) ByteBufferSerializer<?>[]sersSerializers to use.
-
Constructor Summary
Constructors Constructor Description BundleReader(java.nio.channels.FileChannel input)Constructor.BundleReader(java.nio.MappedByteBuffer buffer)Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description MultipleObjectsBundleasMultipleObjectsBundle()Return (or collect) the stream as bundle.booleanassignDBID(DBIDVar var)Assign the current object ID to aDBIDVar.java.lang.Objectdata(int rnum)Access a particular object and representation.BundleMetagetMeta()Get the current meta data.booleanhasDBIDs()Indicate whether the stream contains DBIDs.BundleStreamSource.EventnextEvent()Get the next event(package private) voidopenBuffer()Map the input file.(package private) voidreadMeta()Read the metadata.(package private) voidreadObject()Read an object.
-
-
-
Field Detail
-
MAGIC
public static final int MAGIC
Magic number, shared withBundleReader.- See Also:
- Constant Field Values
-
buffer
java.nio.MappedByteBuffer buffer
The stream buffer.
-
meta
BundleMeta meta
Bundle metadata.
-
input
java.nio.channels.FileChannel input
Input channel.
-
sers
ByteBufferSerializer<?>[] sers
Serializers to use.
-
data
java.lang.Object[] data
Current object.
-
hasids
boolean hasids
Whether or not we have DBIDs.
-
-
Method Detail
-
getMeta
public BundleMeta getMeta()
Description copied from interface:BundleStreamSourceGet the current meta data.- Specified by:
getMetain interfaceBundleStreamSource- Returns:
- Metadata
-
openBuffer
void openBuffer()
Map the input file.
-
readMeta
void readMeta()
Read the metadata.
-
readObject
void readObject()
Read an object.
-
nextEvent
public BundleStreamSource.Event nextEvent()
Description copied from interface:BundleStreamSourceGet the next event- Specified by:
nextEventin interfaceBundleStreamSource- Returns:
- Event type
-
data
public java.lang.Object data(int rnum)
Description copied from interface:BundleStreamSourceAccess a particular object and representation.- Specified by:
datain interfaceBundleStreamSource- Parameters:
rnum- Representation number- Returns:
- Contained data
-
hasDBIDs
public boolean hasDBIDs()
Description copied from interface:BundleStreamSourceIndicate whether the stream contains DBIDs.- Specified by:
hasDBIDsin interfaceBundleStreamSource- Returns:
trueif the stream contains DBIDs.
-
assignDBID
public boolean assignDBID(DBIDVar var)
Description copied from interface:BundleStreamSourceAssign the current object ID to aDBIDVar.- Specified by:
assignDBIDin interfaceBundleStreamSource- Parameters:
var- Variable to assign the object id to- Returns:
falsewhen no object id is available
-
asMultipleObjectsBundle
public MultipleObjectsBundle asMultipleObjectsBundle()
Description copied from interface:BundleStreamSourceReturn (or collect) the stream as bundle.- Specified by:
asMultipleObjectsBundlein interfaceBundleStreamSource- Returns:
- Bundle
-
-