Class ReservoirSampling

  • All Implemented Interfaces:
    java.lang.Iterable<org.api4.java.algorithm.events.IAlgorithmEvent>, java.util.concurrent.Callable<java.io.File>, java.util.Iterator<org.api4.java.algorithm.events.IAlgorithmEvent>, org.api4.java.algorithm.IAlgorithm<java.io.File,​java.io.File>, org.api4.java.common.control.ICancelable, org.api4.java.common.control.ILoggingCustomizable, org.api4.java.common.event.IEventEmitter<java.lang.Object>, org.api4.java.common.event.IRelaxedEventEmitter

    public class ReservoirSampling
    extends AFileSamplingAlgorithm
    Implementation of the Reservoir Sampling algorithm(comparable to a Simple Random Sampling for streamed data). For a desired sample of size n, the first n elements of the stream are directly selected and the remaining ones will replace these with decreasing probability.
    • Constructor Summary

      Constructors 
      Constructor Description
      ReservoirSampling​(java.util.Random random, java.io.File input)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      protected void cleanUp()
      Implement custom clean up behaviour.
      org.api4.java.algorithm.events.IAlgorithmEvent nextWithException()  
      • Methods inherited from class ai.libs.jaicore.basic.algorithm.AAlgorithm

        activate, announceTimeoutDetected, avoidReinterruptionOnShutdownOnCurrentThread, cancel, checkAndConductTermination, checkTermination, computeTimeoutAware, getActivationTime, getConfig, getDeadline, getId, getInput, getListeners, getLoggerName, getNumCPUs, getRemainingTimeToDeadline, getState, getTimeout, getTimeoutPrecautionOffset, hasNext, hasThreadBeenInterruptedDuringShutdown, interruptThreadAsPartOfShutdown, isCanceled, isShutdownInitialized, isStopCriterionSatisfied, isTimeoutDefined, isTimeouted, iterator, next, post, registerActiveThread, registerListener, resolveShutdownInterruptOnCurrentThread, setConfig, setDeadline, setLoggerName, setMaxNumThreads, setNumCPUs, setState, setTimeout, setTimeout, setTimeoutPrecautionOffset, shutdown, terminate, unregisterActiveThread, unregisterThreadAndShutdown
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
      • Methods inherited from interface java.lang.Iterable

        forEach, spliterator
      • Methods inherited from interface java.util.Iterator

        forEachRemaining, remove
    • Constructor Detail

      • ReservoirSampling

        public ReservoirSampling​(java.util.Random random,
                                 java.io.File input)
    • Method Detail

      • nextWithException

        public org.api4.java.algorithm.events.IAlgorithmEvent nextWithException()
                                                                         throws java.lang.InterruptedException,
                                                                                org.api4.java.algorithm.exceptions.AlgorithmExecutionCanceledException,
                                                                                org.api4.java.algorithm.exceptions.AlgorithmException
        Throws:
        java.lang.InterruptedException
        org.api4.java.algorithm.exceptions.AlgorithmExecutionCanceledException
        org.api4.java.algorithm.exceptions.AlgorithmException