World's most powerful open data catalog for building a high-performance, geo-distributed and federated metadata lake.
Java ai-catalogdata-catalogdatalakefederated-querylakehousemetadatametalakemodel-catalogopendatacatalogskycomputingstratosphere
[#136] Improve English and add JavaDocs (#137)
Justin Mclean7fe46aa15b0a
diff --git a/catalog-hive/src/main/java/com/datastrato/graviton/catalog/hive/HiveCatalog.java b/catalog-hive/src/main/java/com/datastrato/graviton/catalog/hive/HiveCatalog.javaindex 15572c58d1..c54292d0d5 100644--- a/catalog-hive/src/main/java/com/datastrato/graviton/catalog/hive/HiveCatalog.java+++ b/catalog-hive/src/main/java/com/datastrato/graviton/catalog/hive/HiveCatalog.java@@ -10,13 +10,25 @@ import com.datastrato.graviton.rel.SupportsSchemas;import com.datastrato.graviton.rel.TableCatalog;import java.util.Map;+/** Implementation of a Hive catalog in Graviton. */public class HiveCatalog extends BaseCatalog<HiveCatalog> {+ /**+ * Returns the short name of the Hive catalog.+ *+ * @return The short name of the catalog.+ */@Overridepublic String shortName() {return "hive";}+ /**+ * Creates a new instance of {@link HiveCatalogOperations} with the provided configuration.+ *+ * @param config The configuration map for the Hive catalog operations.+ * @return A new instance of {@link HiveCatalogOperations}.+ */@Overrideprotected CatalogOperations newOps(Map<String, String> config) {HiveCatalogOperations ops = new HiveCatalogOperations(entity());@@ -24,11 +36,21 @@ public class HiveCatalog extends BaseCatalog<HiveCatalog> {return ops;}+ /**+ * Returns the Hive catalog operations as a {@link SupportsSchemas}.+ *+ * @return The Hive catalog operations as {@link HiveCatalogOperations}.+ */@Overridepublic SupportsSchemas asSchemas() {return (HiveCatalogOperations) ops();}+ /**+ * Returns the Hive catalog operations as a {@link TableCatalog}.+ *+ * @return The Hive catalog operations as {@link HiveCatalogOperations}.+ */@Overridepublic TableCatalog asTableCatalog() {return (HiveCatalogOperations) ops();diff --git a/catalog-hive/src/main/java/com/datastrato/graviton/catalog/hive/HiveCatalogOperations.java b/catalog-hive/src/main/java/com/datastrato/graviton/catalog/hive/HiveCatalogOperations.javaindex 16cd1f7285..e171701710 100644--- a/catalog-hive/src/main/java/com/datastrato/graviton/catalog/hive/HiveCatalogOperations.java+++ b/catalog-hive/src/main/java/com/datastrato/graviton/catalog/hive/HiveCatalogOperations.java@@ -46,6 +46,7 @@ import org.apache.thrift.TException;import org.slf4j.Logger;import org.slf4j.LoggerFactory;+/** Operations for interacting with the Hive catalog in Graviton. */public class HiveCatalogOperations implements CatalogOperations, SupportsSchemas, TableCatalog {public static final Logger LOG = LoggerFactory.getLogger(HiveCatalogOperations.class);@@ -56,10 +57,21 @@ public class HiveCatalogOperations implements CatalogOperations, SupportsSchemasprivate final CatalogEntity entity;+ /**+ * Constructs a new instance of HiveCatalogOperations.+ *+ * @param entity The catalog entity associated with this operations instance.+ */public HiveCatalogOperations(CatalogEntity entity) {this.entity = entity;}+ /**+ * Initializes the Hive catalog operations with the provided configuration.+ *+ * @param conf The configuration map for the Hive catalog operations.+ * @throws RuntimeException if initialization fails.+ */@Overridepublic void initialize(Map<String, String> conf) throws RuntimeException {Configuration hadoopConf = new Configuration();@@ -70,6 +82,7 @@ public class HiveCatalogOperations implements CatalogOperations, SupportsSchemasthis.clientPool = new HiveClientPool(1, hiveConf);}+ /** Closes the Hive catalog and releases the associated client pool. */@Overridepublic void close() {if (clientPool != null) {@@ -78,6 +91,13 @@ public class HiveCatalogOperations implements CatalogOperations, SupportsSchemas}}+ /**+ * Lists the schemas under the given namespace.+ *+ * @param namespace The namespace to list the schemas for.+ * @return An array of {@link NameIdentifier} representing the schemas.+ * @throws NoSuchNamespaceException If the provided namespace is invalid or does not exist.+ */@Overridepublic NameIdentifier[] listSchemas(Namespace namespace) throws NoSuchNamespaceException {if (!isValidNamespace(namespace)) {@@ -105,6 +125,15 @@ public class HiveCatalogOperations implements CatalogOperations, SupportsSchemas}}+ /**+ * Creates a new schema with the provided identifier, comment, and metadata.+ *+ * @param ident The identifier of the schema to create.+ * @param comment The comment for the schema.+ * @param metadata The metadata properties for the schema.+ * @return The created {@link HiveSchema}.+ * @throws SchemaAlreadyExistsException If a schema with the same name already exists.+ */@Overridepublic HiveSchema createSchema(NameIdentifier ident, String comment, Map<String, String> metadata)throws SchemaAlreadyExistsException {@@ -159,6 +188,13 @@ public class HiveCatalogOperations implements CatalogOperations, SupportsSchemas}}+ /**+ * Loads the schema with the provided identifier.+ *+ * @param ident The identifier of the schema to load.+ * @return The loaded {@link HiveSchema}.+ * @throws NoSuchSchemaException If the schema with the provided identifier does not exist.+ */@Overridepublic HiveSchema loadSchema(NameIdentifier ident) throws NoSuchSchemaException {Preconditions.checkArgument(@@ -210,6 +246,14 @@ public class HiveCatalogOperations implements CatalogOperations, SupportsSchemas}}+ /**+ * Alters the schema with the provided identifier according to the specified changes.+ *+ * @param ident The identifier of the schema to alter.+ * @param changes The changes to apply to the schema.+ * @return The altered {@link HiveSchema}.+ * @throws NoSuchSchemaException If the schema with the provided identifier does not exist.+ */@Overridepublic HiveSchema alterSchema(NameIdentifier ident, SchemaChange... changes)throws NoSuchSchemaException {@@ -282,6 +326,14 @@ public class HiveCatalogOperations implements CatalogOperations, SupportsSchemas}}+ /**+ * Drops the schema with the provided identifier.+ *+ * @param ident The identifier of the schema to drop.+ * @param cascade If set to true, drops all the tables in the schema as well.+ * @return true if the schema was dropped successfully, false otherwise.+ * @throws NonEmptySchemaException If the schema is not empty and 'cascade' is set to false.+ */@Overridepublic boolean dropSchema(NameIdentifier ident, boolean cascade) throws NonEmptySchemaException {if (ident.name().isEmpty()) {@@ -324,6 +376,13 @@ public class HiveCatalogOperations implements CatalogOperations, SupportsSchemas}}+ /**+ * Lists all the tables under the specified namespace.+ *+ * @param namespace The namespace to list tables for.+ * @return An array of {@link NameIdentifier} representing the tables in the namespace.+ * @throws NoSuchSchemaException If the schema with the provided namespace does not exist.+ */@Overridepublic NameIdentifier[] listTables(Namespace namespace) throws NoSuchSchemaException {NameIdentifier schemaIdent = NameIdentifier.of(namespace.levels());@@ -353,6 +412,13 @@ public class HiveCatalogOperations implements CatalogOperations, SupportsSchemas}}+ /**+ * Loads a table from the Hive Metastore.+ *+ * @param tableIdent The identifier of the table to load.+ * @return The loaded HiveTable instance representing the table.+ * @throws NoSuchTableException If the specified table does not exist in the Hive Metastore.+ */@Overridepublic Table loadTable(NameIdentifier tableIdent) throws NoSuchTableException {Preconditions.checkArgument(!tableIdent.name().isEmpty(), "Cannot load table with empty name");@@ -397,6 +463,17 @@ public class HiveCatalogOperations implements CatalogOperations, SupportsSchemas}}+ /**+ * Creates a new table in the Hive Metastore.+ *+ * @param tableIdent The identifier of the table to create.+ * @param columns The array of columns for the new table.+ * @param comment The comment for the new table.+ * @param properties The properties for the new table.+ * @return The newly created HiveTable instance.+ * @throws NoSuchSchemaException If the schema for the table does not exist.+ * @throws TableAlreadyExistsException If the table with the same name already exists.+ */@Overridepublic Table createTable(NameIdentifier tableIdent, Column[] columns, String comment, Map<String, String> properties)@@ -451,17 +528,39 @@ public class HiveCatalogOperations implements CatalogOperations, SupportsSchemas}}+ /**+ * Not supported in this implementation. Throws UnsupportedOperationException.+ *+ * @param ident The identifier of the table to alter.+ * @param changes The changes to apply to the table.+ * @return This method always throws UnsupportedOperationException.+ * @throws NoSuchTableException This exception will not be thrown in this method.+ * @throws IllegalArgumentException This exception will not be thrown in this method.+ */@Overridepublic Table alterTable(NameIdentifier ident, TableChange... changes)throws NoSuchTableException, IllegalArgumentException {throw new UnsupportedOperationException("Not support alter Hive table yet");}+ /**+ * Drops a table from the Hive Metastore.+ *+ * @param tableIdent The identifier of the table to drop.+ * @return true if the table is successfully dropped; false if the table does not exist.+ */@Overridepublic boolean dropTable(NameIdentifier tableIdent) {return dropHiveTable(tableIdent, false, false);}+ /**+ * Purges a table from the Hive Metastore.+ *+ * @param tableIdent The identifier of the table to purge.+ * @return true if the table is successfully purged; false if the table does not exist.+ * @throws UnsupportedOperationException If the table type is EXTERNAL_TABLE, it cannot be purged.+ */@Overridepublic boolean purgeTable(NameIdentifier tableIdent) throws UnsupportedOperationException {HiveTable table = (HiveTable) loadTable(tableIdent);@@ -471,6 +570,12 @@ public class HiveCatalogOperations implements CatalogOperations, SupportsSchemasreturn dropHiveTable(tableIdent, true, true);}+ /**+ * Checks if the given namespace is a valid namespace for the Hive schema.+ *+ * @param namespace The namespace to validate.+ * @return true if the namespace is valid; otherwise, false.+ */private boolean dropHiveTable(NameIdentifier tableIdent, boolean deleteData, boolean ifPurge) {Preconditions.checkArgument(!tableIdent.name().isEmpty(), "Cannot drop table with empty name");@@ -504,10 +609,10 @@ public class HiveCatalogOperations implements CatalogOperations, SupportsSchemas}/**- * Valid namespace of Hive schema+ * Checks if the given namespace is a valid namespace for the Hive schema.*- * @param namespace of Hive scheme- * @return true if catalog name equals current+ * @param namespace The namespace to validate.+ * @return true if the namespace is valid; otherwise, false.*/public boolean isValidNamespace(Namespace namespace) {return namespace.levels().length == 2 && namespace.level(1).equals(entity.name());diff --git a/catalog-hive/src/main/java/com/datastrato/graviton/catalog/hive/HiveClientPool.java b/catalog-hive/src/main/java/com/datastrato/graviton/catalog/hive/HiveClientPool.javaindex 35e4265ab2..2f04de03f3 100644--- a/catalog-hive/src/main/java/com/datastrato/graviton/catalog/hive/HiveClientPool.java+++ b/catalog-hive/src/main/java/com/datastrato/graviton/catalog/hive/HiveClientPool.java@@ -32,6 +32,8 @@ import org.apache.thrift.TException;import org.apache.thrift.transport.TTransportException;// hive-metastore/src/main/java/org/apache/iceberg/hive/HiveClientPool.java++/** Represents a client pool for managing connections to the Hive Metastore service. */public class HiveClientPool extends ClientPoolImpl<IMetaStoreClient, TException> {private static final DynMethods.StaticMethod GET_CLIENT =@@ -50,6 +52,12 @@ public class HiveClientPool extends ClientPoolImpl<IMetaStoreClient, TException>private final HiveConf hiveConf;+ /**+ * Creates a new HiveClientPool with the specified pool size and configuration.+ *+ * @param poolSize The number of clients in the pool.+ * @param conf The configuration used to initialize the Hive Metastore clients.+ */public HiveClientPool(int poolSize, Configuration conf) {// Do not allow retry by default as we rely on RetryingHiveClientsuper(poolSize, TTransportException.class, false);@@ -111,6 +119,11 @@ public class HiveClientPool extends ClientPoolImpl<IMetaStoreClient, TException>client.close();}+ /**+ * Gets the HiveConf object used in this HiveClientPool.+ *+ * @return The HiveConf object used in this HiveClientPool.+ */@VisibleForTestingHiveConf hiveConf() {return hiveConf;diff --git a/catalog-hive/src/main/java/com/datastrato/graviton/catalog/hive/HiveColumn.java b/catalog-hive/src/main/java/com/datastrato/graviton/catalog/hive/HiveColumn.javaindex 0f89acaa0c..f9170e13e8 100644--- a/catalog-hive/src/main/java/com/datastrato/graviton/catalog/hive/HiveColumn.java+++ b/catalog-hive/src/main/java/com/datastrato/graviton/catalog/hive/HiveColumn.java@@ -6,12 +6,19 @@ package com.datastrato.graviton.catalog.hive;import com.datastrato.graviton.meta.rel.BaseColumn;+/** Represents a column in the Hive Metastore catalog. */public class HiveColumn extends BaseColumn {private HiveColumn() {}+ /** A builder class for constructing HiveColumn instances. */public static class Builder extends BaseColumnBuilder<Builder, HiveColumn> {+ /**+ * Internal method to build a HiveColumn instance using the provided values.+ *+ * @return A new HiveColumn instance with the configured values.+ */@Overrideprotected HiveColumn internalBuild() {HiveColumn hiveColumn = new HiveColumn();diff --git a/catalog-hive/src/main/java/com/datastrato/graviton/catalog/hive/HiveSchema.java b/catalog-hive/src/main/java/com/datastrato/graviton/catalog/hive/HiveSchema.javaindex 215a5a7fe7..ec2beec8be 100644--- a/catalog-hive/src/main/java/com/datastrato/graviton/catalog/hive/HiveSchema.java+++ b/catalog-hive/src/main/java/com/datastrato/graviton/catalog/hive/HiveSchema.java@@ -16,7 +16,7 @@ import org.apache.hadoop.hive.conf.HiveConf;import org.apache.hadoop.hive.metastore.api.Database;import org.apache.hadoop.hive.metastore.api.PrincipalType;-/** A Hive Schema(Database) entity */+/** Represents a Hive Schema (Database) entity in the Hive Metastore catalog. */@ToStringpublic class HiveSchema extends BaseSchema {private static final String HMS_DB_OWNER = "hive.metastore.database.owner";@@ -28,6 +28,13 @@ public class HiveSchema extends BaseSchema {private HiveSchema() {}+ /**+ * Creates a new HiveSchema instance from a Database and a Builder.+ *+ * @param db The Database representing the HiveSchema.+ * @param builder The Builder used to construct the HiveSchema.+ * @return A new HiveSchema instance.+ */public static HiveSchema fromInnerDB(Database db, Builder builder) {Map<String, String> properties = convertToMetadata(db);@@ -38,6 +45,12 @@ public class HiveSchema extends BaseSchema {.build();}+ /**+ * Converts a Database to metadata represented as a map of key-value pairs.+ *+ * @param database The Database to be converted to metadata.+ * @return A map containing the metadata key-value pairs.+ */public static Map<String, String> convertToMetadata(Database database) {Map<String, String> meta = Maps.newHashMap();@@ -56,6 +69,11 @@ public class HiveSchema extends BaseSchema {return meta;}+ /**+ * Converts this HiveSchema to its corresponding Database.+ *+ * @return The converted Database object.+ */public Database toInnerDB() {if (innerDb != null) {return innerDb;@@ -115,15 +133,27 @@ public class HiveSchema extends BaseSchema {return result;}+ /** A builder class for constructing HiveSchema instances. */public static class Builder extends BaseSchemaBuilder<Builder, HiveSchema> {protected Configuration conf;+ /**+ * Sets the Configuration to be used for building the HiveSchema.+ *+ * @param conf The Configuration.+ * @return The Builder instance.+ */public Builder withConf(Configuration conf) {this.conf = conf;return this;}+ /**+ * Internal method to build a HiveSchema instance using the provided values.+ *+ * @return A new HiveSchema instance with the configured values.+ */@Overrideprotected HiveSchema internalBuild() {HiveSchema hiveSchema = new HiveSchema();diff --git a/catalog-hive/src/main/java/com/datastrato/graviton/catalog/hive/HiveTable.java b/catalog-hive/src/main/java/com/datastrato/graviton/catalog/hive/HiveTable.javaindex 4ef64f1fce..f0441118e8 100644--- a/catalog-hive/src/main/java/com/datastrato/graviton/catalog/hive/HiveTable.java+++ b/catalog-hive/src/main/java/com/datastrato/graviton/catalog/hive/HiveTable.java@@ -23,13 +23,16 @@ import org.apache.hadoop.hive.metastore.api.SerDeInfo;import org.apache.hadoop.hive.metastore.api.StorageDescriptor;import org.apache.hadoop.hive.metastore.api.Table;-/** A Hive Table entity */+/** Represents a Hive Table entity in the Hive Metastore catalog. */@ToString@Getterpublic class HiveTable extends BaseTable {+ // A set of supported Hive table types.public static final Set<TableType> SUPPORT_TABLE_TYPES =Sets.newHashSet(MANAGED_TABLE, EXTERNAL_TABLE);++ // The key to store the Hive table comment in the parameters map.public static final String HMS_TABLE_COMMENT = "comment";private String inputFormat;@@ -42,6 +45,13 @@ public class HiveTable extends BaseTable {private HiveTable() {}+ /**+ * Creates a new HiveTable instance from a Table and a Builder.+ *+ * @param table The inner Table representing the HiveTable.+ * @param builder The Builder used to construct the HiveTable.+ * @return A new HiveTable instance.+ */public static HiveTable fromInnerTable(Table table, Builder builder) {return builder@@ -61,6 +71,11 @@ public class HiveTable extends BaseTable {.build();}+ /**+ * Converts this HiveTable to its corresponding Table in the Hive Metastore.+ *+ * @return The converted Table.+ */public Table toInnerTable() {Table hiveTable = new Table();@@ -97,10 +112,16 @@ public class HiveTable extends BaseTable {return serDeInfo;}+ /**+ * Gets the schema identifier for this HiveTable.+ *+ * @return The schema identifier.+ */public NameIdentifier schemaIdentifier() {return NameIdentifier.of(nameIdentifier().namespace().levels());}+ /** A builder class for constructing HiveTable instances. */public static class Builder extends BaseTableBuilder<Builder, HiveTable> {private String inputFormat;@@ -110,11 +131,23 @@ public class HiveTable extends BaseTable {private TableType tableType;+ /**+ * Sets the input format for the HiveTable.+ *+ * @param inputFormat The input format to set.+ * @return The Builder instance.+ */public Builder withInputFormat(String inputFormat) {this.inputFormat = inputFormat;return this;}+ /**+ * Sets the output format for the HiveTable.+ *+ * @param outputFormat The output format to set.+ * @return The Builder instance.+ */public Builder withOutputFormat(String outputFormat) {this.outputFormat = outputFormat;return this;@@ -125,11 +158,22 @@ public class HiveTable extends BaseTable {return this;}+ /**+ * Sets the table type for the HiveTable.+ *+ * @param tableType The table type to set.+ * @return The Builder instance.+ */public Builder withTableType(TableType tableType) {this.tableType = tableType;return this;}+ /**+ * Internal method to build a HiveTable instance using the provided values.+ *+ * @return A new HiveTable instance with the configured values.+ */@Overrideprotected HiveTable internalBuild() {HiveTable hiveTable = new HiveTable();diff --git a/catalog-hive/src/main/java/com/datastrato/graviton/catalog/hive/converter/FromHiveType.java b/catalog-hive/src/main/java/com/datastrato/graviton/catalog/hive/converter/FromHiveType.javaindex f93c2ea54c..b936166c2b 100644--- a/catalog-hive/src/main/java/com/datastrato/graviton/catalog/hive/converter/FromHiveType.java+++ b/catalog-hive/src/main/java/com/datastrato/graviton/catalog/hive/converter/FromHiveType.java@@ -31,12 +31,28 @@ import org.apache.hadoop.hive.serde2.typeinfo.TypeInfo;import org.apache.hadoop.hive.serde2.typeinfo.UnionTypeInfo;import org.apache.hadoop.hive.serde2.typeinfo.VarcharTypeInfo;+/** Converts Hive data types to corresponding Substrait data types. */public class FromHiveType {++ /**+ * Converts a Hive data type string to the corresponding Substrait data type.+ *+ * @param hiveType The Hive data type string to convert.+ * @return The equivalent Substrait data type.+ * @throws IllegalArgumentException If the Hive data type is unknown or unsupported.+ */public static Type convert(String hiveType) throws IllegalArgumentException {TypeInfo hiveTypeInfo = getTypeInfoFromTypeString(hiveType);return toSubstraitType(hiveTypeInfo);}+ /**+ * Converts a Hive TypeInfo object to the corresponding Substrait Type.+ *+ * @param hiveTypeInfo The Hive TypeInfo object to convert.+ * @return The equivalent Substrait Type.+ * @throws IllegalArgumentException if the Hive data type category is unknown or unsupported.+ */private static Type toSubstraitType(TypeInfo hiveTypeInfo) throws IllegalArgumentException {switch (hiveTypeInfo.getCategory()) {case PRIMITIVE:diff --git a/catalog-hive/src/main/java/com/datastrato/graviton/catalog/hive/converter/ToHiveType.java b/catalog-hive/src/main/java/com/datastrato/graviton/catalog/hive/converter/ToHiveType.javaindex 6e97ae0a14..ed82c21395 100644--- a/catalog-hive/src/main/java/com/datastrato/graviton/catalog/hive/converter/ToHiveType.java+++ b/catalog-hive/src/main/java/com/datastrato/graviton/catalog/hive/converter/ToHiveType.java@@ -32,6 +32,7 @@ import java.util.stream.Collectors;import java.util.stream.IntStream;import org.apache.hadoop.hive.serde2.typeinfo.TypeInfo;+/** Converts Substrait data types to corresponding Hive data types. */public class ToHiveTypeextends ParameterizedTypeVisitor.ParameterizedTypeThrowsVisitor<TypeInfo, RuntimeException> {@@ -41,6 +42,7 @@ public class ToHiveTypesuper("Only support type literals and parameterized types.");}+ // Visit methods for each Substrait data type@Overridepublic TypeInfo visit(Type.Bool type) throws RuntimeException {return getPrimitiveTypeInfo(BOOLEAN_TYPE_NAME);diff --git a/catalog-hive/src/main/java/com/datastrato/graviton/catalog/hive/dyn/DynFields.java b/catalog-hive/src/main/java/com/datastrato/graviton/catalog/hive/dyn/DynFields.javaindex 0f07444a6d..5e25ef327a 100644--- a/catalog-hive/src/main/java/com/datastrato/graviton/catalog/hive/dyn/DynFields.java+++ b/catalog-hive/src/main/java/com/datastrato/graviton/catalog/hive/dyn/DynFields.java@@ -82,10 +82,10 @@ public class DynFields {/*** Returns this method as a BoundMethod for the given receiver.*- * @param target an Object on which to get or set this field- * @return a {@link BoundField} for this field and the target- * @throws IllegalStateException if the method is static- * @throws IllegalArgumentException if the receiver's class is incompatible+ * @param target An Object on which to get or set this field.+ * @return a {@link BoundField} For this field and the target.+ * @throws IllegalStateException If the method is static.+ * @throws IllegalArgumentException If the receiver's class is incompatible.*/public BoundField<T> bind(Object target) {Preconditions.checkState(@@ -102,8 +102,8 @@ public class DynFields {/*** Returns this field as a StaticField.*- * @return a {@link StaticField} for this field- * @throws IllegalStateException if the method is not static+ * @return A {@link StaticField} for this field.+ * @throws IllegalStateException If the method is not static.*/public StaticField<T> asStatic() {Preconditions.checkState(isStatic(), "Field %s is not static", name);@@ -199,8 +199,8 @@ public class DynFields {** <p>If not set, the current thread's ClassLoader is used.*- * @param newLoader a ClassLoader- * @return this Builder for method chaining+ * @param newLoader A ClassLoader.+ * @return This Builder for method chaining.*/public Builder loader(ClassLoader newLoader) {this.loader = newLoader;@@ -210,7 +210,7 @@ public class DynFields {/*** Instructs this builder to return AlwaysNull if no implementation is found.*- * @return this Builder for method chaining+ * @return This Builder for method chaining.*/public Builder defaultAlwaysNull() {this.defaultAlwaysNull = true;@@ -220,9 +220,9 @@ public class DynFields {/*** Checks for an implementation, first finding the class by name.*- * @param className name of a class- * @param fieldName name of the field- * @return this Builder for method chaining+ * @param className The name of a class.+ * @param fieldName The name of the field.+ * @return This Builder for method chaining.* @see Class#forName(String)* @see Class#getField(String)*/@@ -245,9 +245,9 @@ public class DynFields {/*** Checks for an implementation.*- * @param targetClass a class instance- * @param fieldName name of a field (different from constructor)- * @return this Builder for method chaining+ * @param targetClass A class instance.+ * @param fieldName The name of a field (different from constructor).+ * @return This Builder for method chaining.* @see Class#forName(String)* @see Class#getField(String)*/@@ -269,9 +269,9 @@ public class DynFields {/*** Checks for a hidden implementation, first finding the class by name.*- * @param className name of a class- * @param fieldName name of a field (different from constructor)- * @return this Builder for method chaining+ * @param className The name of a class.+ * @param fieldName The name of a field (different from constructor).+ * @return This Builder for method chaining.* @see Class#forName(String)* @see Class#getField(String)*/@@ -294,9 +294,9 @@ public class DynFields {/*** Checks for a hidden implementation.*- * @param targetClass a class instance- * @param fieldName name of a field (different from constructor)- * @return this Builder for method chaining+ * @param targetClass A class instance.+ * @param fieldName The name of a field (different from constructor).+ * @return This Builder for method chaining.* @see Class#forName(String)* @see Class#getField(String)*/@@ -321,9 +321,9 @@ public class DynFields {* Returns the first valid implementation as a UnboundField or throws a NoSuchFieldException if* there is none.*- * @param <T> Java class stored in the field- * @return a {@link UnboundField} with a valid implementation- * @throws NoSuchFieldException if no implementation was found+ * @param <T> Java class stored in the field.+ * @return A {@link UnboundField} with a valid implementation.+ * @throws NoSuchFieldException If no implementation was found.*/@SuppressWarnings("unchecked")public <T> UnboundField<T> buildChecked() throws NoSuchFieldException {@@ -341,12 +341,12 @@ public class DynFields {* Returns the first valid implementation as a BoundMethod or throws a NoSuchMethodException if* there is none.*- * @param target an Object on which to get and set the field- * @param <T> Java class stored in the field- * @return a {@link BoundField} with a valid implementation and target- * @throws IllegalStateException if the method is static- * @throws IllegalArgumentException if the receiver's class is incompatible- * @throws NoSuchFieldException if no implementation was found+ * @param target An Object on which to get and set the field.+ * @param <T> Java class stored in the field.+ * @return A {@link BoundField} with a valid implementation and target.+ * @throws IllegalStateException If the method is static.+ * @throws IllegalArgumentException If the receiver's class is incompatible.+ * @throws NoSuchFieldException If no implementation was found.*/public <T> BoundField<T> buildChecked(Object target) throws NoSuchFieldException {return this.<T>buildChecked().bind(target);@@ -356,9 +356,9 @@ public class DynFields {* Returns the first valid implementation as a UnboundField or throws a NoSuchFieldException if* there is none.*- * @param <T> Java class stored in the field- * @return a {@link UnboundField} with a valid implementation- * @throws RuntimeException if no implementation was found+ * @param <T> Java class stored in the field.+ * @return A {@link UnboundField} with a valid implementation.+ * @throws RuntimeException if no implementation was found.*/@SuppressWarnings("unchecked")public <T> UnboundField<T> build() {@@ -376,12 +376,12 @@ public class DynFields {* Returns the first valid implementation as a BoundMethod or throws a RuntimeException if there* is none.*- * @param target an Object on which to get and set the field- * @param <T> Java class stored in the field- * @return a {@link BoundField} with a valid implementation and target- * @throws IllegalStateException if the method is static- * @throws IllegalArgumentException if the receiver's class is incompatible- * @throws RuntimeException if no implementation was found+ * @param target an Object on which to get and set the field.+ * @param <T> Java class stored in the field.+ * @return A {@link BoundField} with a valid implementation and target.+ * @throws IllegalStateException If the method is static.+ * @throws IllegalArgumentException If the receiver's class is incompatible.+ * @throws RuntimeException If no implementation was found.*/public <T> BoundField<T> build(Object target) {return this.<T>build().bind(target);@@ -391,10 +391,10 @@ public class DynFields {* Returns the first valid implementation as a StaticField or throws a NoSuchFieldException if* there is none.*- * @param <T> Java class stored in the field- * @return a {@link StaticField} with a valid implementation- * @throws IllegalStateException if the method is not static- * @throws NoSuchFieldException if no implementation was found+ * @param <T> Java class stored in the field.+ * @return A {@link StaticField} with a valid implementation.+ * @throws IllegalStateException If the method is not static.+ * @throws NoSuchFieldException If no implementation was found.*/public <T> StaticField<T> buildStaticChecked() throws NoSuchFieldException {return this.<T>buildChecked().asStatic();@@ -404,10 +404,10 @@ public class DynFields {* Returns the first valid implementation as a StaticField or throws a RuntimeException if there* is none.*- * @param <T> Java class stored in the field- * @return a {@link StaticField} with a valid implementation- * @throws IllegalStateException if the method is not static- * @throws RuntimeException if no implementation was found+ * @param <T> Java class stored in the field.+ * @return A {@link StaticField} with a valid implementation.+ * @throws IllegalStateException If the method is not static.+ * @throws RuntimeException If no implementation was found.*/public <T> StaticField<T> buildStatic() {return this.<T>build().asStatic();diff --git a/catalog-hive/src/main/java/com/datastrato/graviton/catalog/hive/dyn/DynMethods.java b/catalog-hive/src/main/java/com/datastrato/graviton/catalog/hive/dyn/DynMethods.javaindex a2114e4938..78a66a7443 100644--- a/catalog-hive/src/main/java/com/datastrato/graviton/catalog/hive/dyn/DynMethods.java+++ b/catalog-hive/src/main/java/com/datastrato/graviton/catalog/hive/dyn/DynMethods.java@@ -34,8 +34,8 @@ public class DynMethods {/*** Constructs a new builder for calling methods dynamically.*- * @param methodName name of the method the builder will locate- * @return a Builder for finding a method+ * @param methodName The Name of the method the builder will locate.+ * @return A Builder for finding a method.*/public static Builder builder(String methodName) {return new Builder(methodName);@@ -117,10 +117,10 @@ public class DynMethods {/*** Returns this method as a BoundMethod for the given receiver.*- * @param receiver an Object to receive the method invocation- * @return a {@link BoundMethod} for this method and the receiver- * @throws IllegalStateException if the method is static- * @throws IllegalArgumentException if the receiver's class is incompatible+ * @param receiver An Object to receive the method invocation.+ * @return A {@link BoundMethod} for this method and the receiver.+ * @throws IllegalStateException If the method is static.+ * @throws IllegalArgumentException If the receiver's class is incompatible.*/public BoundMethod bind(Object receiver) {Preconditions.checkState(@@ -147,8 +147,8 @@ public class DynMethods {/*** Returns this method as a StaticMethod.*- * @return a {@link StaticMethod} for this method- * @throws IllegalStateException if the method is not static+ * @return A {@link StaticMethod} for this method.+ * @throws IllegalStateException If the method is not static.*/public StaticMethod asStatic() {Preconditions.checkState(isStatic(), "Method is not static");@@ -209,8 +209,8 @@ public class DynMethods {** <p>If not set, the current thread's ClassLoader is used.*- * @param newLoader a ClassLoader- * @return this Builder for method chaining+ * @param newLoader A ClassLoader.+ * @return This Builder for method chaining.*/public Builder loader(ClassLoader newLoader) {this.loader = newLoader;@@ -222,7 +222,7 @@ public class DynMethods {** <p>Note: calls to impl will not match after this method is called!*- * @return this Builder for method chaining+ * @return This Builder for method chaining.*/public Builder orNoop() {if (method == null) {@@ -234,10 +234,10 @@ public class DynMethods {/*** Checks for an implementation, first finding the given class by name.*- * @param className name of a class- * @param methodName name of a method (different from constructor)- * @param argClasses argument classes for the method- * @return this Builder for method chaining+ * @param className The name of a class.+ * @param methodName The name of a method (different from constructor).+ * @param argClasses Argument classes for the method.+ * @return This Builder for method chaining.* @see Class#forName(String)* @see Class#getMethod(String, Class[])*/@@ -261,9 +261,9 @@ public class DynMethods {** <p>The name passed to the constructor is the method name used.*- * @param className name of a class- * @param argClasses argument classes for the method- * @return this Builder for method chaining+ * @param className The name of a class.+ * @param argClasses Argument classes for the method.+ * @return This Builder for method chaining.* @see Class#forName(String)* @see Class#getMethod(String, Class[])*/@@ -275,10 +275,10 @@ public class DynMethods {/*** Checks for a method implementation.*- * @param targetClass a class instance- * @param methodName name of a method (different from constructor)- * @param argClasses argument classes for the method- * @return this Builder for method chaining+ * @param targetClass A class instance.+ * @param methodName The name of a method (different from constructor).+ * @param argClasses Argument classes for the method.+ * @return This Builder for method chaining.* @see Class#forName(String)* @see Class#getMethod(String, Class[])*/@@ -301,9 +301,9 @@ public class DynMethods {** <p>The name passed to the constructor is the method name used.*- * @param targetClass a class instance- * @param argClasses argument classes for the method- * @return this Builder for method chaining+ * @param targetClass A class instance.+ * @param argClasses Argument classes for the method.+ * @return This Builder for method chaining.* @see Class#forName(String)* @see Class#getMethod(String, Class[])*/@@ -343,10 +343,10 @@ public class DynMethods {/*** Checks for an implementation, first finding the given class by name.*- * @param className name of a class- * @param methodName name of a method (different from constructor)- * @param argClasses argument classes for the method- * @return this Builder for method chaining+ * @param className The name of a class.+ * @param methodName The name of a method (different from constructor).+ * @param argClasses Argument classes for the method.+ * @return This Builder for method chaining.* @see Class#forName(String)* @see Class#getMethod(String, Class[])*/@@ -370,9 +370,9 @@ public class DynMethods {** <p>The name passed to the constructor is the method name used.*- * @param className name of a class- * @param argClasses argument classes for the method- * @return this Builder for method chaining+ * @param className The name of a class.+ * @param argClasses Argument classes for the method.+ * @return This Builder for method chaining.* @see Class#forName(String)* @see Class#getMethod(String, Class[])*/@@ -384,10 +384,10 @@ public class DynMethods {/*** Checks for a method implementation.*- * @param targetClass a class instance- * @param methodName name of a method (different from constructor)- * @param argClasses argument classes for the method- * @return this Builder for method chaining+ * @param targetClass A class instance.+ * @param methodName The name of a method (different from constructor).+ * @param argClasses Argument classes for the method.+ * @return This Builder for method chaining.* @see Class#forName(String)* @see Class#getMethod(String, Class[])*/@@ -412,9 +412,9 @@ public class DynMethods {** <p>The name passed to the constructor is the method name used.*- * @param targetClass a class instance- * @param argClasses argument classes for the method- * @return this Builder for method chaining+ * @param targetClass A class instance.+ * @param argClasses Argument classes for the method.+ * @return This Builder for method chaining.* @see Class#forName(String)* @see Class#getMethod(String, Class[])*/@@ -427,8 +427,8 @@ public class DynMethods {* Returns the first valid implementation as a UnboundMethod or throws a RuntimeError if there* is none.*- * @return a {@link UnboundMethod} with a valid implementation- * @throws RuntimeException if no implementation was found+ * @return A {@link UnboundMethod} with a valid implementation.+ * @throws RuntimeException If no implementation was found.*/public UnboundMethod build() {if (method != null) {@@ -442,11 +442,11 @@ public class DynMethods {* Returns the first valid implementation as a BoundMethod or throws a RuntimeError if there is* none.*- * @param receiver an Object to receive the method invocation- * @return a {@link BoundMethod} with a valid implementation and receiver- * @throws IllegalStateException if the method is static- * @throws IllegalArgumentException if the receiver's class is incompatible- * @throws RuntimeException if no implementation was found+ * @param receiver An Object to receive the method invocation.+ * @return A {@link BoundMethod} with a valid implementation and receiver.+ * @throws IllegalStateException If the method is static.+ * @throws IllegalArgumentException If the receiver's class is incompatible.+ * @throws RuntimeException If no implementation was found.*/public BoundMethod build(Object receiver) {return build().bind(receiver);@@ -471,11 +471,11 @@ public class DynMethods {* Returns the first valid implementation as a BoundMethod or throws a NoSuchMethodException if* there is none.*- * @param receiver an Object to receive the method invocation- * @return a {@link BoundMethod} with a valid implementation and receiver- * @throws IllegalStateException if the method is static- * @throws IllegalArgumentException if the receiver's class is incompatible- * @throws NoSuchMethodException if no implementation was found+ * @param receiver An Object to receive the method invocation.+ * @return A {@link BoundMethod} with a valid implementation and receiver.+ * @throws IllegalStateException If the method is static.+ * @throws IllegalArgumentException If the receiver's class is incompatible.+ * @throws NoSuchMethodException If no implementation was found.*/public BoundMethod buildChecked(Object receiver) throws NoSuchMethodException {return buildChecked().bind(receiver);@@ -485,9 +485,9 @@ public class DynMethods {* Returns the first valid implementation as a StaticMethod or throws a NoSuchMethodException if* there is none.*- * @return a {@link StaticMethod} with a valid implementation- * @throws IllegalStateException if the method is not static- * @throws NoSuchMethodException if no implementation was found+ * @return a {@link StaticMethod} With a valid implementation.+ * @throws IllegalStateException If the method is not static.+ * @throws NoSuchMethodException If no implementation was found.*/public StaticMethod buildStaticChecked() throws NoSuchMethodException {return buildChecked().asStatic();@@ -497,9 +497,9 @@ public class DynMethods {* Returns the first valid implementation as a StaticMethod or throws a RuntimeException if* there is none.*- * @return a {@link StaticMethod} with a valid implementation- * @throws IllegalStateException if the method is not static- * @throws RuntimeException if no implementation was found+ * @return A {@link StaticMethod} with a valid implementation.+ * @throws IllegalStateException If the method is not static.+ * @throws RuntimeException If no implementation was found.*/public StaticMethod buildStatic() {return build().asStatic();diff --git a/catalog-hive/src/test/java/com/datastrato/graviton/catalog/hive/miniHMS/MiniHiveMetastore.java b/catalog-hive/src/test/java/com/datastrato/graviton/catalog/hive/miniHMS/MiniHiveMetastore.javaindex 8e40f4bae1..6fe6e7e224 100644--- a/catalog-hive/src/test/java/com/datastrato/graviton/catalog/hive/miniHMS/MiniHiveMetastore.java+++ b/catalog-hive/src/test/java/com/datastrato/graviton/catalog/hive/miniHMS/MiniHiveMetastore.java@@ -71,17 +71,18 @@ public class MiniHiveMetastore {.impl(RetryingHMSHandler.class, HiveConf.class, IHMSHandler.class, boolean.class).buildStatic();- // Hive3 introduces background metastore tasks (MetastoreTaskThread) for performing various- // cleanup duties. These- // threads are scheduled and executed in a static thread pool+ // In Hive3, background metastore tasks (MetastoreTaskThread) are introduced to handle various+ // cleanup duties.+ // These threads are scheduled and executed in a static thread pool// (org.apache.hadoop.hive.metastore.ThreadPool).- // This thread pool is shut down normally as part of the JVM shutdown hook, but since we're- // creating and tearing down- // multiple metastore instances within the same JVM, we have to call this cleanup method manually,- // otherwise- // threads from our previous test suite will be stuck in the pool with stale config, and keep on- // being scheduled.- // This can lead to issues, e.g. accidental Persistence Manager closure by+ // The thread pool is normally shut down as part of the JVM shutdown hook. However, in scenarios+ // where multiple+ // metastore instances are created and torn down within the same JVM, manual cleanup becomes+ // necessary.+ // If we fail to perform this cleanup, threads from previous test suites may remain stuck in the+ // pool with stale configurations+ // and continue to be scheduled.+ // This situation can lead to issues, such as accidental closure of the Persistence Manager by// ScheduledQueryExecutionsMaintTask.private static final DynMethods.StaticMethod METASTORE_THREADS_SHUTDOWN =DynMethods.builder("shutdown")@@ -89,8 +90,9 @@ public class MiniHiveMetastore {.orNoop().buildStatic();- // It's tricky to clear all static fields in an HMS instance in order to switch derby root dir.- // Therefore, we reuse the same derby root between tests and remove it after JVM exits.+ // Managing static fields in a Hive Metastore instance to switch the Derby root directory is+ // complex.+ // To simplify testing, we reuse the same Derby root across tests and remove it after JVM exits.private static final File HIVE_LOCAL_DIR;private static final String DERBY_PATH;@@ -146,27 +148,28 @@ public class MiniHiveMetastore {}/**- * Starts a TestHiveMetastore with the default connection pool size (5) and the default HiveConf.+ * Starts a TestHiveMetastore with the default connection pool size (5) with the default Hive+ * configuration.*/public void start() {start(new HiveConf(new Configuration(), MiniHiveMetastore.class), DEFAULT_POOL_SIZE);}/**- * Starts a TestHiveMetastore with the default connection pool size (5) with the provided- * HiveConf.+ * Starts a TestHiveMetastore with the default connection pool size (5) with the provided Hive+ * configuration.*- * @param conf The hive configuration to use+ * @param conf The hive configuration to use.*/public void start(HiveConf conf) {start(conf, DEFAULT_POOL_SIZE);}/**- * Starts a TestHiveMetastore with a provided connection pool size and HiveConf.+ * Starts a TestHiveMetastore with a provided connection pool size and Hive configuration.*- * @param conf The hive configuration to use- * @param poolSize The number of threads in the executor pool+ * @param conf The hive configuration to use.+ * @param poolSize The number of threads in the executor pool.*/public void start(HiveConf conf, int poolSize) {try {@@ -179,8 +182,8 @@ public class MiniHiveMetastore {this.executorService = Executors.newSingleThreadExecutor();this.executorService.submit(() -> server.serve());- // in Hive3, setting this as a system prop ensures that it will be picked up- // whenever a new HiveConf is created+ // In Hive3, by setting this as a system property, we ensure that+ // it gets picked up whenever a new HiveConf is created.System.setProperty(HiveConf.ConfVars.METASTOREURIS.varname,hiveConf.getVar(HiveConf.ConfVars.METASTOREURIS));diff --git a/catalog-hive/src/test/java/com/datastrato/graviton/catalog/hive/miniHMS/ScriptRunner.java b/catalog-hive/src/test/java/com/datastrato/graviton/catalog/hive/miniHMS/ScriptRunner.javaindex eb22030cac..3d2c08a711 100644--- a/catalog-hive/src/test/java/com/datastrato/graviton/catalog/hive/miniHMS/ScriptRunner.java+++ b/catalog-hive/src/test/java/com/datastrato/graviton/catalog/hive/miniHMS/ScriptRunner.java@@ -30,7 +30,7 @@ import java.sql.Statement;// hive-metastore/src/test/java/org/apache/iceberg/hive/ScriptRunner.java-/** Tool to run database scripts */+/** Tool to run database scripts. */public class ScriptRunner {private static final String DEFAULT_DELIMITER = ";";@@ -46,22 +46,37 @@ public class ScriptRunner {private String delimiter = DEFAULT_DELIMITER;private boolean fullLineDelimiter = false;- /** Default constructor */+ /**+ * Constructs a new ScriptRunner instance.+ *+ * @param connection The database connection to use for script execution.+ * @param autoCommit True if auto-commit should be enabled; otherwise, false.+ * @param stopOnError True if script execution should stop on errors; otherwise, false.+ */public ScriptRunner(Connection connection, boolean autoCommit, boolean stopOnError) {this.connection = connection;this.autoCommit = autoCommit;this.stopOnError = stopOnError;}+ /**+ * Sets a new delimiter for SQL statements and whether to treat it as a full-line delimiter.+ *+ * @param newDelimiter The new delimiter to use.+ * @param newFullLineDelimiter True if the delimiter should be treated as a full-line delimiter;+ * otherwise, false.+ */public void setDelimiter(String newDelimiter, boolean newFullLineDelimiter) {this.delimiter = newDelimiter;this.fullLineDelimiter = newFullLineDelimiter;}/**- * Runs an SQL script (read in using the Reader parameter)+ * Runs an SQL script using the provided Reader as the script source.*- * @param reader - the source of the script+ * @param reader The source of the SQL script.+ * @throws IOException If there is an error reading from the Reader.+ * @throws SQLException If any SQL errors occur.*/public void runScript(Reader reader) throws IOException, SQLException {try {@@ -82,12 +97,12 @@ public class ScriptRunner {}/**- * Runs an SQL script (read in using the Reader parameter) using the connection passed in+ * Runs an SQL script using the provided Reader as the script source and the given connection.*- * @param conn - the connection to use for the script- * @param reader - the source of the script- * @throws SQLException if any SQL errors occur- * @throws IOException if there is an error reading from the Reader+ * @param conn The connection to use for executing the script.+ * @param reader The source of the SQL script.+ * @throws IOException If there is an error reading from the Reader.+ * @throws SQLException If any SQL errors occur.*/@SuppressWarnings("checkstyle:CyclomaticComplexity")private void runScript(Connection conn, Reader reader) throws IOException, SQLException {