Skip to content

Commit

Permalink
Revert "remove reflection"
Browse files Browse the repository at this point in the history
This reverts commit a849f4f.
  • Loading branch information
bryanck committed Oct 21, 2023
1 parent 0bc4134 commit b4d413d
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 18 deletions.
8 changes: 4 additions & 4 deletions core/src/main/java/org/apache/iceberg/GenericDataFile.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@
import org.apache.iceberg.relocated.com.google.common.collect.ImmutableMap;
import org.apache.iceberg.types.Types;

public class GenericDataFile extends BaseFile<DataFile> implements DataFile {
class GenericDataFile extends BaseFile<DataFile> implements DataFile {
/** Used by Avro reflection to instantiate this class when reading manifest files. */
public GenericDataFile(Schema avroSchema) {
GenericDataFile(Schema avroSchema) {
super(avroSchema);
}

public GenericDataFile(
GenericDataFile(
int specId,
String filePath,
FileFormat format,
Expand Down Expand Up @@ -73,7 +73,7 @@ private GenericDataFile(GenericDataFile toCopy, boolean fullCopy) {
}

/** Constructor for Java serialization. */
public GenericDataFile() {}
GenericDataFile() {}

@Override
public DataFile copyWithoutStats() {
Expand Down
8 changes: 4 additions & 4 deletions core/src/main/java/org/apache/iceberg/GenericDeleteFile.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@
import org.apache.iceberg.relocated.com.google.common.collect.ImmutableMap;
import org.apache.iceberg.types.Types;

public class GenericDeleteFile extends BaseFile<DeleteFile> implements DeleteFile {
class GenericDeleteFile extends BaseFile<DeleteFile> implements DeleteFile {
/** Used by Avro reflection to instantiate this class when reading manifest files. */
public GenericDeleteFile(Schema avroSchema) {
GenericDeleteFile(Schema avroSchema) {
super(avroSchema);
}

public GenericDeleteFile(
GenericDeleteFile(
int specId,
FileContent content,
String filePath,
Expand Down Expand Up @@ -74,7 +74,7 @@ private GenericDeleteFile(GenericDeleteFile toCopy, boolean fullCopy) {
}

/** Constructor for Java serialization. */
public GenericDeleteFile() {}
GenericDeleteFile() {}

@Override
public DeleteFile copyWithoutStats() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@
import org.apache.avro.SchemaBuilder;
import org.apache.iceberg.DataFile;
import org.apache.iceberg.DeleteFile;
import org.apache.iceberg.GenericDataFile;
import org.apache.iceberg.GenericDeleteFile;
import org.apache.iceberg.PartitionData;
import org.apache.iceberg.avro.AvroSchemaUtil;
import org.apache.iceberg.relocated.com.google.common.collect.ImmutableMap;
Expand Down Expand Up @@ -60,15 +58,19 @@ public CommitResponsePayload(
AvroSchemaUtil.convert(
dataFileStruct,
ImmutableMap.of(
dataFileStruct, GenericDataFile.class.getName(),
partitionType, PartitionData.class.getName()));
dataFileStruct,
"org.apache.iceberg.GenericDataFile",
partitionType,
PartitionData.class.getName()));

Schema deleteFileSchema =
AvroSchemaUtil.convert(
dataFileStruct,
ImmutableMap.of(
dataFileStruct, GenericDeleteFile.class.getName(),
partitionType, PartitionData.class.getName()));
dataFileStruct,
"org.apache.iceberg.GenericDeleteFile",
partitionType,
PartitionData.class.getName()));

this.avroSchema =
SchemaBuilder.builder()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,37 @@

import java.nio.ByteBuffer;
import java.util.Collections;
import java.util.List;
import org.apache.iceberg.DataFile;
import org.apache.iceberg.DeleteFile;
import org.apache.iceberg.FileContent;
import org.apache.iceberg.FileFormat;
import org.apache.iceberg.GenericDataFile;
import org.apache.iceberg.GenericDeleteFile;
import org.apache.iceberg.Metrics;
import org.apache.iceberg.PartitionData;
import org.apache.iceberg.common.DynConstructors;
import org.apache.iceberg.common.DynConstructors.Ctor;
import org.apache.iceberg.types.Types.NestedField;
import org.apache.iceberg.types.Types.StringType;
import org.apache.iceberg.types.Types.StructType;

public class EventTestUtil {
public static DataFile createDataFile() {
Ctor<DataFile> ctor =
DynConstructors.builder(DataFile.class)
.hiddenImpl(
"org.apache.iceberg.GenericDataFile",
int.class,
String.class,
FileFormat.class,
PartitionData.class,
long.class,
Metrics.class,
ByteBuffer.class,
List.class,
int[].class,
Integer.class)
.build();

PartitionData partitionData =
new PartitionData(StructType.of(NestedField.required(999, "type", StringType.get())));
Metrics metrics =
Expand All @@ -44,7 +61,7 @@ public static DataFile createDataFile() {
Collections.emptyMap(),
Collections.emptyMap());

return new GenericDataFile(
return ctor.newInstance(
1,
"path",
FileFormat.PARQUET,
Expand All @@ -58,6 +75,23 @@ public static DataFile createDataFile() {
}

public static DeleteFile createDeleteFile() {
Ctor<DeleteFile> ctor =
DynConstructors.builder(DeleteFile.class)
.hiddenImpl(
"org.apache.iceberg.GenericDeleteFile",
int.class,
FileContent.class,
String.class,
FileFormat.class,
PartitionData.class,
long.class,
Metrics.class,
int[].class,
Integer.class,
List.class,
ByteBuffer.class)
.build();

PartitionData partitionData =
new PartitionData(StructType.of(NestedField.required(999, "type", StringType.get())));
Metrics metrics =
Expand All @@ -68,7 +102,7 @@ public static DeleteFile createDeleteFile() {
Collections.emptyMap(),
Collections.emptyMap());

return new GenericDeleteFile(
return ctor.newInstance(
1,
FileContent.EQUALITY_DELETES,
"path",
Expand Down

0 comments on commit b4d413d

Please sign in to comment.