@@ -28,26 +28,25 @@ namespace iceberg {
2828
2929namespace {
3030
31- constexpr uint8_t kEntropyDirMask = 0x0f ;
32- constexpr uint8_t kRestDirMask = 0xff ;
31+ constexpr uint8_t kEntropyDirMask = 0x0F ;
32+ constexpr uint8_t kRestDirMask = 0xFF ;
3333constexpr int32_t kHashBits = 20 ;
3434constexpr int32_t kEntropyDirLength = 4 ;
3535constexpr int32_t kEntropyDirDepth = 3 ;
3636
37- std::string DataLocation (const TableProperties& properties,
38- std::string_view table_location) {
37+ std::string DataLocation (const TableProperties& properties, std::string_view location) {
3938 auto data_location = properties.Get (TableProperties::kWriteDataLocation );
4039 if (data_location.empty ()) {
41- data_location = std::format (" {}/data" , table_location );
40+ data_location = std::format (" {}/data" , location );
4241 }
4342 return data_location;
4443}
4544
46- std::string PathContext (std::string_view table_location ) {
47- std::string_view path = LocationUtil::StripTrailingSlash (table_location );
45+ std::string PathContext (std::string_view location ) {
46+ std::string_view path = LocationUtil::StripTrailingSlash (location );
4847
4948 size_t last_slash = path.find_last_of (' /' );
50- if (last_slash != std::string ::npos && last_slash < path.length () - 1 ) {
49+ if (last_slash != std::string_view ::npos && last_slash < path.length () - 1 ) {
5150 std::string_view data_path = path.substr (last_slash + 1 );
5251 std::string_view parent_path (path.data (), last_slash);
5352 size_t parent_last_slash = parent_path.find_last_of (' /' );
@@ -60,7 +59,7 @@ std::string PathContext(std::string_view table_location) {
6059 }
6160 }
6261
63- return std::string (table_location );
62+ return std::string (location );
6463}
6564
6665// / \brief Divides hash into directories for optimized orphan removal operation using
@@ -97,50 +96,48 @@ std::string ComputeHash(std::string_view file_name) {
9796
9897} // namespace
9998
100- // / \brief DefaultLocationProvider privides default location provider for local file
101- // / system.
99+ // Default location provider for local file system.
102100class DefaultLocationProvider : public LocationProvider {
103101 public:
104- DefaultLocationProvider (std::string_view table_location,
105- const TableProperties& properties);
102+ DefaultLocationProvider (std::string_view location, const TableProperties& properties);
106103
107104 std::string NewDataLocation (std::string_view filename) override ;
108105
109106 Result<std::string> NewDataLocation (const PartitionSpec& spec,
110- const PartitionValues& partition_data ,
107+ const PartitionValues& partition ,
111108 std::string_view filename) override ;
112109
113110 private:
114111 std::string data_location_;
115112};
116113
117114// Implementation of DefaultLocationProvider
118- DefaultLocationProvider::DefaultLocationProvider (std::string_view table_location ,
115+ DefaultLocationProvider::DefaultLocationProvider (std::string_view location ,
119116 const TableProperties& properties)
120117 : data_location_(
121- LocationUtil::StripTrailingSlash (DataLocation(properties, table_location ))) {}
118+ LocationUtil::StripTrailingSlash (DataLocation(properties, location ))) {}
122119
123120std::string DefaultLocationProvider::NewDataLocation (std::string_view filename) {
124121 return std::format (" {}/{}" , data_location_, filename);
125122}
126123
127124Result<std::string> DefaultLocationProvider::NewDataLocation (
128- const PartitionSpec& spec, const PartitionValues& partition_data ,
125+ const PartitionSpec& spec, const PartitionValues& partition ,
129126 std::string_view filename) {
130- ICEBERG_ASSIGN_OR_RAISE (auto partition_path, spec.PartitionPath (partition_data ));
127+ ICEBERG_ASSIGN_OR_RAISE (auto partition_path, spec.PartitionPath (partition ));
131128 return std::format (" {}/{}/{}" , data_location_, partition_path, filename);
132129}
133130
134- // / \brief ObjectStoreLocationProvider provides location provider for object stores.
131+ // Location provider for object stores.
135132class ObjectStoreLocationProvider : public LocationProvider {
136133 public:
137- ObjectStoreLocationProvider (std::string_view table_location ,
134+ ObjectStoreLocationProvider (std::string_view location ,
138135 const TableProperties& properties);
139136
140137 std::string NewDataLocation (std::string_view filename) override ;
141138
142139 Result<std::string> NewDataLocation (const PartitionSpec& spec,
143- const PartitionValues& partition_data ,
140+ const PartitionValues& partition ,
144141 std::string_view filename) override ;
145142
146143 private:
@@ -151,16 +148,16 @@ class ObjectStoreLocationProvider : public LocationProvider {
151148
152149// Implementation of ObjectStoreLocationProvider
153150ObjectStoreLocationProvider::ObjectStoreLocationProvider (
154- std::string_view table_location , const TableProperties& properties)
151+ std::string_view location , const TableProperties& properties)
155152 : include_partition_paths_(
156153 properties.Get(TableProperties::kWriteObjectStorePartitionedPaths )) {
157154 storage_location_ =
158- LocationUtil::StripTrailingSlash (DataLocation (properties, table_location ));
155+ LocationUtil::StripTrailingSlash (DataLocation (properties, location ));
159156
160157 // If the storage location is within the table prefix, don't add table and database name
161158 // context
162- if (!storage_location_.starts_with (table_location )) {
163- context_ = PathContext (table_location );
159+ if (!storage_location_.starts_with (location )) {
160+ context_ = PathContext (location );
164161 }
165162}
166163
@@ -183,21 +180,21 @@ std::string ObjectStoreLocationProvider::NewDataLocation(std::string_view filena
183180}
184181
185182Result<std::string> ObjectStoreLocationProvider::NewDataLocation (
186- const PartitionSpec& spec, const PartitionValues& partition_data ,
183+ const PartitionSpec& spec, const PartitionValues& partition ,
187184 std::string_view filename) {
188185 if (include_partition_paths_) {
189- ICEBERG_ASSIGN_OR_RAISE (auto partition_path, spec.PartitionPath (partition_data ));
186+ ICEBERG_ASSIGN_OR_RAISE (auto partition_path, spec.PartitionPath (partition ));
190187 return NewDataLocation (std::format (" {}/{}" , partition_path, filename));
191188 } else {
192189 return NewDataLocation (filename);
193190 }
194191}
195192
196193Result<std::unique_ptr<LocationProvider>> LocationProvider::Make (
197- const std::string& input_location , const TableProperties& properties) {
198- std::string_view location = LocationUtil::StripTrailingSlash (input_location );
194+ std::string_view location , const TableProperties& properties) {
195+ location = LocationUtil::StripTrailingSlash (location );
199196
200- // TODO(xxx): Support dynamic constructor according to kWriteLocationProviderImpl
197+ // TODO(xxx): create location provider specified by "write.location-provider.impl"
201198
202199 if (properties.Get (TableProperties::kObjectStoreEnabled )) {
203200 return std::make_unique<ObjectStoreLocationProvider>(location, properties);
0 commit comments