当前位置: 首页>>代码示例>>Java>>正文


Java BloomFilter.readFields方法代码示例

本文整理汇总了Java中org.apache.hadoop.util.bloom.BloomFilter.readFields方法的典型用法代码示例。如果您正苦于以下问题:Java BloomFilter.readFields方法的具体用法?Java BloomFilter.readFields怎么用?Java BloomFilter.readFields使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.hadoop.util.bloom.BloomFilter的用法示例。


在下文中一共展示了BloomFilter.readFields方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: setup

import org.apache.hadoop.util.bloom.BloomFilter; //导入方法依赖的package包/类
@Override
protected void setup(Context context) throws IOException,
		InterruptedException {

	// TODO Create a FileSystem object
	FileSystem fs = FileSystem.get(context.getConfiguration());

	// TODO get the cache files from the context
	URI[] uris = context.getCacheFiles();

	if (uris.length > 0) {
		// TODO create a new Bloom filter
		filter = new BloomFilter();
		
		// TODO call the filter's readFields method, passing in an FSDataInputStream
		filter.readFields(fs.open(new Path(uris[0].toString())));
	} else {
		throw new IOException(
				"Bloom filter file not in DistributedCache");
	}
}
 
开发者ID:adamjshook,项目名称:bloomfilter-course,代码行数:22,代码来源:MRBloomFilter.java

示例2: init

import org.apache.hadoop.util.bloom.BloomFilter; //导入方法依赖的package包/类
private void init() throws IOException {
    filter = new BloomFilter();
    String dir = "./" + getFilenameFromPath(bloomFile);
    String[] partFiles = new File(dir)
            .list(new FilenameFilter() {
                @Override
                public boolean accept(File current, String name) {
                    return name.startsWith("part");
                }
            });

    String dcFile = dir + "/" + partFiles[0];
    DataInputStream dis = new DataInputStream(new FileInputStream(dcFile));
    try {
        filter.readFields(dis);
    } finally {
        dis.close();
    }
}
 
开发者ID:sigmoidanalytics,项目名称:spork,代码行数:20,代码来源:Bloom.java

示例3: setFilter

import org.apache.hadoop.util.bloom.BloomFilter; //导入方法依赖的package包/类
/**
 * For testing only, do not use directly.
 */
public void setFilter(DataByteArray dba) throws IOException {
    DataInputStream dis = new DataInputStream(new
        ByteArrayInputStream(dba.get()));
    filter = new BloomFilter();
    filter.readFields(dis);
}
 
开发者ID:sigmoidanalytics,项目名称:spork-streaming,代码行数:10,代码来源:Bloom.java

示例4: bloomIn

import org.apache.hadoop.util.bloom.BloomFilter; //导入方法依赖的package包/类
protected BloomFilter bloomIn(DataByteArray b) throws IOException {
    DataInputStream dis = new DataInputStream(new
        ByteArrayInputStream(b.get()));
    BloomFilter f = new BloomFilter();
    f.readFields(dis);
    return f;
}
 
开发者ID:sigmoidanalytics,项目名称:spork-streaming,代码行数:8,代码来源:BuildBloomBase.java

示例5: redisMembershipTestWithFilter

import org.apache.hadoop.util.bloom.BloomFilter; //导入方法依赖的package包/类
public void redisMembershipTestWithFilter(Path input, Path bloom)
		throws Exception {

	System.out.println("Testing Redis set membership of " + input
			+ " using a Bloom filter " + bloom);
	
	// TODO create a fileSystem object
	FileSystem fs = FileSystem.get(getConf());
	
	// TODO connect to Redis at localhost, port 6379
	jedis = new Jedis("localhost", 6379);
	jedis.connect();
	
	// TODO Create a new BloomFilter object
	BloomFilter filter = new BloomFilter();
	
	// TODO call readFields with an FSDataInputStream from the file
	filter.readFields(fs.open(bloom));
	
	// TODO Open the testing file for read
	String line = null;
	int numBFhits = 0, numhits = 0, numlines = 0;
	BufferedReader rdr = new BufferedReader(new InputStreamReader(
			fs.open(input)));
	
	// TODO create a new Key to re-use
	Key key = new Key();

	long start = System.currentTimeMillis();
	while ((line = rdr.readLine()) != null) {
		// TODO increment numlines
		++numlines;
		
		// TODO set the bytes of the key to line's bytes with a weight of 1.0
		key.set(line.getBytes(), 1.0);
		
		// TODO membership test the key
		if (filter.membershipTest(key)) {
			// TODO increment numBFhits
			++numBFhits;

			// TODO test jedis using sismember
			if (jedis.sismember(REDIS_SET_KEY, line)) {
				// TODO increment numhits
				++numhits;
			}
		}
	}
	long finish = System.currentTimeMillis();

	// TODO close the file reader and Redis client
	rdr.close();
	jedis.disconnect();

	System.out.println("Took " + (finish - start) + " ms to check Redis "
			+ numlines + " times for " + numhits
			+ " successful tests.  Bloom filter hits: " + numBFhits
			+ " False postives: " + (numBFhits - numhits));
}
 
开发者ID:adamjshook,项目名称:bloomfilter-course,代码行数:60,代码来源:Tester.java

示例6: init

import org.apache.hadoop.util.bloom.BloomFilter; //导入方法依赖的package包/类
private void init() throws IOException {
    filter = new BloomFilter();
    String dcFile = "./" + getFilenameFromPath(bloomFile) +
        "/part-r-00000";
    filter.readFields(new DataInputStream(new FileInputStream(dcFile)));
}
 
开发者ID:sigmoidanalytics,项目名称:spork-streaming,代码行数:7,代码来源:Bloom.java


注:本文中的org.apache.hadoop.util.bloom.BloomFilter.readFields方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。