Skip to content

Commit

Permalink
[apache#3731]Update the tutorial and document for the Java client API…
Browse files Browse the repository at this point in the history
… change
  • Loading branch information
shaofengshi committed Jul 5, 2024
1 parent 34a81df commit 91c953b
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 43 deletions.
16 changes: 7 additions & 9 deletions docs/manage-fileset-metadata-using-gravitino.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,7 @@ Map<String, String> properties = ImmutableMap.<String, String>builder()
// a storage location will be stored under this location.
.build();

Catalog catalog = gravitinoClient.createCatalog(
NameIdentifier.of("metalake", "catalog"),
Catalog catalog = gravitinoClient.createCatalog("catalog",
Type.FILESET,
"hadoop", // provider, Gravitino only supports "hadoop" for now.
"This is a Hadoop fileset catalog",
Expand Down Expand Up @@ -167,7 +166,7 @@ GravitinoClient gravitinoClient = GravitinoClient
.build();

// Assuming you have just created a Hadoop catalog named `catalog`
Catalog catalog = gravitinoClient.loadCatalog(NameIdentifier.of("metalake", "catalog"));
Catalog catalog = gravitinoClient.loadCatalog("catalog");

SupportsSchemas supportsSchemas = catalog.asSchemas();

Expand All @@ -176,8 +175,7 @@ Map<String, String> schemaProperties = ImmutableMap.<String, String>builder()
// specifying storage location will be stored under this location.
.put("location", "file:/tmp/root/schema")
.build();
Schema schema = supportsSchemas.createSchema(
NameIdentifier.of("metalake", "catalog", "schema"),
Schema schema = supportsSchemas.createSchema("schema",
"This is a schema",
schemaProperties
);
Expand Down Expand Up @@ -270,7 +268,7 @@ GravitinoClient gravitinoClient = GravitinoClient
.withMetalake("metalake")
.build();

Catalog catalog = gravitinoClient.loadCatalog(NameIdentifier.of("metalake", "catalog"));
Catalog catalog = gravitinoClient.loadCatalog("catalog");
FilesetCatalog filesetCatalog = catalog.asFilesetCatalog();

Map<String, String> propertiesMap = ImmutableMap.<String, String>builder()
Expand Down Expand Up @@ -362,7 +360,7 @@ curl -X PUT -H "Accept: application/vnd.gravitino.v1+json" \
```java
// ...
// Assuming you have just created a Fileset catalog named `catalog`
Catalog catalog = gravitinoClient.loadCatalog(NameIdentifier.of("metalake", "catalog"));
Catalog catalog = gravitinoClient.loadCatalog("catalog");

FilesetCatalog filesetCatalog = catalog.asFilesetCatalog();

Expand Down Expand Up @@ -419,7 +417,7 @@ http://localhost:8090/api/metalakes/metalake/catalogs/catalog/schemas/schema/fil
```java
// ...
// Assuming you have just created a Fileset catalog named `catalog`
Catalog catalog = gravitinoClient.loadCatalog(NameIdentifier.of("metalake", "catalog"));
Catalog catalog = gravitinoClient.loadCatalog("catalog");

FilesetCatalog filesetCatalog = catalog.asFilesetCatalog();

Expand Down Expand Up @@ -464,7 +462,7 @@ http://localhost:8090/api/metalakes/metalake/catalogs/catalog/schemas/schema/fil

```java
// ...
Catalog catalog = gravitinoClient.loadCatalog(NameIdentifier.of("metalake", "catalog"));
Catalog catalog = gravitinoClient.loadCatalog("catalog");

FilesetCatalog filesetCatalog = catalog.asFilesetCatalog();
NameIdentifier[] identifiers =
Expand Down
11 changes: 5 additions & 6 deletions docs/manage-messaging-metadata-using-gravitino.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,7 @@ Map<String, String> properties = ImmutableMap.<String, String>builder()
.put("bootstrap.servers", "localhost:9092")
.build();

Catalog catalog = gravitinoClient.createCatalog(
NameIdentifier.of("metalake", "catalog"),
Catalog catalog = gravitinoClient.createCatalog("catalog",
Type.MESSAGING,
"kafka", // provider, Gravitino only supports "kafka" for now.
"This is a Kafka catalog",
Expand Down Expand Up @@ -172,7 +171,7 @@ GravitinoClient gravitinoClient = GravitinoClient
.withMetalake("metalake")
.build();

Catalog catalog = gravitinoClient.loadCatalog(NameIdentifier.of("metalake", "catalog"));
Catalog catalog = gravitinoClient.loadCatalog("catalog");
TopicCatalog topicCatalog = catalog.asTopicCatalog();

Map<String, String> propertiesMap = ImmutableMap.<String, String>builder()
Expand Down Expand Up @@ -222,7 +221,7 @@ curl -X PUT -H "Accept: application/vnd.gravitino.v1+json" \
```java
// ...
// Assuming you have just created a Kafka catalog named `catalog`
Catalog catalog = gravitinoClient.loadCatalog(NameIdentifier.of("metalake", "catalog"));
Catalog catalog = gravitinoClient.loadCatalog("catalog");

TopicCatalog topicCatalog = catalog.asTopicCatalog();

Expand Down Expand Up @@ -263,7 +262,7 @@ http://localhost:8090/api/metalakes/metalake/catalogs/catalog/schemas/default/to
```java
// ...
// Assuming you have just created a Kafka catalog named `catalog`
Catalog catalog = gravitinoClient.loadCatalog(NameIdentifier.of("metalake", "catalog"));
Catalog catalog = gravitinoClient.loadCatalog("catalog");

TopicCatalog topicCatalog = catalog.asTopicCatalog();

Expand Down Expand Up @@ -295,7 +294,7 @@ http://localhost:8090/api/metalakes/metalake/catalogs/catalog/schemas/schema/top

```java
// ...
Catalog catalog = gravitinoClient.loadCatalog(NameIdentifier.of("metalake", "catalog"));
Catalog catalog = gravitinoClient.loadCatalog("catalog");

TopicCatalog topicCatalog = catalog.asTopicCatalog();
NameIdentifier[] identifiers =
Expand Down
44 changes: 21 additions & 23 deletions docs/manage-relational-metadata-using-gravitino.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,7 @@ Map<String, String> hiveProperties = ImmutableMap.<String, String>builder()
.put("metastore.uris", "thrift://localhost:9083")
.build();

Catalog catalog = gravitinoClient.createCatalog(
NameIdentifier.of("metalake", "catalog"),
Catalog catalog = gravitinoClient.createCatalog("catalog",
Type.RELATIONAL,
"hive", // provider, We support hive, jdbc-mysql, jdbc-postgresql, lakehouse-iceberg, etc.
"This is a hive catalog",
Expand Down Expand Up @@ -114,7 +113,7 @@ curl -X GET -H "Accept: application/vnd.gravitino.v1+json" \
```java
// ...
// Assuming you have created a metalake named `metalake` and a catalog named `catalog`
Catalog catalog = gravitinoClient.loadCatalog(NameIdentifier.of("metalake", "catalog"));
Catalog catalog = gravitinoClient.loadCatalog("catalog");
// ...
```

Expand Down Expand Up @@ -151,7 +150,7 @@ curl -X PUT -H "Accept: application/vnd.gravitino.v1+json" \
```java
// ...
// Assuming you have created a metalake named `metalake` and a catalog named `catalog`
Catalog catalog = gravitinoClient.alterCatalog(NameIdentifier.of("metalake", "catalog"),
Catalog catalog = gravitinoClient.alterCatalog("catalog",
CatalogChange.rename("alter_catalog"), CatalogChange.updateComment("new comment"));
// ...
```
Expand Down Expand Up @@ -187,7 +186,7 @@ http://localhost:8090/api/metalakes/metalake/catalogs/catalog
```java
// ...
// Assuming you have created a metalake named `metalake` and a catalog named `catalog`
gravitinoClient.dropCatalog(NameIdentifier.of("metalake", "catalog"));
gravitinoClient.dropCatalog("catalog");
// ...

```
Expand Down Expand Up @@ -219,7 +218,7 @@ http://localhost:8090/api/metalakes/metalake/catalogs
```java
// ...
// Assuming you have just created a metalake named `metalake`
NameIdentifier[] catalogsIdents = gravitinoClient.listCatalogs(Namespace.ofCatalog("metalake"));
String[] catalogNames = gravitinoClient.listCatalogs();
// ...
```

Expand All @@ -245,7 +244,7 @@ http://localhost:8090/api/metalakes/metalake/catalogs?details=true
```java
// ...
// Assuming you have just created a metalake named `metalake`
Catalog[] catalogsInfos = gravitinoMetalake.listCatalogsInfo(Namespace.ofCatalog("metalake"));
Catalog[] catalogsInfos = gravitinoMetaLake.listCatalogsInfo();
// ...
```

Expand Down Expand Up @@ -282,14 +281,13 @@ curl -X POST -H "Accept: application/vnd.gravitino.v1+json" \

```java
// Assuming you have just created a Hive catalog named `hive_catalog`
Catalog catalog = gravitinoClient.loadCatalog(NameIdentifier.of("metalake", "hive_catalog"));
Catalog catalog = gravitinoClient.loadCatalog("hive_catalog");

SupportsSchemas supportsSchemas = catalog.asSchemas();

Map<String, String> schemaProperties = ImmutableMap.<String, String>builder()
.build();
Schema schema = supportsSchemas.createSchema(
NameIdentifier.of("metalake", "hive_catalog", "schema"),
Schema schema = supportsSchemas.createSchema("schema",
"This is a schema",
schemaProperties
);
Expand Down Expand Up @@ -339,9 +337,9 @@ http://localhost:8090/api/metalakes/metalake/catalogs/catalog/schemas/schema
```java
// ...
// Assuming you have just created a Hive catalog named `hive_catalog`
Catalog catalog = gravitinoClient.loadCatalog(NameIdentifier.of("metalake", "hive_catalog"));
Catalog catalog = gravitinoClient.loadCatalog("hive_catalog");
SupportsSchemas supportsSchemas = catalog.asSchemas();
Schema schema = supportsSchemas.loadSchema(NameIdentifier.of("metalake", "hive_catalog", "schema"));
Schema schema = supportsSchemas.loadSchema("schema");
// ...
```

Expand Down Expand Up @@ -386,11 +384,11 @@ curl -X PUT -H "Accept: application/vnd.gravitino.v1+json" \
```java
// ...
// Assuming you have just created a Hive catalog named `hive_catalog`
Catalog catalog = gravitinoClient.loadCatalog(NameIdentifier.of("metalake", "hive_catalog"));
Catalog catalog = gravitinoClient.loadCatalog("hive_catalog");

SupportsSchemas supportsSchemas = catalog.asSchemas();

Schema schema = supportsSchemas.alterSchema(NameIdentifier.of("metalake", "hive_catalog", "schema"),
Schema schema = supportsSchemas.alterSchema("schema",
SchemaChange.removeProperty("key1"),
SchemaChange.setProperty("key2", "value2"));
// ...
Expand Down Expand Up @@ -440,11 +438,11 @@ http://localhost:8090/api/metalakes/metalake/catalogs/catalog/schemas/schema?cas
```java
// ...
// Assuming you have just created a Hive catalog named `hive_catalog`
Catalog catalog = gravitinoClient.loadCatalog(NameIdentifier.of("metalake", "hive_catalog"));
Catalog catalog = gravitinoClient.loadCatalog("hive_catalog");

SupportsSchemas supportsSchemas = catalog.asSchemas();
// cascade can be true or false
supportsSchemas.dropSchema(NameIdentifier.of("metalake", "hive_catalog", "schema"), true);
supportsSchemas.dropSchema("schema", true);
```

</TabItem>
Expand Down Expand Up @@ -483,10 +481,10 @@ curl -X GET -H "Accept: application/vnd.gravitino.v1+json" \
```java
// ...
// Assuming you have just created a Hive catalog named `hive_catalog`
Catalog catalog = gravitinoClient.loadCatalog(NameIdentifier.of("metalake", "hive_catalog"));
Catalog catalog = gravitinoClient.loadCatalog("hive_catalog");

SupportsSchemas supportsSchemas = catalog.asSchemas();
NameIdentifier[] schemas = supportsSchemas.listSchemas(Namespace.ofSchema("metalake", "hive_catalog"));
String[] schemas = supportsSchemas.listSchemas();
```

</TabItem>
Expand Down Expand Up @@ -645,7 +643,7 @@ curl -X POST -H "Accept: application/vnd.gravitino.v1+json" \

```java
// Assuming you have just created a Hive catalog named `hive_catalog`
Catalog catalog = gravitinoClient.loadCatalog(NameIdentifier.of("metalake", "hive_catalog"));
Catalog catalog = gravitinoClient.loadCatalog("hive_catalog");

TableCatalog tableCatalog = catalog.asTableCatalog();

Expand Down Expand Up @@ -858,7 +856,7 @@ http://localhost:8090/api/metalakes/metalake/catalogs/catalog/schemas/schema/tab
```java
// ...
// Assuming you have just created a Hive catalog named `hive_catalog`
Catalog catalog = gravitinoClient.loadCatalog(NameIdentifier.of("metalake", "hive_catalog"));
Catalog catalog = gravitinoClient.loadCatalog("hive_catalog");

TableCatalog tableCatalog = catalog.asTableCatalog();
tableCatalog.loadTable(NameIdentifier.of("metalake", "hive_catalog", "schema", "table"));
Expand Down Expand Up @@ -902,7 +900,7 @@ curl -X PUT -H "Accept: application/vnd.gravitino.v1+json" \
```java
// ...
// Assuming you have just created a Hive catalog named `hive_catalog`
Catalog catalog = gravitinoClient.loadCatalog(NameIdentifier.of("metalake", "hive_catalog"));
Catalog catalog = gravitinoClient.loadCatalog("hive_catalog");

TableCatalog tableCatalog = catalog.asTableCatalog();

Expand Down Expand Up @@ -952,7 +950,7 @@ http://localhost:8090/api/metalakes/metalake/catalogs/catalog/schemas/schema/tab
```java
// ...
// Assuming you have just created a Hive catalog named `hive_catalog`
Catalog catalog = gravitinoClient.loadCatalog(NameIdentifier.of("metalake", "hive_catalog"));
Catalog catalog = gravitinoClient.loadCatalog("hive_catalog");

TableCatalog tableCatalog = catalog.asTableCatalog();

Expand Down Expand Up @@ -993,7 +991,7 @@ http://localhost:8090/api/metalakes/metalake/catalogs/catalog/schemas/schema/tab
```java
// ...
// Assuming you have just created a Hive catalog named `hive_catalog`
Catalog catalog = gravitinoClient.loadCatalog(NameIdentifier.of("metalake", "hive_catalog"));
Catalog catalog = gravitinoClient.loadCatalog("hive_catalog");

TableCatalog tableCatalog = catalog.asTableCatalog();
NameIdentifier[] identifiers =
Expand Down
10 changes: 5 additions & 5 deletions docs/manage-table-partition-using-gravitino.md
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ GravitinoClient gravitinoClient = GravitinoClient
// Assume that you have a partitioned table named "metalake.catalog.schema.table".
Partition addedPartition =
gravitinoClient
.loadCatalog(NameIdentifier.of("metalake", "catalog"))
.loadCatalog("catalog")
.asTableCatalog()
.loadTable(NameIdentifier.of("metalake", "catalog", "schema", "table"))
.supportPartitions()
Expand Down Expand Up @@ -300,7 +300,7 @@ GravitinoClient gravitinoClient = GravitinoClient
// Assume that you have a partitioned table named "metalake.catalog.schema.table".
Partition Partition =
gravitinoClient
.loadCatalog(NameIdentifier.of("metalake", "catalog"))
.loadCatalog("catalog")
.asTableCatalog()
.loadTable(NameIdentifier.of("metalake", "catalog", "schema", "table"))
.supportPartitions()
Expand Down Expand Up @@ -336,7 +336,7 @@ GravitinoClient gravitinoClient = GravitinoClient
// Assume that you have a partitioned table named "metalake.catalog.schema.table".
String[] partitionNames =
gravitinoClient
.loadCatalog(NameIdentifier.of("metalake", "catalog"))
.loadCatalog("catalog")
.asTableCatalog()
.loadTable(NameIdentifier.of("metalake", "catalog", "schema", "table"))
.supportPartitions()
Expand Down Expand Up @@ -367,7 +367,7 @@ http://localhost:8090/api/metalakes/metalake/catalogs/catalog/schemas/schema/tab
// Assume that you have a partitioned table named "metalake.catalog.schema.table".
Partition[] partitions =
gravitinoClient
.loadCatalog(NameIdentifier.of("metalake", "catalog"))
.loadCatalog("catalog")
.asTableCatalog()
.loadTable(NameIdentifier.of("metalake", "catalog", "schema", "table"))
.supportPartitions()
Expand Down Expand Up @@ -407,7 +407,7 @@ GravitinoClient gravitinoClient = GravitinoClient
// Assume that you have a partitioned table named "metalake.catalog.schema.table".
Partition Partition =
gravitinoClient
.loadCatalog(NameIdentifier.of("metalake", "catalog"))
.loadCatalog("catalog")
.asTableCatalog()
.loadTable(NameIdentifier.of("metalake", "catalog", "schema", "table"))
.supportPartitions()
Expand Down

0 comments on commit 91c953b

Please sign in to comment.