Skip to content

Commit 4e4902f

Browse files
authored
Remove Position trait (#1163) (#2479)
1 parent e80656f commit 4e4902f

File tree

1 file changed

+4
-25
lines changed

1 file changed

+4
-25
lines changed

parquet/src/util/io.rs

Lines changed: 4 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -38,14 +38,6 @@ impl<T: Read + Seek + Length + TryClone> ParquetReader for T {}
3838

3939
// Read/Write wrappers for `File`.
4040

41-
/// Position trait returns the current position in the stream.
42-
/// Should be viewed as a lighter version of `Seek` that does not allow seek operations,
43-
/// and does not require mutable reference for the current position.
44-
pub trait Position {
45-
/// Returns position in the stream.
46-
fn pos(&self) -> u64;
47-
}
48-
4941
/// Struct that represents a slice of a file data with independent start position and
5042
/// length. Internally clones provided file handle, wraps with a custom implementation
5143
/// of BufReader that resets position before any read.
@@ -142,25 +134,12 @@ impl<R: ParquetReader> Read for FileSource<R> {
142134
}
143135
}
144136

145-
impl<R: ParquetReader> Position for FileSource<R> {
146-
fn pos(&self) -> u64 {
147-
self.start
148-
}
149-
}
150-
151137
impl<R: ParquetReader> Length for FileSource<R> {
152138
fn len(&self) -> u64 {
153139
self.end - self.start
154140
}
155141
}
156142

157-
// Position implementation for Cursor to use in various tests.
158-
impl<'a> Position for Cursor<&'a mut Vec<u8>> {
159-
fn pos(&self) -> u64 {
160-
self.position()
161-
}
162-
}
163-
164143
#[cfg(test)]
165144
mod tests {
166145
use super::*;
@@ -196,10 +175,10 @@ mod tests {
196175
let mut src = FileSource::new(&get_test_file("alltypes_plain.parquet"), 0, 4);
197176

198177
let _ = src.read(&mut [0; 1]).unwrap();
199-
assert_eq!(src.pos(), 1);
178+
assert_eq!(src.start, 1);
200179

201180
let _ = src.read(&mut [0; 4]).unwrap();
202-
assert_eq!(src.pos(), 4);
181+
assert_eq!(src.start, 4);
203182
}
204183

205184
#[test]
@@ -208,12 +187,12 @@ mod tests {
208187

209188
// Read all bytes from source
210189
let _ = src.read(&mut [0; 128]).unwrap();
211-
assert_eq!(src.pos(), 4);
190+
assert_eq!(src.start, 4);
212191

213192
// Try reading again, should return 0 bytes.
214193
let bytes_read = src.read(&mut [0; 128]).unwrap();
215194
assert_eq!(bytes_read, 0);
216-
assert_eq!(src.pos(), 4);
195+
assert_eq!(src.start, 4);
217196
}
218197

219198
#[test]

0 commit comments

Comments
 (0)