You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@asterixdb.apache.org by mb...@apache.org on 2021/03/06 16:57:54 UTC

[asterixdb] 07/17: [NO ISSUE][OTH] Introduce DatasetFullyQualifiedName

This is an automated email from the ASF dual-hosted git repository.

mblow pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/asterixdb.git

commit 08200153038688b7ce392df7e53317590fc9ab02
Author: Murtadha Hubail <mh...@apache.org>
AuthorDate: Mon Mar 1 23:26:59 2021 +0300

    [NO ISSUE][OTH] Introduce DatasetFullyQualifiedName
    
    - user model changes: no
    - storage format changes: no
    - interface changes: no
    
    Details:
    
    - Introduce DatasetFullyQualifiedName that is used to represent
      a dataset's DataverseName as well as its name.
    - This new class can be used as an identifier for a dataset rather
      than using a Pair object of a DataverseName and a String.
    
    Change-Id: Ie94b5dc400c04a143f5be3b1cb2a652d765dfdba
    Reviewed-on: https://asterix-gerrit.ics.uci.edu/c/asterixdb/+/10303
    Integration-Tests: Jenkins <je...@fulliautomatix.ics.uci.edu>
    Tested-by: Jenkins <je...@fulliautomatix.ics.uci.edu>
    Reviewed-by: Murtadha Hubail <mh...@apache.org>
    Reviewed-by: Dmitry Lychagin <dm...@couchbase.com>
---
 .../common/metadata/DatasetFullyQualifiedName.java | 64 ++++++++++++++++++++++
 .../apache/asterix/metadata/entities/Dataset.java  |  8 +++
 2 files changed, 72 insertions(+)

diff --git a/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/metadata/DatasetFullyQualifiedName.java b/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/metadata/DatasetFullyQualifiedName.java
new file mode 100644
index 0000000..4a1a118
--- /dev/null
+++ b/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/metadata/DatasetFullyQualifiedName.java
@@ -0,0 +1,64 @@
+/*
+ * 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 org.apache.asterix.common.metadata;
+
+import java.io.Serializable;
+import java.util.Objects;
+
+public class DatasetFullyQualifiedName implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+    private final DataverseName dataverseName;
+    private final String datasetName;
+
+    public DatasetFullyQualifiedName(DataverseName dataverseName, String datasetName) {
+        this.dataverseName = dataverseName;
+        this.datasetName = datasetName;
+    }
+
+    public DataverseName getDataverseName() {
+        return dataverseName;
+    }
+
+    public String getDatasetName() {
+        return datasetName;
+    }
+
+    @Override
+    public String toString() {
+        return dataverseName + "." + datasetName;
+    }
+
+    @Override
+    public boolean equals(Object o) {
+        if (this == o) {
+            return true;
+        }
+        if (o instanceof DatasetFullyQualifiedName) {
+            DatasetFullyQualifiedName that = (DatasetFullyQualifiedName) o;
+            return dataverseName.equals(that.dataverseName) && datasetName.equals(that.datasetName);
+        }
+        return false;
+    }
+
+    @Override
+    public int hashCode() {
+        return Objects.hash(dataverseName, datasetName);
+    }
+}
diff --git a/asterixdb/asterix-metadata/src/main/java/org/apache/asterix/metadata/entities/Dataset.java b/asterixdb/asterix-metadata/src/main/java/org/apache/asterix/metadata/entities/Dataset.java
index dd3f67d..39a8eff 100644
--- a/asterixdb/asterix-metadata/src/main/java/org/apache/asterix/metadata/entities/Dataset.java
+++ b/asterixdb/asterix-metadata/src/main/java/org/apache/asterix/metadata/entities/Dataset.java
@@ -38,6 +38,7 @@ import org.apache.asterix.common.exceptions.CompilationException;
 import org.apache.asterix.common.exceptions.ErrorCode;
 import org.apache.asterix.common.ioopcallbacks.LSMIndexIOOperationCallbackFactory;
 import org.apache.asterix.common.ioopcallbacks.LSMIndexPageWriteCallbackFactory;
+import org.apache.asterix.common.metadata.DatasetFullyQualifiedName;
 import org.apache.asterix.common.metadata.DataverseName;
 import org.apache.asterix.common.metadata.IDataset;
 import org.apache.asterix.common.transactions.IRecoveryManager.ResourceType;
@@ -154,6 +155,7 @@ public class Dataset implements IMetadataEntity<Dataset>, IDataset {
     private final long rebalanceCount;
     private int pendingOp;
     private final String compressionScheme;
+    private final DatasetFullyQualifiedName datasetFullyQualifiedName;
 
     public Dataset(DataverseName dataverseName, String datasetName, DataverseName recordTypeDataverseName,
             String recordTypeName, String nodeGroupName, String compactionPolicy,
@@ -203,6 +205,7 @@ public class Dataset implements IMetadataEntity<Dataset>, IDataset {
         this.hints = hints;
         this.rebalanceCount = rebalanceCount;
         this.compressionScheme = compressionScheme;
+        datasetFullyQualifiedName = new DatasetFullyQualifiedName(dataverseName, datasetName);
     }
 
     @Override
@@ -877,4 +880,9 @@ public class Dataset implements IMetadataEntity<Dataset>, IDataset {
     public String getCompressionScheme() {
         return compressionScheme;
     }
+
+    public DatasetFullyQualifiedName getDatasetFullyQualifiedName() {
+        return datasetFullyQualifiedName;
+    }
+
 }