Autonomy Software C++ 24.5.1
Welcome to the Autonomy Software repository of the Mars Rover Design Team (MRDT) at Missouri University of Science and Technology (Missouri S&T)! API reference contains the source code and other resources for the development of the autonomy software for our Mars rover. The Autonomy Software project aims to compete in the University Rover Challenge (URC) by demonstrating advanced autonomous capabilities and robust navigation algorithms.
Loading...
Searching...
No Matches
duckdb::OwningStringMap< VALUE_TYPE, STRING_MAP_TYPE > Class Template Reference
Collaboration diagram for duckdb::OwningStringMap< VALUE_TYPE, STRING_MAP_TYPE >:

Public Types

using size_type = typename STRING_MAP_TYPE::size_type
using key_type = typename STRING_MAP_TYPE::key_type
using mapped_type = typename STRING_MAP_TYPE::mapped_type
using value_type = typename STRING_MAP_TYPE::value_type
using iterator = typename STRING_MAP_TYPE::iterator
using const_iterator = typename STRING_MAP_TYPE::const_iterator

Public Member Functions

 OwningStringMap (Allocator &allocator)
 OwningStringMap (ArenaAllocator &allocator)
pair< iterator, bool > insert (value_type entry)
std::pair< iterator, bool > emplace (value_type &&entry)
size_type erase (const key_type &k)
void clear ()
size_type size () const noexcept
bool empty () const noexcept
iterator begin () noexcept
const_iterator begin () const noexcept
iterator end () noexcept
const_iterator end () const noexcept
iterator find (const key_type &k)
const_iterator find (const key_type &k) const
mapped_type & operator[] (const key_type &k)
mapped_type & operator[] (key_type &&k)

Private Member Functions

string_t GetInsertionString (string_t input_str)
string_t CopyString (string_t input_str)
mapped_type & GetOrCreate (key_type k)
void DestroyString (const string_t &str) const
void Destroy ()

Private Attributes

Allocator & allocator
STRING_MAP_TYPE map
AllocatorFreeType free_type

Detailed Description

template<class VALUE_TYPE, class STRING_MAP_TYPE = string_map_t<VALUE_TYPE>>
class duckdb::OwningStringMap< VALUE_TYPE, STRING_MAP_TYPE >

The owning string map is equivalent to string_map_t, except that it manages ownership of all data using the provided allocator

Constructor & Destructor Documentation

◆ OwningStringMap() [1/2]

template<class VALUE_TYPE, class STRING_MAP_TYPE = string_map_t<VALUE_TYPE>>
duckdb::OwningStringMap< VALUE_TYPE, STRING_MAP_TYPE >::OwningStringMap ( Allocator & allocator)
inlineexplicit
131489 : allocator(allocator), free_type(AllocatorFreeType::REQUIRES_FREE) {
131490 }
Definition duckdb.cpp:131479

◆ OwningStringMap() [2/2]

template<class VALUE_TYPE, class STRING_MAP_TYPE = string_map_t<VALUE_TYPE>>
duckdb::OwningStringMap< VALUE_TYPE, STRING_MAP_TYPE >::OwningStringMap ( ArenaAllocator & allocator)
inlineexplicit
131492 : allocator(allocator.GetAllocator()), free_type(AllocatorFreeType::DOES_NOT_REQUIRE_FREE) {
131493 }

◆ ~OwningStringMap()

template<class VALUE_TYPE, class STRING_MAP_TYPE = string_map_t<VALUE_TYPE>>
duckdb::OwningStringMap< VALUE_TYPE, STRING_MAP_TYPE >::~OwningStringMap ( )
inline
131494 {
131495 Destroy();
131496 }

Member Function Documentation

◆ insert()

template<class VALUE_TYPE, class STRING_MAP_TYPE = string_map_t<VALUE_TYPE>>
pair< iterator, bool > duckdb::OwningStringMap< VALUE_TYPE, STRING_MAP_TYPE >::insert ( value_type entry)
inline
131498 { // NOLINT: match std style
131499 if (entry.first.IsInlined()) {
131500 return map.insert(std::move(entry));
131501 } else {
131502 return map.insert(make_pair(CopyString(entry.first), std::move(entry.second)));
131503 }
131504 }

