Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package org.rsankar.lucenecodecs.mapcodec;
- import java.io.IOException;
- import org.apache.lucene.index.Terms;
- import org.apache.lucene.index.TermsEnum;
- import org.apache.lucene.util.BytesRef;
- public class ParameterAnalyzer {
- int k;
- int capacity;
- int termCount;
- int distSizeBytes;
- public ParameterAnalyzer(Terms terms) throws IOException {
- this.capacity = 1672501;
- this.k = 128;
- this.termCount = countTerms(terms);
- this.distSizeBytes = 1;
- }
- public static int getHashcode(long key, int k, int capacity) {
- return (int) ((key * k) % capacity);
- }
- public int getHashcode(long key) {
- return getHashcode(key, k, capacity);
- }
- private static int countTerms(Terms t) throws IOException {
- TermsEnum te = t.iterator();
- int count = 0;
- while (true) {
- BytesRef term = te.next();
- if (term == null) {
- break;
- }
- ++count;
- }
- return count;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement