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::GeometryStats Struct Reference

Static Public Member Functions

static DUCKDB_API BaseStatistics CreateUnknown (LogicalType type)
 Unknown statistics.
static DUCKDB_API BaseStatistics CreateEmpty (LogicalType type)
 Empty statistics.
static DUCKDB_API void Serialize (const BaseStatistics &stats, Serializer &serializer)
static DUCKDB_API void Deserialize (Deserializer &deserializer, BaseStatistics &base)
static DUCKDB_API string ToString (const BaseStatistics &stats)
static DUCKDB_API void Update (BaseStatistics &stats, const string_t &value)
static DUCKDB_API void Merge (BaseStatistics &stats, const BaseStatistics &other)
static DUCKDB_API void Verify (const BaseStatistics &stats, Vector &vector, const SelectionVector &sel, idx_t count)
static DUCKDB_API FilterPropagateResult CheckZonemap (const BaseStatistics &stats, const unique_ptr< Expression > &expr)
 Check if a spatial predicate check with a constant could possibly be satisfied by rows given the statistics.
static DUCKDB_API GeometryExtent & GetExtent (BaseStatistics &stats)
static DUCKDB_API const GeometryExtent & GetExtent (const BaseStatistics &stats)
static DUCKDB_API GeometryTypeSet & GetTypes (BaseStatistics &stats)
static DUCKDB_API const GeometryTypeSet & GetTypes (const BaseStatistics &stats)
static DUCKDB_API GeometryStatsFlags & GetFlags (BaseStatistics &stats)
static DUCKDB_API const GeometryStatsFlags & GetFlags (const BaseStatistics &stats)
static GeometryStatsData & GetDataUnsafe (BaseStatistics &stats)
static const GeometryStatsData & GetDataUnsafe (const BaseStatistics &stats)

Member Function Documentation

◆ CreateUnknown()

BaseStatistics duckdb::GeometryStats::CreateUnknown ( LogicalType type)
static

Unknown statistics.

423480 {
423481 BaseStatistics result(std::move(type));
423482 result.InitializeUnknown();
423483 GetDataUnsafe(result).SetUnknown();
423484 return result;
423485}

◆ CreateEmpty()

BaseStatistics duckdb::GeometryStats::CreateEmpty ( LogicalType type)
static

Empty statistics.

423487 {
423488 BaseStatistics result(std::move(type));
423489 result.InitializeEmpty();
423490 GetDataUnsafe(result).SetEmpty();
423491 return result;
423492}

◆ Serialize()

void duckdb::GeometryStats::Serialize ( const BaseStatistics & stats,
Serializer & serializer )
static
423494 {
423495 // Should we serialize as old extension geometry type for backwards compatibility?
423496 // (in that case, write unknown string stats)
423497 if (!serializer.ShouldSerialize(7)) {
423498 auto string_stats = StringStats::CreateUnknown(LogicalType::VARCHAR);
423499 StringStats::Serialize(string_stats, serializer);
423500 return;
423501 }
423502
423503 const auto &data = GetDataUnsafe(stats);
423504
423505 // Write extent
423506 serializer.WriteObject(300, "extent", [&](Serializer &extent) {
423507 extent.WriteProperty<double>(101, "x_min", data.extent.x_min);
423508 extent.WriteProperty<double>(102, "x_max", data.extent.x_max);
423509 extent.WriteProperty<double>(103, "y_min", data.extent.y_min);
423510 extent.WriteProperty<double>(104, "y_max", data.extent.y_max);
423511 extent.WriteProperty<double>(105, "z_min", data.extent.z_min);
423512 extent.WriteProperty<double>(106, "z_max", data.extent.z_max);
423513 extent.WriteProperty<double>(107, "m_min", data.extent.m_min);
423514 extent.WriteProperty<double>(108, "m_max", data.extent.m_max);
423515 });
423516
423517 // Write types
423518 serializer.WriteObject(301, "types", [&](Serializer &types) {
423519 types.WriteProperty<uint8_t>(101, "types_xy", data.types.sets[0]);
423520 types.WriteProperty<uint8_t>(102, "types_xyz", data.types.sets[1]);
423521 types.WriteProperty<uint8_t>(103, "types_xym", data.types.sets[2]);
423522 types.WriteProperty<uint8_t>(104, "types_xyzm", data.types.sets[3]);
423523 });
423524
423525 // Write flags
423526 serializer.WritePropertyWithDefault(302, "flags", data.flags.flags);
423527}
::uint8_t uint8_t
static DUCKDB_API BaseStatistics CreateUnknown(LogicalType type)
Unknown statistics - i.e. "has_unicode" is true, "max_string_length" is unknown, "min" is \0,...
Definition duckdb.cpp:424515

◆ Deserialize()

