Davis-Zhang-Onehouse commented on code in PR #13489:
URL: https://github.com/apache/hudi/pull/13489#discussion_r2180619107
##########
hudi-common/src/main/java/org/apache/hudi/common/table/HoodieTableMetaClient.java:
##########
@@ -270,13 +263,49 @@ public boolean buildIndexDefinition(HoodieIndexDefinition
indexDefinition) {
public void deleteIndexDefinition(String indexName) {
checkState(indexMetadataOpt.isPresent(), "Index metadata is not present");
indexMetadataOpt.get().getIndexDefinitions().remove(indexName);
+ writeIndexMetadataToStorage();
+ }
+
+ /**
+ * Writes the current index metadata to storage.
+ */
+ public void writeIndexMetadataToStorage() {
+ if (!indexMetadataOpt.isPresent()) {
+ return;
+ }
+ writeIndexMetadataToStorage(indexMetadataOpt.get());
+ }
+
+ /**
+ * Writes the provided index metadata to storage.
+ *
+ * @param indexMetadata the index metadata to write
+ */
+ public void writeIndexMetadataToStorage(HoodieIndexMetadata indexMetadata) {
String indexMetaPath = getIndexDefinitionPath();
try {
// TODO[HUDI-9094]: should not write byte array directly
FileIOUtils.createFileInPath(storage, new StoragePath(indexMetaPath),
-
Option.of(HoodieInstantWriter.convertByteArrayToWriter(getUTF8Bytes(indexMetadataOpt.get().toJson()))));
- } catch (IOException e) {
- throw new HoodieIOException("Could not write expression index metadata
at path: " + indexMetaPath, e);
+
Option.of(HoodieInstantWriter.convertByteArrayToWriter(getUTF8Bytes(indexMetadata.toJson()))));
+ } catch (IOException e) {
+ throw new HoodieIOException("Could not write index metadata at path: " +
indexMetaPath, e);
+ }
+ }
+
+ /**
+ * Static method to write index metadata to storage.
+ *
+ * @param storage the storage to write to
+ * @param indexDefinitionPath the path where the index metadata should be
written
+ * @param indexMetadata the index metadata to write
+ */
+ public static void writeIndexMetadataToStorage(HoodieStorage storage, String
indexDefinitionPath, HoodieIndexMetadata indexMetadata) {
+ try {
Review Comment:
covered in upgrade/downgrade UT already
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]