本文整理汇总了Java中org.apache.lucene.util.BitUtil类的典型用法代码示例。如果您正苦于以下问题:Java BitUtil类的具体用法?Java BitUtil怎么用?Java BitUtil使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
BitUtil类属于org.apache.lucene.util包,在下文中一共展示了BitUtil类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: stringEncodeFromMortonLong
import org.apache.lucene.util.BitUtil; //导入依赖的package包/类
/**
* Encode to a geohash string at a given level from a morton long
*/
public static final String stringEncodeFromMortonLong(long hashedVal, final int level) {
// bit twiddle to geohash (since geohash is a swapped (lon/lat) encoding)
hashedVal = BitUtil.flipFlop(hashedVal);
StringBuilder geoHash = new StringBuilder();
short precision = 0;
final short msf = (GeoPointField.BITS<<1)-5;
long mask = 31L<<msf;
do {
geoHash.append(BASE_32[(int)((mask & hashedVal)>>>(msf-(precision*5)))]);
// next 5 bits
mask >>>= 5;
} while (++precision < level);
return geoHash.toString();
}
开发者ID:justor,项目名称:elasticsearch_my,代码行数:19,代码来源:GeoHashUtils.java
示例2: HashDocSet
import org.apache.lucene.util.BitUtil; //导入依赖的package包/类
/** Create a HashDocSet from a list of *unique* ids */
public HashDocSet(int[] docs, int offset, int len, float inverseLoadFactor) {
int tsize = Math.max(BitUtil.nextHighestPowerOfTwo(len), 1);
if (tsize < len * inverseLoadFactor) {
tsize <<= 1;
}
mask=tsize-1;
table = new int[tsize];
// (for now) better then: Arrays.fill(table, EMPTY);
// https://issues.apache.org/jira/browse/SOLR-390
for (int i=tsize-1; i>=0; i--) table[i]=EMPTY;
int end = offset + len;
for (int i=offset; i<end; i++) {
put(docs[i]);
}
size = len;
}
开发者ID:europeana,项目名称:search,代码行数:22,代码来源:HashDocSet.java
示例3: mortonEncode
import org.apache.lucene.util.BitUtil; //导入依赖的package包/类
/**
* Encode to a morton long value from a given geohash string
*/
public static final long mortonEncode(final String hash) {
int level = 11;
long b;
long l = 0L;
for(char c : hash.toCharArray()) {
b = (long)(BASE_32_STRING.indexOf(c));
l |= (b<<((level--*5) + MORTON_OFFSET));
}
return BitUtil.flipFlop(l);
}
开发者ID:justor,项目名称:elasticsearch_my,代码行数:14,代码来源:GeoHashUtils.java
示例4: bbox
import org.apache.lucene.util.BitUtil; //导入依赖的package包/类
/**
* Computes the bounding box coordinates from a given geohash
*
* @param geohash Geohash of the defined cell
* @return GeoRect rectangle defining the bounding box
*/
public static Rectangle bbox(final String geohash) {
// bottom left is the coordinate
GeoPoint bottomLeft = GeoPoint.fromGeohash(geohash);
long ghLong = longEncode(geohash);
// shift away the level
ghLong >>>= 4;
// deinterleave and add 1 to lat and lon to get topRight
long lat = BitUtil.deinterleave(ghLong >>> 1) + 1;
long lon = BitUtil.deinterleave(ghLong) + 1;
GeoPoint topRight = GeoPoint.fromGeohash(BitUtil.interleave((int)lon, (int)lat) << 4 | geohash.length());
return new Rectangle(bottomLeft.lat(), topRight.lat(), bottomLeft.lon(), topRight.lon());
}
开发者ID:justor,项目名称:elasticsearch_my,代码行数:20,代码来源:GeoHashUtils.java
示例5: writeZLong
import org.apache.lucene.util.BitUtil; //导入依赖的package包/类
/**
* Writes a long in a variable-length format. Writes between one and ten bytes.
* Values are remapped by sliding the sign bit into the lsb and then encoded as an unsigned number
* e.g., 0 -;> 0, -1 -;> 1, 1 -;> 2, ..., Long.MIN_VALUE -;> -1, Long.MAX_VALUE -;> -2
* Numbers with small absolute value will have a small encoding
* If the numbers are known to be non-negative, use {@link #writeVLong(long)}
*/
public void writeZLong(long i) throws IOException {
// zig-zag encoding cf. https://developers.google.com/protocol-buffers/docs/encoding?hl=en
long value = BitUtil.zigZagEncode(i);
while ((value & 0xFFFFFFFFFFFFFF80L) != 0L) {
writeByte((byte)((value & 0x7F) | 0x80));
value >>>= 7;
}
writeByte((byte) (value & 0x7F));
}
开发者ID:justor,项目名称:elasticsearch_my,代码行数:17,代码来源:StreamOutput.java
示例6: readZLong
import org.apache.lucene.util.BitUtil; //导入依赖的package包/类
public long readZLong() throws IOException {
long accumulator = 0L;
int i = 0;
long currentByte;
while (((currentByte = readByte()) & 0x80L) != 0) {
accumulator |= (currentByte & 0x7F) << i;
i += 7;
if (i > 63) {
throw new IOException("variable-length stream is too long");
}
}
return BitUtil.zigZagDecode(accumulator | (currentByte << i));
}
开发者ID:justor,项目名称:elasticsearch_my,代码行数:14,代码来源:StreamInput.java
示例7: getRecomputedCount
import org.apache.lucene.util.BitUtil; //导入依赖的package包/类
/** For testing */
public final int getRecomputedCount() {
int c = 0;
int end = bits.length;
for (int i = 0; i < end; i++) {
c += BitUtil.bitCount(bits[i]); // sum bits per byte
}
return c;
}
开发者ID:lamsfoundation,项目名称:lams,代码行数:10,代码来源:BitVector.java
示例8: unionCount
import org.apache.lucene.util.BitUtil; //导入依赖的package包/类
/** Returns the popcount or cardinality of the union of the two sets.
* Neither set is modified.
*/
public static long unionCount(OpenBitSet a, OpenBitSet b) {
long tot = BitUtil.pop_union(a.bits, b.bits, 0, Math.min(a.wlen, b.wlen));
if (a.wlen < b.wlen) {
tot += BitUtil.pop_array(b.bits, a.wlen, b.wlen-a.wlen);
} else if (a.wlen > b.wlen) {
tot += BitUtil.pop_array(a.bits, b.wlen, a.wlen-b.wlen);
}
return tot;
}
开发者ID:chensed,项目名称:my-first-github,代码行数:13,代码来源:OpenBitSet.java
示例9: andNotCount
import org.apache.lucene.util.BitUtil; //导入依赖的package包/类
/** Returns the popcount or cardinality of "a and not b"
* or "intersection(a, not(b))".
* Neither set is modified.
*/
public static long andNotCount(OpenBitSet a, OpenBitSet b) {
long tot = BitUtil.pop_andnot(a.bits, b.bits, 0, Math.min(a.wlen, b.wlen));
if (a.wlen > b.wlen) {
tot += BitUtil.pop_array(a.bits, b.wlen, a.wlen-b.wlen);
}
return tot;
}
开发者ID:chensed,项目名称:my-first-github,代码行数:12,代码来源:OpenBitSet.java
示例10: xorCount
import org.apache.lucene.util.BitUtil; //导入依赖的package包/类
/** Returns the popcount or cardinality of the exclusive-or of the two sets.
* Neither set is modified.
*/
public static long xorCount(OpenBitSet a, OpenBitSet b) {
long tot = BitUtil.pop_xor(a.bits, b.bits, 0, Math.min(a.wlen, b.wlen));
if (a.wlen < b.wlen) {
tot += BitUtil.pop_array(b.bits, a.wlen, b.wlen-a.wlen);
} else if (a.wlen > b.wlen) {
tot += BitUtil.pop_array(a.bits, b.wlen, a.wlen-b.wlen);
}
return tot;
}
开发者ID:chensed,项目名称:my-first-github,代码行数:13,代码来源:OpenBitSet.java
示例11: VersionInfo
import org.apache.lucene.util.BitUtil; //导入依赖的package包/类
public VersionInfo(UpdateLog ulog, int nBuckets) {
this.ulog = ulog;
IndexSchema schema = ulog.uhandler.core.getLatestSchema();
versionField = getAndCheckVersionField(schema);
idField = schema.getUniqueKeyField();
buckets = new VersionBucket[ BitUtil.nextHighestPowerOfTwo(nBuckets) ];
for (int i=0; i<buckets.length; i++) {
buckets[i] = new VersionBucket();
}
}
开发者ID:europeana,项目名称:search,代码行数:11,代码来源:VersionInfo.java
示例12: VersionInfo
import org.apache.lucene.util.BitUtil; //导入依赖的package包/类
public VersionInfo(UpdateLog ulog, int nBuckets) {
this.ulog = ulog;
SolrCore core = ulog.uhandler.core;
versionField = getAndCheckVersionField(core.getSchema());
idField = core.getSchema().getUniqueKeyField();
buckets = new VersionBucket[ BitUtil.nextHighestPowerOfTwo(nBuckets) ];
for (int i=0; i<buckets.length; i++) {
buckets[i] = new VersionBucket();
}
}
开发者ID:pkarmstr,项目名称:NYBC,代码行数:11,代码来源:VersionInfo.java
示例13: resetFromGeoHash
import org.apache.lucene.util.BitUtil; //导入依赖的package包/类
public GeoPoint resetFromGeoHash(long geohashLong) {
final int level = (int)(12 - (geohashLong&15));
return this.resetFromIndexHash(BitUtil.flipFlop((geohashLong >>> 4) << ((level * 5) + 2)));
}
开发者ID:justor,项目名称:elasticsearch_my,代码行数:5,代码来源:GeoPoint.java
示例14: longEncode
import org.apache.lucene.util.BitUtil; //导入依赖的package包/类
/**
* Encode lon/lat to the geohash based long format (lon/lat interleaved, 4 least significant bits = level)
*/
public static final long longEncode(final double lon, final double lat, final int level) {
// shift to appropriate level
final short msf = (short)(((12 - level) * 5) + MORTON_OFFSET);
return ((BitUtil.flipFlop(GeoPointField.encodeLatLon(lat, lon)) >>> msf) << 4) | level;
}
开发者ID:justor,项目名称:elasticsearch_my,代码行数:9,代码来源:GeoHashUtils.java
示例15: fromMorton
import org.apache.lucene.util.BitUtil; //导入依赖的package包/类
/**
* Convert from a morton encoded long from a geohash encoded long
*/
public static long fromMorton(long morton, int level) {
long mFlipped = BitUtil.flipFlop(morton);
mFlipped >>>= (((GeoHashUtils.PRECISION - level) * 5) + MORTON_OFFSET);
return (mFlipped << 4) | level;
}
开发者ID:justor,项目名称:elasticsearch_my,代码行数:9,代码来源:GeoHashUtils.java
示例16: cardinality
import org.apache.lucene.util.BitUtil; //导入依赖的package包/类
/** @return the number of set bits */
public long cardinality() {
return BitUtil.pop_array(bits,0,wlen);
}
开发者ID:chensed,项目名称:my-first-github,代码行数:5,代码来源:OpenBitSet.java
示例17: intersectionCount
import org.apache.lucene.util.BitUtil; //导入依赖的package包/类
/** Returns the popcount or cardinality of the intersection of the two sets.
* Neither set is modified.
*/
public static long intersectionCount(OpenBitSet a, OpenBitSet b) {
return BitUtil.pop_intersect(a.bits, b.bits, 0, Math.min(a.wlen, b.wlen));
}
开发者ID:chensed,项目名称:my-first-github,代码行数:7,代码来源:OpenBitSet.java
示例18: shift
import org.apache.lucene.util.BitUtil; //导入依赖的package包/类
private void shift() {
if ((int)word ==0) {wordShift +=32; word = word >>>32; }
if ((word & 0x0000FFFF) == 0) { wordShift +=16; word >>>=16; }
if ((word & 0x000000FF) == 0) { wordShift +=8; word >>>=8; }
indexArray = BitUtil.bitList((byte) word);
}
开发者ID:chensed,项目名称:my-first-github,代码行数:7,代码来源:OpenBitSetIterator.java
示例19: readZInt
import org.apache.lucene.util.BitUtil; //导入依赖的package包/类
/**
* Read a {@link BitUtil#zigZagDecode(int) zig-zag}-encoded
* {@link #readVInt() variable-length} integer.
* @see DataOutput#writeZInt(int)
*/
public int readZInt() throws IOException {
return BitUtil.zigZagDecode(readVInt());
}
开发者ID:lamsfoundation,项目名称:lams,代码行数:9,代码来源:DataInput.java
示例20: readZLong
import org.apache.lucene.util.BitUtil; //导入依赖的package包/类
/**
* Read a {@link BitUtil#zigZagDecode(long) zig-zag}-encoded
* {@link #readVLong() variable-length} integer. Reads between one and ten
* bytes.
* @see DataOutput#writeZLong(long)
*/
public long readZLong() throws IOException {
return BitUtil.zigZagDecode(readVLong(true));
}
开发者ID:lamsfoundation,项目名称:lams,代码行数:10,代码来源:DataInput.java
注:本文中的org.apache.lucene.util.BitUtil类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论