ACloudViewer  3.9.4
A Modern Library for 3D Data Processing
cloudViewer::core::HashSet Class Reference

#include <HashSet.h>

Inheritance diagram for cloudViewer::core::HashSet:
Collaboration diagram for cloudViewer::core::HashSet:

Public Member Functions

 HashSet (int64_t init_capacity, const Dtype &key_dtype, const SizeVector &key_element_shape, const Device &device, const HashBackendType &backend=HashBackendType::Default)
 Initialize a hash set given a key dtype and element shape. More...
 
 ~HashSet ()=default
 Default destructor. More...
 
void Reserve (int64_t capacity)
 Reserve the internal hash map with the capcity by rehashing. More...
 
std::pair< Tensor, TensorInsert (const Tensor &input_keys)
 
std::pair< Tensor, TensorFind (const Tensor &input_keys)
 
Tensor Erase (const Tensor &input_keys)
 
Tensor GetActiveIndices () const
 
void Insert (const Tensor &input_keys, Tensor &output_buf_indices, Tensor &output_masks)
 
void Find (const Tensor &input_keys, Tensor &output_buf_indices, Tensor &output_masks)
 
void Erase (const Tensor &input_keys, Tensor &output_masks)
 
void GetActiveIndices (Tensor &output_buf_indices) const
 
void Clear ()
 Clear stored map without reallocating the buffers. More...
 
void Save (const std::string &file_name)
 
HashSet Clone () const
 Clone the hash set with buffers. More...
 
HashSet To (const Device &device, bool copy=false) const
 Convert the hash set to another device. More...
 
int64_t Size () const
 Get the size (number of active entries) of the hash set. More...
 
int64_t GetCapacity () const
 Get the capacity of the hash set. More...
 
int64_t GetBucketCount () const
 Get the number of buckets of the internal hash set. More...
 
Device GetDevice () const override
 Get the device of the hash set. More...
 
Tensor GetKeyTensor () const
 
std::vector< int64_t > BucketSizes () const
 Return number of elements per bucket. More...
 
float LoadFactor () const
 Return size / bucket_count. More...
 
std::shared_ptr< DeviceHashBackendGetDeviceHashBackend () const
 Return the implementation of the device hash backend. More...
 
- Public Member Functions inherited from cloudViewer::core::IsDevice
 IsDevice ()=default
 
virtual ~IsDevice ()=default
 
bool IsCPU () const
 
bool IsCUDA () const
 
bool IsSYCL () const
 

Static Public Member Functions

static HashSet Load (const std::string &file_name)
 Load active keys and values from a npz file that contains 'key'. More...
 

Detailed Description

Definition at line 19 of file HashSet.h.

Constructor & Destructor Documentation

◆ HashSet()

cloudViewer::core::HashSet::HashSet ( int64_t  init_capacity,
const Dtype key_dtype,
const SizeVector key_element_shape,
const Device device,
const HashBackendType backend = HashBackendType::Default 
)

Initialize a hash set given a key dtype and element shape.

Definition at line 20 of file HashSet.cpp.

Referenced by Clone(), Load(), and To().

◆ ~HashSet()

cloudViewer::core::HashSet::~HashSet ( )
default

Default destructor.

Member Function Documentation

◆ BucketSizes()

std::vector< int64_t > cloudViewer::core::HashSet::BucketSizes ( ) const

Return number of elements per bucket.

Definition at line 108 of file HashSet.cpp.

◆ Clear()

void cloudViewer::core::HashSet::Clear ( )

Clear stored map without reallocating the buffers.

Definition at line 77 of file HashSet.cpp.

◆ Clone()

HashSet cloudViewer::core::HashSet::Clone ( ) const

Clone the hash set with buffers.

Definition at line 88 of file HashSet.cpp.

References GetDevice(), and HashSet().

Referenced by cloudViewer::core::pybind_core_hashset().

◆ Erase() [1/2]

Tensor cloudViewer::core::HashSet::Erase ( const Tensor input_keys)

Parallel erase an array of keys in Tensor. Return: output_masks stores if the erase is a success or failure (key not found all already erased in another thread).

Definition at line 44 of file HashSet.cpp.

Referenced by cloudViewer::core::pybind_core_hashset().

◆ Erase() [2/2]

void cloudViewer::core::HashSet::Erase ( const Tensor input_keys,
Tensor output_masks 
)

Same as Erase, but takes output_masks as input. If its shape and type matches, reallocation is not needed.

Definition at line 69 of file HashSet.cpp.

◆ Find() [1/2]

std::pair< Tensor, Tensor > cloudViewer::core::HashSet::Find ( const Tensor input_keys)

Parallel find an array of keys in Tensor. Return: output_buf_indices, its role is the same as in Insert. Return: output_masks stores if the finding is a success or failure (key not found).

Definition at line 38 of file HashSet.cpp.

References cloudViewer::core::make_pair().

Referenced by cloudViewer::core::pybind_core_hashset(), and cloudViewer::t::geometry::PointCloud::VoxelDownSample().

◆ Find() [2/2]

void cloudViewer::core::HashSet::Find ( const Tensor input_keys,
Tensor output_buf_indices,
Tensor output_masks 
)

