Spaces:
Build error
Build error
File size: 3,796 Bytes
84d2a97 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 |
use std::path::Path;
use std::sync::Arc;
use std::time::Duration;
use async_trait::async_trait;
use common::counter::hardware_accumulator::HwMeasurementAcc;
use common::tar_ext;
use segment::data_types::facets::{FacetParams, FacetResponse};
use segment::data_types::order_by::OrderBy;
use segment::types::{
ExtendedPointId, Filter, ScoredPoint, SnapshotFormat, WithPayload, WithPayloadInterface,
WithVector,
};
use tokio::runtime::Handle;
use crate::operations::types::{
CollectionError, CollectionInfo, CollectionResult, CoreSearchRequestBatch,
CountRequestInternal, CountResult, PointRequestInternal, RecordInternal, ShardStatus,
UpdateResult,
};
use crate::operations::universal_query::shard_query::{ShardQueryRequest, ShardQueryResponse};
use crate::operations::OperationWithClockTag;
use crate::shards::shard_trait::ShardOperation;
use crate::shards::telemetry::LocalShardTelemetry;
#[derive(Clone, Debug)]
pub struct DummyShard {
message: String,
}
impl DummyShard {
pub fn new(message: impl Into<String>) -> Self {
Self {
message: message.into(),
}
}
pub async fn create_snapshot(
&self,
_temp_path: &Path,
_tar: &tar_ext::BuilderExt,
_format: SnapshotFormat,
_save_wal: bool,
) -> CollectionResult<()> {
self.dummy()
}
pub async fn on_optimizer_config_update(&self) -> CollectionResult<()> {
self.dummy()
}
pub fn get_telemetry_data(&self) -> LocalShardTelemetry {
LocalShardTelemetry {
variant_name: Some("dummy shard".into()),
status: Some(ShardStatus::Green),
total_optimized_points: 0,
segments: vec![],
optimizations: Default::default(),
async_scorer: None,
}
}
fn dummy<T>(&self) -> CollectionResult<T> {
Err(CollectionError::service_error(self.message.to_string()))
}
}
#[async_trait]
impl ShardOperation for DummyShard {
async fn update(&self, _: OperationWithClockTag, _: bool) -> CollectionResult<UpdateResult> {
self.dummy()
}
/// Forward read-only `scroll_by` to `wrapped_shard`
async fn scroll_by(
&self,
_: Option<ExtendedPointId>,
_: usize,
_: &WithPayloadInterface,
_: &WithVector,
_: Option<&Filter>,
_: &Handle,
_: Option<&OrderBy>,
_: Option<Duration>,
) -> CollectionResult<Vec<RecordInternal>> {
self.dummy()
}
async fn info(&self) -> CollectionResult<CollectionInfo> {
self.dummy()
}
async fn core_search(
&self,
_: Arc<CoreSearchRequestBatch>,
_: &Handle,
_: Option<Duration>,
_: &HwMeasurementAcc,
) -> CollectionResult<Vec<Vec<ScoredPoint>>> {
self.dummy()
}
async fn count(
&self,
_: Arc<CountRequestInternal>,
_: &Handle,
_: Option<Duration>,
_: &HwMeasurementAcc,
) -> CollectionResult<CountResult> {
self.dummy()
}
async fn retrieve(
&self,
_: Arc<PointRequestInternal>,
_: &WithPayload,
_: &WithVector,
_: &Handle,
_: Option<Duration>,
) -> CollectionResult<Vec<RecordInternal>> {
self.dummy()
}
async fn query_batch(
&self,
_requests: Arc<Vec<ShardQueryRequest>>,
_search_runtime_handle: &Handle,
_timeout: Option<Duration>,
_: &HwMeasurementAcc,
) -> CollectionResult<Vec<ShardQueryResponse>> {
self.dummy()
}
async fn facet(
&self,
_: Arc<FacetParams>,
_search_runtime_handle: &Handle,
_: Option<Duration>,
) -> CollectionResult<FacetResponse> {
self.dummy()
}
}
|