|
@@ -628,6 +628,91 @@ public:
|
|
|
return result;
|
|
return result;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ // ===== Collection Configuration =====
|
|
|
|
|
+
|
|
|
|
|
+ bool configureCollection(const std::string& collection, const Client::CollectionConfig& cfg) {
|
|
|
|
|
+ smartbotic::databasepb::ConfigureCollectionRequest request;
|
|
|
|
|
+ request.set_collection(collection);
|
|
|
|
|
+ request.mutable_config()->set_timestamp_precision(cfg.timestampPrecision);
|
|
|
|
|
+
|
|
|
|
|
+ smartbotic::databasepb::ConfigureCollectionResponse response;
|
|
|
|
|
+ grpc::ClientContext context;
|
|
|
|
|
+ setDeadline(context);
|
|
|
|
|
+
|
|
|
|
|
+ auto status = stub_->ConfigureCollection(&context, request, &response);
|
|
|
|
|
+ if (!status.ok()) {
|
|
|
|
|
+ spdlog::error("Client::configureCollection failed: {}", status.error_message());
|
|
|
|
|
+ return false;
|
|
|
|
|
+ }
|
|
|
|
|
+ if (!response.success()) {
|
|
|
|
|
+ spdlog::error("Client::configureCollection rejected: {}", response.error());
|
|
|
|
|
+ return false;
|
|
|
|
|
+ }
|
|
|
|
|
+ return true;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ Client::CollectionConfig getCollectionConfig(const std::string& collection) {
|
|
|
|
|
+ smartbotic::databasepb::GetCollectionConfigRequest request;
|
|
|
|
|
+ request.set_collection(collection);
|
|
|
|
|
+
|
|
|
|
|
+ smartbotic::databasepb::GetCollectionConfigResponse response;
|
|
|
|
|
+ grpc::ClientContext context;
|
|
|
|
|
+ setDeadline(context);
|
|
|
|
|
+
|
|
|
|
|
+ Client::CollectionConfig out;
|
|
|
|
|
+ auto status = stub_->GetCollectionConfig(&context, request, &response);
|
|
|
|
|
+ if (!status.ok()) {
|
|
|
|
|
+ spdlog::error("Client::getCollectionConfig failed: {}", status.error_message());
|
|
|
|
|
+ return out;
|
|
|
|
|
+ }
|
|
|
|
|
+ out.timestampPrecision = response.config().timestamp_precision();
|
|
|
|
|
+ if (out.timestampPrecision.empty()) out.timestampPrecision = "ms";
|
|
|
|
|
+ return out;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ bool hasCollectionConfig(const std::string& collection) {
|
|
|
|
|
+ smartbotic::databasepb::GetCollectionConfigRequest request;
|
|
|
|
|
+ request.set_collection(collection);
|
|
|
|
|
+
|
|
|
|
|
+ smartbotic::databasepb::GetCollectionConfigResponse response;
|
|
|
|
|
+ grpc::ClientContext context;
|
|
|
|
|
+ setDeadline(context);
|
|
|
|
|
+
|
|
|
|
|
+ auto status = stub_->GetCollectionConfig(&context, request, &response);
|
|
|
|
|
+ if (!status.ok()) return false;
|
|
|
|
|
+ return response.found();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ Client::TimestampMigrationResult migrateCollectionTimestamps(
|
|
|
|
|
+ const std::string& collection,
|
|
|
|
|
+ const std::string& fromPrecision,
|
|
|
|
|
+ const std::string& toPrecision
|
|
|
|
|
+ ) {
|
|
|
|
|
+ smartbotic::databasepb::MigrateCollectionTimestampsRequest request;
|
|
|
|
|
+ request.set_collection(collection);
|
|
|
|
|
+ request.set_from_precision(fromPrecision);
|
|
|
|
|
+ request.set_to_precision(toPrecision);
|
|
|
|
|
+
|
|
|
|
|
+ smartbotic::databasepb::MigrateCollectionTimestampsResponse response;
|
|
|
|
|
+ grpc::ClientContext context;
|
|
|
|
|
+ // Longer deadline — can iterate many rows
|
|
|
|
|
+ auto deadline = std::chrono::system_clock::now() + std::chrono::minutes(10);
|
|
|
|
|
+ context.set_deadline(deadline);
|
|
|
|
|
+
|
|
|
|
|
+ Client::TimestampMigrationResult out;
|
|
|
|
|
+ auto status = stub_->MigrateCollectionTimestamps(&context, request, &response);
|
|
|
|
|
+ if (!status.ok()) {
|
|
|
|
|
+ out.success = false;
|
|
|
|
|
+ out.error = status.error_message();
|
|
|
|
|
+ return out;
|
|
|
|
|
+ }
|
|
|
|
|
+ out.success = response.success();
|
|
|
|
|
+ out.error = response.error();
|
|
|
|
|
+ out.rowsMigrated = response.rows_migrated();
|
|
|
|
|
+ out.rowsSkipped = response.rows_skipped();
|
|
|
|
|
+ return out;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
// ===== View Management =====
|
|
// ===== View Management =====
|
|
|
|
|
|
|
|
bool createView(const std::string& name,
|
|
bool createView(const std::string& name,
|
|
@@ -1366,6 +1451,26 @@ std::optional<Client::CollectionInfo> Client::getCollectionInfo(const std::strin
|
|
|
return impl_->getCollectionInfo(name);
|
|
return impl_->getCollectionInfo(name);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+bool Client::configureCollection(const std::string& collection, const CollectionConfig& cfg) {
|
|
|
|
|
+ return impl_->configureCollection(collection, cfg);
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+Client::CollectionConfig Client::getCollectionConfig(const std::string& collection) {
|
|
|
|
|
+ return impl_->getCollectionConfig(collection);
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+bool Client::hasCollectionConfig(const std::string& collection) {
|
|
|
|
|
+ return impl_->hasCollectionConfig(collection);
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+Client::TimestampMigrationResult Client::migrateCollectionTimestamps(
|
|
|
|
|
+ const std::string& collection,
|
|
|
|
|
+ const std::string& fromPrecision,
|
|
|
|
|
+ const std::string& toPrecision
|
|
|
|
|
+) {
|
|
|
|
|
+ return impl_->migrateCollectionTimestamps(collection, fromPrecision, toPrecision);
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
bool Client::createView(const std::string& name,
|
|
bool Client::createView(const std::string& name,
|
|
|
const std::string& collection,
|
|
const std::string& collection,
|
|
|
const std::vector<std::string>& include,
|
|
const std::vector<std::string>& include,
|