zeroshade commented on code in PR #953:
URL: https://github.com/apache/iceberg-go/pull/953#discussion_r3164073998


##########
catalog/hadoop/hadoop.go:
##########
@@ -0,0 +1,178 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+package hadoop
+
+import (
+       "context"
+       "errors"
+       "fmt"
+       "iter"
+       "os"
+       "path/filepath"
+       "regexp"
+       "strings"
+
+       "github.com/apache/iceberg-go"
+       "github.com/apache/iceberg-go/catalog"
+       "github.com/apache/iceberg-go/table"
+)
+
+func init() {
+       catalog.Register(string(catalog.Hadoop), catalog.RegistrarFunc(
+               func(_ context.Context, name string, props iceberg.Properties) 
(catalog.Catalog, error) {
+                       warehouse := props.Get("warehouse", "")
+
+                       return NewCatalog(name, warehouse, props)
+               },
+       ))
+}
+
+var _ catalog.Catalog = (*Catalog)(nil)
+
+// versionPattern matches Hadoop catalog metadata filenames:
+// v1.metadata.json, v42.metadata.json, v1.gz.metadata.json, etc.
+var versionPattern = regexp.MustCompile(`^v([0-9]+)(?:\.gz)?\.metadata\.json$`)
+
+// Catalog is a filesystem-based Iceberg catalog that requires no external
+// metastore. All state lives on disk as directories and versioned JSON
+// metadata files.
+type Catalog struct {
+       name      string
+       warehouse string
+       props     iceberg.Properties
+}
+
+// NewCatalog creates a new Hadoop catalog rooted at the given warehouse path.
+// The warehouse directory is not created on construction; it is created
+// implicitly by the first CreateNamespace call.
+func NewCatalog(name, warehouse string, props iceberg.Properties) (*Catalog, 
error) {
+       if warehouse == "" {
+               return nil, errors.New("hadoop catalog requires a warehouse 
path")
+       }
+
+       warehouse = strings.TrimPrefix(warehouse, "file://")
+       warehouse = strings.TrimPrefix(warehouse, "file:")
+       warehouse = strings.TrimRight(warehouse, "/")

Review Comment:
   should we do a url.Parse and validate either no scheme or file:// as the 
scheme. then we can just create the string without the scheme.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to