Class CoinFunc

java.lang.Object
io.nosqlbench.virtdata.library.basics.shared.from_long.to_object.CoinFunc
All Implemented Interfaces:
java.util.function.Function<java.lang.Long,​java.lang.Object>

public class CoinFunc
extends java.lang.Object
implements java.util.function.Function<java.lang.Long,​java.lang.Object>
This is a higher-order function which takes an input value, and flips a coin. The first parameter is used as the threshold for choosing a function. If the sample values derived from the input is lower than the threshold value, then the first following function is used, and otherwise the second is used. For example, if the threshold is 0.23, and the input value is hashed and sampled in the unit interval to 0.43, then the second of the two provided functions will be used. The input value does not need to be hashed beforehand, since the user may need to use the full input value before hashing as the input to one or both of the functions. This function will accept either a LongFunction or a Function or a LongUnaryOperator in either position. If necessary, use ToLongFunction to adapt other function forms to be compatible with these signatures.
  • Constructor Summary

    Constructors 
    Constructor Description
    CoinFunc​(double threshold, java.lang.Object first, java.lang.Object second)  
  • Method Summary

    Modifier and Type Method Description
    java.lang.Object apply​(java.lang.Long aLong)  

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface java.util.function.Function

    andThen, compose
  • Constructor Details

    • CoinFunc

      public CoinFunc​(double threshold, java.lang.Object first, java.lang.Object second)
  • Method Details

    • apply

      public java.lang.Object apply​(java.lang.Long aLong)
      Specified by:
      apply in interface java.util.function.Function<java.lang.Long,​java.lang.Object>