Same as Find, but takes output_buf_indices and output_masks as input. If their shapes and types match, reallocation is not needed.

Definition at line 63 of file HashSet.cpp.

◆ GetActiveIndices() [1/2]

Tensor cloudViewer::core::HashSet::GetActiveIndices ( ) const

Parallel collect all indices in the buffer corresponding to the active entries in the hash map. Return output_buf_indices, collected buffer indices.

Definition at line 50 of file HashSet.cpp.

Referenced by cloudViewer::core::pybind_core_hashset().

◆ GetActiveIndices() [2/2]

void cloudViewer::core::HashSet::GetActiveIndices ( Tensor output_buf_indices) const

Same as GetActiveIndices, but takes output_buf_indices as input. If its shape and type matches, reallocation is not needed.

Definition at line 73 of file HashSet.cpp.

◆ GetBucketCount()

int64_t cloudViewer::core::HashSet::GetBucketCount ( ) const

Get the number of buckets of the internal hash set.

Definition at line 102 of file HashSet.cpp.

◆ GetCapacity()

int64_t cloudViewer::core::HashSet::GetCapacity ( ) const

Get the capacity of the hash set.

Definition at line 100 of file HashSet.cpp.

Referenced by cloudViewer::core::pybind_core_hashset().

◆ GetDevice()

Device cloudViewer::core::HashSet::GetDevice ( ) const
overridevirtual

Get the device of the hash set.

Implements cloudViewer::core::IsDevice.

Definition at line 104 of file HashSet.cpp.

Referenced by Clone(), and cloudViewer::core::pybind_core_hashset().

◆ GetDeviceHashBackend()

std::shared_ptr< DeviceHashBackend > cloudViewer::core::HashSet::GetDeviceHashBackend ( ) const

Return the implementation of the device hash backend.

Definition at line 114 of file HashSet.cpp.

◆ GetKeyTensor()

Tensor cloudViewer::core::HashSet::GetKeyTensor ( ) const

Get the key tensor buffer to be used along with buf_indices and masks. Example: GetKeyTensor().IndexGet({buf_indices.To(core::Int64).IndexGet{masks}})

Definition at line 106 of file HashSet.cpp.

Referenced by cloudViewer::core::pybind_core_hashset().

◆ Insert() [1/2]

std::pair< Tensor, Tensor > cloudViewer::core::HashSet::Insert ( const Tensor input_keys)

Parallel insert arrays of keys and values in Tensors. Return: output_buf_indices stores buffer indices that access buffer tensors obtained from GetKeyTensor() and GetValueTensor() via advanced indexing. NOTE: output_buf_indices are stored in Int32. A conversion to Int64 is required for further indexing. Return: output_masks stores if the insertion is a success or failure (key already exists).

Definition at line 32 of file HashSet.cpp.

References cloudViewer::core::make_pair().

Referenced by cloudViewer::core::pybind_core_hashset(), cloudViewer::t::geometry::PointCloud::RemoveDuplicatedPoints(), and cloudViewer::t::geometry::PointCloud::VoxelDownSample().

◆ Insert() [2/2]

void cloudViewer::core::HashSet::Insert ( const Tensor input_keys,
Tensor output_buf_indices,
Tensor output_masks 
)

Same as Insert, but takes output_buf_indices and output_masks as input. If their shapes and types match, reallocation is not needed.

Definition at line 56 of file HashSet.cpp.

◆ Load()

HashSet cloudViewer::core::HashSet::Load ( const std::string &  file_name)
static

Load active keys and values from a npz file that contains 'key'.

Definition at line 83 of file HashSet.cpp.

References HashSet(), and cloudViewer::t::io::ReadHashMap().

Referenced by cloudViewer::core::pybind_core_hashset().

◆ LoadFactor()

float cloudViewer::core::HashSet::LoadFactor ( ) const

Return size / bucket_count.

Definition at line 112 of file HashSet.cpp.

◆ Reserve()

void cloudViewer::core::HashSet::Reserve ( int64_t  capacity)

Reserve the internal hash map with the capcity by rehashing.

Definition at line 30 of file HashSet.cpp.

Referenced by cloudViewer::core::pybind_core_hashset().

◆ Save()

void cloudViewer::core::HashSet::Save ( const std::string &  file_name)

Save active keys to a npz file at 'key'. The file name should end with 'npz', otherwise 'npz' will be added as an extension.

Definition at line 79 of file HashSet.cpp.

References cloudViewer::t::io::WriteHashMap().

Referenced by cloudViewer::core::pybind_core_hashset().

◆ Size()

int64_t cloudViewer::core::HashSet::Size ( ) const

Get the size (number of active entries) of the hash set.

Definition at line 98 of file HashSet.cpp.

Referenced by cloudViewer::core::pybind_core_hashset(), and cloudViewer::t::geometry::PointCloud::VoxelDownSample().

◆ To()

HashSet cloudViewer::core::HashSet::To ( const Device device,
bool  copy = false 
) const

Convert the hash set to another device.

Definition at line 93 of file HashSet.cpp.

References copy, and HashSet().

Referenced by cloudViewer::core::pybind_core_hashset().


The documentation for this class was generated from the following files: