Skip to content

Commit

Permalink
Bumping object version to 0.8 (#4757)
Browse files Browse the repository at this point in the history
  • Loading branch information
fulmicoton committed Mar 18, 2024
1 parent 0868894 commit 7af4596
Show file tree
Hide file tree
Showing 28 changed files with 1,004 additions and 115 deletions.
19 changes: 10 additions & 9 deletions quickwit/quickwit-config/src/index_config/serialize.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,23 +29,24 @@ use crate::{
};

/// Alias for the latest serialization format.
type IndexConfigForSerialization = IndexConfigV0_7;
type IndexConfigForSerialization = IndexConfigV0_8;

#[derive(Clone, Debug, Serialize, Deserialize, utoipa::ToSchema)]
#[serde(tag = "version")]
pub(crate) enum VersionedIndexConfig {
#[serde(rename = "0.7")]
#[serde(rename = "0.8")]
// Retro compatibility
#[serde(alias = "0.4")]
#[serde(alias = "0.5")]
#[serde(alias = "0.6")]
V0_7(IndexConfigV0_7),
#[serde(alias = "0.7")]
V0_8(IndexConfigV0_8),
}

impl From<VersionedIndexConfig> for IndexConfigForSerialization {
fn from(versioned_config: VersionedIndexConfig) -> IndexConfigForSerialization {
match versioned_config {
VersionedIndexConfig::V0_7(v0_6) => v0_6,
VersionedIndexConfig::V0_8(v0_8) => v0_8,
}
}
}
Expand Down Expand Up @@ -109,7 +110,7 @@ impl IndexConfigForSerialization {

impl From<IndexConfig> for VersionedIndexConfig {
fn from(index_config: IndexConfig) -> Self {
VersionedIndexConfig::V0_7(index_config.into())
VersionedIndexConfig::V0_8(index_config.into())
}
}

Expand All @@ -118,14 +119,14 @@ impl TryFrom<VersionedIndexConfig> for IndexConfig {

fn try_from(versioned_index_config: VersionedIndexConfig) -> anyhow::Result<Self> {
match versioned_index_config {
VersionedIndexConfig::V0_7(v0_6) => v0_6.build_and_validate(None),
VersionedIndexConfig::V0_8(v0_8) => v0_8.build_and_validate(None),
}
}
}

#[derive(Clone, Debug, Serialize, Deserialize, utoipa::ToSchema)]
#[serde(deny_unknown_fields)]
pub struct IndexConfigV0_7 {
pub struct IndexConfigV0_8 {
pub index_id: String,
#[schema(value_type = String)]
#[serde(default)]
Expand All @@ -140,9 +141,9 @@ pub struct IndexConfigV0_7 {
pub retention_policy_opt: Option<RetentionPolicy>,
}

impl From<IndexConfig> for IndexConfigV0_7 {
impl From<IndexConfig> for IndexConfigV0_8 {
fn from(index_config: IndexConfig) -> Self {
IndexConfigV0_7 {
IndexConfigV0_8 {
index_id: index_config.index_id,
index_uri: Some(index_config.index_uri),
doc_mapping: index_config.doc_mapping,
Expand Down
2 changes: 1 addition & 1 deletion quickwit/quickwit-config/src/index_template/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ use anyhow::ensure;
use quickwit_common::uri::Uri;
use quickwit_proto::types::IndexId;
use serde::{Deserialize, Serialize};
pub use serialize::{IndexTemplateV0_7, VersionedIndexTemplate};
pub use serialize::{IndexTemplateV0_8, VersionedIndexTemplate};

use crate::index_config::validate_index_config;
use crate::{
Expand Down
37 changes: 19 additions & 18 deletions quickwit/quickwit-config/src/index_template/serialize.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,14 @@ use crate::{DocMapping, IndexingSettings, RetentionPolicy, SearchSettings};
#[derive(Clone, Debug, Serialize, Deserialize, utoipa::ToSchema)]
#[serde(tag = "version")]
pub enum VersionedIndexTemplate {
#[serde(rename = "0.7")]
V0_7(IndexTemplateV0_7),
#[serde(rename = "0.8")]
#[serde(alias = "0.7")]
V0_8(IndexTemplateV0_8),
}

#[derive(Clone, Debug, Serialize, Deserialize, utoipa::ToSchema)]
#[serde(deny_unknown_fields)]
pub struct IndexTemplateV0_7 {
pub struct IndexTemplateV0_8 {
#[schema(value_type = String)]
pub template_id: IndexTemplateId,
#[schema(value_type = Vec<String>)]
Expand All @@ -56,36 +57,36 @@ pub struct IndexTemplateV0_7 {
impl From<VersionedIndexTemplate> for IndexTemplate {
fn from(versioned_index_template: VersionedIndexTemplate) -> Self {
match versioned_index_template {
VersionedIndexTemplate::V0_7(v0_7) => v0_7.into(),
VersionedIndexTemplate::V0_8(v0_8) => v0_8.into(),
}
}
}

impl From<IndexTemplate> for VersionedIndexTemplate {
fn from(index_template: IndexTemplate) -> Self {
VersionedIndexTemplate::V0_7(index_template.into())
VersionedIndexTemplate::V0_8(index_template.into())
}
}

impl From<IndexTemplateV0_7> for IndexTemplate {
fn from(index_template_v0_7: IndexTemplateV0_7) -> Self {
impl From<IndexTemplateV0_8> for IndexTemplate {
fn from(index_template_v0_8: IndexTemplateV0_8) -> Self {
IndexTemplate {
template_id: index_template_v0_7.template_id,
index_id_patterns: index_template_v0_7.index_id_patterns,
index_root_uri: index_template_v0_7.index_root_uri,
priority: index_template_v0_7.priority,
description: index_template_v0_7.description,
doc_mapping: index_template_v0_7.doc_mapping,
indexing_settings: index_template_v0_7.indexing_settings,
search_settings: index_template_v0_7.search_settings,
retention_policy_opt: index_template_v0_7.retention,
template_id: index_template_v0_8.template_id,
index_id_patterns: index_template_v0_8.index_id_patterns,
index_root_uri: index_template_v0_8.index_root_uri,
priority: index_template_v0_8.priority,
description: index_template_v0_8.description,
doc_mapping: index_template_v0_8.doc_mapping,
indexing_settings: index_template_v0_8.indexing_settings,
search_settings: index_template_v0_8.search_settings,
retention_policy_opt: index_template_v0_8.retention,
}
}
}

impl From<IndexTemplate> for IndexTemplateV0_7 {
impl From<IndexTemplate> for IndexTemplateV0_8 {
fn from(index_template: IndexTemplate) -> Self {
IndexTemplateV0_7 {
IndexTemplateV0_8 {
template_id: index_template.template_id,
index_id_patterns: index_template.index_id_patterns,
index_root_uri: index_template.index_root_uri,
Expand Down
8 changes: 4 additions & 4 deletions quickwit/quickwit-config/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ mod templating;
pub use cluster_config::ClusterConfig;
// We export that one for backward compatibility.
// See #2048
use index_config::serialize::{IndexConfigV0_7, VersionedIndexConfig};
use index_config::serialize::{IndexConfigV0_8, VersionedIndexConfig};
pub use index_config::{
build_doc_mapper, load_index_config_from_user_config, DocMapping, IndexConfig,
IndexingResources, IndexingSettings, RetentionPolicy, SearchSettings,
Expand All @@ -60,7 +60,7 @@ pub use source_config::{
};
use tracing::warn;

use crate::index_template::IndexTemplateV0_7;
use crate::index_template::IndexTemplateV0_8;
pub use crate::index_template::{IndexTemplate, IndexTemplateId, VersionedIndexTemplate};
use crate::merge_policy_config::{
ConstWriteAmplificationMergePolicyConfig, MergePolicyConfig, StableLogMergePolicyConfig,
Expand Down Expand Up @@ -90,9 +90,9 @@ pub use crate::storage_config::{
SourceConfigV0_7,
SourceConfigV0_8,
VersionedIndexConfig,
IndexConfigV0_7,
IndexConfigV0_8,
VersionedIndexTemplate,
IndexTemplateV0_7,
IndexTemplateV0_8,
SourceInputFormat,
SourceParams,
FileSourceParams,
Expand Down
7 changes: 4 additions & 3 deletions quickwit/quickwit-config/src/node_config/serialize.rs
Original file line number Diff line number Diff line change
Expand Up @@ -149,18 +149,19 @@ pub async fn load_node_config_with_env(
#[derive(Debug, Deserialize)]
#[serde(tag = "version")]
enum VersionedNodeConfig {
#[serde(rename = "0.7")]
#[serde(rename = "0.8")]
// Retro compatibility.
#[serde(alias = "0.7")]
#[serde(alias = "0.6")]
#[serde(alias = "0.5")]
#[serde(alias = "0.4")]
V0_7(NodeConfigBuilder),
V0_8(NodeConfigBuilder),
}

impl From<VersionedNodeConfig> for NodeConfigBuilder {
fn from(versioned_node_config: VersionedNodeConfig) -> Self {
match versioned_node_config {
VersionedNodeConfig::V0_7(node_config_builder) => node_config_builder,
VersionedNodeConfig::V0_8(node_config_builder) => node_config_builder,
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ use crate::{IndexMetadata, SplitMetadata};
/// #[serde(rename="0.2")]
/// V0_2(MyResourceV1) //< there was no change in this version.
/// }
const GLOBAL_QUICKWIT_RESOURCE_VERSION: &str = "0.7";
const GLOBAL_QUICKWIT_RESOURCE_VERSION: &str = "0.8";

/// This test makes sure that the resource is using the current `GLOBAL_QUICKWIT_RESOURCE_VERSION`.
fn test_global_version<T: Serialize>(serializable: &T) -> anyhow::Result<()> {
Expand Down
8 changes: 4 additions & 4 deletions quickwit/quickwit-metastore/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ use std::ops::Range;
pub use error::MetastoreResolverError;
pub use metastore::control_plane_metastore::ControlPlaneMetastore;
pub use metastore::file_backed::FileBackedMetastore;
pub(crate) use metastore::index_metadata::serialize::{IndexMetadataV0_7, VersionedIndexMetadata};
pub(crate) use metastore::index_metadata::serialize::{IndexMetadataV0_8, VersionedIndexMetadata};
#[cfg(feature = "postgres")]
pub use metastore::postgres::PostgresqlMetastore;
pub use metastore::{
Expand All @@ -58,16 +58,16 @@ pub use metastore_resolver::MetastoreResolver;
use quickwit_common::is_disjoint;
use quickwit_doc_mapper::tag_pruning::TagFilterAst;
pub use split_metadata::{Split, SplitInfo, SplitMaturity, SplitMetadata, SplitState};
pub(crate) use split_metadata_version::{SplitMetadataV0_7, VersionedSplitMetadata};
pub(crate) use split_metadata_version::{SplitMetadataV0_8, VersionedSplitMetadata};

#[derive(utoipa::OpenApi)]
#[openapi(components(schemas(
Split,
SplitState,
VersionedIndexMetadata,
IndexMetadataV0_7,
IndexMetadataV0_8,
VersionedSplitMetadata,
SplitMetadataV0_7,
SplitMetadataV0_8,
)))]
/// Schema used for the OpenAPI generation which are apart of this crate.
pub struct MetastoreApiSchemas;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,30 +34,31 @@ use crate::{IndexMetadata, Split};
#[derive(Clone, Debug, Serialize, Deserialize)]
#[serde(tag = "version")]
pub(crate) enum VersionedFileBackedIndex {
#[serde(rename = "0.7")]
#[serde(rename = "0.8")]
// Retro compatibility.
#[serde(alias = "0.7")]
#[serde(alias = "0.6")]
#[serde(alias = "0.5")]
#[serde(alias = "0.4")]
V0_7(FileBackedIndexV0_7),
V0_8(FileBackedIndexV0_8),
}

impl From<FileBackedIndex> for VersionedFileBackedIndex {
fn from(index: FileBackedIndex) -> Self {
VersionedFileBackedIndex::V0_7(index.into())
VersionedFileBackedIndex::V0_8(index.into())
}
}

impl From<VersionedFileBackedIndex> for FileBackedIndex {
fn from(index: VersionedFileBackedIndex) -> Self {
match index {
VersionedFileBackedIndex::V0_7(v0_6) => v0_6.into(),
VersionedFileBackedIndex::V0_8(v0_8) => v0_8.into(),
}
}
}

#[derive(Clone, Debug, Serialize, Deserialize)]
pub(crate) struct FileBackedIndexV0_7 {
pub(crate) struct FileBackedIndexV0_8 {
#[serde(rename = "index")]
metadata: IndexMetadata,
splits: Vec<Split>,
Expand All @@ -68,7 +69,7 @@ pub(crate) struct FileBackedIndexV0_7 {
delete_tasks: Vec<DeleteTask>,
}

impl From<FileBackedIndex> for FileBackedIndexV0_7 {
impl From<FileBackedIndex> for FileBackedIndexV0_8 {
fn from(index: FileBackedIndex) -> Self {
let splits = index
.splits
Expand Down Expand Up @@ -104,8 +105,8 @@ impl From<FileBackedIndex> for FileBackedIndexV0_7 {
}
}

impl From<FileBackedIndexV0_7> for FileBackedIndex {
fn from(mut index: FileBackedIndexV0_7) -> Self {
impl From<FileBackedIndexV0_8> for FileBackedIndex {
fn from(mut index: FileBackedIndexV0_8) -> Self {
// if the index is otel-traces-v0_6, convert set bytes fields input and output format to hex
// to be compatible with the v0_6 version.
// TODO: remove after 0.8 release.
Expand Down
19 changes: 10 additions & 9 deletions quickwit/quickwit-metastore/src/metastore/file_backed/manifest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,46 +74,47 @@ pub(crate) struct Manifest {
#[derive(Clone, Debug, Serialize, Deserialize)]
#[serde(tag = "version")]
enum VersionedManifest {
#[serde(rename = "0.7")]
V0_7(ManifestV0_7),
#[serde(rename = "0.8")]
#[serde(alias = "0.7")]
V0_8(ManifestV0_8),
}

impl From<Manifest> for VersionedManifest {
fn from(manifest: Manifest) -> Self {
VersionedManifest::V0_7(manifest.into())
VersionedManifest::V0_8(manifest.into())
}
}

impl From<VersionedManifest> for Manifest {
fn from(versioned_manifest: VersionedManifest) -> Self {
match versioned_manifest {
VersionedManifest::V0_7(manifest) => manifest.into(),
VersionedManifest::V0_8(manifest) => manifest.into(),
}
}
}

#[derive(Clone, Debug, Serialize, Deserialize)]
struct ManifestV0_7 {
struct ManifestV0_8 {
indexes: BTreeMap<IndexId, IndexStatus>,
templates: Vec<IndexTemplate>,
}

impl From<Manifest> for ManifestV0_7 {
impl From<Manifest> for ManifestV0_8 {
fn from(manifest: Manifest) -> Self {
let templates = manifest
.templates
.into_values()
.sorted_unstable_by(|left, right| left.template_id.cmp(&right.template_id))
.collect();
ManifestV0_7 {
ManifestV0_8 {
indexes: manifest.indexes,
templates,
}
}
}

impl From<ManifestV0_7> for Manifest {
fn from(manifest: ManifestV0_7) -> Self {
impl From<ManifestV0_8> for Manifest {
fn from(manifest: ManifestV0_8) -> Self {
let indexes = manifest.indexes.into_iter().collect();
let templates = manifest
.templates
Expand Down
Loading

0 comments on commit 7af4596

Please sign in to comment.