use of org.projectnessie.versioned.WithHash in project nessie by projectnessie.
the class ContentApiImpl method getMultipleContents.
@Override
public GetMultipleContentsResponse getMultipleContents(String namedRef, String hashOnRef, GetMultipleContentsRequest request) throws NessieNotFoundException {
try {
WithHash<NamedRef> ref = namedRefWithHashOrThrow(namedRef, hashOnRef);
List<ContentKey> externalKeys = request.getRequestedKeys();
List<Key> internalKeys = externalKeys.stream().map(ContentApiImpl::toKey).collect(Collectors.toList());
Map<Key, Content> values = getStore().getValues(ref.getHash(), internalKeys);
List<ContentWithKey> output = values.entrySet().stream().map(e -> ContentWithKey.of(toContentKey(e.getKey()), e.getValue())).collect(Collectors.toList());
return ImmutableGetMultipleContentsResponse.builder().contents(output).build();
} catch (ReferenceNotFoundException ex) {
throw new NessieReferenceNotFoundException(ex.getMessage(), ex);
}
}
use of org.projectnessie.versioned.WithHash in project nessie by projectnessie.
the class TreeApiImpl method getEntries.
@Override
public EntriesResponse getEntries(String namedRef, EntriesParams params) throws NessieNotFoundException {
Preconditions.checkArgument(params.pageToken() == null, "Paging not supported");
WithHash<NamedRef> refWithHash = namedRefWithHashOrThrow(namedRef, params.hashOnRef());
// all existing VersionStore implementations have to read all keys anyways so we don't get much
try {
List<EntriesResponse.Entry> entries;
try (Stream<EntriesResponse.Entry> entryStream = getStore().getKeys(refWithHash.getHash()).map(key -> EntriesResponse.Entry.builder().name(fromKey(key.getValue())).type((Type) key.getType()).build())) {
Stream<EntriesResponse.Entry> entriesStream = filterEntries(entryStream, params.filter());
if (params.namespaceDepth() != null && params.namespaceDepth() > 0) {
entriesStream = entriesStream.filter(e -> e.getName().getElements().size() >= params.namespaceDepth()).map(e -> truncate(e, params.namespaceDepth())).distinct();
}
entries = entriesStream.collect(ImmutableList.toImmutableList());
}
return EntriesResponse.builder().addAllEntries(entries).build();
} catch (ReferenceNotFoundException e) {
throw new NessieReferenceNotFoundException(e.getMessage(), e);
}
}
Aggregations