Skip to content

Commit

Permalink
fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
generall committed Jun 19, 2024
1 parent 31842ce commit 2d5e6a8
Show file tree
Hide file tree
Showing 8 changed files with 67 additions and 40 deletions.
20 changes: 18 additions & 2 deletions src/builder_ext.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,23 @@
use std::collections::HashMap;

use crate::builder_types::RecommendExample;
use crate::qdrant::{BinaryQuantizationBuilder, ClearPayloadPointsBuilder, ContextExamplePair, CountPointsBuilder, CreateAliasBuilder, CreateCollectionBuilder, CreateFieldIndexCollectionBuilder, CreateShardKeyRequestBuilder, DeleteCollectionBuilder, DeleteFieldIndexCollectionBuilder, DeletePayloadPointsBuilder, DeletePointsBuilder, DeletePointVectorsBuilder, DeleteShardKey, DeleteShardKeyRequestBuilder, DiscoverBatchPointsBuilder, DiscoverPoints, DiscoverPointsBuilder, Distance, GetPointsBuilder, LookupLocationBuilder, OrderByBuilder, PayloadExcludeSelector, PayloadIncludeSelector, PointId, PointStruct, PointsUpdateOperation, PointVectors, ProductQuantizationBuilder, QuantizationType, QueryPointsBuilder, RecommendBatchPointsBuilder, RecommendPointGroups, RecommendPointGroupsBuilder, RecommendPoints, RecommendPointsBuilder, RenameAliasBuilder, ScalarQuantizationBuilder, ScrollPointsBuilder, SearchBatchPointsBuilder, SearchPointGroupsBuilder, SearchPoints, SearchPointsBuilder, SetPayloadPointsBuilder, shard_key, ShardKey, TextIndexParamsBuilder, TokenizerType, UpdateBatchPointsBuilder, UpdateCollectionBuilder, UpdateCollectionClusterSetupRequestBuilder, UpdatePointVectorsBuilder, UpsertPointsBuilder, Value, VectorParamsBuilder, VectorsSelector, WithLookupBuilder};
use crate::qdrant::{
shard_key, BinaryQuantizationBuilder, ClearPayloadPointsBuilder, ContextExamplePair,
CountPointsBuilder, CreateAliasBuilder, CreateCollectionBuilder,
CreateFieldIndexCollectionBuilder, CreateShardKeyRequestBuilder, DeleteCollectionBuilder,
DeleteFieldIndexCollectionBuilder, DeletePayloadPointsBuilder, DeletePointVectorsBuilder,
DeletePointsBuilder, DeleteShardKey, DeleteShardKeyRequestBuilder, DiscoverBatchPointsBuilder,
DiscoverPoints, DiscoverPointsBuilder, Distance, GetPointsBuilder, LookupLocationBuilder,
OrderByBuilder, PayloadExcludeSelector, PayloadIncludeSelector, PointId, PointStruct,
PointVectors, PointsUpdateOperation, ProductQuantizationBuilder, QuantizationType,
QueryPointsBuilder, RecommendBatchPointsBuilder, RecommendPointGroups,
RecommendPointGroupsBuilder, RecommendPoints, RecommendPointsBuilder, RenameAliasBuilder,
ScalarQuantizationBuilder, ScrollPointsBuilder, SearchBatchPointsBuilder,
SearchPointGroupsBuilder, SearchPoints, SearchPointsBuilder, SetPayloadPointsBuilder, ShardKey,
TextIndexParamsBuilder, TokenizerType, UpdateBatchPointsBuilder, UpdateCollectionBuilder,
UpdateCollectionClusterSetupRequestBuilder, UpdatePointVectorsBuilder, UpsertPointsBuilder,
Value, VectorParamsBuilder, VectorsSelector, WithLookupBuilder,
};

impl VectorParamsBuilder {
pub fn new(size: u64, distance: Distance) -> Self {
Expand Down Expand Up @@ -461,4 +477,4 @@ impl QueryPointsBuilder {
builder.collection_name = Some(collection_name.into());
builder
}
}
}
2 changes: 1 addition & 1 deletion src/grpc_conversions/query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@
// variant: Some(query::Variant::Nearest()),
// }
// }
// }
// }
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,9 +134,9 @@ mod tests {
SetPayloadPointsBuilder, SnapshotDownloadBuilder, Struct, UpsertPointsBuilder, Value,
VectorParamsBuilder,
};
use crate::qdrant_client::config::QdrantConfig;
use crate::qdrant_client::Qdrant;
use std::collections::HashMap;
use crate::qdrant_client::config::QdrantConfig;

