我正在写一个Accumulo迭代器来返回一个百分位表的随机样本 [英] I am looking at writing an Accumulo iterator to return a random sample of a percentile of a table
本文介绍了我正在写一个Accumulo迭代器来返回一个百分位表的随机样本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如果有任何建议,我将不胜感激。
$ b
Thnaks,
Chris
解决方案
您可以扩展org.apache.accumulo.core.iterators.Filter并随机接受x%的条目。以下迭代器会随机返回5%的条目。
import java.util.Random;
import org.apache.accumulo.core.data.Key;
import org.apache.accumulo.core.data.Value;
import org.apache.accumulo.core.iterators.Filter;
public class RandomAcceptFilter extends Filter {
private Random rand = new Random();
@Override
public boolean accept(Key k,Value v){
return rand.nextDouble()< 0.05;
}
}
I am looking at writing an Accumulo iterator to return a random sample of a percentile of a table.
I would appreciate any suggestions.
Thnaks,
Chris
解决方案
You can extend org.apache.accumulo.core.iterators.Filter and randomly accept x% of the entries. The following iterator would randomly return 5 percent of the entries.
import java.util.Random;
import org.apache.accumulo.core.data.Key;
import org.apache.accumulo.core.data.Value;
import org.apache.accumulo.core.iterators.Filter;
public class RandomAcceptFilter extends Filter {
private Random rand = new Random();
@Override
public boolean accept(Key k, Value v) {
return rand.nextDouble() < .05;
}
}
这篇关于我正在写一个Accumulo迭代器来返回一个百分位表的随机样本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文