Skip to content

Commit 4b2adb0

Browse files
wippp
1 parent ea5547c commit 4b2adb0

37 files changed

+882
-146
lines changed

server/app/src/main/java/io/whitefox/api/deltasharing/DeltaMappers.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55
import io.whitefox.core.*;
66
import io.whitefox.core.Schema;
77
import io.whitefox.core.Share;
8+
import io.whitefox.core.delta.Metadata;
9+
import io.whitefox.core.delta.Protocol;
10+
import io.whitefox.core.results.ReadTableResult;
811
import io.whitefox.core.services.DeltaSharingCapabilities;
912
import java.util.*;
1013
import java.util.stream.Collectors;

server/app/src/main/java/io/whitefox/api/server/WhitefoxMappers.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@
1414
import io.whitefox.core.actions.*;
1515
import io.whitefox.core.actions.CreateMetastore;
1616
import io.whitefox.core.actions.CreateStorage;
17+
import io.whitefox.core.delta.Metadata;
18+
import io.whitefox.core.delta.Protocol;
19+
1720
import java.util.ArrayList;
1821
import java.util.Optional;
1922
import java.util.function.Function;

server/core/build.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ plugins {
22
`java-library`
33
`java-test-fixtures`
44
id("whitefox.java-conventions")
5+
id("io.freefair.lombok") version "8.4"
56
}
67

78
val quarkusPlatformGroupId: String by project

server/core/src/main/java/io/whitefox/core/ReadTableResult.java

Lines changed: 0 additions & 55 deletions
This file was deleted.

server/core/src/main/java/io/whitefox/core/ReadTableResultToBeSigned.java

Lines changed: 0 additions & 56 deletions
This file was deleted.