#[test]
fn display() {
Expand Down
2 changes: 1 addition & 1 deletion src/qdrant_client/collection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -219,9 +219,9 @@ mod tests {
CountPointsBuilder, CreateCollectionBuilder, PointStruct, SearchPointsBuilder,
UpsertPointsBuilder, VectorParamsBuilder,
};
use crate::qdrant_client::config::QdrantConfig;
use std::time::Duration;
use tokio::time::sleep;
use crate::qdrant_client::config::QdrantConfig;

#[tokio::test]
async fn create_collection_and_do_the_search() -> Result<()> {
Expand Down
2 changes: 1 addition & 1 deletion src/qdrant_client/config.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::prelude::QdrantError;
use crate::qdrant_client::Qdrant;
use std::time::Duration;
use crate::prelude::QdrantError;

pub struct QdrantConfig {
pub uri: String,
Expand Down
4 changes: 2 additions & 2 deletions src/qdrant_client/mod.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
pub mod collection;
pub mod config;
pub mod errors;
mod points;
mod query;
pub mod sharding_keys;
pub mod snapshot;
mod query;
pub mod config;

use crate::channel_pool::ChannelPool;
use crate::qdrant::{qdrant_client, HealthCheckReply, HealthCheckRequest};
Expand Down
63 changes: 36 additions & 27 deletions src/qdrant_client/points.rs
Original file line number Diff line number Diff line change
@@ -1,19 +1,28 @@
use std::future::Future;

use tonic::codegen::InterceptedService;
use tonic::Status;
use tonic::transport::Channel;
use tonic::Status;

use crate::auth::TokenInterceptor;
use crate::prelude::SearchPoints;
use crate::qdrant::{ClearPayloadPoints, CountPoints, CountResponse, CreateFieldIndexCollection, DeleteFieldIndexCollection, DeletePayloadPoints, DeletePoints, DeletePointVectors, DiscoverBatchPoints, DiscoverBatchResponse, DiscoverPoints, DiscoverResponse, GetPoints, GetResponse, PointsOperationResponse, RecommendBatchPoints, RecommendBatchResponse, RecommendGroupsResponse, RecommendPointGroups, RecommendPoints, RecommendResponse, ScrollPoints, ScrollResponse, SearchBatchPoints, SearchBatchResponse, SearchGroupsResponse, SearchPointGroups, SearchResponse, SetPayloadPoints, UpdateBatchPoints, UpdateBatchResponse, UpdatePointVectors, UpsertPoints};
use crate::qdrant::points_client::PointsClient;
use crate::qdrant::{
ClearPayloadPoints, CountPoints, CountResponse, CreateFieldIndexCollection,
DeleteFieldIndexCollection, DeletePayloadPoints, DeletePointVectors, DeletePoints,
DiscoverBatchPoints, DiscoverBatchResponse, DiscoverPoints, DiscoverResponse, GetPoints,
GetResponse, PointsOperationResponse, RecommendBatchPoints, RecommendBatchResponse,
RecommendGroupsResponse, RecommendPointGroups, RecommendPoints, RecommendResponse,
ScrollPoints, ScrollResponse, SearchBatchPoints, SearchBatchResponse, SearchGroupsResponse,
SearchPointGroups, SearchResponse, SetPayloadPoints, UpdateBatchPoints, UpdateBatchResponse,
UpdatePointVectors, UpsertPoints,
};
use crate::qdrant_client::{Qdrant, Result};

impl Qdrant {
pub(crate) async fn with_points_client<
T,
O: Future<Output=std::result::Result<T, Status>>,
O: Future<Output = std::result::Result<T, Status>>,
>(
&self,
f: impl Fn(PointsClient<InterceptedService<Channel, TokenInterceptor>>) -> O,
Expand Down Expand Up @@ -45,7 +54,7 @@ impl Qdrant {
let result = points_api.search(request.clone()).await?;
Ok(result.into_inner())
})
.await
.await
}

pub async fn search_batch_points(
Expand All @@ -58,7 +67,7 @@ impl Qdrant {
let result = points_api.search_batch(request.clone()).await?;
Ok(result.into_inner())
})
.await
.await
}

pub async fn search_groups(
Expand All @@ -71,7 +80,7 @@ impl Qdrant {
let result = points_api.search_groups(request.clone()).await?;
Ok(result.into_inner())
})
.await
.await
}

pub async fn batch_updates(
Expand All @@ -83,7 +92,7 @@ impl Qdrant {
self.with_points_client(|mut points_api| async move {
Ok(points_api.update_batch(request.clone()).await?.into_inner())
})
.await
.await
}

/// Update or insert points into the collection.
Expand All @@ -98,7 +107,7 @@ impl Qdrant {
self.with_points_client(|mut points_api| async move {
Ok(points_api.upsert(request.clone()).await?.into_inner())
})
.await
.await
}

/// Update or insert points into the collection, splitting in chunks.
Expand Down Expand Up @@ -137,7 +146,7 @@ impl Qdrant {

Ok(resp)
})
.await
.await
}

pub async fn set_payload(
Expand All @@ -150,7 +159,7 @@ impl Qdrant {
let result = points_api.set_payload(request.clone()).await?;
Ok(result.into_inner())
})
.await
.await
}

pub async fn overwrite_payload(
Expand All @@ -163,7 +172,7 @@ impl Qdrant {
let result = points_api.overwrite_payload(request.clone()).await?;
Ok(result.into_inner())
})
.await
.await
}

