use of org.projectnessie.model.CommitMeta in project iceberg by apache.
the class NessieUtilTest method testAuthorIsNullWithoutJvmUser.
@Test
public void testAuthorIsNullWithoutJvmUser() {
String jvmUserName = System.getProperty("user.name");
try {
System.clearProperty("user.name");
CommitMeta commitMeta = NessieUtil.buildCommitMetadata("commit msg", ImmutableMap.of());
Assertions.assertThat(commitMeta.getAuthor()).isNull();
} finally {
System.setProperty("user.name", jvmUserName);
}
}
use of org.projectnessie.model.CommitMeta in project nessie by projectnessie.
the class PersistVersionStoreExtension method afterBeanDiscovery.
@SuppressWarnings("unused")
public void afterBeanDiscovery(@Observes AfterBeanDiscovery abd, BeanManager bm) {
TableCommitMetaStoreWorker storeWorker = new TableCommitMetaStoreWorker();
abd.addBean().addType(new TypeLiteral<VersionStore<Content, CommitMeta, Type>>() {
}).addQualifier(Default.Literal.INSTANCE).scope(ApplicationScoped.class).produceWith(i -> new PersistVersionStore<>(databaseAdapter.get(), storeWorker));
}
use of org.projectnessie.model.CommitMeta in project nessie by projectnessie.
the class AbstractSparkSqlTest method commitAndReturnLog.
private List<Object[]> commitAndReturnLog(String branch) throws NessieConflictException, NessieNotFoundException {
assertThat(sql("CREATE BRANCH %s IN nessie", branch)).containsExactly(row("Branch", branch, hash));
ContentKey key = ContentKey.of("table", "name");
CommitMeta cm1 = ImmutableCommitMeta.builder().author("sue").authorTime(Instant.ofEpochMilli(1)).message("1").putProperties("test", "123").build();
CommitMeta cm2 = ImmutableCommitMeta.builder().author("janet").authorTime(Instant.ofEpochMilli(10)).message("2").putProperties("test", "123").build();
CommitMeta cm3 = ImmutableCommitMeta.builder().author("alice").authorTime(Instant.ofEpochMilli(100)).message("3").putProperties("test", "123").build();
Operations ops = ImmutableOperations.builder().addOperations(Operation.Put.of(key, IcebergTable.of("foo", 42, 42, 42, 42))).commitMeta(cm1).build();
Operations ops2 = ImmutableOperations.builder().addOperations(Operation.Put.of(key, IcebergTable.of("bar", 42, 42, 42, 42))).commitMeta(cm2).build();
Operations ops3 = ImmutableOperations.builder().addOperations(Operation.Put.of(key, IcebergTable.of("baz", 42, 42, 42, 42))).commitMeta(cm3).build();
Branch ref1 = api.commitMultipleOperations().branchName(branch).hash(hash).operations(ops.getOperations()).commitMeta(ops.getCommitMeta()).commit();
Branch ref2 = api.commitMultipleOperations().branchName(branch).hash(ref1.getHash()).operations(ops2.getOperations()).commitMeta(ops2.getCommitMeta()).commit();
Branch ref3 = api.commitMultipleOperations().branchName(branch).hash(ref2.getHash()).operations(ops3.getOperations()).commitMeta(ops3.getCommitMeta()).commit();
List<Object[]> resultList = new ArrayList<>();
resultList.add(cmToRow(cm3, ref3.getHash()));
resultList.add(cmToRow(cm2, ref2.getHash()));
resultList.add(cmToRow(cm1, ref1.getHash()));
return resultList;
}
use of org.projectnessie.model.CommitMeta in project nessie by projectnessie.
the class TreeApiImpl method filterReferences.
/**
* Applies different filters to the {@link Stream} of references on the filter.
*
* @param references The references that different filters will be applied to
* @param filter The filter to filter by
* @return A potentially filtered {@link Stream} of commits based on the filter
*/
private Stream<Reference> filterReferences(Stream<Reference> references, String filter) {
if (Strings.isNullOrEmpty(filter)) {
return references;
}
final Script script;
try {
script = SCRIPT_HOST.buildScript(filter).withContainer(CONTAINER).withDeclarations(REFERENCES_DECLARATIONS).withTypes(REFERENCES_TYPES).build();
} catch (ScriptException e) {
throw new IllegalArgumentException(e);
}
return references.filter(reference -> {
try {
ReferenceMetadata refMeta = reference.getMetadata();
if (refMeta == null) {
refMeta = CELUtil.EMPTY_REFERENCE_METADATA;
}
CommitMeta commit = refMeta.getCommitMetaOfHEAD();
if (commit == null) {
commit = CELUtil.EMPTY_COMMIT_META;
}
return script.execute(Boolean.class, ImmutableMap.of(VAR_REF, reference, VAR_REF_TYPE, reference.getType().name(), VAR_COMMIT, commit, VAR_REF_META, refMeta));
} catch (ScriptException e) {
throw new RuntimeException(e);
}
});
}
use of org.projectnessie.model.CommitMeta in project nessie by projectnessie.
the class TreeApiImpl method assignReference.
protected void assignReference(NamedRef ref, String oldHash, Reference assignTo) throws NessieNotFoundException, NessieConflictException {
try {
ReferenceInfo<CommitMeta> resolved = getStore().getNamedRef(ref.getName(), GetNamedRefsParams.DEFAULT);
getStore().assign(resolved.getNamedRef(), toHash(oldHash, true), toHash(assignTo.getName(), assignTo.getHash()));
} catch (ReferenceNotFoundException e) {
throw new NessieReferenceNotFoundException(e.getMessage(), e);
} catch (ReferenceConflictException e) {
throw new NessieReferenceConflictException(e.getMessage(), e);
}
}
Aggregations