From e2c4ad22f7af4a2917753c9e3d3335df9a721d0c Mon Sep 17 00:00:00 2001 From: Nipunn Koorapati Date: Tue, 10 Sep 2024 13:47:59 -0700 Subject: [PATCH] Recreate the exports_by_requestor index (#29737) Includes creationTime GitOrigin-RevId: 609fa50006e1d7cfa105884c5a297d28c1ea2e6a --- crates/model/src/exports/mod.rs | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/crates/model/src/exports/mod.rs b/crates/model/src/exports/mod.rs index 84ff88df..0a2ae17e 100644 --- a/crates/model/src/exports/mod.rs +++ b/crates/model/src/exports/mod.rs @@ -5,6 +5,7 @@ use common::{ document::{ ParsedDocument, ResolvedDocument, + CREATION_TIME_FIELD_PATH, }, maybe_val, query::{ @@ -47,12 +48,18 @@ pub static EXPORTS_TABLE: LazyLock = pub static EXPORTS_BY_STATE_AND_TS_INDEX: LazyLock = LazyLock::new(|| system_index(&EXPORTS_TABLE, "by_state_and_ts")); +pub static EXPORTS_BY_REQUESTOR: LazyLock = + LazyLock::new(|| system_index(&EXPORTS_TABLE, "by_requestor")); + pub static EXPORTS_STATE_FIELD: LazyLock = LazyLock::new(|| "state".parse().expect("Invalid built-in field")); pub static EXPORTS_TS_FIELD: LazyLock = LazyLock::new(|| "start_ts".parse().expect("Invalid built-in field")); +static EXPORTS_REQUESTOR_FIELD: LazyLock = + LazyLock::new(|| "requestor".parse().expect("Invalid built-in field")); + pub struct ExportsTable; impl SystemTable for ExportsTable { fn table_name(&self) -> &'static TableName { @@ -60,12 +67,23 @@ impl SystemTable for ExportsTable { } fn indexes(&self) -> Vec { - vec![SystemIndex { - name: EXPORTS_BY_STATE_AND_TS_INDEX.clone(), - fields: vec![EXPORTS_STATE_FIELD.clone(), EXPORTS_TS_FIELD.clone()] + vec![ + SystemIndex { + name: EXPORTS_BY_STATE_AND_TS_INDEX.clone(), + fields: vec![EXPORTS_STATE_FIELD.clone(), EXPORTS_TS_FIELD.clone()] + .try_into() + .unwrap(), + }, + SystemIndex { + name: EXPORTS_BY_REQUESTOR.clone(), + fields: vec![ + EXPORTS_REQUESTOR_FIELD.clone(), + CREATION_TIME_FIELD_PATH.clone(), + ] .try_into() .unwrap(), - }] + }, + ] } fn validate_document(&self, document: ResolvedDocument) -> anyhow::Result<()> {