Skip to content

Commit

Permalink
[recode] addParition.
Browse files Browse the repository at this point in the history
  • Loading branch information
askwang committed Jun 5, 2024
1 parent 1845ae4 commit e9ec743
Showing 1 changed file with 35 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
package org.apache.paimon.flink;

import com.google.common.cache.Cache;
import com.google.common.cache.CacheBuilder;
import org.apache.paimon.data.BinaryRow;
import org.apache.paimon.fs.Path;
import org.junit.jupiter.api.Test;

import java.time.Duration;
import java.util.concurrent.Callable;
import java.util.concurrent.TimeUnit;
import java.util.function.BinaryOperator;

public class AskwangJavaITCase {
Expand All @@ -29,4 +35,33 @@ public void testPathGetName() {
String pos = path1.getName().substring(SNAPSHOT_PREFIX.length());
System.out.println(pos);
}

@Test
public void testAddCommitPartitionCache() {
Cache<BinaryRow, Boolean> cache = CacheBuilder.newBuilder()
.expireAfterAccess(30, TimeUnit.MINUTES)
.maximumSize(300)
.softValues()
.build();

// askwang-todo: partition transform to BinaryRow
// paimon-0.9: AddPartitionCommitCallback#addPartition. cache的使用
BinaryRow partition = null;
try {
Boolean added = cache.get(partition, new Callable<Boolean>() {
@Override
public Boolean call() throws Exception {
return false;
}
});
if (added) {
// return
}
// client.addPartition(partition);
cache.put(partition, true);
} catch (Exception e) {
throw new RuntimeException(e);
}
}

}

0 comments on commit e9ec743

Please sign in to comment.