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.MappedByteBuffer
buffer
The stream buffer.(package private) java.lang.Object[]
data
Current object.(package private) boolean
hasids
Whether or not we have DBIDs.(package private) java.nio.channels.FileChannel
input
Input channel.static int
MAGIC
Magic number, shared withBundleReader
.(package private) BundleMeta
meta
Bundle metadata.(package private) ByteBufferSerializer<?>[]
sers
Serializers 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 MultipleObjectsBundle
asMultipleObjectsBundle()
Return (or collect) the stream as bundle.boolean
assignDBID(DBIDVar var)
Assign the current object ID to aDBIDVar
.java.lang.Object
data(int rnum)
Access a particular object and representation.BundleMeta
getMeta()
Get the current meta data.boolean
hasDBIDs()
Indicate whether the stream contains DBIDs.BundleStreamSource.Event
nextEvent()
Get the next event(package private) void
openBuffer()
Map the input file.(package private) void
readMeta()
Read the metadata.(package private) void
readObject()
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:BundleStreamSource
Get the current meta data.- Specified by:
getMeta
in 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:BundleStreamSource
Get the next event- Specified by:
nextEvent
in interfaceBundleStreamSource
- Returns:
- Event type
-
data
public java.lang.Object data(int rnum)
Description copied from interface:BundleStreamSource
Access a particular object and representation.- Specified by:
data
in interfaceBundleStreamSource
- Parameters:
rnum
- Representation number- Returns:
- Contained data
-
hasDBIDs
public boolean hasDBIDs()
Description copied from interface:BundleStreamSource
Indicate whether the stream contains DBIDs.- Specified by:
hasDBIDs
in interfaceBundleStreamSource
- Returns:
true
if the stream contains DBIDs.
-
assignDBID
public boolean assignDBID(DBIDVar var)
Description copied from interface:BundleStreamSource
Assign the current object ID to aDBIDVar
.- Specified by:
assignDBID
in interfaceBundleStreamSource
- Parameters:
var
- Variable to assign the object id to- Returns:
false
when no object id is available
-
asMultipleObjectsBundle
public MultipleObjectsBundle asMultipleObjectsBundle()
Description copied from interface:BundleStreamSource
Return (or collect) the stream as bundle.- Specified by:
asMultipleObjectsBundle
in interfaceBundleStreamSource
- Returns:
- Bundle
-
-