server/core/src/main/java/io/whitefox/core/TableFileToBeSigned.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,7 @@ public class TableFileToBeSigned {
99

1010
private final String url;
1111
private final long size;
12-
1312
private final long version;
14-
1513
private final Optional<Long> timestamp;
1614

1715
private final String stats;

server/core/src/main/java/io/whitefox/core/Metadata.java renamed to server/core/src/main/java/io/whitefox/core/delta/Metadata.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,9 @@
1-
package io.whitefox.core;
1+
package io.whitefox.core.delta;
22

33
import io.whitefox.annotations.SkipCoverageGenerated;
4-
import io.whitefox.core.services.DeltaSharingCapabilities;
54
import io.whitefox.core.types.StructType;
6-
import shadedelta.org.apache.parquet.hadoop.metadata.ParquetMetadata;
75

86
import java.util.*;
9-
import java.util.stream.Collectors;
107

118
public abstract class Metadata {
129
Metadata() {

server/core/src/main/java/io/whitefox/core/Protocol.java renamed to server/core/src/main/java/io/whitefox/core/delta/Protocol.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
package io.whitefox.core;
1+
package io.whitefox.core.delta;
22

33
import io.whitefox.annotations.SkipCoverageGenerated;
44
import io.whitefox.core.services.DeltaSharingCapabilities;
55

6+
import java.util.Map;
67
import java.util.Objects;
78
import java.util.Set;
89

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
package io.whitefox.core.delta;
2+
3+
import lombok.AllArgsConstructor;
4+
import lombok.Builder;
5+
import lombok.Data;
6+
import lombok.RequiredArgsConstructor;
7+
8+
import java.util.List;
9+
import java.util.Set;
10+
11+
@Data
12+
@Builder(toBuilder = true)
13+
@AllArgsConstructor
14+
@RequiredArgsConstructor
15+
public class Stats {
16+
private final long numRecords;
17+
private final Set<ColumnStat<Double>> minValues = Set.of();
18+
private final Set<ColumnStat<Double>> maxValues = Set.of();
19+
private final Set<ColumnStat<Long>> nullCount = Set.of();
20+
@Data
21+
public static class ColumnStat<T> {
22+
private final List<String> columnPath;
23+
private final T value;
24+
}
25+
}
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
package io.whitefox.core.delta.signed;
2+
3+
import io.whitefox.core.delta.unsigned.DeltaFileToBeSigned;
4+
import lombok.AllArgsConstructor;
5+
import lombok.Builder;
6+
import lombok.Data;
7+
import lombok.RequiredArgsConstructor;
8+
9+
import java.util.Optional;
10+
11+
@Data
12+
@Builder(toBuilder = true)
13+
@AllArgsConstructor
14+
public class DeltaFile implements DeltaFileAction {
15+
16+
/**
17+
* A unique string for the file in a table. The same file is guaranteed to have the same id across multiple requests. A client may cache the file content and use this id as a key to decide whether to use the cached file content.
18+
*/
19+
private final String id;
20+
21+
/**
22+
* A unique string for the deletion vector file in a table. The same deletion vector file is guaranteed to have the same id across multiple requests. A client may cache the file content and use this id as a key to decide whether to use the cached file content.
23+
*/
24+
private final Optional<String> deletionVectorFileId;
25+
26+
/**
27+
* The table version of the file, returned when querying a table data with a version or timestamp parameter.
28+
*/
29+
private final Optional<Long> version;
30+
31+
/**
32+
* The unix timestamp corresponding to the table version of the file, in milliseconds, returned when querying a table data with a version or timestamp parameter.
33+
*/
34+
private final Optional<Long> timestamp;
35+
36+
/**
37+
* The unix timestamp corresponding to the expiration of the url, in milliseconds, returned when the server supports the feature.
38+
*/
39+
private final Optional<Long> expirationTimestamp;
40+
41+
/**
42+
* Need to be parsed by a delta library as a delta single action, the path field is replaced by pr-signed url.
43+
*/
44+
private final ParquetFileAction deltaSingleAction;
45+
46+
public static DeltaFile signed(DeltaFileToBeSigned tbs,
47+
ParquetFileAction signed,
48+
Optional<Long> newExpirationTimestamp,
49+
String newId) {
50+
return new DeltaFile(
51+
newId,
52+
tbs.getDeletionVectorFileId(),
53+
tbs.getVersion(),
54+
tbs.getTimestamp(),
55+
newExpirationTimestamp,
56+
signed
57+
);
58+
}
59+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
package io.whitefox.core.delta.signed;
2+
3+
public interface DeltaFileAction extends FileAction {
4+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
package io.whitefox.core.delta.signed;
2+
3+
public interface FileAction {
4+
}
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
package io.whitefox.core.delta.signed;
2+
3+
import io.whitefox.core.delta.Stats;
4+
import io.whitefox.core.delta.unsigned.ParquetAddFileToBeSigned;
5+
import io.whitefox.core.delta.unsigned.ParquetCDFFileToBeSigned;
6+
import lombok.AllArgsConstructor;
7+
import lombok.Builder;
8+
import lombok.Data;
9+
import lombok.RequiredArgsConstructor;
10+
11+
import java.net.URI;
12+
import java.util.Map;
13+
import java.util.Optional;
14+
15+
@Data
16+
@AllArgsConstructor
17+
@RequiredArgsConstructor
18+
@Builder(toBuilder = true)
19+
public class ParquetAddFile implements ParquetFileAction {
20+
/**
21+
* An https url that a client can use to read the file directly. The same file in different responses may have different urls
22+
*/
23+
private final String url;
24+
/**
25+
* A unique string for the file in a table. The same file is guaranteed to have the same id across multiple requests. A client may cache the file content and use this id as a key to decide whether to use the cached file content.
26+
*/
27+
private final String id;
28+
/**
29+
* A map from partition column to value for this file. When the table doesn’t have partition columns, this will be an empty map.
30+
*/
31+
private final Map<String, String> partitionValues;
32+
/**
33+
* The size of this file in bytes.
34+
*/
35+
private final long size;
36+
/**
37+
* The timestamp of the file in milliseconds from epoch.
38+
*/
39+
private final long timestamp;
40+
/**
41+
* The table version of this file
42+
*/
43+
private final int version;
44+
/**
45+
* Contains statistics (e.g., count, min/max values for columns) about the data in this file. This field may be missing. A file may or may not have stats. A client can decide whether to use stats or drop it.
46+
*/
47+
private final Optional<Stats> stats;
48+
/**
49+
* The unix timestamp corresponding to the expiration of the url, in milliseconds, returned when the server supports the feature.
50+
*/
51+
private final Optional<Long> expirationTimestamp;
52+
53+
@Override
54+
public Optional<Long> getExpTs() {
55+
return expirationTimestamp;
56+
}
57+
58+
public static ParquetAddFile signed(
59+
ParquetAddFileToBeSigned f,
60+
URI signedUrl,
61+
Optional<Long> expirationTimestamp,
62+
String newId
63+
) {
64+
return new ParquetAddFile(
65+
signedUrl.toASCIIString(),
66+
newId,
67+
f.getPartitionValues(),
68+
f.getSize(),
69+
f.getTimestamp(),
70+
f.getVersion(),
71+
f.getStats(),
72+
expirationTimestamp);
73+
}
74+
}

0 commit comments

Comments
 (0)