forked from apache/gravitino
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[apache#3460] feat(api): Add API design for Tag system (apache#3486)
### What changes were proposed in this pull request? This PR adds the API support for Tag system in Gravitino. ### Why are the changes needed? This is the first step to add a tag system. Fix: apache#3460 ### Does this PR introduce _any_ user-facing change? Yes. ### How was this patch tested? No. Test will be added later when implementing the logic.
- Loading branch information
Showing
10 changed files
with
674 additions
and
104 deletions.
There are no files selected for viewing
79 changes: 79 additions & 0 deletions
79
api/src/main/java/com/datastrato/gravitino/MetadataObject.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
/* | ||
* Copyright 2024 Datastrato Pvt Ltd. | ||
* This software is licensed under the Apache License version 2. | ||
*/ | ||
|
||
package com.datastrato.gravitino; | ||
|
||
import com.datastrato.gravitino.annotation.Unstable; | ||
import javax.annotation.Nullable; | ||
|
||
/** | ||
* The MetadataObject is the basic unit of the Gravitino system. It represents the metadata object | ||
* in the Gravitino system. The object can be a metalake, catalog, schema, table, topic, etc. | ||
*/ | ||
@Unstable | ||
public interface MetadataObject { | ||
/** | ||
* The type of object in the Gravitino system. Every type will map one kind of the entity of the | ||
* underlying system. | ||
*/ | ||
enum Type { | ||
/** | ||
* A metalake is a concept of tenant. It means an organization. A metalake contains many data | ||
* sources. | ||
*/ | ||
METALAKE, | ||
/** | ||
* A catalog is a collection of metadata from a specific metadata source, like Apache Hive | ||
* catalog, Apache Iceberg catalog, JDBC catalog, etc. | ||
*/ | ||
CATALOG, | ||
/** | ||
* A schema is a sub collection of the catalog. The schema can contain filesets, tables, topics, | ||
* etc. | ||
*/ | ||
SCHEMA, | ||
/** A fileset is mapped to a directory on a file system like HDFS, S3, ADLS, GCS, etc. */ | ||
FILESET, | ||
/** A table is mapped the table of relational data sources like Apache Hive, MySQL, etc. */ | ||
TABLE, | ||
/** | ||
* A topic is mapped the topic of messaging data sources like Apache Kafka, Apache Pulsar, etc. | ||
*/ | ||
TOPIC, | ||
/** A column is a sub-collection of the table that represents a group of same type data. */ | ||
COLUMN | ||
} | ||
|
||
/** | ||
* The parent full name of the object. If the object doesn't have parent, this method will return | ||
* null. | ||
* | ||
* @return The parent full name of the object. | ||
*/ | ||
@Nullable | ||
String parent(); | ||
|
||
/** | ||
* The name of th object. | ||
* | ||
* @return The name of the object. | ||
*/ | ||
String name(); | ||
|
||
/** | ||
* The full name of th object. Full name will be separated by "." to represent a string identifier | ||
* of the object, like catalog, catalog.table, etc. | ||
* | ||
* @return The name of the object. | ||
*/ | ||
String fullName(); | ||
|
||
/** | ||
* The type of the object. | ||
* | ||
* @return The type of the object. | ||
*/ | ||
Type type(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
api/src/main/java/com/datastrato/gravitino/exceptions/NoSuchTagException.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/* | ||
* Copyright 2024 Datastrato Pvt Ltd. | ||
* This software is licensed under the Apache License version 2. | ||
*/ | ||
|
||
package com.datastrato.gravitino.exceptions; | ||
|
||
import com.google.errorprone.annotations.FormatMethod; | ||
|
||
/** Exception thrown when a tag with specified name is not existed. */ | ||
public class NoSuchTagException extends NotFoundException { | ||
|
||
/** | ||
* Constructs a new exception with the specified detail message. | ||
* | ||
* @param message the detail message. | ||
* @param args the arguments to the message. | ||
*/ | ||
@FormatMethod | ||
public NoSuchTagException(String message, Object... args) { | ||
super(message, args); | ||
} | ||
|
||
/** | ||
* Constructs a new exception with the specified detail message and cause. | ||
* | ||
* @param cause the cause. | ||
* @param message the detail message. | ||
* @param args the arguments to the message. | ||
*/ | ||
@FormatMethod | ||
public NoSuchTagException(Throwable cause, String message, Object... args) { | ||
super(cause, message, args); | ||
} | ||
} |
35 changes: 35 additions & 0 deletions
35
api/src/main/java/com/datastrato/gravitino/exceptions/TagAlreadyExistsException.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/* | ||
* Copyright 2024 Datastrato Pvt Ltd. | ||
* This software is licensed under the Apache License version 2. | ||
*/ | ||
|
||
package com.datastrato.gravitino.exceptions; | ||
|
||
import com.google.errorprone.annotations.FormatMethod; | ||
|
||
/** Exception thrown when a tag with specified name already exists. */ | ||
public class TagAlreadyExistsException extends AlreadyExistsException { | ||
|
||
/** | ||
* Constructs a new exception with the specified detail message. | ||
* | ||
* @param message the detail message. | ||
* @param args the arguments to the message. | ||
*/ | ||
@FormatMethod | ||
public TagAlreadyExistsException(String message, Object... args) { | ||
super(message, args); | ||
} | ||
|
||
/** | ||
* Constructs a new exception with the specified detail message and cause. | ||
* | ||
* @param cause the cause. | ||
* @param message the detail message. | ||
* @param args the arguments to the message. | ||
*/ | ||
@FormatMethod | ||
public TagAlreadyExistsException(Throwable cause, String message, Object... args) { | ||
super(cause, message, args); | ||
} | ||
} |
49 changes: 49 additions & 0 deletions
49
api/src/main/java/com/datastrato/gravitino/tag/SupportsTags.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
/* | ||
* Copyright 2024 Datastrato Pvt Ltd. | ||
* This software is licensed under the Apache License version 2. | ||
*/ | ||
|
||
package com.datastrato.gravitino.tag; | ||
|
||
import com.datastrato.gravitino.annotation.Evolving; | ||
import com.datastrato.gravitino.exceptions.NoSuchTagException; | ||
|
||
/** | ||
* Interface for supporting getting or associate tags to objects. This interface will be mixed with | ||
* metadata objects to provide tag operations. | ||
*/ | ||
@Evolving | ||
public interface SupportsTags { | ||
|
||
/** | ||
* List all the tag names for the specific object. | ||
* | ||
* @return The list of tag names. | ||
*/ | ||
String[] listTags(); | ||
|
||
/** | ||
* List all the tags with details for the specific object. | ||
* | ||
* @return The list of tags. | ||
*/ | ||
Tag[] listTagsInfo(); | ||
|
||
/** | ||
* Get a tag by its name for the specific object. | ||
* | ||
* @param name The name of the tag. | ||
* @return The tag. | ||
*/ | ||
Tag getTag(String name) throws NoSuchTagException; | ||
|
||
/** | ||
* Associate tags to the specific object. The tagsToAdd will be added to the object, and the | ||
* tagsToRemove will be removed from the object. | ||
* | ||
* @param tagsToAdd The arrays of tag name to be added to the object. | ||
* @param tagsToRemove The array of tag name to be removed from the object. | ||
* @return The array of tag names that are associated with the object. | ||
*/ | ||
String[] associateTags(String[] tagsToAdd, String[] tagsToRemove); | ||
} |
Oops, something went wrong.