Skip to content

Commit

Permalink
Allow retrieval of all entities in a snapshot
Browse files Browse the repository at this point in the history
  • Loading branch information
Tobias Hafner committed Jan 19, 2025
1 parent b9feffc commit 08431ee
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -177,4 +177,6 @@ default List<? extends Operator> getOperatorList() {
@NotNull
Optional<LogicalEntity> getLogicalEntity( long namespaceId, String entity );

@NotNull
List<LogicalEntity> getLogicalEntities(long namespaceId);
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
package org.polypheny.db.catalog.snapshot.impl;

import com.google.common.collect.ImmutableMap;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Optional;
Expand Down Expand Up @@ -212,6 +214,22 @@ public Optional<AdapterTemplate> getAdapterTemplate( long templateId ) {
return graph.getGraph( id );
}

@Override
public @NotNull List<LogicalEntity> getLogicalEntities(long namespaceId) {
List<LogicalTable> tables = rel.getTables(namespaceId, null);
if (!tables.isEmpty()) {
return new ArrayList<>(tables);
}

List<LogicalCollection> collections = doc.getCollections(namespaceId, null);
if (!collections.isEmpty()) {
return new ArrayList<>(collections);
}

Optional<LogicalGraph> optionalGraph = graph.getGraph( namespaceId );
return optionalGraph.<List<LogicalEntity>>map( List::of ).orElseGet( List::of );
}


@Override
public @NotNull Optional<AdapterTemplate> getAdapterTemplate( String name, AdapterType adapterType ) {
Expand Down

0 comments on commit 08431ee

Please sign in to comment.