Skip to content

Instantly share code, notes, and snippets.

View mfuerstenau's full-sized avatar

M. Fürstenau mfuerstenau

  • Germany/Deutschland, Duisburg, Essen, Gelsenkirchen
View GitHub Profile
@mfuerstenau
mfuerstenau / zigzag-encoding.README
Last active February 22, 2024 03:40
ZigZag encoding/decoding explained
ZigZag-Encoding
---------------
Maps negative values to positive values while going back and
forth (0 = 0, -1 = 1, 1 = 2, -2 = 3, 2 = 4, -3 = 5, 3 = 6 ...)
(i >> bitlength-1) ^ (i << 1)
with "i" being the number to be encoded, "^" being
XOR-operation and ">>" would be arithemtic shifting-operation
@mfuerstenau
mfuerstenau / SimpleDisjunctionDISI.java
Created September 1, 2021 22:56
Heap based disjunction of multiple DocIdSetIterator instances
import org.apache.lucene.search.DocIdSetIterator;
import org.apache.lucene.util.BitSetIterator;
import org.apache.lucene.util.FixedBitSet;
import org.apache.lucene.util.RoaringDocIdSet;
import java.io.IOException;
public class SimpleDisjunctionDISI extends DocIdSetIterator
{
private final DISIWrapper[] heap;
@mfuerstenau
mfuerstenau / StreamAsIterable.java
Last active August 21, 2016 12:54
Streams can be iterated over in Java 8
public class StreamAsIterable
{
public static void main (String[] args)
{
for (String s : (Iterable<String>) Stream.of ("This", "is", "a", "stream")::iterator)
{
System.out.println (s);
}
}
}