◆ emplace()

template<class VALUE_TYPE, class STRING_MAP_TYPE = string_map_t<VALUE_TYPE>>
std::pair< iterator, bool > duckdb::OwningStringMap< VALUE_TYPE, STRING_MAP_TYPE >::emplace ( value_type && entry)
inline
131505 { // NOLINT: match std style
131506 auto it = find(entry.first);
131507 if (it != end()) {
131508 return std::make_pair(it, false);
131509 }
131510 return insert(std::move(entry));
131511 }

◆ erase()

template<class VALUE_TYPE, class STRING_MAP_TYPE = string_map_t<VALUE_TYPE>>
size_type duckdb::OwningStringMap< VALUE_TYPE, STRING_MAP_TYPE >::erase ( const key_type & k)
inline
131512 { // NOLINT: match std style
131513 auto entry = map.find(k);
131514 if (entry == map.end()) {
131515 return 0;
131516 }
131517 string_t erase_string = entry->first;
131518 map.erase(entry);
131519 DestroyString(erase_string);
131520 return 1;
131521 }

◆ clear()

template<class VALUE_TYPE, class STRING_MAP_TYPE = string_map_t<VALUE_TYPE>>
void duckdb::OwningStringMap< VALUE_TYPE, STRING_MAP_TYPE >::clear ( )
inline
131523 { // NOLINT: match std style
131524 Destroy();
131525 }

◆ size()

template<class VALUE_TYPE, class STRING_MAP_TYPE = string_map_t<VALUE_TYPE>>
size_type duckdb::OwningStringMap< VALUE_TYPE, STRING_MAP_TYPE >::size ( ) const
inlinenoexcept
131527 { // NOLINT: match std style
131528 return map.size();
131529 }

◆ empty()

template<class VALUE_TYPE, class STRING_MAP_TYPE = string_map_t<VALUE_TYPE>>
bool duckdb::OwningStringMap< VALUE_TYPE, STRING_MAP_TYPE >::empty ( ) const
inlinenoexcept
131531 { // NOLINT: match std style
131532 return map.empty();
131533 }

◆ begin() [1/2]

template<class VALUE_TYPE, class STRING_MAP_TYPE = string_map_t<VALUE_TYPE>>
iterator duckdb::OwningStringMap< VALUE_TYPE, STRING_MAP_TYPE >::begin ( )
inlinenoexcept
131534 { // NOLINT: match std style
131535 return map.begin();
131536 }

◆ begin() [2/2]

template<class VALUE_TYPE, class STRING_MAP_TYPE = string_map_t<VALUE_TYPE>>
const_iterator duckdb::OwningStringMap< VALUE_TYPE, STRING_MAP_TYPE >::begin ( ) const
inlinenoexcept
131537 { // NOLINT: match std style
131538 return map.begin();
131539 }

◆ end() [1/2]

template<class VALUE_TYPE, class STRING_MAP_TYPE = string_map_t<VALUE_TYPE>>
iterator duckdb::OwningStringMap< VALUE_TYPE, STRING_MAP_TYPE >::end ( )
inlinenoexcept
131540 { // NOLINT: match std style
131541 return map.end();
131542 }

◆ end() [2/2]

template<class VALUE_TYPE, class STRING_MAP_TYPE = string_map_t<VALUE_TYPE>>
const_iterator duckdb::OwningStringMap< VALUE_TYPE, STRING_MAP_TYPE >::end ( ) const
inlinenoexcept
131543 { // NOLINT: match std style
131544 return map.end();
131545 }

◆ find() [1/2]