void duckdb::GeometryStats::Deserialize ( Deserializer & deserializer,
BaseStatistics & base )
static
423529 {
423530 auto &data = GetDataUnsafe(base);
423531
423532 // Read old garbage string stats if present, but ignore it since it is not relevant to geometry stats
423533 if (deserializer.CanDeserializeProperty(200, "min")) {
423534 auto string_stats = StringStats::CreateEmpty(LogicalType::VARCHAR);
423535 StringStats::Deserialize(deserializer, string_stats);
423536
423537 // We don't know how to interpret the old string stats, so we just set the geometry stats to unknown
423538 data.extent = GeometryExtent::Unknown();
423539 data.types = GeometryTypeSet::Unknown();
423540 data.flags = GeometryStatsFlags::Unknown();
423541 return;
423542 }
423543
423544 // Read extent
423545 deserializer.ReadObject(300, "extent", [&](Deserializer &extent) {
423546 extent.ReadProperty<double>(101, "x_min", data.extent.x_min);
423547 extent.ReadProperty<double>(102, "x_max", data.extent.x_max);
423548 extent.ReadProperty<double>(103, "y_min", data.extent.y_min);
423549 extent.ReadProperty<double>(104, "y_max", data.extent.y_max);
423550 extent.ReadProperty<double>(105, "z_min", data.extent.z_min);
423551 extent.ReadProperty<double>(106, "z_max", data.extent.z_max);
423552 extent.ReadProperty<double>(107, "m_min", data.extent.m_min);
423553 extent.ReadProperty<double>(108, "m_max", data.extent.m_max);
423554 });
423555
423556 // Read types
423557 deserializer.ReadObject(301, "types", [&](Deserializer &types) {
423558 types.ReadProperty<uint8_t>(101, "types_xy", data.types.sets[0]);
423559 types.ReadProperty<uint8_t>(102, "types_xyz", data.types.sets[1]);
423560 types.ReadProperty<uint8_t>(103, "types_xym", data.types.sets[2]);
423561 types.ReadProperty<uint8_t>(104, "types_xyzm", data.types.sets[3]);
423562 });
423563
423564 // Read flags
423565 deserializer.ReadPropertyWithDefault<uint8_t>(302, "flags", data.flags.flags);
423566}
static DUCKDB_API BaseStatistics CreateEmpty(LogicalType type)
Empty statistics - i.e. "has_unicode" is false, "max_string_length" is 0, "min" is \xFF,...
Definition duckdb.cpp:424529

◆ ToString()

string duckdb::GeometryStats::ToString ( const BaseStatistics & stats)
static
423568 {
423569 const auto &data = GetDataUnsafe(stats);
423570 string result;
423571
423572 result += "[";
423573 result += StringUtil::Format("Extent: [X: [%f, %f], Y: [%f, %f], Z: [%f, %f], M: [%f, %f]]", data.extent.x_min,
423574 data.extent.x_max, data.extent.y_min, data.extent.y_max, data.extent.z_min,
423575 data.extent.z_max, data.extent.m_min, data.extent.m_max);
423576 result += StringUtil::Format(", Types: [%s]", StringUtil::Join(data.types.ToString(true), ", "));
423577 result += StringUtil::Format(
423578 ", Flags: [Has Empty Geom: %s, Has No Empty Geom: %s, Has Empty Part: %s, Has No Empty Part: %s]",
423579 data.flags.HasEmptyGeometry() ? "true" : "false", data.flags.HasNonEmptyGeometry() ? "true" : "false",
423580 data.flags.HasEmptyPart() ? "true" : "false", data.flags.HasNonEmptyPart() ? "true" : "false");
423581
423582 result += "]";
423583 return result;
423584}
static string Format(const string fmt_str, ARGS... params)
Format a string using printf semantics.
Definition duckdb.hpp:4002
static DUCKDB_API string Join(const vector< string > &input, const string &separator)
Join multiple strings into one string. Components are concatenated by the given separator.
Definition duckdb.cpp:109497

◆ Update()

void duckdb::GeometryStats::Update ( BaseStatistics & stats,
const string_t & value )
static
423586 {
423587 auto &data = GetDataUnsafe(stats);
423588 data.Update(value);
423589}

◆ Merge()

void duckdb::GeometryStats::Merge ( BaseStatistics & stats,
const BaseStatistics & other )
static
423591 {
423592 if (other.GetType().id() == LogicalTypeId::VALIDITY) {
423593 return;
423594 }
423595 if (other.GetType().id() == LogicalTypeId::SQLNULL) {
423596 return;
423597 }
423598
423599 auto &target = GetDataUnsafe(stats);
423600 auto &source = GetDataUnsafe(other);
423601 target.Merge(source);
423602}

◆ Verify()

void duckdb::GeometryStats::Verify ( const BaseStatistics & stats,
Vector & vector,
const SelectionVector & sel,
idx_t count )
static
423604 {
423605 // TODO: Verify stats
423606}

◆ CheckZonemap()

FilterPropagateResult duckdb::GeometryStats::CheckZonemap ( const BaseStatistics & stats,
const unique_ptr< Expression > & expr )
static

Check if a spatial predicate check with a constant could possibly be satisfied by rows given the statistics.

