Skip to content

Commit 931d1c4

Browse files
authored
fix: escape type keyword in tracing::info! macros (#4068)
I run into issues due to the use of the `type` keyword in `tracing::info` macros - this PR replaces it with the escaped `r#type` version. Sample of the error I previously got: ``` error: no rules expected keyword `type` --> /Users/.../.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/lance-table-0.30.0/src/io/deletion.rs:113:13 | 113 | info!(target: TRACE_FILE_AUDIT, mode=AUDIT_MODE_CREATE, type=AUDIT_TYPE_DELETION, path = path.to_string()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ no rules expected this token in macro call ```
1 parent cf27c3d commit 931d1c4

10 files changed

Lines changed: 23 additions & 23 deletions

File tree

rust/lance-index/src/scalar/btree.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -773,7 +773,7 @@ impl BTreeIndex {
773773
return Ok(cached);
774774
}
775775
metrics.record_part_load();
776-
info!(target: TRACE_IO_EVENTS, type=IO_TYPE_LOAD_SCALAR_PART, index_type="btree", part_id=page_number);
776+
info!(target: TRACE_IO_EVENTS, r#type=IO_TYPE_LOAD_SCALAR_PART, index_type="btree", part_id=page_number);
777777
let index_reader = index_reader.get().await?;
778778
let mut serialized_page = index_reader
779779
.read_record_batch(page_number as u64, self.batch_size)

rust/lance-index/src/scalar/inverted/index.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -956,7 +956,7 @@ impl PostingListReader {
956956
.posting_cache
957957
.try_get_with(token_id, async move {
958958
metrics.record_part_load();
959-
info!(target: TRACE_IO_EVENTS, type=IO_TYPE_LOAD_SCALAR_PART, index_type="inverted", part_id=token_id);
959+
info!(target: TRACE_IO_EVENTS, r#type=IO_TYPE_LOAD_SCALAR_PART, index_type="inverted", part_id=token_id);
960960
let batch = self.posting_batch(token_id, false).await?;
961961
self.posting_list_from_batch(&batch, token_id)
962962
})
@@ -1033,7 +1033,7 @@ impl PostingListReader {
10331033
.await.map_err(|e| {
10341034
match e {
10351035
Error::Schema { .. } => Error::Index {
1036-
message: "position is not found but required for phrase queries, try recreating the index with position".to_owned(),
1036+
message: "position is not found but required for phrase queries, try recreating the index with position".to_owned(),
10371037
location: location!(),
10381038
},
10391039
e => e

rust/lance-index/src/scalar/ngram.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ impl NGramPostingListReader {
203203
self.cache
204204
.try_get_with(row_offset, async move {
205205
metrics.record_part_load();
206-
tracing::info!(target: TRACE_IO_EVENTS, type=IO_TYPE_LOAD_SCALAR_PART, index_type="ngram", part_id=row_offset);
206+
tracing::info!(target: TRACE_IO_EVENTS, r#type=IO_TYPE_LOAD_SCALAR_PART, index_type="ngram", part_id=row_offset);
207207
let batch = self
208208
.reader
209209
.read_range(

rust/lance-table/src/io/deletion.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ pub async fn write_deletion_file(
9191

9292
object_store.put(&path, &out).await?;
9393

94-
info!(target: TRACE_FILE_AUDIT, mode=AUDIT_MODE_CREATE, type=AUDIT_TYPE_DELETION, path = path.to_string());
94+
info!(target: TRACE_FILE_AUDIT, mode=AUDIT_MODE_CREATE, r#type=AUDIT_TYPE_DELETION, path = path.to_string());
9595

9696
Some(deletion_file)
9797
}
@@ -110,7 +110,7 @@ pub async fn write_deletion_file(
110110

111111
object_store.put(&path, &out).await?;
112112

113-
info!(target: TRACE_FILE_AUDIT, mode=AUDIT_MODE_CREATE, type=AUDIT_TYPE_DELETION, path = path.to_string());
113+
info!(target: TRACE_FILE_AUDIT, mode=AUDIT_MODE_CREATE, r#type=AUDIT_TYPE_DELETION, path = path.to_string());
114114

115115
Some(deletion_file)
116116
}

rust/lance/src/dataset.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1895,7 +1895,7 @@ fn write_manifest_file_to_path<'a>(
18951895
.write_magics(pos, MAJOR_VERSION, MINOR_VERSION, MAGIC)
18961896
.await?;
18971897
let res = object_writer.shutdown().await?;
1898-
info!(target: TRACE_FILE_AUDIT, mode=AUDIT_MODE_CREATE, type=AUDIT_TYPE_MANIFEST, path = path.to_string());
1898+
info!(target: TRACE_FILE_AUDIT, mode=AUDIT_MODE_CREATE, r#type=AUDIT_TYPE_MANIFEST, path = path.to_string());
18991899
Ok(res)
19001900
})
19011901
}

rust/lance/src/dataset/cleanup.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,7 @@ impl<'a> CleanupTask<'a> {
295295

296296
let old_manifests_stream = stream::iter(old_manifests)
297297
.map(|path| {
298-
info!(target: TRACE_FILE_AUDIT, mode=AUDIT_MODE_DELETE, type=AUDIT_TYPE_MANIFEST, path = path.to_string());
298+
info!(target: TRACE_FILE_AUDIT, mode=AUDIT_MODE_DELETE, r#type=AUDIT_TYPE_MANIFEST, path = path.to_string());
299299
Ok(path)
300300
})
301301
.boxed();
@@ -349,14 +349,14 @@ impl<'a> CleanupTask<'a> {
349349
{
350350
return Ok(None);
351351
} else if !maybe_in_progress {
352-
info!(target: TRACE_FILE_AUDIT, mode=AUDIT_MODE_DELETE_UNVERIFIED, type=AUDIT_TYPE_INDEX, path = path.to_string());
352+
info!(target: TRACE_FILE_AUDIT, mode=AUDIT_MODE_DELETE_UNVERIFIED, r#type=AUDIT_TYPE_INDEX, path = path.to_string());
353353
return Ok(Some(path));
354354
} else if inspection
355355
.verified_files
356356
.index_uuids
357357
.contains(uuid.as_ref())
358358
{
359-
info!(target: TRACE_FILE_AUDIT, mode=AUDIT_MODE_DELETE, type=AUDIT_TYPE_INDEX, path = path.to_string());
359+
info!(target: TRACE_FILE_AUDIT, mode=AUDIT_MODE_DELETE, r#type=AUDIT_TYPE_INDEX, path = path.to_string());
360360
return Ok(Some(path));
361361
}
362362
} else {
@@ -373,14 +373,14 @@ impl<'a> CleanupTask<'a> {
373373
{
374374
Ok(None)
375375
} else if !maybe_in_progress {
376-
info!(target: TRACE_FILE_AUDIT, mode=AUDIT_MODE_DELETE_UNVERIFIED, type=AUDIT_TYPE_DATA, path = path.to_string());
376+
info!(target: TRACE_FILE_AUDIT, mode=AUDIT_MODE_DELETE_UNVERIFIED, r#type=AUDIT_TYPE_DATA, path = path.to_string());
377377
Ok(Some(path))
378378
} else if inspection
379379
.verified_files
380380
.data_paths
381381
.contains(&relative_path)
382382
{
383-
info!(target: TRACE_FILE_AUDIT, mode=AUDIT_MODE_DELETE, type=AUDIT_TYPE_DATA, path = path.to_string());
383+
info!(target: TRACE_FILE_AUDIT, mode=AUDIT_MODE_DELETE, r#type=AUDIT_TYPE_DATA, path = path.to_string());
384384
Ok(Some(path))
385385
} else {
386386
Ok(None)
@@ -403,14 +403,14 @@ impl<'a> CleanupTask<'a> {
403403
{
404404
Ok(None)
405405
} else if !maybe_in_progress {
406-
info!(target: TRACE_FILE_AUDIT, mode=AUDIT_MODE_DELETE_UNVERIFIED, type=AUDIT_TYPE_DELETION, path = path.to_string());
406+
info!(target: TRACE_FILE_AUDIT, mode=AUDIT_MODE_DELETE_UNVERIFIED, r#type=AUDIT_TYPE_DELETION, path = path.to_string());
407407
Ok(Some(path))
408408
} else if inspection
409409
.verified_files
410410
.delete_paths
411411
.contains(&relative_path)
412412
{
413-
info!(target: TRACE_FILE_AUDIT, mode=AUDIT_MODE_DELETE, type=AUDIT_TYPE_DELETION, path = path.to_string());
413+
info!(target: TRACE_FILE_AUDIT, mode=AUDIT_MODE_DELETE, r#type=AUDIT_TYPE_DELETION, path = path.to_string());
414414
Ok(Some(path))
415415
} else {
416416
Ok(None)

rust/lance/src/dataset/write.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,7 @@ pub async fn do_write_fragments(
307307
|| writer.as_mut().unwrap().tell().await? >= params.max_bytes_per_file as u64
308308
{
309309
let (num_rows, data_file) = writer.take().unwrap().finish().await?;
310-
info!(target: TRACE_FILE_AUDIT, mode=AUDIT_MODE_CREATE, type=AUDIT_TYPE_DATA, path = &data_file.path);
310+
info!(target: TRACE_FILE_AUDIT, mode=AUDIT_MODE_CREATE, r#type=AUDIT_TYPE_DATA, path = &data_file.path);
311311
debug_assert_eq!(num_rows, num_rows_in_current_file);
312312
params.progress.complete(fragments.last().unwrap()).await?;
313313
let last_fragment = fragments.last_mut().unwrap();
@@ -320,7 +320,7 @@ pub async fn do_write_fragments(
320320
// Complete the final writer
321321
if let Some(mut writer) = writer.take() {
322322
let (num_rows, data_file) = writer.finish().await?;
323-
info!(target: TRACE_FILE_AUDIT, mode=AUDIT_MODE_CREATE, type=AUDIT_TYPE_DATA, path = &data_file.path);
323+
info!(target: TRACE_FILE_AUDIT, mode=AUDIT_MODE_CREATE, r#type=AUDIT_TYPE_DATA, path = &data_file.path);
324324
let last_fragment = fragments.last_mut().unwrap();
325325
last_fragment.physical_rows = Some(num_rows as usize);
326326
last_fragment.files.push(data_file);

rust/lance/src/index.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -966,7 +966,7 @@ impl DatasetIndexInternalExt for Dataset {
966966

967967
let index = scalar::open_scalar_index(self, column, &index_meta, metrics).await?;
968968

969-
info!(target: TRACE_IO_EVENTS, index_uuid=uuid, type=IO_TYPE_OPEN_SCALAR, index_type=index.index_type().to_string());
969+
info!(target: TRACE_IO_EVENTS, index_uuid=uuid, r#type=IO_TYPE_OPEN_SCALAR, index_type=index.index_type().to_string());
970970
metrics.record_index_load();
971971

972972
self.session.index_cache.insert_scalar(uuid, index.clone());
@@ -997,7 +997,7 @@ impl DatasetIndexInternalExt for Dataset {
997997
// TODO: we need to change the legacy IVF_PQ to be in lance format
998998
let index = match (major_version, minor_version) {
999999
(0, 1) | (0, 0) => {
1000-
info!(target: TRACE_IO_EVENTS, index_uuid=uuid, type=IO_TYPE_OPEN_VECTOR, version="0.1", index_type="IVF_PQ");
1000+
info!(target: TRACE_IO_EVENTS, index_uuid=uuid, r#type=IO_TYPE_OPEN_VECTOR, version="0.1", index_type="IVF_PQ");
10011001
let proto = open_index_proto(reader.as_ref()).await?;
10021002
match &proto.implementation {
10031003
Some(Implementation::VectorIndex(vector_index)) => {
@@ -1012,7 +1012,7 @@ impl DatasetIndexInternalExt for Dataset {
10121012
}
10131013

10141014
(0, 2) => {
1015-
info!(target: TRACE_IO_EVENTS, index_uuid=uuid, type=IO_TYPE_OPEN_VECTOR, version="0.2", index_type="IVF_PQ");
1015+
info!(target: TRACE_IO_EVENTS, index_uuid=uuid, r#type=IO_TYPE_OPEN_VECTOR, version="0.2", index_type="IVF_PQ");
10161016
let reader = FileReader::try_new_self_described_from_reader(
10171017
reader.clone(),
10181018
Some(&self.metadata_cache),
@@ -1055,7 +1055,7 @@ impl DatasetIndexInternalExt for Dataset {
10551055

10561056
let (_, element_type) = get_vector_type(self.schema(), column)?;
10571057

1058-
info!(target: TRACE_IO_EVENTS, index_uuid=uuid, type=IO_TYPE_OPEN_VECTOR, version="0.3", index_type=index_metadata.index_type);
1058+
info!(target: TRACE_IO_EVENTS, index_uuid=uuid, r#type=IO_TYPE_OPEN_VECTOR, version="0.3", index_type=index_metadata.index_type);
10591059

10601060
match index_metadata.index_type.as_str() {
10611061
"IVF_FLAT" => match element_type {
@@ -1175,7 +1175,7 @@ impl DatasetIndexInternalExt for Dataset {
11751175
let index_details = load_frag_reuse_index_details(self, &index_meta).await?;
11761176
let index = open_frag_reuse_index(index_details.as_ref()).await?;
11771177

1178-
info!(target: TRACE_IO_EVENTS, index_uuid=uuid, type=IO_TYPE_OPEN_FRAG_REUSE);
1178+
info!(target: TRACE_IO_EVENTS, index_uuid=uuid, r#type=IO_TYPE_OPEN_FRAG_REUSE);
11791179
metrics.record_index_load();
11801180

11811181
self.session

rust/lance/src/index/vector/ivf.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ impl IVFIndex {
179179
part_idx
180180
} else {
181181
metrics.record_part_load();
182-
tracing::info!(target: TRACE_IO_EVENTS, type=IO_TYPE_LOAD_VECTOR_PART, index_type="ivf", part_id=cache_key);
182+
tracing::info!(target: TRACE_IO_EVENTS, r#type=IO_TYPE_LOAD_VECTOR_PART, index_type="ivf", part_id=cache_key);
183183

184184
let mtx = self.partition_locks.get_partition_mutex(partition_id);
185185
let _guard = mtx.lock().await;

rust/lance/src/index/vector/ivf/v2.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ impl<S: IvfSubIndex + 'static, Q: Quantization> IVFIndex<S, Q> {
232232
{
233233
part_idx
234234
} else {
235-
info!(target: TRACE_IO_EVENTS, type=IO_TYPE_LOAD_VECTOR_PART, index_type="ivf", part_id=cache_key);
235+
info!(target: TRACE_IO_EVENTS, r#type=IO_TYPE_LOAD_VECTOR_PART, index_type="ivf", part_id=cache_key);
236236
metrics.record_part_load();
237237
if partition_id >= self.ivf.num_partitions() {
238238
return Err(Error::Index {

0 commit comments

Comments
 (0)