use of org.projectnessie.model.Reference in project nessie by projectnessie.
the class IdentifyContentsPerExecutor method handleCommitForExpiredContents.
private static void handleCommitForExpiredContents(Reference reference, LogResponse.LogEntry logEntry, Map<String, ContentBloomFilter> liveContentsBloomFilterMap, IdentifiedResult result) {
if (logEntry.getOperations() != null) {
logEntry.getOperations().stream().filter(operation -> operation instanceof Operation.Put).forEach(operation -> {
Content content = ((Operation.Put) operation).getContent();
ContentBloomFilter bloomFilter = liveContentsBloomFilterMap.get(content.getId());
// But live contents never be considered as expired.
if (bloomFilter == null || !bloomFilter.mightContain(content)) {
result.addContent(reference.getName(), content);
}
});
}
}
use of org.projectnessie.model.Reference in project nessie by projectnessie.
the class IdentifyContentsPerExecutor method computeLiveContents.
private Map<String, ContentBloomFilter> computeLiveContents(Instant cutOffTimestamp, String reference, Instant droppedRefTime, long bloomFilterSize) {
try (NessieApiV1 api = GCUtil.getApi(gcParams.getNessieClientConfigs())) {
boolean isRefDroppedAfterCutoffTimeStamp = droppedRefTime == null || droppedRefTime.compareTo(cutOffTimestamp) >= 0;
if (!isRefDroppedAfterCutoffTimeStamp) {
// All the contents for all the keys are expired.
return new HashMap<>();
}
Predicate<CommitMeta> liveCommitPredicate = commitMeta -> commitMeta.getCommitTime().compareTo(cutOffTimestamp) >= 0;
ImmutableGCStateParamsPerTask gcStateParamsPerTask = ImmutableGCStateParamsPerTask.builder().api(api).reference(GCUtil.deserializeReference(reference)).liveCommitPredicate(liveCommitPredicate).bloomFilterSize(bloomFilterSize).build();
return walkLiveCommitsInReference(gcStateParamsPerTask);
}
}
use of org.projectnessie.model.Reference in project nessie by projectnessie.
the class ITUpgradePath method commitLog.
@Test
@Order(104)
void commitLog() {
assertThat(api.getAllReferences().get().getReferences().stream().filter(r -> r.getName().startsWith(VERSION_BRANCH_PREFIX))).isNotEmpty().allSatisfy(ref -> {
String versionFromRef = ref.getName().substring(VERSION_BRANCH_PREFIX.length());
LogResponse commitLog = api.getCommitLog().refName(ref.getName()).get();
String commitMessage = "hello world " + versionFromRef;
assertThat(commitLog.getLogEntries()).hasSize(1).map(LogEntry::getCommitMeta).map(CommitMeta::getMessage).containsExactly(commitMessage);
}).allSatisfy(ref -> {
String versionFromRef = ref.getName().substring(VERSION_BRANCH_PREFIX.length());
ContentKey key = ContentKey.of("my", "tables", "table_name");
IcebergTable content = IcebergTable.of("metadata-location", 42L, 43, 44, 45, "content-id-" + versionFromRef);
Map<ContentKey, Content> contents = api.getContent().reference(ref).key(key).get();
assertThat(contents).containsExactly(entry(key, content));
});
}
use of org.projectnessie.model.Reference in project nessie by projectnessie.
the class AbstractSparkSqlTest method removeBranches.
@AfterEach
void removeBranches() throws NessieConflictException, NessieNotFoundException {
for (Reference ref : api.getAllReferences().get().getReferences()) {
if (ref instanceof Branch) {
api.deleteBranch().branchName(ref.getName()).hash(ref.getHash()).delete();
}
if (ref instanceof Tag) {
api.deleteTag().tagName(ref.getName()).hash(ref.getHash()).delete();
}
}
api.createReference().reference(Branch.of("main", null)).create();
api.close();
api = null;
}
use of org.projectnessie.model.Reference in project nessie by projectnessie.
the class AbstractSparkSqlTest method testAssignTag.
@Test
void testAssignTag() throws NessieConflictException, NessieNotFoundException {
String random = "randomTag";
assertThat(sql("CREATE TAG %s IN nessie", random)).containsExactly(row("Tag", random, hash));
commitAndReturnLog(refName);
sql("USE REFERENCE %s IN nessie", refName);
sql("MERGE BRANCH %s INTO main IN nessie", refName);
Reference main = api.getReference().refName("main").get();
assertThat(sql("ASSIGN TAG %s IN nessie", random)).containsExactly(row("Tag", random, main.getHash()));
}
Aggregations