You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@iceberg.apache.org by GitBox <gi...@apache.org> on 2021/08/14 00:31:08 UTC

[GitHub] [iceberg] szehon-ho commented on a change in pull request #2975: Core: Serialize all specs in SerializableTable

szehon-ho commented on a change in pull request #2975:
URL: https://github.com/apache/iceberg/pull/2975#discussion_r688836595



##########
File path: core/src/main/java/org/apache/iceberg/SerializableTable.java
##########
@@ -168,23 +172,27 @@ public Schema schema() {
 
   @Override
   public PartitionSpec spec() {
-    if (lazySpec == null) {
+    return specs().get(defaultSpecId);
+  }
+
+  @Override
+  public Map<Integer, PartitionSpec> specs() {
+    if (lazySpecs == null) {
       synchronized (this) {
-        if (lazySpec == null && lazyTable == null) {
+        if (lazySpecs == null && lazyTable == null) {

Review comment:
       Opt: A nested if may be clearer to reader, to avoid the same check (lazySpecs == null) twice?

##########
File path: core/src/main/java/org/apache/iceberg/SerializableTable.java
##########
@@ -168,23 +172,27 @@ public Schema schema() {
 
   @Override
   public PartitionSpec spec() {
-    if (lazySpec == null) {
+    return specs().get(defaultSpecId);
+  }
+
+  @Override
+  public Map<Integer, PartitionSpec> specs() {
+    if (lazySpecs == null) {
       synchronized (this) {
-        if (lazySpec == null && lazyTable == null) {
+        if (lazySpecs == null && lazyTable == null) {
           // prefer parsing JSON as opposed to loading the metadata
-          this.lazySpec = PartitionSpecParser.fromJson(schema(), specAsJson);
-        } else if (lazySpec == null) {
-          this.lazySpec = lazyTable.spec();
+          Map<Integer, PartitionSpec> parsedSpecs = Maps.newHashMap();

Review comment:
       Can we optimize by newHashMapWithExpectedSize?




-- 
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: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org