11// SPDX-License-Identifier: Apache-2.0
22// SPDX-FileCopyrightText: Copyright the Vortex contributors
33
4- use std:: mem;
54use std:: sync:: Arc ;
65
7- use cudarc:: driver:: { CudaSlice , CudaView } ;
6+ use cudarc:: driver:: CudaView ;
87use vortex_error:: VortexExpect ;
98use vortex_layout:: segments:: { GpuSegmentFuture , GpuSegmentSource , SegmentId } ;
109
1110use crate :: SegmentSpec ;
1211
1312pub struct FileGpuSegmentSource {
1413 segments : Arc < [ SegmentSpec ] > ,
15- contents : CudaSlice < u8 > ,
14+ contents : CudaView < ' static , u8 > ,
1615}
1716
1817impl FileGpuSegmentSource {
19- pub fn new ( segments : Arc < [ SegmentSpec ] > , contents : CudaSlice < u8 > ) -> Self {
18+ pub fn new ( segments : Arc < [ SegmentSpec ] > , contents : CudaView < ' static , u8 > ) -> Self {
2019 FileGpuSegmentSource { segments, contents }
2120 }
22-
23- #[ inline]
24- fn contents ( & self ) -> CudaView < ' static , u8 > {
25- // SAFETY: This is only fine because the callers of this function will be dropped before this segment source is dropped
26- unsafe {
27- mem:: transmute :: < CudaView < ' _ , u8 > , CudaView < ' static , u8 > > ( self . contents . as_view ( ) )
28- }
29- }
3021}
3122
3223impl GpuSegmentSource for FileGpuSegmentSource {
@@ -40,6 +31,6 @@ impl GpuSegmentSource for FileGpuSegmentSource {
4031 let off_usize = usize:: try_from ( spec. offset ) . vortex_expect ( "offset must fit usize" ) ;
4132 let len_usize = usize:: try_from ( spec. length ) . vortex_expect ( "length must fit usize" ) ;
4233
43- Ok ( self . contents ( ) . slice ( off_usize..( off_usize + len_usize) ) )
34+ Ok ( self . contents . slice ( off_usize..( off_usize + len_usize) ) )
4435 }
4536}
0 commit comments