Skip to content

Commit 52bb393

Browse files
committed
refactor: use string_view for filename parameters in LocationProvider
1 parent bc97f52 commit 52bb393

3 files changed

Lines changed: 11 additions & 11 deletions

File tree

src/iceberg/location_provider.cc

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -104,11 +104,11 @@ class DefaultLocationProvider : public LocationProvider {
104104
DefaultLocationProvider(std::string_view table_location,
105105
const TableProperties& properties);
106106

107-
std::string NewDataLocation(const std::string& filename) override;
107+
std::string NewDataLocation(std::string_view filename) override;
108108

109109
Result<std::string> NewDataLocation(const PartitionSpec& spec,
110110
const PartitionValues& partition_data,
111-
const std::string& filename) override;
111+
std::string_view filename) override;
112112

113113
private:
114114
std::string data_location_;
@@ -120,13 +120,13 @@ DefaultLocationProvider::DefaultLocationProvider(std::string_view table_location
120120
: data_location_(
121121
LocationUtil::StripTrailingSlash(DataLocation(properties, table_location))) {}
122122

123-
std::string DefaultLocationProvider::NewDataLocation(const std::string& filename) {
123+
std::string DefaultLocationProvider::NewDataLocation(std::string_view filename) {
124124
return std::format("{}/{}", data_location_, filename);
125125
}
126126

127127
Result<std::string> DefaultLocationProvider::NewDataLocation(
128128
const PartitionSpec& spec, const PartitionValues& partition_data,
129-
const std::string& filename) {
129+
std::string_view filename) {
130130
ICEBERG_ASSIGN_OR_RAISE(auto partition_path, spec.PartitionPath(partition_data));
131131
return std::format("{}/{}/{}", data_location_, partition_path, filename);
132132
}
@@ -137,11 +137,11 @@ class ObjectStoreLocationProvider : public LocationProvider {
137137
ObjectStoreLocationProvider(std::string_view table_location,
138138
const TableProperties& properties);
139139

140-
std::string NewDataLocation(const std::string& filename) override;
140+
std::string NewDataLocation(std::string_view filename) override;
141141

142142
Result<std::string> NewDataLocation(const PartitionSpec& spec,
143143
const PartitionValues& partition_data,
144-
const std::string& filename) override;
144+
std::string_view filename) override;
145145

146146
private:
147147
std::string storage_location_;
@@ -164,7 +164,7 @@ ObjectStoreLocationProvider::ObjectStoreLocationProvider(
164164
}
165165
}
166166

167-
std::string ObjectStoreLocationProvider::NewDataLocation(const std::string& filename) {
167+
std::string ObjectStoreLocationProvider::NewDataLocation(std::string_view filename) {
168168
std::string hash = ComputeHash(filename);
169169

170170
if (!context_.empty()) {
@@ -184,7 +184,7 @@ std::string ObjectStoreLocationProvider::NewDataLocation(const std::string& file
184184

185185
Result<std::string> ObjectStoreLocationProvider::NewDataLocation(
186186
const PartitionSpec& spec, const PartitionValues& partition_data,
187-
const std::string& filename) {
187+
std::string_view filename) {
188188
if (include_partition_paths_) {
189189
ICEBERG_ASSIGN_OR_RAISE(auto partition_path, spec.PartitionPath(partition_data));
190190
return NewDataLocation(std::format("{}/{}", partition_path, filename));

src/iceberg/location_provider.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ class ICEBERG_EXPORT LocationProvider {
3737
///
3838
/// \param filename a file name
3939
/// \return a fully-qualified location URI for a data file
40-
virtual std::string NewDataLocation(const std::string& filename) = 0;
40+
virtual std::string NewDataLocation(std::string_view filename) = 0;
4141

4242
/// \brief Return a fully-qualified data file location for the given partition and
4343
/// filename.
@@ -49,7 +49,7 @@ class ICEBERG_EXPORT LocationProvider {
4949
/// \return a fully-qualified location URI for a data file
5050
virtual Result<std::string> NewDataLocation(const PartitionSpec& spec,
5151
const PartitionValues& partition_data,
52-
const std::string& filename) = 0;
52+
std::string_view filename) = 0;
5353

5454
/// \brief Create a LocationProvider for the given table location and properties.
5555
///

src/iceberg/util/location_util.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020
#pragma once
2121

22-
#include <string>
22+
#include <string_view>
2323

2424
#include "iceberg/iceberg_export.h"
2525

0 commit comments

Comments
 (0)