Struct sql_ops::partition::PartitionedRelation
source · [−]pub struct PartitionedRelation<T: DeviceCopy> {
pub relation: Mem<T>,
pub offsets: Mem<u64>,
/* private fields */
}
Expand description
A radix-partitioned relation, optionally with padding in front of each partition.
The relation supports chunking on a single GPU. E.g. in the Chunked
algorithm, there is a chunk per thread block. In this case, chunks
should
equal the grid size.
Invariants
len
must match inPartitionOffsets
radix_bits
must match inGpuRadixPartitioner
.max_chunks
must equal the maximum number of chunks computed at runtime (e.g., the grid size).
Fields
relation: Mem<T>
offsets: Mem<u64>
Implementations
sourceimpl<T: DeviceCopy> PartitionedRelation<T>
impl<T: DeviceCopy> PartitionedRelation<T>
sourcepub fn new(
len: usize,
histogram_algorithm_type: HistogramAlgorithmType,
radix_bits: u32,
max_chunks: u32,
partition_alloc_fn: MemAllocFn<T>,
offsets_alloc_fn: MemAllocFn<u64>
) -> Self
pub fn new(
len: usize,
histogram_algorithm_type: HistogramAlgorithmType,
radix_bits: u32,
max_chunks: u32,
partition_alloc_fn: MemAllocFn<T>,
offsets_alloc_fn: MemAllocFn<u64>
) -> Self
Creates a new partitioned relation, and automatically includes the necessary padding and metadata.
sourcepub fn len(&self) -> usize
pub fn len(&self) -> usize
Returns the total number of elements in the relation (excluding padding).
sourcepub fn padded_len(&self) -> usize
pub fn padded_len(&self) -> usize
Returns the total number of elements in the relation including padding.
sourcepub fn bytes(&self) -> usize
pub fn bytes(&self) -> usize
Returns the total number of bytes used to store the relation (including metadata).
sourcepub fn capacity(&self) -> usize
pub fn capacity(&self) -> usize
Returns the number of elements allocated in memory (excluding padding).
The capacity includes unused elements, but excludes padding.
sourcepub fn resize(&mut self, new_len: usize) -> Result<()>
pub fn resize(&mut self, new_len: usize) -> Result<()>
Resizes the PartitionedRelation
in-place so that len
is equal to new_len
.
If new_len
is greater than the allocated memory capacity, then the
resize will abort and return Err
.
Post-conditions
- The resize invalidates all data contained in
relation
and theoffsets
. - However, an aborted resize leaves
PartitionedRelation
intact and unmodified.
sourcepub fn num_chunks(&self) -> u32
pub fn num_chunks(&self) -> u32
Returs the number of chunks.
sourcepub fn radix_bits(&self) -> u32
pub fn radix_bits(&self) -> u32
Returns the number of radix bits.
sourcepub fn partition_len(&self, partition_id: u32) -> Result<usize>
pub fn partition_len(&self, partition_id: u32) -> Result<usize>
Returns the length of the requested partition.
If the offsets are accessible by the CPU (i.e., in DerefMem), then the length is returned. Otherwise, the function returns an error.
sourcepub fn padding_len(&self) -> u32
pub fn padding_len(&self) -> u32
Returns the number of padding elements per partition.
sourcepub unsafe fn as_raw_relation_slice(&self) -> Result<&[T]>
pub unsafe fn as_raw_relation_slice(&self) -> Result<&[T]>
Returns the internal representation of the relation data as a slice.
This function is intended for unit testing. Use the methods provided by
the Index
trait or chunks_mut()
instead if possible.
The function is unsafe because:
- the internal representation may change
- padding may contain uninitialized memory.
sourcepub unsafe fn as_raw_relation_mut_slice(&mut self) -> Result<&mut [T]>
pub unsafe fn as_raw_relation_mut_slice(&mut self) -> Result<&mut [T]>
Returns the internal representation of the relation data as a mutable slice.
This function is intended for unit testing. Use the methods provided by
the Index
trait or chunks_mut()
instead if possible.
The function is unsafe because:
- the internal representation may change
- padding may contain uninitialized memory.
sourceimpl<K: DeviceCopy, V: DeviceCopy> PartitionedRelation<Tuple<K, V>>
impl<K: DeviceCopy, V: DeviceCopy> PartitionedRelation<Tuple<K, V>>
sourcepub fn chunks_mut(&mut self) -> PartitionedRelationChunksMut<'_, Tuple<K, V>>ⓘNotable traits for PartitionedRelationChunksMut<'a, T>impl<'a, T: DeviceCopy> Iterator for PartitionedRelationChunksMut<'a, T> type Item = PartitionedRelationMutSlice<'a, T>;
pub fn chunks_mut(&mut self) -> PartitionedRelationChunksMut<'_, Tuple<K, V>>ⓘNotable traits for PartitionedRelationChunksMut<'a, T>impl<'a, T: DeviceCopy> Iterator for PartitionedRelationChunksMut<'a, T> type Item = PartitionedRelationMutSlice<'a, T>;
Returns an iterator over the chunks contained inside the relation.
Chunks are non-overlapping and can safely be used for parallel processing.
Trait Implementations
sourceimpl<T: Debug + DeviceCopy> Debug for PartitionedRelation<T>
impl<T: Debug + DeviceCopy> Debug for PartitionedRelation<T>
sourceimpl<T: DeviceCopy> Index<(u32, u32)> for PartitionedRelation<T>
impl<T: DeviceCopy> Index<(u32, u32)> for PartitionedRelation<T>
Returns the specified chunk and partition as a subslice of the relation.
sourceimpl<T: DeviceCopy> IndexMut<(u32, u32)> for PartitionedRelation<T>
impl<T: DeviceCopy> IndexMut<(u32, u32)> for PartitionedRelation<T>
Returns the specified chunk and partition as a mutable subslice of the relation.
sourceimpl<T: DeviceCopy> MemLock for PartitionedRelation<T>
impl<T: DeviceCopy> MemLock for PartitionedRelation<T>
sourcefn mlock(&mut self) -> NumaGpuResult<()>
fn mlock(&mut self) -> NumaGpuResult<()>
Lock memory
sourcefn munlock(&mut self) -> NumaGpuResult<()>
fn munlock(&mut self) -> NumaGpuResult<()>
Unlock memory
Auto Trait Implementations
impl<T> RefUnwindSafe for PartitionedRelation<T> where
T: RefUnwindSafe,
impl<T> Send for PartitionedRelation<T> where
T: Send,
impl<T> Sync for PartitionedRelation<T> where
T: Sync,
impl<T> Unpin for PartitionedRelation<T> where
T: Unpin,
impl<T> UnwindSafe for PartitionedRelation<T> where
T: UnwindSafe + RefUnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcepub fn borrow_mut(&mut self) -> &mut T
pub fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more