Skip to content

Commit 67ee5be

Browse files
ding-youngalamb
authored andcommitted
Remove uses of #[allow(dead_code)] in favor of _identifier (#13328)
* Remove uses of #[allow(dead_code)] in favor of _identifier * update comments
1 parent 9b414e6 commit 67ee5be

File tree

9 files changed

+29
-34
lines changed

9 files changed

+29
-34
lines changed

datafusion-examples/examples/advanced_parquet_index.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -229,9 +229,9 @@ async fn main() -> Result<()> {
229229
/// `file1.parquet` contains values `0..1000`
230230
#[derive(Debug)]
231231
pub struct IndexTableProvider {
232-
/// Where the file is stored (cleanup on drop)
233-
#[allow(dead_code)]
234-
tmpdir: TempDir,
232+
/// Pointer to temporary file storage. Keeping it in scope to prevent temporary folder
233+
/// to be deleted prematurely
234+
_tmpdir: TempDir,
235235
/// The file that is being read.
236236
indexed_file: IndexedFile,
237237
/// The underlying object store
@@ -250,7 +250,7 @@ impl IndexTableProvider {
250250

251251
Ok(Self {
252252
indexed_file,
253-
tmpdir,
253+
_tmpdir: tmpdir,
254254
object_store,
255255
use_row_selections: AtomicBool::new(false),
256256
})

datafusion/core/tests/parquet/external_access_plan.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,7 @@ impl TestFull {
313313
} = self;
314314

315315
let TestData {
316-
temp_file: _,
316+
_temp_file: _,
317317
schema,
318318
file_name,
319319
file_size,
@@ -361,9 +361,9 @@ impl TestFull {
361361

362362
// Holds necessary data for these tests to reuse the same parquet file
363363
struct TestData {
364-
// field is present as on drop the file is deleted
365-
#[allow(dead_code)]
366-
temp_file: NamedTempFile,
364+
/// Pointer to temporary file storage. Keeping it in scope to prevent temporary folder
365+
/// to be deleted prematurely
366+
_temp_file: NamedTempFile,
367367
schema: SchemaRef,
368368
file_name: String,
369369
file_size: u64,
@@ -402,7 +402,7 @@ fn get_test_data() -> &'static TestData {
402402
let file_size = temp_file.path().metadata().unwrap().len();
403403

404404
TestData {
405-
temp_file,
405+
_temp_file: temp_file,
406406
schema,
407407
file_name,
408408
file_size,

datafusion/core/tests/parquet/mod.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,10 +100,9 @@ enum Unit {
100100
/// table "t" registered, pointing at a parquet file made with
101101
/// `make_test_file`
102102
struct ContextWithParquet {
103-
#[allow(dead_code)]
104103
/// temp file parquet data is written to. The file is cleaned up
105104
/// when dropped
106-
file: NamedTempFile,
105+
_file: NamedTempFile,
107106
provider: Arc<dyn TableProvider>,
108107
ctx: SessionContext,
109108
}
@@ -217,7 +216,7 @@ impl ContextWithParquet {
217216
ctx.register_table("t", provider.clone()).unwrap();
218217

219218
Self {
220-
file,
219+
_file: file,
221220
provider,
222221
ctx,
223222
}

datafusion/execution/src/disk_manager.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ impl DiskManager {
139139

140140
let dir_index = thread_rng().gen_range(0..local_dirs.len());
141141
Ok(RefCountedTempFile {
142-
parent_temp_dir: Arc::clone(&local_dirs[dir_index]),
142+
_parent_temp_dir: Arc::clone(&local_dirs[dir_index]),
143143
tempfile: Builder::new()
144144
.tempfile_in(local_dirs[dir_index].as_ref())
145145
.map_err(DataFusionError::IoError)?,
@@ -153,8 +153,7 @@ impl DiskManager {
153153
pub struct RefCountedTempFile {
154154
/// The reference to the directory in which temporary files are created to ensure
155155
/// it is not cleaned up prior to the NamedTempFile
156-
#[allow(dead_code)]
157-
parent_temp_dir: Arc<TempDir>,
156+
_parent_temp_dir: Arc<TempDir>,
158157
tempfile: NamedTempFile,
159158
}
160159

datafusion/physical-plan/src/joins/cross_join.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,7 @@ struct JoinLeftData {
5353
merged_batch: RecordBatch,
5454
/// Track memory reservation for merged_batch. Relies on drop
5555
/// semantics to release reservation when JoinLeftData is dropped.
56-
#[allow(dead_code)]
57-
reservation: MemoryReservation,
56+
_reservation: MemoryReservation,
5857
}
5958

6059
#[allow(rustdoc::private_intra_doc_links)]
@@ -209,7 +208,7 @@ async fn load_left_input(
209208

210209
Ok(JoinLeftData {
211210
merged_batch,
212-
reservation,
211+
_reservation: reservation,
213212
})
214213
}
215214

datafusion/physical-plan/src/joins/hash_join.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,7 @@ struct JoinLeftData {
9292
probe_threads_counter: AtomicUsize,
9393
/// Memory reservation that tracks memory used by `hash_map` hash table
9494
/// `batch`. Cleared on drop.
95-
#[allow(dead_code)]
96-
reservation: MemoryReservation,
95+
_reservation: MemoryReservation,
9796
}
9897

9998
impl JoinLeftData {
@@ -110,7 +109,7 @@ impl JoinLeftData {
110109
batch,
111110
visited_indices_bitmap,
112111
probe_threads_counter,
113-
reservation,
112+
_reservation: reservation,
114113
}
115114
}
116115

datafusion/physical-plan/src/joins/nested_loop_join.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69,22 +69,21 @@ struct JoinLeftData {
6969
probe_threads_counter: AtomicUsize,
7070
/// Memory reservation for tracking batch and bitmap
7171
/// Cleared on `JoinLeftData` drop
72-
#[allow(dead_code)]
73-
reservation: MemoryReservation,
72+
_reservation: MemoryReservation,
7473
}
7574

7675
impl JoinLeftData {
7776
fn new(
7877
batch: RecordBatch,
7978
bitmap: SharedBitmapBuilder,
8079
probe_threads_counter: AtomicUsize,
81-
reservation: MemoryReservation,
80+
_reservation: MemoryReservation,
8281
) -> Self {
8382
Self {
8483
batch,
8584
bitmap,
8685
probe_threads_counter,
87-
reservation,
86+
_reservation,
8887
}
8988
}
9089

datafusion/physical-plan/src/repartition/mod.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -623,7 +623,7 @@ impl ExecutionPlan for RepartitionExec {
623623
Box::pin(PerPartitionStream {
624624
schema: Arc::clone(&schema_captured),
625625
receiver,
626-
drop_helper: Arc::clone(&abort_helper),
626+
_drop_helper: Arc::clone(&abort_helper),
627627
reservation: Arc::clone(&reservation),
628628
}) as SendableRecordBatchStream
629629
})
@@ -651,7 +651,7 @@ impl ExecutionPlan for RepartitionExec {
651651
num_input_partitions_processed: 0,
652652
schema: input.schema(),
653653
input: rx.swap_remove(0),
654-
drop_helper: abort_helper,
654+
_drop_helper: abort_helper,
655655
reservation,
656656
}) as SendableRecordBatchStream)
657657
}
@@ -906,8 +906,7 @@ struct RepartitionStream {
906906
input: DistributionReceiver<MaybeBatch>,
907907

908908
/// Handle to ensure background tasks are killed when no longer needed.
909-
#[allow(dead_code)]
910-
drop_helper: Arc<Vec<SpawnedTask<()>>>,
909+
_drop_helper: Arc<Vec<SpawnedTask<()>>>,
911910

912911
/// Memory reservation.
913912
reservation: SharedMemoryReservation,
@@ -970,8 +969,7 @@ struct PerPartitionStream {
970969
receiver: DistributionReceiver<MaybeBatch>,
971970

972971
/// Handle to ensure background tasks are killed when no longer needed.
973-
#[allow(dead_code)]
974-
drop_helper: Arc<Vec<SpawnedTask<()>>>,
972+
_drop_helper: Arc<Vec<SpawnedTask<()>>>,
975973

976974
/// Memory reservation.
977975
reservation: SharedMemoryReservation,

datafusion/physical-plan/src/sorts/cursor.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -156,8 +156,7 @@ pub struct RowValues {
156156

157157
/// Tracks for the memory used by in the `Rows` of this
158158
/// cursor. Freed on drop
159-
#[allow(dead_code)]
160-
reservation: MemoryReservation,
159+
_reservation: MemoryReservation,
161160
}
162161

163162
impl RowValues {
@@ -173,7 +172,10 @@ impl RowValues {
173172
"memory reservation mismatch"
174173
);
175174
assert!(rows.num_rows() > 0);
176-
Self { rows, reservation }
175+
Self {
176+
rows,
177+
_reservation: reservation,
178+
}
177179
}
178180
}
179181

0 commit comments

Comments
 (0)