This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pub fn encode_vbyte(li: &[usize]) -> Vec<u8> { | |
fn encode(k: usize) -> Vec<u8> { | |
let mut vbytes = Vec::new(); | |
let mut tmp = k; | |
while tmp >= 128 { | |
vbytes.push(128 + (tmp & 127) as u8); | |
tmp >>= 7; | |
} | |
vbytes.push(tmp as u8); | |
vbytes |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// https://crates.io/crates/bit-vec | |
use bit_vec::BitVec; | |
pub fn encode_rice(li: &[usize], m: u32) -> BitVec { | |
fn encode_quotient(k: usize, m: u32) -> BitVec { | |
let q: usize = (((k - 1) / m as usize) as f64).floor() as usize; | |
// encode (quotient + 1) in unary code | |
let mut bv = BitVec::from_elem(q + 1, false); | |
bv.set(q, true); | |
bv |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// https://crates.io/crates/bit-vec | |
use bit_vec::BitVec; | |
pub fn encode_golomb(li: &[usize], m: u32) -> BitVec { | |
fn encode_quotient(k: usize, m: u32) -> BitVec { | |
let q: usize = (((k - 1) / m as usize) as f64).floor() as usize; | |
// encode (quotient + 1) in unary code | |
let mut bv = BitVec::from_elem(q + 1, false); | |
bv.set(q, true); | |
bv |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// https://crates.io/crates/bit-vec | |
use bit_vec::BitVec; | |
pub fn encode_gamma(li: &[usize]) -> BitVec { | |
fn encode(k: usize) -> BitVec { | |
let body_len: usize = ((k as f64).log2().floor() as usize) + 1; | |
let body = BitVec::from_bytes(&k.to_be_bytes()); | |
let mut bv = BitVec::from_elem(body_len * 2 - 1, false); | |
// set selector bit |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// https://crates.io/crates/bit-vec | |
use bit_vec::BitVec; | |
pub fn encode_delta(li: &[usize]) -> BitVec { | |
fn encode(k: usize) -> BitVec { | |
let body_len: usize = ((k as f64).log2().floor() as usize) + 1; | |
let body = BitVec::from_bytes(&k.to_be_bytes()); | |
// set gamma encoded selector | |
let mut bv = encode_gamma(&[body_len]); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# base image | |
FROM docker.elastic.co/elasticsearch/elasticsearch:7.7.0 | |
# PATH | |
ENV PATH /usr/share/elasticsearch/bin:$PATH | |
USER elasticsearch | |
# copy configuration file | |
COPY elasticsearch.yml /usr/share/elasticsearch/config/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# base image | |
FROM docker.elastic.co/elasticsearch/elasticsearch:7.7.0 | |
# PATH | |
ENV PATH /usr/share/elasticsearch/bin:$PATH | |
# work directory | |
WORKDIR /usr/share/elasticsearch | |
USER elasticsearch |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package example; | |
import org.apache.lucene.analysis.standard.StandardAnalyzer; | |
import org.apache.lucene.document.*; | |
import org.apache.lucene.index.*; | |
import org.apache.lucene.queryparser.classic.ParseException; | |
import org.apache.lucene.queryparser.classic.QueryParser; | |
import org.apache.lucene.search.*; | |
import org.apache.lucene.store.Directory; | |
import org.apache.lucene.store.FSDirectory; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.io.IOException; | |
import java.nio.file.FileVisitResult; | |
import java.nio.file.Files; | |
import java.nio.file.Path; | |
import java.nio.file.Paths; | |
import java.nio.file.SimpleFileVisitor; | |
import java.nio.file.attribute.BasicFileAttributes; | |
import java.util.Arrays; | |
import java.util.Random; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
import psycopg2 | |
import xml.sax | |
from xml.sax.handler import ContentHandler | |
from dicttoxml import dicttoxml | |
INSERT_STMT = "INSERT INTO pages (id, page) VALUES('%s', '%s')" | |
COMMIT_WINDOW = 10000 |