jnagel12 commented on code in PR #629:
URL: https://github.com/apache/iceberg-go/pull/629#discussion_r2542958488


##########
view/metadata.go:
##########
@@ -18,135 +18,523 @@
 package view
 
 import (
-       "context"
        "encoding/json"
        "errors"
        "fmt"
+       "io"
+       "maps"
+       "slices"
+       "strconv"
+       "strings"
+       "sync"
        "time"
 
        "github.com/apache/iceberg-go"
-       "github.com/apache/iceberg-go/internal"
-       "github.com/apache/iceberg-go/io"
+       iceinternal "github.com/apache/iceberg-go/internal"
+       "github.com/apache/iceberg-go/table"
+
        "github.com/google/uuid"
 )
 
-// LoadMetadata reads and parses a view metadata file from the specified 
location.
+var (
+       ErrInvalidViewMetadata              = errors.New("invalid view 
metadata")
+       ErrInvalidViewMetadataFormatVersion = errors.New("invalid or missing 
format-version in view metadata")
+)
+
+const (
+       // LastAddedID is used in place of ID fields (e.g. schema, version) to 
indicate that
+       // the last added instance of that type should be used.
+       LastAddedID                = -1
+       SupportedViewFormatVersion = 1
+       DefaultViewFormatVersion   = SupportedViewFormatVersion
+)
+
+const (
+       initialSchemaID = 0
+
+       viewEngineProperty = "engine-name"
+       defaultViewEngine  = "iceberg-go"
+)
+
+// Metadata for an iceberg view as specified in the Iceberg spec
+// https://iceberg.apache.org/view-spec/
+type Metadata interface {
+       // FormatVersion indicates the version of this metadata, 1 for V1
+       FormatVersion() int
+       // ViewUUID returns a UUID that identifies the view, generated when the
+       // view is created. Implementations must throw an exception if a view's
+       // UUID does not match the expected UUID after refreshing metadata.
+       ViewUUID() uuid.UUID
+       // Location is the table's base location. This is used by writers to 
determine
+       // where to store data files, manifest files, and table metadata files.
+       Location() string
+       // Schemas returns the list of view schemas
+       Schemas() []*iceberg.Schema
+       // CurrentVersionID returns the ID of the current version of the view 
(version-id)
+       CurrentVersionID() int64
+       // CurrentVersion returns the current version of the view
+       CurrentVersion() *Version
+       // CurrentSchemaID returns the ID of the current schema
+       CurrentSchemaID() int
+       // CurrentSchema returns the current schema of the view
+       CurrentSchema() *iceberg.Schema
+       // SchemasByID returns a map of schema IDs to schemas
+       SchemasByID() map[int]*iceberg.Schema
+       // Versions returns the list of view versions
+       Versions() []*Version
+       // VersionLog returns a list of version log entries
+       // with the timestamp and version-id for every change to 
current-version-id
+       VersionLog() []VersionLogEntry
+       // Properties is a string to string map of view properties.
+       Properties() iceberg.Properties
+
+       // Updates returns the list of metadata updates used to build this 
metadata
+       Updates() Updates

Review Comment:
   I guess to play devil's advocate, I can see why the java implementation 
might choose to couple changes / updates and metadata. The only reason I added 
a method for `BuildWithoutUpdates` was to discard the updates reference to save 
memory if the caller doesn't need it. But it's not as though the updates is a 
big chunk of memory.
   
   I could also just get rid of the ugly switching on `withUpdates` to make 
this cleaner if you're ok with that as well



-- 
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