org.databene.benerator.distribution.sequence
Class ExpandGeneratorProxy<E>
java.lang.Object
org.databene.benerator.util.AbstractGenerator<P>
org.databene.benerator.wrapper.GeneratorWrapper<E,E>
org.databene.benerator.wrapper.GeneratorProxy<E>
org.databene.benerator.distribution.sequence.ExpandGeneratorProxy<E>
- All Implemented Interfaces:
- java.io.Closeable, Generator<E>, org.databene.commons.Resettable, org.databene.commons.ThreadAware
public class ExpandGeneratorProxy<E>
- extends GeneratorProxy<E>
GeneratorProxy implementation that supports distribution of unlimited data volumes
(provided by a source generator) in a unique or non-unique manner.
Handling of unlimited data volume is provided with a cache of limited size,
distribution is implemented by distributing source data randomly over buckets
and uniqueness can be assured (when setting duplicationQuota to 0) by removing
used data from its bucket.
For maximum efficiency, source data first is randomly distributed over buckets of limited size.
As long as further source data is available, the proxy randomly selects an entry from a random
bucket returns it to the caller and replaces it with new data if no duplicates are allowed or
should not be applied in this case.
If no more source data is available, the proxy returns the last element from a bucket, allowing
to reduce the used bucket size without shifting elements. If a bucket is empty, it is removed.
The buckets were introduced for quickly freeing RAM after usage and for allowing a more erratic
behavior in the phase when no more source data is available and elements are taken from bucket end
to beginning.
Created: 10.12.2009 11:32:35
- Since:
- 0.6.0
- Author:
- Volker Bergmann
| Methods inherited from class java.lang.Object |
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
MIN_BUCKET_SIZE
public static final int MIN_BUCKET_SIZE
- See Also:
- Constant Field Values
DEFAULT_DUPLICATION_QUOTA
public static final float DEFAULT_DUPLICATION_QUOTA
- See Also:
- Constant Field Values
ExpandGeneratorProxy
public ExpandGeneratorProxy(Generator<E> source,
float duplicationQuota)
ExpandGeneratorProxy
public ExpandGeneratorProxy(Generator<E> source,
float duplicationQuota,
int cacheSize)
ExpandGeneratorProxy
public ExpandGeneratorProxy(Generator<E> source,
float duplicationQuota,
int cacheSize,
int bucketSize)
uniqueProxy
public static <T> ExpandGeneratorProxy<T> uniqueProxy(Generator<T> source,
int cacheSize,
int bucketSize)
defaultBucketSize
public static int defaultBucketSize(int cacheSize)
getCacheSize
public int getCacheSize()
setCacheSize
public void setCacheSize(int cacheSize)
getDuplicationQuota
public float getDuplicationQuota()
setDuplicationQuota
public void setDuplicationQuota(float duplicationQuota)
getBucketSize
public int getBucketSize()
setBucketSize
public void setBucketSize(int bucketSize)
init
public void init(GeneratorContext context)
- Specified by:
init in interface Generator<E>- Overrides:
init in class GeneratorWrapper<E,E>
generate
public E generate()
- Description copied from interface:
Generator
- Returns an instance of the generic type E.
- Specified by:
generate in interface Generator<E>- Overrides:
generate in class GeneratorProxy<E>
reset
public void reset()
- Specified by:
reset in interface org.databene.commons.Resettable- Overrides:
reset in class GeneratorWrapper<E,E>
printState
public void printState()
Copyright © 2011. All Rights Reserved.