use of org.projectnessie.model.Operation.Put in project nessie by projectnessie.
the class ITUpgradePath method commit.
@Test
@Order(103)
void commit() throws Exception {
ContentKey key = ContentKey.of("my", "tables", "table_name");
IcebergTable content = IcebergTable.of("metadata-location", 42L, 43, 44, 45, "content-id-" + version);
String commitMessage = "hello world " + version;
Put operation = Put.of(key, content);
Branch branchNew = commitMaybeRetry(api.commitMultipleOperations().commitMeta(CommitMeta.fromMessage(commitMessage)).operation(operation).branch(versionBranch));
assertThat(branchNew).isNotEqualTo(versionBranch).extracting(Branch::getName).isEqualTo(versionBranch.getName());
expectedRefLogEntry("COMMIT");
}
use of org.projectnessie.model.Operation.Put in project nessie by projectnessie.
the class NamespaceApiImpl method createNamespace.
@Override
public Namespace createNamespace(NamespaceParams params) throws NessieNamespaceAlreadyExistsException, NessieReferenceNotFoundException {
try {
BranchName branch = branchFromRefName(params.getRefName());
Callable<Void> validator = () -> {
if (getExplicitlyCreatedNamespace(params, branch).isPresent()) {
throw namespaceAlreadyExistsException(params);
}
if (getImplicitlyCreatedNamespace(params, branch).isPresent()) {
throw namespaceAlreadyExistsException(params);
}
return null;
};
Namespace namespace = params.getNamespace();
Put put = Put.of(ContentKey.of(namespace.getElements()), namespace);
commit(branch, "create namespace " + namespace.name(), TreeApiImpl.toOp(put), validator);
return namespace;
} catch (ReferenceNotFoundException | ReferenceConflictException e) {
throw new NessieReferenceNotFoundException(e.getMessage(), e);
}
}
use of org.projectnessie.model.Operation.Put in project nessie by projectnessie.
the class AbstractCompatibilityTests method commit.
@Test
void commit() throws Exception {
Branch defaultBranch = api.getDefaultBranch();
Branch branch = Branch.of("commitToBranch", defaultBranch.getHash());
Reference created = api.createReference().sourceRefName(defaultBranch.getName()).reference(branch).create();
assertThat(created).isEqualTo(branch);
ContentKey key = ContentKey.of("my", "tables", "table_name");
IcebergTable content = IcebergTable.of("metadata-location", 42L, 43, 44, 45, "content-id");
String commitMessage = "hello world";
Put operation = Put.of(key, content);
Branch branchNew = api.commitMultipleOperations().commitMeta(CommitMeta.fromMessage(commitMessage)).operation(operation).branch(branch).commit();
assertThat(branchNew).isNotEqualTo(branch).extracting(Branch::getName).isEqualTo(branch.getName());
LogResponse commitLog = api.getCommitLog().refName(branch.getName()).get();
assertThat(commitLog.getLogEntries()).hasSize(1).map(LogEntry::getCommitMeta).map(CommitMeta::getMessage).containsExactly(commitMessage);
}
use of org.projectnessie.model.Operation.Put in project nessie by projectnessie.
the class AbstractRestGC method fillExpectedContents.
void fillExpectedContents(Branch branch, int numCommits, IdentifiedResult expected) throws NessieNotFoundException {
fetchLogEntries(branch, numCommits).stream().map(LogEntry::getOperations).filter(Objects::nonNull).flatMap(Collection::stream).filter(op -> op instanceof Put).forEach(op -> {
Content content = ((Put) op).getContent();
expected.addContent(branch.getName(), content);
});
}
use of org.projectnessie.model.Operation.Put in project nessie by projectnessie.
the class ITUpgradePath method keysUpgradeAddCommits.
@Test
@Order(203)
void keysUpgradeAddCommits() throws Exception {
keysUpgradeBranch = (Branch) api.getReference().refName(keysUpgradeBranch.getName()).get();
Map<ContentKey, IcebergTable> currentKeyValues = keysUpgradeAtHash.getOrDefault(keysUpgradeBranch.getHash(), Collections.emptyMap());
for (int i = 0; i < keysUpgradeCommitsPerVersion; i++) {
ContentKey key = ContentKey.of("keys.upgrade.table" + i);
if ((i % 10) == 9) {
keysUpgradeBranch = commitMaybeRetry(api.commitMultipleOperations().branch(keysUpgradeBranch).commitMeta(CommitMeta.fromMessage("Commit #" + i + "/delete from Nessie version " + version)).operation(Delete.of(key)));
Map<ContentKey, IcebergTable> newKeyValues = new HashMap<>(currentKeyValues);
newKeyValues.remove(key);
keysUpgradeAtHash.put(keysUpgradeBranch.getHash(), newKeyValues);
}
Content currentContent = api.getContent().refName(keysUpgradeBranch.getName()).key(key).get().get(key);
String cid = currentContent == null ? "table-" + i + "-" + version : currentContent.getId();
IcebergTable newContent = IcebergTable.of("pointer-" + version + "-commit-" + i, keysUpgradeSequence++, i, i, i, cid);
Put put = currentContent != null ? Put.of(key, newContent, currentContent) : Put.of(key, newContent);
keysUpgradeBranch = commitMaybeRetry(api.commitMultipleOperations().branch(keysUpgradeBranch).commitMeta(CommitMeta.fromMessage("Commit #" + i + "/put from Nessie version " + version)).operation(put));
Map<ContentKey, IcebergTable> newKeyValues = new HashMap<>(currentKeyValues);
newKeyValues.remove(key);
keysUpgradeAtHash.put(keysUpgradeBranch.getHash(), newKeyValues);
}
}
Aggregations