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:
[legend]
Collaboration diagram for cloudViewer::core::HashSet:
[legend]

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, Tensor > Insert (const Tensor &input_keys)
 
std::pair< Tensor, Tensor > Find (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< DeviceHashBackend > GetDeviceHashBackend () 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...
 

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.

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.

◆ Clear()

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

Clear stored map without reallocating the buffers.

◆ Clone()

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

Clone the hash set with buffers.

References GetDevice(), and 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).

◆ 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.

◆ 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).

References cloudViewer::core::make_pair().

Referenced by 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.

◆ 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.

◆ 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.

◆ GetBucketCount()

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

Get the number of buckets of the internal hash set.

◆ GetCapacity()

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

Get the capacity of the hash set.

◆ GetDevice()

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

Get the device of the hash set.

Implements cloudViewer::core::IsDevice.

Referenced by Clone().

◆ GetDeviceHashBackend()

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

Return the implementation of the device hash backend.

◆ 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}})

◆ 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).

References cloudViewer::core::make_pair().

Referenced by 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.

◆ Load()

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

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

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

◆ LoadFactor()

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

Return size / bucket_count.

◆ Reserve()

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

Reserve the internal hash map with the capcity by rehashing.

◆ 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.

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

◆ Size()

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

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

Referenced by 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.

References copy, and HashSet().


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