@Test public void testJsonWithPreviousMetadataLog() throws Exception { long previousSnapshotId = System.currentTimeMillis() - new Random(1234).nextInt(3600); Snapshot previousSnapshot = new BaseSnapshot( ops.io(), previousSnapshotId, null, previousSnapshotId, null, null, ImmutableList.of( new GenericManifestFile(localInput("file:/tmp/manfiest.1.avro"), SPEC_5.specId()))); long currentSnapshotId = System.currentTimeMillis(); Snapshot currentSnapshot = new BaseSnapshot( ops.io(), currentSnapshotId, previousSnapshotId, currentSnapshotId, null, null, ImmutableList.of( new GenericManifestFile(localInput("file:/tmp/manfiest.2.avro"), SPEC_5.specId()))); List<HistoryEntry> reversedSnapshotLog = Lists.newArrayList(); long currentTimestamp = System.currentTimeMillis(); List<MetadataLogEntry> previousMetadataLog = Lists.newArrayList(); previousMetadataLog.add(new MetadataLogEntry(currentTimestamp, "/tmp/000001-" + UUID.randomUUID().toString() + ".metadata.json")); TableMetadata base = new TableMetadata(null, 1, UUID.randomUUID().toString(), TEST_LOCATION, 0, System.currentTimeMillis(), 3, TEST_SCHEMA, 5, ImmutableList.of(SPEC_5), ImmutableMap.of("property", "value"), currentSnapshotId, Arrays.asList(previousSnapshot, currentSnapshot), reversedSnapshotLog, ImmutableList.copyOf(previousMetadataLog)); String asJson = TableMetadataParser.toJson(base); TableMetadata metadataFromJson = TableMetadataParser.fromJson(ops.io(), null, JsonUtil.mapper().readValue(asJson, JsonNode.class)); Assert.assertEquals("Metadata logs should match", previousMetadataLog, metadataFromJson.previousFiles()); }
public List<MetadataLogEntry> previousFiles() { return previousFiles; }
TableMetadata implements Serializable { public List<MetadataLogEntry> previousFiles() { return previousFiles; } }
TableMetadata implements Serializable { public List<MetadataLogEntry> previousFiles() { return previousFiles; } TableMetadata(InputFile file,
                int formatVersion,
                String uuid,
                String location,
                long lastSequenceNumber,
                long lastUpdatedMillis,
                int lastColumnId,
                Schema schema,
                int defaultSpecId,
                List<PartitionSpec> specs,
                Map<String, String> properties,
                long currentSnapshotId,
                List<Snapshot> snapshots,
                List<HistoryEntry> snapshotLog,
                List<MetadataLogEntry> previousFiles); }
TableMetadata implements Serializable { public List<MetadataLogEntry> previousFiles() { return previousFiles; } TableMetadata(InputFile file,
                int formatVersion,
                String uuid,
                String location,
                long lastSequenceNumber,
                long lastUpdatedMillis,
                int lastColumnId,
                Schema schema,
                int defaultSpecId,
                List<PartitionSpec> specs,
                Map<String, String> properties,
                long currentSnapshotId,
                List<Snapshot> snapshots,
                List<HistoryEntry> snapshotLog,
                List<MetadataLogEntry> previousFiles); @Deprecated static TableMetadata newTableMetadata(TableOperations ops,
                                               Schema schema,
                                               PartitionSpec spec,
                                               String location,
                                               Map<String, String> properties); static TableMetadata newTableMetadata(Schema schema,
                                               PartitionSpec spec,
                                               String location,
                                               Map<String, String> properties); int formatVersion(); String metadataFileLocation(); String uuid(); long lastSequenceNumber(); long nextSequenceNumber(); long lastUpdatedMillis(); int lastColumnId(); Schema schema(); PartitionSpec spec(); PartitionSpec spec(int id); List<PartitionSpec> specs(); Map<Integer, PartitionSpec> specsById(); int defaultSpecId(); String location(); Map<String, String> properties(); String property(String property, String defaultValue); boolean propertyAsBoolean(String property, boolean defaultValue); int propertyAsInt(String property, int defaultValue); long propertyAsLong(String property, long defaultValue); Snapshot snapshot(long snapshotId); Snapshot currentSnapshot(); List<Snapshot> snapshots(); List<HistoryEntry> snapshotLog(); List<MetadataLogEntry> previousFiles(); TableMetadata withUUID(); TableMetadata updateSchema(Schema newSchema, int newLastColumnId); TableMetadata updatePartitionSpec(PartitionSpec newPartitionSpec); TableMetadata addStagedSnapshot(Snapshot snapshot); TableMetadata replaceCurrentSnapshot(Snapshot snapshot); TableMetadata removeSnapshotsIf(Predicate<Snapshot> removeIf); TableMetadata replaceProperties(Map<String, String> newProperties); TableMetadata removeSnapshotLogEntries(Set<Long> snapshotIds); TableMetadata buildReplacement(Schema updatedSchema, PartitionSpec updatedPartitionSpec,
                                        String newLocation, Map<String, String> updatedProperties); TableMetadata updateLocation(String newLocation); TableMetadata upgradeToFormatVersion(int newFormatVersion); }
TableMetadata implements Serializable { public List<MetadataLogEntry> previousFiles() { return previousFiles; } TableMetadata(InputFile file,
                int formatVersion,
                String uuid,
                String location,
                long lastSequenceNumber,
                long lastUpdatedMillis,
                int lastColumnId,
                Schema schema,
                int defaultSpecId,
                List<PartitionSpec> specs,
                Map<String, String> properties,
                long currentSnapshotId,
                List<Snapshot> snapshots,
                List<HistoryEntry> snapshotLog,
                List<MetadataLogEntry> previousFiles); @Deprecated static TableMetadata newTableMetadata(TableOperations ops,
                                               Schema schema,
                                               PartitionSpec spec,
                                               String location,
                                               Map<String, String> properties); static TableMetadata newTableMetadata(Schema schema,
                                               PartitionSpec spec,
                                               String location,
                                               Map<String, String> properties); int formatVersion(); String metadataFileLocation(); String uuid(); long lastSequenceNumber(); long nextSequenceNumber(); long lastUpdatedMillis(); int lastColumnId(); Schema schema(); PartitionSpec spec(); PartitionSpec spec(int id); List<PartitionSpec> specs(); Map<Integer, PartitionSpec> specsById(); int defaultSpecId(); String location(); Map<String, String> properties(); String property(String property, String defaultValue); boolean propertyAsBoolean(String property, boolean defaultValue); int propertyAsInt(String property, int defaultValue); long propertyAsLong(String property, long defaultValue); Snapshot snapshot(long snapshotId); Snapshot currentSnapshot(); List<Snapshot> snapshots(); List<HistoryEntry> snapshotLog(); List<MetadataLogEntry> previousFiles(); TableMetadata withUUID(); TableMetadata updateSchema(Schema newSchema, int newLastColumnId); TableMetadata updatePartitionSpec(PartitionSpec newPartitionSpec); TableMetadata addStagedSnapshot(Snapshot snapshot); TableMetadata replaceCurrentSnapshot(Snapshot snapshot); TableMetadata removeSnapshotsIf(Predicate<Snapshot> removeIf); TableMetadata replaceProperties(Map<String, String> newProperties); TableMetadata removeSnapshotLogEntries(Set<Long> snapshotIds); TableMetadata buildReplacement(Schema updatedSchema, PartitionSpec updatedPartitionSpec,
                                        String newLocation, Map<String, String> updatedProperties); TableMetadata updateLocation(String newLocation); TableMetadata upgradeToFormatVersion(int newFormatVersion);  }