Skip to content

Instantly share code, notes, and snippets.

View daixque's full-sized avatar

Dai Sugimori daixque

View GitHub Profile
@daixque
daixque / es_quantization_test.md
Last active October 24, 2025 02:26
Verify the quantizations for vector data on Elasticsearch

Overview

Elasticsearch supports vector search, but when implementing vector search, it is essentially expected that all data resides in RAM (off-heap memory). Previously, there was no way to know how much memory was required by indexes storing vector data, but starting from v9.1, metrics related to vector data can now be obtained.

This article introduces how to obtain these metrics and their meanings. Additionally, we compare the metrics when storing vectors with four types of index options: Flat, HNSW, Int8 HNSW, and BBQ HNSW, and verify the impact of each index option on RAM.

Theoretical Values

Vector data in Elasticsearch is stored in off-heap memory. Off-heap refers to native memory areas outside of the JVM's heap memory. By using off-heap memory, Elasticsearch/Lucene can efficiently handle large amounts of vector data. However, since it is managed separately from the JVM's heap memory, it is not included in regular JVM memory usage metrics. Therefore, it is necessary to obtain off-heap memory u

@daixque
daixque / client.rb
Created February 25, 2012 14:55
RPC over AMQP (RabbitMQ)
require 'amqp'
class Client
def initialize
@config = {
:host => 'localhost'
}
end
def request(api, msg, reply_to)
@daixque
daixque / consumer.rb
Created February 20, 2012 09:32
Sample AMQP consumer/producer for RabbitMQ with direct exchange
require 'amqp'
def run
config = {
:host => 'localhost'
}
AMQP.start(config) do |connection|
channel = AMQP::Channel.new(connection)
queue = channel.queue('', :auto_delete => true)
exchange = channel.direct 'ex.direct'
@daixque
daixque / ArithmeticParser.scala
Created January 14, 2012 09:00
Arithmetic parser/evaluator written in scala using parser combinator
import scala.util.parsing.combinator._
abstract class Value {
def eval():Double
}
case class Number(n:Double) extends Value {
def eval():Double = n
}
case class Binomial(op: String, v1:Value, v2:Value) extends Value {
def eval():Double = op match {