423674 {
423675 if (expr->GetExpressionType() != ExpressionType::BOUND_FUNCTION) {
423676 return FilterPropagateResult::NO_PRUNING_POSSIBLE;
423677 }
423678 if (expr->return_type != LogicalType::BOOLEAN) {
423679 return FilterPropagateResult::NO_PRUNING_POSSIBLE;
423680 }
423681 const auto &func = expr->Cast<BoundFunctionExpression>();
423682 if (func.children.size() != 2) {
423683 return FilterPropagateResult::NO_PRUNING_POSSIBLE;
423684 }
423685
423686 if (func.children[0]->return_type.id() != LogicalTypeId::GEOMETRY ||
423687 func.children[1]->return_type.id() != LogicalTypeId::GEOMETRY) {
423688 return FilterPropagateResult::NO_PRUNING_POSSIBLE;
423689 }
423690
423691 // The set of geometry predicates that can be optimized using the bounding box
423692 static constexpr const char *geometry_predicates[2] = {"&&", "st_intersects_extent"};
423693
423694 auto found = false;
423695 for (const auto &name : geometry_predicates) {
423696 if (StringUtil::CIEquals(func.function.name.c_str(), name)) {
423697 found = true;
423698 break;
423699 }
423700 }
423701 if (!found) {
423702 // Not a geometry predicate we can optimize
423703 return FilterPropagateResult::NO_PRUNING_POSSIBLE;
423704 }
423705
423706 const auto lhs_kind = func.children[0]->GetExpressionType();
423707 const auto rhs_kind = func.children[1]->GetExpressionType();
423708 const auto lhs_is_const = lhs_kind == ExpressionType::VALUE_CONSTANT && rhs_kind == ExpressionType::BOUND_REF;
423709 const auto rhs_is_const = rhs_kind == ExpressionType::VALUE_CONSTANT && lhs_kind == ExpressionType::BOUND_REF;
423710
423711 if (!stats.CanHaveNoNull()) {
423712 // no non-null values are possible: always false
423713 return FilterPropagateResult::FILTER_ALWAYS_FALSE;
423714 }
423715
423716 auto &data = GetDataUnsafe(stats);
423717
423718 if (!data.extent.HasXY()) {
423719 // If the extent is empty or unknown, we cannot prune
423720 return FilterPropagateResult::NO_PRUNING_POSSIBLE;
423721 }
423722
423723 if (lhs_is_const) {
423724 return CheckIntersectionFilter(data, func.children[0]->Cast<BoundConstantExpression>().value);
423725 }
423726 if (rhs_is_const) {
423727 return CheckIntersectionFilter(data, func.children[1]->Cast<BoundConstantExpression>().value);
423728 }
423729 // Else, no constant argument
423730 return FilterPropagateResult::NO_PRUNING_POSSIBLE;
423731}
static DUCKDB_API bool CIEquals(const string &l1, const string &l2)
Case insensitive equals.
Definition duckdb.cpp:109696
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetExtent() [1/2]

GeometryExtent & duckdb::GeometryStats::GetExtent ( BaseStatistics & stats)
static
423618 {
423619 return GetDataUnsafe(stats).extent;
423620}

◆ GetExtent() [2/2]

const GeometryExtent & duckdb::GeometryStats::GetExtent ( const BaseStatistics & stats)
static
423630 {
423631 return GetDataUnsafe(stats).extent;
423632}

◆ GetTypes() [1/2]

GeometryTypeSet & duckdb::GeometryStats::GetTypes ( BaseStatistics & stats)
static
423622 {
423623 return GetDataUnsafe(stats).types;
423624}

◆ GetTypes() [2/2]

const GeometryTypeSet & duckdb::GeometryStats::GetTypes ( const BaseStatistics & stats)
static
423634 {
423635 return GetDataUnsafe(stats).types;
423636}

◆ GetFlags() [1/2]

GeometryStatsFlags & duckdb::GeometryStats::GetFlags ( BaseStatistics & stats)
static
423626 {
423627 return GetDataUnsafe(stats).flags;
423628}

◆ GetFlags() [2/2]

const GeometryStatsFlags & duckdb::GeometryStats::GetFlags ( const BaseStatistics & stats)
static
423638 {
423639 return GetDataUnsafe(stats).flags;
423640}

◆ GetDataUnsafe() [1/2]

GeometryStatsData & duckdb::GeometryStats::GetDataUnsafe ( BaseStatistics & stats)
static
423613 {
423614 D_ASSERT(stats.GetStatsType() == StatisticsType::GEOMETRY_STATS);
423615 return stats.stats_union.geometry_data;
423616}

◆ GetDataUnsafe() [2/2]

const GeometryStatsData & duckdb::GeometryStats::GetDataUnsafe ( const BaseStatistics & stats)
static
423608 {
423609 D_ASSERT(stats.GetStatsType() == StatisticsType::GEOMETRY_STATS);
423610 return stats.stats_union.geometry_data;
423611}

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