Skip to content

Instantly share code, notes, and snippets.

@mschoch
mschoch / force_mege.go
Created March 3, 2021 21:45
A utility function to force merge a Bleve index into a single segment
func forceMerge(index bleve.Index) error {
internalIndex, err := index.Advanced()
if err != nil {
return fmt.Errorf("unable to access internal index: %v", err)
}
if scorchIndex, ok := internalIndex.(*scorch.Scorch); ok {
numFiles := scorchIndex.StatsMap()["num_files_on_disk"].(uint64)
for numFiles > 2 {
err = scorchIndex.ForceMerge(context.Background(), nil)
if err != nil {
[ 19%] Linking CXX executable couch_dbdump
/usr/bin/ld: ../tlm/deps/flatbuffers.exploded/lib/libflatbuffers.a(idl_parser.cpp.o): relocation R_X86_64_32S against `.rodata' can not be used when making a PIE object; recompile with -fPIC
/usr/bin/ld: ../tlm/deps/flatbuffers.exploded/lib/libflatbuffers.a(idl_gen_text.cpp.o): relocation R_X86_64_32 against `.rodata.str1.1' can not be used when making a PIE object; recompile with -fPIC
/usr/bin/ld: ../tlm/deps/flatbuffers.exploded/lib/libflatbuffers.a(util.cpp.o): relocation R_X86_64_32S against symbol `_ZTVSt9basic_iosIcSt11char_traitsIcEE@@GLIBCXX_3.4' can not be used when making a PIE object; recompile with -fPIC
/usr/bin/ld: final link failed: Nonrepresentable section on output
collect2: error: ld returned 1 exit status
couchstore/CMakeFiles/couch_dbdump.dir/build.make:241: recipe for target 'couchstore/couch_dbdump' failed
make[4]: *** [couchstore/couch_dbdump] Error 1
CMakeFiles/Makefile2:9108: recipe for target 'couchstore/CMakeFiles/couch_dbdump.dir/all' fai
mschoch@mschoch-virtualbox:/mnt/build$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 18.04.4 LTS
Release: 18.04
Codename: bionic
mschoch@mschoch-virtualbox:/mnt/build$ uname -a
Linux mschoch-virtualbox 5.3.0-42-generic #34~18.04.1-Ubuntu SMP Fri Feb 28 13:42:26 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux
#!/bin/sh
# create temp directory to do all work
tmpfile=$(mktemp -d)
echo "Working in $tmpfile"
cd $tmpfile
# check out gocbcore
git clone [email protected]:couchbase/gocbcore.git
@mschoch
mschoch / main.go
Created March 10, 2020 14:32
reproduce deleted files still open (as shown by lsof)
package main
import (
"github.com/blevesearch/bleve"
"github.com/blevesearch/bleve/index/scorch"
"log"
)
func main() {
Poky (Yocto Project Reference Distro) SDK installer version 2.1.3
=================================================================
Enter target directory for SDK (default: /opt/poky/2.1.3):
You are about to install the SDK to "/opt/poky/2.1.3". Proceed[Y/n]? Y
[sudo] password for mschoch:
Extracting SDK......................................................................................done
Setting it up...done
SDK has been successfully set up and is ready to be used.
Each time you wish to use the SDK in a new shell session, you need to source the environment setup script e.g.
$ . /opt/poky/2.1.3/environment-setup-cortexa9hf-neon-poky-linux-gnueabi
package main
import (
"log"
"os"
"github.com/couchbase/vellum"
)
func main() {
➜ testscore ./testscore
2018/07/06 12:33:02 scorch
2018/07/06 12:33:02 calling compose for public_likes with length 2
2018/07/06 12:33:02 calling compose for reviews.date with length 7
2018/07/06 12:33:02 calling compose for reviews.ratings.Cleanliness with length 16
2018/07/06 12:33:02 calling compose for reviews.ratings.Location with length 16
2018/07/06 12:33:02 calling compose for reviews.ratings.Overall with length 16
2018/07/06 12:33:02 calling compose for reviews.ratings.Rooms with length 16
2018/07/06 12:33:02 calling compose for reviews.ratings.Service with length 16
2018/07/06 12:33:02 calling compose for reviews.author with length 2
{
"address": "4750 Geary Blvd",
"alias": null,
"checkin": null,
"checkout": null,
"city": "San Francisco",
"country": "United States",
"description": "This former dive has been completely remodeled with clean rooms, nice televisions, microwaves, blowdryers, irons, and mini fridges. Reasonable prices, safe and neat - the owners have put a lot of effort into making this motel quiet and nice.",
"directions": "at 12th Ave",
"email": null,
{
"conjuncts": [
{
"disjuncts": [
{
"match": "planner_hostname_1",
"field": "hostname",
"prefix_length": 0,
"fuzziness": 0
},