Skip to content

Commit

Permalink
checkpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
cdouglas committed Dec 10, 2024
1 parent ebfef93 commit 67a540b
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 1 deletion.
18 changes: 18 additions & 0 deletions core/src/main/java/org/apache/iceberg/TableMetadataParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import java.util.Map;
import java.util.zip.GZIPInputStream;
import java.util.zip.GZIPOutputStream;
import org.apache.commons.io.IOUtils;
import org.apache.iceberg.TableMetadata.MetadataLogEntry;
import org.apache.iceberg.TableMetadata.SnapshotLogEntry;
import org.apache.iceberg.exceptions.RuntimeIOException;
Expand Down Expand Up @@ -134,6 +135,23 @@ public static void internalWrite(
}
}

public static void internalWrite(TableMetadata metadata, OutputStream out, boolean close) {
OutputStreamWriter writer = null;
try {
writer = new OutputStreamWriter(out);
JsonGenerator generator = JsonUtil.factory().createGenerator(writer);
generator.useDefaultPrettyPrinter();
toJson(metadata, generator);
generator.flush();
} catch (IOException e) {
throw new RuntimeIOException(e, "Failed to write json to stream");
} finally {
if (close) {
IOUtils.closeQuietly(writer);
}
}
}

public static String getFileExtension(String codecName) {
return getFileExtension(Codec.fromName(codecName));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,7 @@ public void commitTransaction(List<TableCommit> commits) {
if (newMetadata.changes().isEmpty()) {
continue;
}
// !#! HERE
final String newLocation = ops.writeUpdateMetadata(false, newMetadata);
newCatalog.updateTable(tableId, newLocation);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

import static org.assertj.core.api.Assertions.assertThat;

import java.io.ByteArrayOutputStream;
import java.io.OutputStream;
import java.util.Collections;
import java.util.Map;
Expand Down Expand Up @@ -61,5 +62,7 @@ public void testCatalogNamespace() {
}

@Test
public void testSerDe() {}
public void testSerDe() {
ByteArrayOutputStream bos = new ByteArrayOutputStream();
}
}

0 comments on commit 67a540b

Please sign in to comment.