template<class VALUE_TYPE, class STRING_MAP_TYPE = string_map_t<VALUE_TYPE>>
iterator duckdb::OwningStringMap< VALUE_TYPE, STRING_MAP_TYPE >::find ( const key_type & k)
inline
131546 { // NOLINT: match std style
131547 return map.find(k);
131548 }

◆ find() [2/2]

template<class VALUE_TYPE, class STRING_MAP_TYPE = string_map_t<VALUE_TYPE>>
const_iterator duckdb::OwningStringMap< VALUE_TYPE, STRING_MAP_TYPE >::find ( const key_type & k) const
inline
131549 { // NOLINT: match std style
131550 return map.find(k);
131551 }

◆ operator[]() [1/2]

template<class VALUE_TYPE, class STRING_MAP_TYPE = string_map_t<VALUE_TYPE>>
mapped_type & duckdb::OwningStringMap< VALUE_TYPE, STRING_MAP_TYPE >::operator[] ( const key_type & k)
inline
131553 {
131554 return GetOrCreate(k);
131555 }

◆ operator[]() [2/2]

template<class VALUE_TYPE, class STRING_MAP_TYPE = string_map_t<VALUE_TYPE>>
mapped_type & duckdb::OwningStringMap< VALUE_TYPE, STRING_MAP_TYPE >::operator[] ( key_type && k)
inline
131556 {
131557 return GetOrCreate(std::move(k));
131558 }

◆ GetInsertionString()

template<class VALUE_TYPE, class STRING_MAP_TYPE = string_map_t<VALUE_TYPE>>
string_t duckdb::OwningStringMap< VALUE_TYPE, STRING_MAP_TYPE >::GetInsertionString ( string_t input_str)
inlineprivate
131561 {
131562 if (input_str.IsInlined()) {
131563 // inlined strings can be inserted directly
131564 return input_str;
131565 } else {
131566 return CopyString(input_str);
131567 }
131568 }

◆ CopyString()

template<class VALUE_TYPE, class STRING_MAP_TYPE = string_map_t<VALUE_TYPE>>
string_t duckdb::OwningStringMap< VALUE_TYPE, STRING_MAP_TYPE >::CopyString ( string_t input_str)
inlineprivate
131570 {
131571 D_ASSERT(!input_str.IsInlined());
131572 // if the string is not inlined we need to allocate space for it
131574 auto string_memory = allocator.AllocateData(input_str_size);
131575 // copy over the string
131577 // now return the final string_t
131579 }

◆ GetOrCreate()

template<class VALUE_TYPE, class STRING_MAP_TYPE = string_map_t<VALUE_TYPE>>
mapped_type & duckdb::OwningStringMap< VALUE_TYPE, STRING_MAP_TYPE >::GetOrCreate ( key_type k)
inlineprivate
131581 {
131582 auto entry = map.find(k);
131583 if (entry != map.end()) {
131584 return entry->second;
131585 }
131586 auto result = insert(make_pair(k, mapped_type()));
131587 return result.first->second;
131588 }

◆ DestroyString()

template<class VALUE_TYPE, class STRING_MAP_TYPE = string_map_t<VALUE_TYPE>>
void duckdb::OwningStringMap< VALUE_TYPE, STRING_MAP_TYPE >::DestroyString ( const string_t & str) const
inlineprivate
131590 {
131591 if (free_type != AllocatorFreeType::REQUIRES_FREE) {
131592 return;
131593 }
131594 if (str.IsInlined()) {
131595 return;
131596 }
131597 allocator.FreeData(data_ptr_cast(str.GetDataWriteable()), str.GetSize());
131598 }

◆ Destroy()

template<class VALUE_TYPE, class STRING_MAP_TYPE = string_map_t<VALUE_TYPE>>
void duckdb::OwningStringMap< VALUE_TYPE, STRING_MAP_TYPE >::Destroy ( )
inlineprivate
131600 {
131601 if (free_type == AllocatorFreeType::REQUIRES_FREE) {
131602 for (auto &str : map) {
131603 DestroyString(str.first);
131604 }
131605 }
131606 map.clear();
131607 }

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