sha256 stringlengths 64 64 | language stringclasses 28
values | size int32 1 491k | lines int32 1 23.2k | content stringlengths 1 200k |
|---|---|---|---|---|
721bbaa5201fdb3419a9e2105ed718adf27254700dc0e7d649c7a42f00fd7111 | Rust | 3,652 | 89 | use axum::body::{Body, HttpBody};
use axum::extract::{rejection::JsonRejection, FromRequest, Request};
use axum::response::IntoResponse;
use axum::{BoxError, RequestExt};
use http_body_util::BodyExt;
use tracing::Instrument;
/// TracedJson is a thin wrapper around axum::Json that allows us to trace the request body bu... |
ae7f01a526762c704c6bf80ec20ca0f4b51780ecc72b8552b8941ed345fb6f42 | Rust | 3,657 | 113 | use crate::common;
use chroma_index::sparse::types::encode_u32;
use chroma_types::DIRECTORY_PREFIX;
#[tokio::test]
async fn blockfile_roundtrip_basic() {
let docs = vec![
(0u32, vec![(1u32, 0.5f32), (2, 0.3)]),
(1, vec![(1, 0.8), (3, 0.2)]),
(2, vec![(2, 0.6), (3, 0.9)]),
];
let (_... |
2349bfd36014ecbde1cbc2bad351cb1d3d0df3a6197b8c5892331b4cb25cab84 | Rust | 3,710 | 130 | //! Collection-scoped conditional transaction example.
//!
//! Run against a Chroma server that supports conditional transactions:
//!
//! ```bash
//! cargo run -p chroma --example conditional_transactions
//! ```
//!
//! Optional environment:
//!
//! ```text
//! CHROMA_ENDPOINT=http://localhost:8000
//! CHROMA_TENANT=... |
845221bbdf549122ad413adaa4d485e8e2096c3e04824c4ce6d67484696c62d0 | Rust | 3,711 | 113 | use chroma_log::CollectionRecord;
use chroma_types::DatabaseName;
use crate::compactor::types::CompactionJob;
pub(crate) trait SchedulerPolicy: Send + Sync + SchedulerPolicyClone {
fn determine(&self, collections: Vec<CollectionRecord>, number_jobs: i32)
-> Vec<CompactionJob>;
}
pub(crate) trait Schedule... |
2d5577c1f9bf550218813ff3c283608486c7d75db11495529e7dbe2d5ffcde88 | Rust | 3,733 | 112 | use crate::{chroma_proto, ConversionError};
use chroma_error::{ChromaError, ErrorCodes};
use thiserror::Error;
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
pub enum SegmentScope {
VECTOR,
METADATA,
RECORD,
SQLITE,
}
impl From<SegmentScope> for String {
fn from(scope: SegmentScope) -> String {
... |
076d02ad45044d8079ca652b54b9d0b3939978540c78c60a92b0773777adbc55 | Rust | 3,744 | 104 | use chroma_storage::config::{RegionalStorage, TopologicalStorage};
use chroma_tracing::{OtelFilter, OtelFilterLevel};
use chroma_types::{MultiCloudMultiRegionConfiguration, RegionName, TopologyName};
use figment::providers::{Env, Format, Yaml};
use serde::{Deserialize, Serialize};
pub use chroma_config::spanner::{Span... |
d0080694032c1e7f41fce5649f4ad70f92825ce90449331b8de669a88d4bc36f | Rust | 3,772 | 109 | use chroma_memberlist::config::CustomResourceMemberlistProviderConfig;
use serde::{Deserialize, Serialize};
#[derive(Deserialize, Clone, Serialize, Debug)]
pub struct GrpcLogConfig {
#[serde(default = "GrpcLogConfig::default_connect_timeout_ms")]
pub connect_timeout_ms: u64,
#[serde(default = "GrpcLogConfi... |
6602957c72787a9fdfcb24e4b5eb0ee313535d9234062d3902b7cbaf829e3a69 | Rust | 3,782 | 101 | //! Embedding function abstractions for converting text to vector representations.
//!
//! This module provides the [`EmbeddingFunction`] trait that defines how to transform
//! text strings into embeddings. Implementations are available for various
//! embedding models, including dense embeddings (Ollama) and sparse e... |
d9759ed6e9a1b1b1d043d7c9ada0966199ff38c60a99fcd1a2873bae4215b686 | Rust | 3,858 | 117 | // This test is simplified since we can't easily simulate storage failures in integration tests.
// The retry logic with backon is tested implicitly through other tests that perform operations.
// For thorough retry testing, unit tests with mocked storage would be more appropriate.
use std::sync::Arc;
use chroma_stor... |
e78abc1eee4cdb87d87356020561947f74b5649b17e088ed9a625393925cfd57 | Rust | 3,860 | 128 | use std::collections::BinaryHeap;
use async_trait::async_trait;
use chroma_distance::DistanceFunction;
use chroma_error::{ChromaError, ErrorCodes};
use chroma_index::spann::types::SpannPosting;
use chroma_types::{operator::RecordMeasure, SignedRoaringBitmap};
use thiserror::Error;
use chroma_system::Operator;
// Pub... |
b57c4e1fc30a0251b03e5bcd2856fd934dd26b9be15c769636b17e4b3ef26c1d | Rust | 3,870 | 126 | use std::cmp::Reverse;
use async_trait::async_trait;
use chroma_error::{ChromaError, ErrorCodes};
use chroma_system::Operator;
use chroma_types::operator::{Merge, RecordMeasure};
use thiserror::Error;
/// The `KnnMerge` operator selects the records nearest to target from the two vectors of records
/// which are both... |
f4e62b52f0ffdbf34ee9001b19fbe24d1f1112a1e90e3e926136f3c2c793b285 | Rust | 3,882 | 117 | #[cfg(target_os = "linux")]
pub(crate) fn pin_current_thread(core_id: usize) -> bool {
if core_id >= libc::CPU_SETSIZE as usize {
return false;
}
// SAFETY: cpu_set_t is initialized before use, core_id bounds are checked,
// and sched_setaffinity is called for the current thread/process (pid 0)... |
e4669684ac09e3d797ed004ef5eb7cd06c8f1caaf2df806319dc0bb22e04cf5f | Rust | 3,889 | 116 | use std::sync::Arc;
use chroma_storage::s3_client_for_test_with_new_bucket;
use wal3::{
create_s3_factories, FragmentManagerFactory, LogPosition, LogReader, LogReaderOptions,
LogWriter, LogWriterOptions, ManifestManagerFactory, S3ManifestManagerFactory, SnapshotOptions,
};
#[tokio::test]
async fn test_k8s_in... |
6a875e595e590481fd82c26741d8906292e2495c9f09292270c927bd8b0a4d6f | Rust | 3,895 | 110 | //! The SSE event schema `/api/agent` emits, plus the projections from the
//! agent's trajectory types into it.
//!
//! [`AgentSseEvent`] is the outbound contract: one JSON object per SSE frame,
//! tagged by `type` with its payload under `data`. The `action_*` /
//! `observation_*` helpers project the agent's [`Actio... |
999b6443f420d1c68572226cb891ca7f18b1844efc1d9655c6df57980fa0396c | Rust | 3,898 | 107 | use super::{BlockfileFlusher, Key, Value};
use crate::arrow::blockfile::ArrowUnorderedBlockfileWriter;
use crate::arrow::ordered_blockfile_writer::ArrowOrderedBlockfileWriter;
use crate::arrow::types::{ArrowWriteableKey, ArrowWriteableValue};
use crate::key::KeyWrapper;
use crate::memory::reader_writer::MemoryBlockfile... |
e76bb5bf55c9ca9be79804b1e8e1b0d49adc9a7653ee3742b7420b3ddc2ec00b | Rust | 3,903 | 104 | use regex_syntax::hir::{self, Class, ClassUnicode, HirKind, Repetition};
use super::ChromaRegexError;
/// Chroma custom internal representation for a Regex pattern.
///
/// This Hir is modeled from regex_syntax::HirKind, with some notable difference:
/// - HirKind::Literal contains a String instead of a Box<[u8]>, be... |
8446229ad7b5feda3c55c27385fc1de1a496261e0a3c4b7a7ffb9974bb23fe42 | Rust | 3,911 | 123 | #![recursion_limit = "256"]
use std::iter::once;
use chroma_benchmark::benchmark::{bench_run, tokio_multi_thread};
use chroma_log::test::{upsert_generator, LoadFromGenerator};
use chroma_segment::test::TestDistributedSegment;
use chroma_system::Operator;
use chroma_types::operator::Filter;
use chroma_types::{
Boo... |
40129bba734e6ba7191fdc2593e47a0e60453f81db0d1826aefcc4079a455bf5 | Rust | 3,933 | 123 | use std::sync::Arc;
use chroma_storage::s3_client_for_test_with_new_bucket;
use wal3::{
create_s3_factories, Cursor, CursorName, CursorStoreOptions, FragmentManagerFactory,
GarbageCollectionOptions, Limits, LogPosition, LogReader, LogReaderOptions, LogWriter,
LogWriterOptions,
};
#[tokio::test]
async fn ... |
9348e0ec749f3efff6a882ac20daacba6b903ab9090102983f70c41401677402 | Rust | 3,982 | 119 | use chroma_system::ReceiverForMessage;
use std::sync::OnceLock;
use tracing::Span;
use crate::{core::MeterEvent, MeteringError};
pub static METER_EVENT_RECEIVER: OnceLock<Box<dyn ReceiverForMessage<MeterEvent>>> =
OnceLock::new();
pub fn meter_event_receiver_initialized() -> bool {
METER_EVENT_RECEIVER.get()... |
a890b0ee2cf3ad5e20806569df16e4fba12fe4c1a8f52f5fbdb687012a2225ad | Rust | 3,983 | 96 | use crate::common;
use chroma_types::SignedRoaringBitmap;
fn all_mask() -> SignedRoaringBitmap {
SignedRoaringBitmap::Exclude(Default::default())
}
/// Documents spanning the 4096-entry window boundary.
/// Verifies that the window loop, accumulator reset, and bitmap
/// zeroing work correctly when documents cros... |
9a0f7397e1b4a60f79678018c39c25fbdffe9c40a23541ce9156df3cca1edefa | Rust | 3,995 | 121 | //! Bootstrap functionality for Spanner emulator.
use std::time::Duration;
use chroma_config::spanner::SpannerEmulatorConfig;
use google_cloud_gax::conn::Environment;
use google_cloud_googleapis::spanner::admin::database::v1::CreateDatabaseRequest;
use google_cloud_googleapis::spanner::admin::instance::v1::{CreateIns... |
969c423a9bae034a75a1e0f6c4c1987938facdfa50093a09c68d3d76c0fa0d99 | Rust | 4,020 | 112 | use std::time::Duration;
use chroma_benchmark::datasets::types::{FrozenQuerySubset, QueryDataset, RecordDataset};
use futures::TryFutureExt;
use indicatif::{MultiProgress, ProgressBar, ProgressStyle};
pub async fn get_record_dataset<RecordCorpus: RecordDataset>() -> RecordCorpus {
let style = ProgressStyle::defau... |
bd8273fa05b1098df08f96bee706500b75bcff5cdfb6c02d942ade86a0deab35 | Rust | 4,035 | 122 | use std::sync::Arc;
use crate::{
arrow::{
block::delta::{
single_column_size_tracker::SingleColumnSizeTracker,
single_column_storage::SingleColumnStorage, BlockStorage, UnorderedBlockDelta,
},
types::{ArrowReadableValue, ArrowWriteableKey, ArrowWriteableValue},
}... |
697ccad644531348b3f8a32eb874468031c7649d307609a44426ef0139251bf1 | Rust | 4,076 | 149 | use crate::client::utils::send_request;
use reqwest::header::{HeaderMap, HeaderValue, COOKIE};
use reqwest::Method;
use serde::{Deserialize, Serialize};
use thiserror::Error;
#[derive(Debug, Error)]
pub enum DashboardClientError {
#[error("Failed to parse session cookies")]
CookiesParse,
#[error("Failed to... |
5cdbe112f611839b2f1b0c1e866a667dcecc0d802ace7aacc77bbedab309908e | Rust | 4,086 | 112 | use std::sync::Arc;
use chroma_storage::s3_client_for_test_with_new_bucket;
use wal3::{
create_s3_factories, now_micros, upload_parquet, FragmentIdentifier, FragmentManagerFactory,
FragmentSeqNo, LogPosition, LogReaderOptions, LogWriter, LogWriterOptions, Manifest,
ManifestManagerFactory,
};
mod common;
... |
546d04e023a7255cf0feaf2b9f920b0acff936246ebec2c68a615ada37a1c638 | Rust | 4,102 | 123 | use std::sync::Arc;
use crate::{
arrow::{
block::delta::{
single_column_size_tracker::SingleColumnSizeTracker,
single_column_storage::SingleColumnStorage, BlockStorage, UnorderedBlockDelta,
},
types::{ArrowReadableValue, ArrowWriteableKey, ArrowWriteableValue},
}... |
a5b31058bdeae681e7ee9fab00f02715fe87bc88794356badd2f55fffa1a8c47 | Rust | 4,128 | 119 | //! Shared attached-function helpers for HTTP frontends.
use chroma_sysdb::SysDb;
use chroma_types::{
operators_generated::FUNCTION_COUNT_TO_FILE_ASYNC_NAME, AttachFunctionError, AttachedFunction,
AttachedFunctionUuid, CollectionUuid, DatabaseName,
};
#[derive(Debug)]
pub struct AddAttachedFunctionInputResult... |
2ce49375e50d9d91d8e8fdb1d1ef875c4e013d82f79100e3b8f1118a9d2e10aa | Rust | 4,182 | 137 | use chroma_cache::CacheConfig;
use serde::{Deserialize, Serialize};
#[derive(Deserialize, Debug, Clone, Default, Serialize)]
pub struct HnswProviderConfig {
#[serde(default = "HnswProviderConfig::default_hnsw_temporary_path")]
pub hnsw_temporary_path: String,
#[serde(default)]
pub hnsw_cache_config: Ca... |
7d3c6fa380779b7cb6b59497676ebf7718e48f11a9f1966d9da88152478edc47 | Rust | 4,203 | 113 | use std::{collections::HashMap, path::PathBuf};
use super::{
types::{QueryDataset, Record, RecordDataset},
util::get_or_populate_cached_dataset_file,
};
use anyhow::{anyhow, Result};
use bloom::{BloomFilter, ASMS};
use futures::FutureExt;
use tokio::{fs::File, io::AsyncBufReadExt};
use tokio_stream::{wrappers:... |
eb04d641db4bbfd844fbb75e0f8fa964b8bfc45d99fb75a61a14b170217709e9 | Rust | 4,213 | 109 | //! Retry policy for transient sysdb failures.
//!
//! Setup operations (creating databases, collections, and attached functions)
//! talk to sysdb over gRPC. A momentary backend hiccup — the service briefly
//! `UNAVAILABLE`, an aborted Spanner transaction, a missed deadline — should
//! not fail the whole operation. ... |
c8d8f8a9944e433082cb705cad4fb746bd33f7ffb55687ea1abe9745af942125 | Rust | 4,217 | 109 | //! Regression test: incremental commits must not lose postings when a
//! dimension's posting blocks straddle an Arrow blockfile block boundary.
//!
//! With small Arrow blocks, the Arrow block containing a dimension's
//! first posting block can start at a sparse-index delimiter carrying an
//! EARLIER dimension's pr... |
553aad50feb19ef7ad1c2b800d6c9666f1e5b35d195c9fe6b18289a19971cf0f | Rust | 4,238 | 129 | use chroma_types::{are_metadatas_close_to_equal, GetResponse};
use ndarray::{Array, Array2};
fn embeddings_list_to_ndarray(embeddings: &[Vec<f32>]) -> Array2<f32> {
if embeddings.is_empty() {
return Array::from_shape_vec((0, 0), vec![]).unwrap();
}
let n = embeddings.len();
let d = embeddings[... |
fa1b772ac501487c6893ace694ce94f68855485ab6b2f1443856520d258d3e27 | Rust | 4,251 | 123 | use crate::{
arrow::{
block::delta::{
single_column_size_tracker::SingleColumnSizeTracker,
single_column_storage::SingleColumnStorage, BlockStorage, UnorderedBlockDelta,
},
types::{ArrowReadableValue, ArrowWriteableKey, ArrowWriteableValue},
},
key::KeyWrapper... |
2f4db9d9a6e244dd3e20feeb369f754a38ff27db15f50d00d17337276293683a | Rust | 4,299 | 121 | use crate::common;
use chroma_index::sparse::maxscore::PostingCursor;
use chroma_types::{SignedRoaringBitmap, SparsePostingBlock};
fn all_mask() -> SignedRoaringBitmap {
SignedRoaringBitmap::Exclude(Default::default())
}
#[test]
fn cursor_sequential_advance() {
let block =
SparsePostingBlock::from_sor... |
fe36cf412394cb31d951c11d23964838fe476f894712ee37ee50a92358241615 | Rust | 4,328 | 85 | use super::block::delta::{BlockKeyArrowBuilder, BlockStorage, UnorderedBlockDelta};
use crate::{key::KeyWrapper, BlockfileWriterMutationOrdering, Key, Value};
use arrow::{array::Array, datatypes::Field};
use std::sync::Arc;
pub trait ArrowWriteableKey: Key + Default {
type ReadableKey<'referred_data>: ArrowReadabl... |
2bfbe9dbd017bc70fe766a7824832d1a2cbdf474ef2e80305f9778d8a03c6596 | Rust | 4,329 | 120 | use chroma_api_types::{StaleReadError as ApiStaleReadError, CONDITIONAL_WRITE_CONFLICT_MESSAGE};
use chroma_error::{source_chain_contains, ChromaError, ErrorCodes};
use chroma_log::PushLogsError;
use chroma_types::{ConditionalCommitError, ConditionalTransactionError};
use pyo3::PyErr;
use thiserror::Error;
pyo3::impor... |
7e2a8542d4d2f589cfd97e41e13df1e36fa2b50e284aa16ff1bf42d6afedbd42 | Rust | 4,335 | 134 | use super::{
reader_writer::{MemoryBlockfileReader, MemoryBlockfileWriter},
storage::{Readable, StorageManager},
};
use crate::{
arrow::types::{ArrowReadableKey, ArrowReadableValue},
key::{InvalidKeyConversion, KeyWrapper},
provider::{CreateError, OpenError},
BlockfileReader, BlockfileWriter, Bl... |
4b4943382670946963c2fe1555b8eb79843edf33ff2d16cb5553a95426d72223 | Rust | 4,388 | 136 | use crate::common;
use chroma_index::sparse::maxscore::PostingCursor;
use chroma_index::sparse::types::encode_u32;
use chroma_types::SignedRoaringBitmap;
fn all_mask() -> SignedRoaringBitmap {
SignedRoaringBitmap::Exclude(Default::default())
}
#[tokio::test]
async fn lazy_cursor_advance_matches_eager() {
let ... |
28ce7cddc883862ce70971afb5bf6192ede2a8076f5c314b2ce22ce4cd7dc0a1 | Rust | 4,404 | 146 | use std::{path::Path, sync::Arc};
pub mod config;
#[allow(dead_code)]
pub mod executor;
pub mod get_collection_with_segments_provider;
pub mod impls;
pub mod quota;
pub mod server;
mod types;
// Re-export scaffolding from frontend-core so that internal modules can keep
// referring to `crate::ac::*`, `crate::auth::*`... |
0c275711c1aa294b9a091f52ff05994e6b0dbd7f6279138aa2403fe6cb2c10b2 | Rust | 4,411 | 144 | use chroma_benchmark::datasets::sift::Sift1MData;
use chroma_log::{in_memory_log::InMemoryLog, test::modulo_metadata, Log};
use chroma_segment::test::TestDistributedSegment;
use chroma_types::{
operator::{Filter, Limit, Projection},
Chunk, CollectionUuid, LogRecord, MetadataComparison, MetadataExpression, Metad... |
e7239ced045a3ee0800dc8986e23513fafd56c84d093f6ad3a27cb814c48c705 | Rust | 4,442 | 137 | use std::sync::Arc;
use chroma_storage::s3_client_for_test_with_new_bucket;
use uuid::Uuid;
use wal3::{
create_repl_factories, LogWriter, LogWriterOptions, Manifest, ManifestConsumer,
ManifestManagerFactory, ReplicatedManifestManagerFactory, StorageWrapper,
};
mod common;
use common::{default_repl_options, s... |
dcf6be585e9d517398a49c1bb2bec2fd7e8edd473d40aade37bb6c2faa4ca76c | Rust | 4,475 | 122 | use http::HeaderValue;
use opentelemetry::trace::TraceContextExt;
use std::{
future::Future,
pin::Pin,
task::{Context, Poll},
};
use tonic::{body::Body, transport::Error, Code};
use tower::{Layer, Service};
use tracing::{field::Empty, info_span, Instrument, Span};
use tracing_opentelemetry::OpenTelemetrySpa... |
df33ddc90efb1f2e4d953109758d7357f2580c444f15cf046fba574b9246d031 | Rust | 4,481 | 108 | use std::fmt;
use proc_macro2::TokenStream;
/// A compile-time error generated while attempting to parse the tokens provided to the
/// [`crate::initialize_metering`] macro.
#[derive(Debug)]
pub enum MeteringMacrosError {
SynError(syn::Error),
// Capability-related errors
InvalidCapabilityAttribute(proc_m... |
1ef2060b31d1e4c2b561aa2bbcfe3d5e8ecfa83b64e15bc4de89b62c4499303a | Rust | 4,488 | 168 | use super::Key;
use chroma_error::{ChromaError, ErrorCodes};
use serde::{Deserialize, Serialize};
use std::hash::{Hash, Hasher};
// TODO(rescrv): This used to be a panic/unwrap, but could be a nicer type.
#[derive(thiserror::Error, Debug)]
#[error("runtime type error")]
pub struct InvalidKeyConversion;
impl ChromaEr... |
6edc79b440117506b1a4823955ce1cc74c84f6ca16b15253a6a0197e8f6ee749 | Rust | 4,494 | 136 | use chroma_error::{ChromaError, ErrorCodes};
use thiserror::Error;
pub const STALE_READ_ERROR_NAME: &str = "StaleReadError";
/// Identifies the log upper bound that defines an OCC read snapshot.
///
/// A token is captured from a read that has observed a concrete log upper
/// bound. Later reads can use the token to ... |
b50fb1de0a91edaa902a3b8f6269fa5f90ceec8b8ccd6231640a937a233adb5a | Rust | 4,495 | 109 | use chroma_memberlist::config::CustomResourceMemberlistProviderConfig;
use serde::{Deserialize, Serialize};
/// Configuration for the gRPC heap service client.
///
/// This configures how to connect to the heap tender service instances via memberlist.
#[derive(Deserialize, Clone, Serialize, Debug)]
pub struct GrpcHeap... |
6a8f40af152dae238e883e968f7f25270a4e9bbece210beea650c5cfc075fbca | Rust | 4,509 | 125 | use proc_macro2::{Ident, TokenStream};
use quote::quote;
use std::collections::HashMap;
use crate::capabilities::Capability;
/// Represents a user-defined context. A context is set of fields that, by way of handlers,
/// can be modified whenever a capability that is registered for the context is called.
#[derive(Debu... |
9b4a13e6f6f69b8dc5a970114d378cef54160927a568b3eb1c253172b9bb2d12 | Rust | 4,513 | 113 | use crate::utils::{CliError, UtilsError};
use arboard::Clipboard;
use clap::ValueEnum;
use colored::Colorize;
use crossterm::event::{Event, KeyCode, KeyEvent};
use crossterm::terminal::{disable_raw_mode, enable_raw_mode};
use crossterm::{cursor, event, ExecutableCommand};
use regex::Regex;
use serde::{Deserialize, Seri... |
537057d86e61c1a649592b59e0885b0af6e31bd528fe4a9062027082105b8d92 | Rust | 4,520 | 136 | use std::sync::Arc;
use chroma_storage::s3_client_for_test_with_new_bucket;
use wal3::{
create_s3_factories, FragmentManagerFactory, Limits, LogPosition, LogReader, LogReaderOptions,
LogWriter, LogWriterOptions, Manifest, ManifestManagerFactory, S3ManifestManagerFactory,
SnapshotOptions,
};
#[tokio::test... |
ca0d2ad3633858e91e47722d6e68d9b707881df2e6c464f8972b1fa257e5c298 | Rust | 4,543 | 151 | pub fn merge_sorted_vecs_disjunction<T: Ord + Clone>(a: &[T], b: &[T]) -> Vec<T> {
let mut result = Vec::with_capacity(a.len() + b.len());
let mut a_idx = 0;
let mut b_idx = 0;
while a_idx < a.len() || b_idx < b.len() {
if a_idx == a.len() {
result.push(b[b_idx].clone());
... |
ca6fa0ab3b57c52c73d59bf6c42be1498355011e4de99bf41776db4766be99fb | Rust | 4,543 | 147 | use crate::common;
use chroma_types::SignedRoaringBitmap;
fn all_mask() -> SignedRoaringBitmap {
SignedRoaringBitmap::Exclude(Default::default())
}
#[tokio::test]
async fn three_batch_basic_correctness() {
let vectors = vec![
(0u32, vec![(1u32, 0.5f32), (2, 0.3)]),
(1, vec![(1, 0.1), (2, 0.9)]... |
26571cfac615c044a686f380f512891663e7c07ac08a5995c27a3d550c723384 | Rust | 4,566 | 149 | use std::sync::Arc;
use chroma_storage::s3_client_for_test_with_new_bucket;
use uuid::Uuid;
use wal3::{
create_repl_factories, FragmentManagerFactory, Limits, LogPosition, LogReader,
LogReaderOptions, LogWriter, LogWriterOptions, ManifestManagerFactory, SnapshotOptions,
StorageWrapper,
};
mod common;
use... |
51ab2d38bf31da3ebeb00cf8a8206d018b5607d91dba05e89329e319d229e9f1 | Rust | 4,647 | 155 | //! Product-owned Foundation identities and their backing Chroma databases.
//!
//! Implementations authorize every operation using the original caller. A
//! service credential identifies the registrar; it never expands caller access.
//! Implementations must reserve identities atomically and never rebind a name
//! t... |
c0bd17ba487d95c649fd762e337abd9a43dd56afc6c62595ec3505e5f00b2a59 | Rust | 4,654 | 157 | use async_trait::async_trait;
use chroma_error::ChromaError;
use chroma_storage::{GetOptions, Storage};
use chroma_system::{Operator, OperatorType};
use chroma_types::chroma_proto::CollectionLineageFile;
use prost::Message;
use thiserror::Error;
#[derive(Clone)]
pub struct FetchLineageFileInput {
storage: Storage,... |
320ff121262ed3aa44de1b8ecdd0fc59da9d268fd8ee9e73e35617cb53c3f08f | Rust | 4,663 | 141 | use crate::commands::db::get_db_name;
use crate::commands::install::InstallError;
use crate::config_store::{ConfigStore, FileConfigStore};
use crate::terminal::{SystemTerminal, Terminal};
use crate::tui::collection_browser::CollectionBrowser;
use crate::ui_utils::Theme;
use crate::utils::{cloud_client, connect_local, C... |
f0bfe8af1fc1b22a68676ecf1f01a9102e88759ad4e5448df40a9fbc229eb6f8 | Rust | 4,663 | 167 | use async_trait::async_trait;
use chroma_error::ChromaError;
use chroma_sysdb::SysDb;
use chroma_system::{Operator, OperatorType};
use chroma_types::{BatchGetCollectionVersionFilePathsError, CollectionUuid, DatabaseName};
use std::collections::HashMap;
use thiserror::Error;
#[derive(Clone, Debug)]
pub struct GetVersio... |
dd06b6070cf7ef28fab4bc5c103f343612dd300b12b03938f0efc8005fa2467c | Rust | 4,672 | 144 | #![recursion_limit = "256"]
use std::sync::atomic::{AtomicU64, Ordering};
use std::sync::Arc;
use std::time::{Duration, Instant};
use chrono::{DurationRound, Utc};
use guacamole::combinators::*;
use guacamole::Guacamole;
use chroma_storage::s3::s3_client_for_test_with_bucket_name;
use uuid::Uuid;
use s3heap::{
E... |
5305cf26afcb35f9f150ff06c96a2af4091e0680c4e953fcbc0d1118fe56eba3 | Rust | 4,707 | 105 | //! Verify durable compaction progress before rejecting writes for a full log.
use super::*;
// Concurrent rejected requests share a short-lived result rather than each reading storage.
const BACKPRESSURE_CURSOR_MAX_AGE: Duration = Duration::from_secs(1);
#[derive(Serialize, Deserialize)]
pub(super) struct VerifiedCu... |
40360483f3c9e8780a0376383720daaa3f8ef51b1a1fce744274a72b1a1c50f1 | Rust | 4,726 | 139 | //! `read_page` agent tool: reconstruct a single wiki page in full by slug.
//!
//! Wraps the same [`read_page_from_collection`] core the `POST /api/read-page`
//! route and the `read_page` MCP tool use, so every surface reassembles pages
//! the same way. The per-request state (the resolved collection, the tenant,
//!... |
18cc446e690d6482753db31bece9ce31145b0b3d75732c7b326cb0ea2523fa05 | Rust | 4,746 | 164 | //! Lightweight helpers for recording OpenTelemetry metrics.
use std::time::{Duration, Instant};
use opentelemetry::{metrics::Histogram, KeyValue};
/// Unit used when recording elapsed time in a histogram.
pub enum StopWatchUnit {
Micros,
Millis,
Seconds,
}
/// Records elapsed time once, on explicit com... |
85549f30133dde182e807e06c41c48bc169db979bf1ca877cb4ec548ed49bc01 | Rust | 4,746 | 129 | use anyhow::Result;
use async_tempfile::TempFile;
use std::{future::Future, path::PathBuf};
use tokio::io::{AsyncWrite, AsyncWriteExt};
pub(crate) fn get_dir_for_persistent_dataset_files() -> PathBuf {
PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("dataset_files")
}
async fn get_dataset_cache_path(
dataset_n... |
262bab82b3138adfe324c8ca65a48d12faa7bc075cb2384e10f04825de57f424 | Rust | 4,762 | 109 | //! Shared spec for the `slack_raw` append-log collection.
//!
//! Real-time Slack messages are written as raw, single records to
//! `slack_raw` (an append log). Record **metadata** (channel/team/thread/op)
//! is inverted-indexed so records are filterable at read time, while the
//! text/vector indexes stay disabled:... |
7c8090011d2c7112fc704f82fc41e28b67099d5d30aed28d7c4395bc22d6b612 | Rust | 4,768 | 147 | use std::future::Future;
use chroma_error::ChromaError;
use chroma_types::{
operator::{CountResult, GetResult, KnnBatchResult, SearchResult},
plan::{Count, Get, Knn, Search},
ExecutorError, Segment, SegmentType,
};
use distributed::DistributedExecutor;
use local::LocalExecutor;
//////////////////////// Ex... |
daa6ddc94dcc40338f22d4e4229bc1e8e988a577c865a2a432e4990a5353ba59 | Rust | 4,823 | 146 | use std::sync::Arc;
use chroma_storage::{s3_client_for_test_with_new_bucket, GetOptions};
use uuid::Uuid;
use wal3::{
create_repl_factories, Cursor, CursorName, CursorStore, CursorStoreOptions, Error,
GarbageCollectionOptions, LogPosition, LogWriter, LogWriterOptions, SnapshotOptions,
StorageWrapper,
};
... |
44f626dc93899bae5fb6f829c5ae7d406edfd06c61430643d7d3355b47a479a7 | Rust | 4,917 | 162 | use std::{path::Path, time::Duration};
use crate::db::{SqliteCreationError, SqliteDb};
use async_trait::async_trait;
use chroma_config::{
registry::{Injectable, Registry},
Configurable,
};
use serde::{Deserialize, Serialize};
use sqlx::sqlite::{SqliteConnectOptions, SqlitePoolOptions};
use tokio::fs::create_di... |
7804eed3da3a76b1275ff2784266103599df76260bd5d9e45eb62bec686c208d | Rust | 4,921 | 138 | use async_trait::async_trait;
use chroma_error::ChromaError;
use chroma_segment::blockfile_record::{
RecordSegmentReader, RecordSegmentReaderOptions, RecordSegmentReaderShardCreationError,
};
use chroma_segment::types::{
materialize_logs, LogMaterializerError, PartitionedMaterializeLogsResult,
};
use chroma_sys... |
b29db99de9d00720d2ec86adfc71f0028fdc55571d8bde65925d4549010f3e7e | Rust | 4,941 | 137 | //! OAuth protected-resource discovery for the Foundation MCP endpoint.
//!
//! Serves the protected-resource metadata document and derives the public URLs
//! (the resource identifier and the authorization server) advertised to MCP
//! clients during OAuth discovery.
use axum::{extract::State, Json};
use serde::Seria... |
95819ed6de9bffd8a341cd1a3236346139dc43182d7c5d5d2697a5c184ae3b37 | Rust | 4,975 | 157 | use async_trait::async_trait;
use chroma_blockstore::provider::BlockfileProvider;
use chroma_config::{registry::Registry, Configurable};
use chroma_error::ChromaError;
#[cfg(feature = "usearch")]
use chroma_index::usearch::USearchIndexProvider;
use chroma_index::{
config::SpannProviderConfig,
hnsw_provider::Hns... |
1db8e30f5c8e90b1749c5843316426a57622e4f07e5d5fe31b855e4c0645fc46 | Rust | 4,986 | 182 | //! This file is not intended for public consumption, but is kept for completeness.
//!
//! In this file you will find that we reason about the bootstrap process by completely exploring
//! the state space and pruning known good states. The goal is to prune every state or print a
//! list of states that are bad.
//!
/... |
13b807e1801d7b76dba023d2b6a9ebbd8d344ee7cdafbd69bc4c2ec64f3f947c | Rust | 4,993 | 148 | use crate::config::RootConfig;
use crate::work_queue::work_queue_manager::{WorkQueueManager, WorkQueueReadyMessage};
use crate::work_queue::work_queue_server::WorkQueueServer;
use chroma_config::assignment::assignment_policy::RendezvousHashingAssignmentPolicy;
use chroma_config::registry::Registry;
use chroma_config::C... |
4ff318612b603f0db558f2755f16698980a3f0755544330d57f0ea05d4893cdd | Rust | 4,993 | 146 | use async_trait::async_trait;
use chroma_error::{ChromaError, ErrorCodes};
use chroma_segment::blockfile_record::RecordSegmentReaderShard;
use chroma_system::Operator;
use chroma_types::{Chunk, LogRecord, OperationRecord};
use futures::{StreamExt, TryStreamExt};
use thiserror::Error;
/// The `SourceRecordSegmentOperat... |
27f110b71840317a0fc6cfbf9890fce0c55e8329bc9550883308ea335ccfef4a | Rust | 5,010 | 150 | use chroma_error::{ChromaError, ErrorCodes};
use chroma_types::{
Operation, OperationRecord, ScalarEncoding, UpdateMetadata, UpdateMetadataValue,
CHROMA_DOCUMENT_KEY, CHROMA_URI_KEY,
};
#[derive(thiserror::Error, Debug)]
pub(crate) enum ToRecordsError {
#[error("Inconsistent number of IDs, embeddings, docu... |
3ec3b66e4e25d2895adaec142334af582481ff061cb5f3a2cfee93b6cf72a9a8 | Rust | 5,010 | 170 | use std::collections::HashMap;
use async_trait::async_trait;
use chroma_segment::test::TestDistributedSegment;
use chroma_types::{Chunk, LogRecord, Operation, OperationRecord, UpdateMetadataValue};
use rand::{
distributions::{Alphanumeric, Open01},
thread_rng, Rng,
};
pub const TEST_EMBEDDING_DIMENSION: usize... |
8ac84da01e5c51040b6f1a34b86e4995712e0725f908a251224ff764c3810f00 | Rust | 5,019 | 150 | use crate::arrow::root::{RootWriter, Version};
use crate::arrow::sparse_index::SparseIndexWriter;
use crate::arrow::sparse_index::{AddError, SetCountError};
use crate::key::CompositeKey;
use crate::RootManager;
use chroma_cache::nop::NopCache;
use chroma_error::ChromaError;
use chroma_storage::Storage;
use uuid::Uuid;
... |
82332b32293538caae4c99a26fe11a93e06153f4015d841ce2028ea488df9766 | Rust | 5,058 | 145 | use super::{dispatcher::TaskRequestMessage, operator::TaskMessage};
use crate::execution::affinity::{cpu_core_for_worker, pin_current_thread};
use crate::{
utils::duration_ms, Component, ComponentContext, ComponentRuntime, Handler, ReceiverForMessage,
};
use async_trait::async_trait;
use std::fmt::{Debug, Formatter... |
798620a80597b71445cd72a8845edc5d7a52101ecce3d2df02a9fecf24f59b3a | Rust | 5,070 | 154 | use async_trait::async_trait;
use chroma_error::ChromaError;
use chroma_sysdb::sysdb::SysDb;
use chroma_system::{Operator, OperatorType};
use chroma_types::{
AttachedFunction, AttachedFunctionConversionError, AttachedFunctionUuid, CollectionUuid,
ListAttachedFunctionsError,
};
use thiserror::Error;
/// The `Ge... |
cc4adc61210697ea31f687ce0e4b1f0617497d474e683812a9a3a641fb23a5e4 | Rust | 5,073 | 127 | //! Builds the Messages API request body from an [`InferenceContext`].
use serde_json::{json, Value};
use super::AnthropicAgentInferenceModel;
use crate::inference::InferenceContext;
use crate::provider::ProviderFormat;
impl AnthropicAgentInferenceModel {
pub(super) fn request_body(&self, ctx: &InferenceContext<... |
acfdfe6180190143ee749e50b4d2fe792fc7f8017f33fdac22b0cff2290dcc2e | Rust | 5,083 | 160 | use chroma_distance::DistanceFunction;
use criterion::{criterion_group, criterion_main, Criterion};
use rand::Rng;
fn distance_metrics(c: &mut Criterion) {
c.bench_function("distance_metrics", |b| {
let mut x: Vec<f32> = Vec::with_capacity(786);
for _ in 0..x.capacity() {
x.push(rand::r... |
9433022b1fae4fd40dfb8cb6c257e7233edbfc6b951d75e22480c9730f602059 | Rust | 5,085 | 119 | //! Type definitions and re-exports for client requests and responses.
pub use chroma_api_types::{GetUserIdentityResponse, HeartbeatResponse};
pub use chroma_types::{IndexStatusError, IndexStatusResponse};
pub use chroma_types::operator::rrf;
pub use chroma_types::operator::Aggregate;
pub use chroma_types::operator::... |
b6304fc5c4844c80c5ce358f6abe60871afd135ba5905b9639533ccca562c0e4 | Rust | 5,140 | 174 | use crate::terminal::{SystemTerminal, Terminal};
use crate::ui_utils::{HOLIDAY_LOGO, LOGO};
use crate::utils::CliError;
use chroma_frontend::config::FrontendServerConfig;
use chroma_frontend::frontend_service_entrypoint_with_config;
use chrono::{Datelike, Local};
use clap::Parser;
use colored::Colorize;
use std::net::T... |
aada53b85540a93e016875b2b4db19248a31e0fc0b5ecc297a02627b0114dd0c | Rust | 5,142 | 149 | use async_trait::async_trait;
use chroma_error::{ChromaError, ErrorCodes};
use chroma_log::Log;
use chroma_sysdb::SysDb;
use chroma_system::Operator;
use chroma_types::{AttachedFunctionUpdateInfo, AttachedFunctionUuid, CollectionFlushInfo};
use thiserror::Error;
use tonic;
/// The finish attached function operator is ... |
8aa750385a525914b90763130ee465ea370d99f4cac5a7e6d49f1092790fa001 | Rust | 5,162 | 279 | use std::collections::HashSet;
use std::sync::LazyLock;
use rust_stemmers::{Algorithm, Stemmer};
use crate::embed::Tokenizer;
/// Default English stopwords array for BM25 tokenization.
///
/// This list is derived from NLTK's English stopwords. Total: 179 stopwords.
const DEFAULT_ENGLISH_STOPWORDS_ARRAY: &[&str] = &... |
adcece65914932a95400ab3416c056c8c9881e1160a16fcfe129723203d24fee | Rust | 5,162 | 146 | use crate::common;
use chroma_index::sparse::maxscore::PostingCursor;
use chroma_types::{SignedRoaringBitmap, SparsePostingBlock};
fn all_mask() -> SignedRoaringBitmap {
SignedRoaringBitmap::Exclude(Default::default())
}
/// Build a view cursor from entry slices. Returns the owned raw bytes
/// (must stay alive) ... |
6478f01e2f9b9c19a69174cea85e20e260c80eb58d62e1714df33aa9c5eabc57 | Rust | 5,203 | 177 | #![recursion_limit = "256"]
use std::sync::Arc;
use std::time::{Duration, Instant};
use guacamole::combinators::*;
use guacamole::Guacamole;
use chroma_storage::s3::s3_client_for_test_with_bucket_name;
use chroma_storage::Storage;
use wal3::{create_s3_factories, Error, LogReaderOptions, LogWriter, LogWriterOptions};... |
b06226b78be63553de950df984c98db739c4f1b9bc1f286f403c042ed9bf716c | Rust | 5,269 | 141 | use std::{fmt::Debug, sync::Arc, time::Duration};
use chroma_config::{
registry::Registry,
spanner::{SpannerChannelConfig, SpannerConfig, SpannerSessionPoolConfig},
Configurable,
};
use chroma_error::{ChromaError, ErrorCodes};
use chroma_storage::{config::StorageConfig, Storage};
use chroma_types::MultiClo... |
2f698072df32b3432a2b800b3592c6f50b72fc2f8883abdea8f346e96bbe7ace | Rust | 5,271 | 166 | use chrono::{Duration, DurationRound, TimeDelta, Utc};
use s3heap::{HeapReader, HeapWriter, Limits, Schedule};
mod common;
use common::{
create_test_triggerable, setup_test_environment, test_nonce, test_time_at_minute_offset,
verify_bucket_count,
};
#[tokio::test]
async fn test_k8s_integration_03_merge_same_... |
71684ec3c903b738dcef08dbb2b4a3978029ab0306b745bd966ee78e7e8f851b | Rust | 5,321 | 179 | #![recursion_limit = "256"]
use std::sync::atomic::{AtomicUsize, Ordering};
use std::sync::Arc;
use std::time::Duration;
use chroma_storage::s3_client_for_test_with_new_bucket;
use wal3::{
create_s3_factories, Error, LogReaderOptions, LogWriter, LogWriterOptions, Manifest,
ManifestManagerFactory, S3ManifestM... |
f04d7e41eb637820978b691e4519c2599e9920ba6b66b2a854b4e48ba7ea87e3 | Rust | 5,350 | 175 | use std::collections::HashMap;
use std::fmt::Debug;
use chroma_error::{ChromaError, ErrorCodes};
use chroma_types::{CollectionUuid, LogRecord};
use thiserror::Error;
use crate::types::CollectionInfo;
#[derive(Error, Debug)]
pub enum InMemoryLogError {
#[error("Failed to update log offset (simulated failure)")]
... |
71276fb9a0eaa31224e5c5a5c77f230745b41d57b291f4689cbfe162fbae04de | Rust | 5,440 | 161 | use serde::{Deserialize, Serialize};
// A canonical UUID in GetWorkRequest.excluded_fn_ids encodes as a one-byte
// field tag, a one-byte length, and 36 bytes of UTF-8 data.
const ENCODED_EXCLUDED_FN_ID_BYTES: usize = 38;
pub(crate) fn validate_max_concurrent_workers(
max_concurrent_workers: usize,
max_request... |
0aa26dbb5ef7e5749647eafafff78bedcd60672989ac1811d7735f48b03e9f39 | Rust | 5,493 | 139 | //! A perfect backoff algorithm.
//!
//! This algorithm is based upon the following insight: The integral of system headroom across the
//! recovery window must be at least as large as the integral of the system downtime during an
//! outage.
//!
//! It looks like this:
//! ```text
//! │
//! │ ... |
e7d0da5cf1f83a39a3716a7b8b654fea81034aae41e473bf4433753016dccc12 | Rust | 5,553 | 186 | #![recursion_limit = "256"]
use std::sync::atomic::{AtomicUsize, Ordering};
use std::sync::Arc;
use std::time::Duration;
use chroma_storage::s3_client_for_test_with_new_bucket;
use uuid::Uuid;
use wal3::{
create_repl_factories, Error, LogWriter, LogWriterOptions, Manifest, ManifestManagerFactory,
ReplicatedM... |
82fefcc53e8dd1b9f391421a3cd017d516e124515714ae7b69a710234453a711 | Rust | 5,574 | 171 | //! Spanner migration CLI binary.
use chroma_tracing::{init_global_filter_layer, init_otel_layer, init_stdout_layer, init_tracing};
use clap::{Parser, Subcommand};
use spanner_migrations::{run_migrations, MigrationMode, RootConfig, MIGRATION_DIRS};
/// Validates that the provided slug exists in MIGRATION_DIRS.
fn val... |
e83c902dc9514ac8250aa56c80c372cb22eb7d04d505abdd3deb8ac00e1bb206 | Rust | 5,596 | 128 | #![allow(missing_docs)]
use chroma::types::{Metadata, MetadataValue, UpdateMetadata, UpdateMetadataValue};
use super::error::TrajectoryError;
use super::ids::{decode_fixed_base36_to_be_bytes, decode_index, hex_lower, tid_to_uuid};
use super::limits::{CHUNK_INDEX_WIDTH, ENTRY_INDEX_WIDTH, ITEM_ID_WIDTH};
/// Convert ... |
0fb07d344664fcb6a67371072295eac3c17e5c66172dd4b9f12f815ccd7d47a1 | Rust | 5,637 | 153 | //! Pure unit tests: model-string mapping, trajectory-to-event projections, and
//! the wire serialization of [`AgentSseEvent`].
use super::super::events::{
action_event, action_text, observation_event, AgentSseEvent, AgentToolCall,
};
use super::super::{default_model, default_system_prompt, AgentRequest};
use chr... |
32752f5182660d7570ede258db760af76037036c19b57ebdb689b08e216d7f38 | Rust | 5,638 | 185 | use std::sync::Arc;
#[derive(Debug)]
pub struct Chunk<T> {
data: Arc<[T]>,
visibility: Arc<[bool]>,
visible_count: usize,
}
impl<T> Clone for Chunk<T> {
fn clone(&self) -> Self {
Chunk {
data: self.data.clone(),
visibility: self.visibility.clone(),
visible_c... |
9563c24a764ddf62aafe87c6d389330f18c1cdb74965c09d48e9f6a9d01dd2c4 | Rust | 5,642 | 184 | use crate::tui::collection_browser::app_ui::ColorPalette;
use crate::tui::collection_browser::{Record, RecordField};
use chroma_types::MetadataValue;
use ratatui::buffer::Buffer;
use ratatui::layout::{Constraint, Rect};
use ratatui::style::Style;
use ratatui::text::Text;
use ratatui::widgets::{Cell, HighlightSpacing, R... |
b4c1b8445b35e77ca035ceeb87ace83778dc56128eead4a53aef2a65a0dfa654 | Rust | 5,645 | 177 | use std::sync::Arc;
use tokio::sync::Barrier;
use chroma_storage::s3_client_for_test_with_new_bucket;
use wal3::{
create_s3_factories, FragmentManagerFactory, LogPosition, LogReader, LogReaderOptions,
LogWriter, LogWriterOptions, ManifestManagerFactory, S3ManifestManagerFactory, ThrottleOptions,
};
#[tokio::... |
671dd9608a29b294b3cda26de14703b89b3a77e8c6091359dbf19a46de154689 | Rust | 5,667 | 169 | //! Ollama embedding function implementation for local model inference.
//!
//! This module provides [`OllamaEmbeddingFunction`], which connects to a locally running
//! Ollama instance to generate embeddings using models like `nomic-embed-text` or `mxbai-embed-large`.
//! Ollama enables privacy-preserving embeddings w... |
e3bcf74fa82a43b3641acc2e838d88898b87700a6b9159c00b8add5dc548f279 | Rust | 5,678 | 177 | use super::{Component, ComponentContext, Handler, Message};
use async_trait::async_trait;
use futures::FutureExt;
use std::{fmt::Debug, panic::AssertUnwindSafe};
use tokio::sync::oneshot;
// Why is this separate from the WrappedMessage struct? WrappedMessage is only generic
// over the component type, not the message ... |
ff441c7b106c57047732977c50823d0caf356b39cb4eac808544c5244d0a8ae4 | Rust | 5,688 | 146 | pub(crate) struct GetRequestSelectivity {
pub where_clause_only: Vec<f64>,
pub where_clause_and_ids: Vec<f64>,
pub ids_only: Vec<f64>,
}
pub(crate) struct QueryRequestSelectivity {
pub where_clause_only: Vec<f64>,
pub where_clause_and_ids: Vec<f64>,
pub ids_only: Vec<f64>,
pub embeddings_on... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.