mirror of
https://github.com/hanzoai/traces.git
synced 2026-10-30 18:20:41 +00:00
* starting parquet support starting parquet support. some things are still todo: compaction, find trace by ID Co-Authored-By: Annanay Agarwal <[email protected]> Co-Authored-By: Martin Disibio <[email protected]> * add parquet reusable streaming block * Add parquet compaction * Add findTraceByID logic and parquet -> proto conversion Signed-off-by: Annanay <[email protected]> * Switch findtracebyid to readrow until we get SeekToRow working * Fix error handling in bufferedReaderAt. Add various instrumentation and log messages * Use jsonpb to roundtrip event attributes * Improve buffered reader when reading near end of file. More instrumentation and tidiness * Add totalBlockBytes instrumentation. Fix inspectedBytes instrumentation * parquet.FindTraceByID check bloom * Make compator flush on trace count until we get the row group size target working * Support maxDuration in parquet search * Correct attribute translation for array/kvlist Signed-off-by: Annanay <[email protected]> * extend roundtrip test Signed-off-by: Annanay <[email protected]> * Use default page buffer size * Fix size url param to be uint64 * Increase parquet searches to 1MB stripes * Add test for findtracebyid * make row group size configurable Signed-off-by: Annanay <[email protected]> * Record parquet footer size in block meta and short-circuit header/footer reads * Add tests for SubstringPredicate * Switch compaction to compact blocks of same version, use re-usable buffer in findtracebyid Signed-off-by: Annanay <[email protected]> * Add search support for remaining well-known attributes and span status, add search tests * Benchmark substringPredicate * Make block version configurable, default to v2 * memoize substringPredicate * Update segmentio/parquet-go to catch SeekToRow fix, revert hack in FindTraceByID Signed-off-by: Annanay <[email protected]> * Add multi block prefetch iterator for use in compactor Signed-off-by: Annanay <[email protected]> * Add BufferedWriter with outgoing queue to flush traces async Signed-off-by: Annanay <[email protected]> Make compactor block complete async Signed-off-by: Annanay <[email protected]> * First pass CLI to dump schema and column sizes from block Signed-off-by: Annanay <[email protected]> * honor search start/end time range * Improve error message, add blockID Signed-off-by: Annanay <[email protected]> * Fix race in InstrumentedPredicate with atomics * Make bufferedReaderAt not single-threaded * Debug SeekToRow panic, add test data from vulture tenant Signed-off-by: Annanay <[email protected]> * fix test * repair tests * Address println warnings * Experiment with bookmark prefetch Signed-off-by: Annanay <[email protected]> Remove quitCh from bookmark Signed-off-by: Annanay <[email protected]> * fix prefetch on the bookmarks Signed-off-by: Annanay <[email protected]> * lint * tracker -> RowNumber, lint * delete unused predicates * lint * lint * mod vendor * remove pool from buffered writer queue Signed-off-by: Annanay <[email protected]> * post merge cleanup Signed-off-by: Annanay <[email protected]> * Close quitCh instead of attempting to signal to it Signed-off-by: Annanay <[email protected]> * split multiblock and prefetch iterators, refactor around interface Signed-off-by: Annanay <[email protected]> * Split search into 2 phases to avoid loading traceid/display columns unless there is a match * Make columnIterator.SeekTo do something * update to catch segmentio/parquet-go#220 Signed-off-by: Annanay <[email protected]> * Fix column index to store entire 32-byte trace ID string. lint * Make parquet honor the adjusted start/end times that come from the wal * post merge cleanup: use compaction metric callbacks Signed-off-by: Annanay <[email protected]> * serverless sum/mods Signed-off-by: Annanay <[email protected]> * parquetquery predicates handle column index not present * Make parquet compaction really honor input block start/end times, add universal test at tempodb-level * parquet skip page indexes while searching to reduce latency on openfile * More testing around iterators and combiner Signed-off-by: Annanay <[email protected]> * Update to latest parquet lib to catch rle bitpack fix * Review feedback: LatestEncoding -> DefaultEncoding * Pass block footerSize through serverless * mod vendor for serverless * Fix tests * add blockID to error message in block iterator Signed-off-by: Annanay <[email protected]> * increase readvalues buffer, add more span instrumentation Signed-off-by: Annanay <[email protected]> * changelog and docs * Remove the use of async writer in vparquet compactor Signed-off-by: Annanay <[email protected]> Co-authored-by: Annanay Agarwal <[email protected]>
145 lines
4.0 KiB
Go
145 lines
4.0 KiB
Go
package brotli
|
|
|
|
/* Copyright 2013 Google Inc. All Rights Reserved.
|
|
|
|
Distributed under MIT license.
|
|
See file LICENSE for detail or copy at https://opensource.org/licenses/MIT
|
|
*/
|
|
|
|
/* Block split point selection utilities. */
|
|
|
|
type blockSplit struct {
|
|
num_types uint
|
|
num_blocks uint
|
|
types []byte
|
|
lengths []uint32
|
|
types_alloc_size uint
|
|
lengths_alloc_size uint
|
|
}
|
|
|
|
const (
|
|
kMaxLiteralHistograms uint = 100
|
|
kMaxCommandHistograms uint = 50
|
|
kLiteralBlockSwitchCost float64 = 28.1
|
|
kCommandBlockSwitchCost float64 = 13.5
|
|
kDistanceBlockSwitchCost float64 = 14.6
|
|
kLiteralStrideLength uint = 70
|
|
kCommandStrideLength uint = 40
|
|
kSymbolsPerLiteralHistogram uint = 544
|
|
kSymbolsPerCommandHistogram uint = 530
|
|
kSymbolsPerDistanceHistogram uint = 544
|
|
kMinLengthForBlockSplitting uint = 128
|
|
kIterMulForRefining uint = 2
|
|
kMinItersForRefining uint = 100
|
|
)
|
|
|
|
func countLiterals(cmds []command) uint {
|
|
var total_length uint = 0
|
|
/* Count how many we have. */
|
|
|
|
for i := range cmds {
|
|
total_length += uint(cmds[i].insert_len_)
|
|
}
|
|
|
|
return total_length
|
|
}
|
|
|
|
func copyLiteralsToByteArray(cmds []command, data []byte, offset uint, mask uint, literals []byte) {
|
|
var pos uint = 0
|
|
var from_pos uint = offset & mask
|
|
for i := range cmds {
|
|
var insert_len uint = uint(cmds[i].insert_len_)
|
|
if from_pos+insert_len > mask {
|
|
var head_size uint = mask + 1 - from_pos
|
|
copy(literals[pos:], data[from_pos:][:head_size])
|
|
from_pos = 0
|
|
pos += head_size
|
|
insert_len -= head_size
|
|
}
|
|
|
|
if insert_len > 0 {
|
|
copy(literals[pos:], data[from_pos:][:insert_len])
|
|
pos += insert_len
|
|
}
|
|
|
|
from_pos = uint((uint32(from_pos+insert_len) + commandCopyLen(&cmds[i])) & uint32(mask))
|
|
}
|
|
}
|
|
|
|
func myRand(seed *uint32) uint32 {
|
|
/* Initial seed should be 7. In this case, loop length is (1 << 29). */
|
|
*seed *= 16807
|
|
|
|
return *seed
|
|
}
|
|
|
|
func bitCost(count uint) float64 {
|
|
if count == 0 {
|
|
return -2.0
|
|
} else {
|
|
return fastLog2(count)
|
|
}
|
|
}
|
|
|
|
const histogramsPerBatch = 64
|
|
|
|
const clustersPerBatch = 16
|
|
|
|
func initBlockSplit(self *blockSplit) {
|
|
self.num_types = 0
|
|
self.num_blocks = 0
|
|
self.types = self.types[:0]
|
|
self.lengths = self.lengths[:0]
|
|
self.types_alloc_size = 0
|
|
self.lengths_alloc_size = 0
|
|
}
|
|
|
|
func splitBlock(cmds []command, data []byte, pos uint, mask uint, params *encoderParams, literal_split *blockSplit, insert_and_copy_split *blockSplit, dist_split *blockSplit) {
|
|
{
|
|
var literals_count uint = countLiterals(cmds)
|
|
var literals []byte = make([]byte, literals_count)
|
|
|
|
/* Create a continuous array of literals. */
|
|
copyLiteralsToByteArray(cmds, data, pos, mask, literals)
|
|
|
|
/* Create the block split on the array of literals.
|
|
Literal histograms have alphabet size 256. */
|
|
splitByteVectorLiteral(literals, literals_count, kSymbolsPerLiteralHistogram, kMaxLiteralHistograms, kLiteralStrideLength, kLiteralBlockSwitchCost, params, literal_split)
|
|
|
|
literals = nil
|
|
}
|
|
{
|
|
var insert_and_copy_codes []uint16 = make([]uint16, len(cmds))
|
|
/* Compute prefix codes for commands. */
|
|
|
|
for i := range cmds {
|
|
insert_and_copy_codes[i] = cmds[i].cmd_prefix_
|
|
}
|
|
|
|
/* Create the block split on the array of command prefixes. */
|
|
splitByteVectorCommand(insert_and_copy_codes, kSymbolsPerCommandHistogram, kMaxCommandHistograms, kCommandStrideLength, kCommandBlockSwitchCost, params, insert_and_copy_split)
|
|
|
|
/* TODO: reuse for distances? */
|
|
|
|
insert_and_copy_codes = nil
|
|
}
|
|
{
|
|
var distance_prefixes []uint16 = make([]uint16, len(cmds))
|
|
var j uint = 0
|
|
/* Create a continuous array of distance prefixes. */
|
|
|
|
for i := range cmds {
|
|
var cmd *command = &cmds[i]
|
|
if commandCopyLen(cmd) != 0 && cmd.cmd_prefix_ >= 128 {
|
|
distance_prefixes[j] = cmd.dist_prefix_ & 0x3FF
|
|
j++
|
|
}
|
|
}
|
|
|
|
/* Create the block split on the array of distance prefixes. */
|
|
splitByteVectorDistance(distance_prefixes, j, kSymbolsPerDistanceHistogram, kMaxCommandHistograms, kCommandStrideLength, kDistanceBlockSwitchCost, params, dist_split)
|
|
|
|
distance_prefixes = nil
|
|
}
|
|
}
|