pub async fn delete_payload(
Expand All @@ -176,7 +185,7 @@ impl Qdrant {
let result = points_api.delete_payload(request.clone()).await?;
Ok(result.into_inner())
})
.await
.await
}

pub async fn clear_payload(
Expand All @@ -189,7 +198,7 @@ impl Qdrant {
let result = points_api.clear_payload(request.clone()).await?;
Ok(result.into_inner())
})
.await
.await
}

pub async fn get_points(&self, request: impl Into<GetPoints>) -> Result<GetResponse> {
Expand All @@ -199,7 +208,7 @@ impl Qdrant {
let result = points_api.get(request.clone()).await?;
Ok(result.into_inner())
})
.await
.await
}

pub async fn delete_points(
Expand All @@ -212,7 +221,7 @@ impl Qdrant {
let result = points_api.delete(request.clone()).await?;
Ok(result.into_inner())
})
.await
.await
}

pub async fn delete_vectors(
Expand All @@ -225,7 +234,7 @@ impl Qdrant {
let result = points_api.delete_vectors(request.clone()).await?;
Ok(result.into_inner())
})
.await
.await
}

pub async fn update_vectors(
Expand All @@ -238,7 +247,7 @@ impl Qdrant {
let result = points_api.update_vectors(request.clone()).await?;
Ok(result.into_inner())
})
.await
.await
}

pub async fn scroll(&self, request: impl Into<ScrollPoints>) -> Result<ScrollResponse> {
Expand All @@ -248,7 +257,7 @@ impl Qdrant {
let result = points_api.scroll(request.clone()).await?;
Ok(result.into_inner())
})
.await
.await
}

pub async fn recommend(
Expand All @@ -261,7 +270,7 @@ impl Qdrant {
let result = points_api.recommend(request.clone()).await?;
Ok(result.into_inner())
})
.await
.await
}

pub async fn recommend_batch(
Expand All @@ -274,7 +283,7 @@ impl Qdrant {
let result = points_api.recommend_batch(request.clone()).await?;
Ok(result.into_inner())
})
.await
.await
}

pub async fn recommend_groups(
Expand All @@ -287,7 +296,7 @@ impl Qdrant {
let result = points_api.recommend_groups(request.clone()).await?;
Ok(result.into_inner())
})
.await
.await
}

pub async fn discover(&self, request: impl Into<DiscoverPoints>) -> Result<DiscoverResponse> {
Expand All @@ -297,7 +306,7 @@ impl Qdrant {
let result = points_api.discover(request.clone()).await?;
Ok(result.into_inner())
})
.await
.await
}

pub async fn discover_batch(
Expand All @@ -308,7 +317,7 @@ impl Qdrant {
let result = points_api.discover_batch(request.clone()).await?;
Ok(result.into_inner())
})
.await
.await
}

pub async fn count(&self, request: impl Into<CountPoints>) -> Result<CountResponse> {
Expand All @@ -318,7 +327,7 @@ impl Qdrant {
let result = points_api.count(request.clone()).await?;
Ok(result.into_inner())
})
.await
.await
}

pub async fn update_batch_points(
Expand All @@ -331,7 +340,7 @@ impl Qdrant {
let result = points_api.update_batch(request.clone()).await?;
Ok(result.into_inner())
})
.await
.await
}

/// Create index for a payload field
Expand All @@ -345,7 +354,7 @@ impl Qdrant {
let result = client.create_field_index(request.clone()).await?;
Ok(result.into_inner())
})
.await
.await
}

pub async fn delete_field_index(
Expand All @@ -358,6 +367,6 @@ impl Qdrant {
let result = client.delete_field_index(request.clone()).await?;
Ok(result.into_inner())
})
.await
.await
}
}
12 changes: 7 additions & 5 deletions src/qdrant_client/query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,24 @@ use crate::qdrant::{QueryPoints, QueryResponse};
use crate::qdrant_client::Qdrant;

impl Qdrant {
pub async fn query(&self, request: impl Into<QueryPoints>) -> crate::qdrant_client::Result<QueryResponse> {
pub async fn query(
&self,
request: impl Into<QueryPoints>,
) -> crate::qdrant_client::Result<QueryResponse> {
let request = &request.into();

self.with_points_client(|mut points_api| async move {
let result = points_api.query(request.clone()).await?;
Ok(result.into_inner())
})
.await
.await
}
}


#[cfg(test)]
mod tests {
use crate::qdrant::{CreateCollectionBuilder, QueryPointsBuilder};
use super::*;
use crate::qdrant::{CreateCollectionBuilder, QueryPointsBuilder};

#[tokio::test]
async fn test_query() {
Expand All @@ -33,4 +35,4 @@ mod tests {
let response = client.query(request).await.unwrap();
assert_eq!(response.result.len(), 0);
}
}
}

0 comments on commit 2d5e6a8

Please sign in to comment.