Package moa.streams
Class PartitioningStream
- java.lang.Object
-
- moa.AbstractMOAObject
-
- moa.options.AbstractOptionHandler
-
- moa.streams.PartitioningStream
-
- All Implemented Interfaces:
Configurable
,Serializable
,CapabilitiesHandler
,MOAObject
,OptionHandler
,ExampleStream
public class PartitioningStream extends AbstractOptionHandler implements ExampleStream
This stream partitions the base stream into n distinct streams and outputs one of them- Version:
- $Revision: 1 $
- Author:
- Tuan Pham Minh (tuan.pham@ovgu.de)
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected ExampleStream
baseStream
protected int
numPartitions
IntOption
numPartitionsOption
protected int
partitionIndex
IntOption
partitionIndexOption
protected Random
random
IntOption
randomSeedOption
ClassOption
streamOption
-
Fields inherited from class moa.options.AbstractOptionHandler
config
-
-
Constructor Summary
Constructors Constructor Description PartitioningStream()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
discardNexInstancesNotFromPartition()
discarding all instances which are exluded until an instance which can be seen by this stream or the stream is emptylong
estimatedRemainingInstances()
Gets the estimated number of remaining instances in this streamvoid
getDescription(StringBuilder sb, int indent)
Returns a string representation of this object.InstancesHeader
getHeader()
Gets the header of this stream.protected int
getNextPartitionToLeaveOut()
get the partition which is excluded from seeing the next instanceboolean
hasMoreInstances()
Gets whether this stream has more instances to output.protected boolean
isNextInstanceFromPartition()
check if this stream is excluded from seeing the next instanceboolean
isRestartable()
Gets whether this stream can restart.Example<Instance>
nextInstance()
Gets the next example from this stream.protected void
prepareForUseImpl(TaskMonitor monitor, ObjectRepository repository)
This method describes the implementation of how to prepare this object for use.void
restart()
Restarts this stream.-
Methods inherited from class moa.options.AbstractOptionHandler
copy, getCLICreationString, getOptions, getPreparedClassOption, getPurposeString, prepareClassOptions, prepareForUse, prepareForUse
-
Methods inherited from class moa.AbstractMOAObject
copy, measureByteSize, measureByteSize, toString
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface moa.capabilities.CapabilitiesHandler
getCapabilities
-
Methods inherited from interface moa.streams.ExampleStream
defineImmutableCapabilities
-
Methods inherited from interface moa.MOAObject
measureByteSize
-
-
-
-
Field Detail
-
streamOption
public ClassOption streamOption
-
partitionIndexOption
public IntOption partitionIndexOption
-
numPartitionsOption
public IntOption numPartitionsOption
-
randomSeedOption
public IntOption randomSeedOption
-
baseStream
protected ExampleStream baseStream
-
partitionIndex
protected int partitionIndex
-
numPartitions
protected int numPartitions
-
random
protected Random random
-
-
Method Detail
-
getHeader
public InstancesHeader getHeader()
Description copied from interface:ExampleStream
Gets the header of this stream. This is useful to know attributes and classes. InstancesHeader is an extension of weka.Instances.- Specified by:
getHeader
in interfaceExampleStream
- Returns:
- the header of this stream
-
estimatedRemainingInstances
public long estimatedRemainingInstances()
Description copied from interface:ExampleStream
Gets the estimated number of remaining instances in this stream- Specified by:
estimatedRemainingInstances
in interfaceExampleStream
- Returns:
- the estimated number of instances to get from this stream
-
hasMoreInstances
public boolean hasMoreInstances()
Description copied from interface:ExampleStream
Gets whether this stream has more instances to output. This is useful when reading streams from files.- Specified by:
hasMoreInstances
in interfaceExampleStream
- Returns:
- true if this stream has more instances to output
-
nextInstance
public Example<Instance> nextInstance()
Description copied from interface:ExampleStream
Gets the next example from this stream.- Specified by:
nextInstance
in interfaceExampleStream
- Returns:
- the next example of this stream
-
isRestartable
public boolean isRestartable()
Description copied from interface:ExampleStream
Gets whether this stream can restart.- Specified by:
isRestartable
in interfaceExampleStream
- Returns:
- true if this stream can restart
-
restart
public void restart()
Description copied from interface:ExampleStream
Restarts this stream. It must be similar to starting a new stream from scratch.- Specified by:
restart
in interfaceExampleStream
-
getDescription
public void getDescription(StringBuilder sb, int indent)
Description copied from interface:MOAObject
Returns a string representation of this object. Used inAbstractMOAObject.toString
to give a string representation of the object.- Specified by:
getDescription
in interfaceMOAObject
- Parameters:
sb
- the stringbuilder to add the descriptionindent
- the number of characters to indent
-
prepareForUseImpl
protected void prepareForUseImpl(TaskMonitor monitor, ObjectRepository repository)
Description copied from class:AbstractOptionHandler
This method describes the implementation of how to prepare this object for use. All classes that extends this class have to implementprepareForUseImpl
and notprepareForUse
sinceprepareForUse
callsprepareForUseImpl
.- Specified by:
prepareForUseImpl
in classAbstractOptionHandler
- Parameters:
monitor
- the TaskMonitor to userepository
- the ObjectRepository to use
-
getNextPartitionToLeaveOut
protected int getNextPartitionToLeaveOut()
get the partition which is excluded from seeing the next instance- Returns:
- the index of the excluded partition
-
isNextInstanceFromPartition
protected boolean isNextInstanceFromPartition()
check if this stream is excluded from seeing the next instance- Returns:
-
discardNexInstancesNotFromPartition
protected void discardNexInstancesNotFromPartition()
discarding all instances which are exluded until an instance which can be seen by this stream or the stream is empty
-
-