Skip to content

Commit

Permalink
seperated rel namespaces from all namespaces, attempted to differenti…
Browse files Browse the repository at this point in the history
…ate btw. views and materialized views, first attempt at gathering indexes
  • Loading branch information
flurfis committed Nov 2, 2023
1 parent 57fb8e1 commit c19fd0e
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public BackupManager() {
im.addGroup( informationGroupOverview );

// start backup button
InformationText startBackup = new InformationText( informationGroupOverview, "Start the Backup." );
InformationText startBackup = new InformationText( informationGroupOverview, "Create the Backup." );
startBackup.setOrder( 1 );
im.registerInformation( startBackup );

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import org.polypheny.db.catalog.entity.LogicalConstraint;
import org.polypheny.db.catalog.entity.logical.*;
import org.polypheny.db.catalog.impl.PolyCatalog;
import org.polypheny.db.catalog.logistic.NamespaceType;
import org.polypheny.db.catalog.snapshot.Snapshot;
import org.polypheny.db.catalog.snapshot.impl.SnapshotBuilder;

Expand All @@ -53,8 +54,11 @@ public class GatherSchema {

//table id, list of views for the table
ImmutableMap<Long, List<LogicalView>> views;
ImmutableMap<Long, List<LogicalMaterializedView>> materializedViews;
ImmutableMap<Long, List<LogicalColumn>> columns;
ImmutableMap<Long, List<LogicalKey>> keysPerTable;
ImmutableMap<Long, List<LogicalIndex>> logicalIndexes;
// index -> can only be created per (one) table

public GatherSchema() {
}
Expand Down Expand Up @@ -90,15 +94,22 @@ private void getSnapshot() {
* Gets the tables, views, columns, keys, indexes, constraints and nodes from the snapshot
*/
private void getRelSchema() {
HashMap<Long, List<LogicalTable>> tables = new HashMap<>();
HashMap<Long, List<LogicalView>> views = new HashMap<>();
HashMap<Long, List<LogicalColumn>> columns = new HashMap<>();
HashMap<Long, List<LogicalConstraint>> constraints = new HashMap<>();
HashMap<Long, List<LogicalKey>> keysPerTable = new HashMap<>();
//TODO(FF): differentiate between views and materialized views (safe them seperately)
Map<Long, List<LogicalTable>> tables = new HashMap<>();
Map<Long, List<LogicalView>> views = new HashMap<>();
Map<Long, List<LogicalMaterializedView>> materializedViews = new HashMap<>();
Map<Long, List<LogicalColumn>> columns = new HashMap<>();
Map<Long, List<LogicalConstraint>> constraints = new HashMap<>();
Map<Long, List<LogicalKey>> keysPerTable = new HashMap<>();
Map<Long, List<LogicalIndex>> logicalIndex1 = new HashMap<>();
Map<Long, List<LogicalIndex>> logicalIndex2 = new HashMap<>();
//List<LogicalView> getConnectedViews( long id );

List<LogicalNamespace> relNamespaces = namespaces.stream().filter( n -> n.namespaceType == NamespaceType.RELATIONAL ).collect( Collectors.toList() );

// go through the list of namespaces and get the id of each namespace, map the tables to the namespace id
for (LogicalNamespace namespace : namespaces) {
//TODO(FF)?: views - list is just empty, but creates it nontheless, same for constraints, keys
for (LogicalNamespace namespace : relNamespaces) {
Long namespaceId = namespace.getId();

// get tables from namespace
Expand All @@ -115,7 +126,14 @@ private void getRelSchema() {

//views
List<LogicalView> connectedViews = snapshot.rel().getConnectedViews( tableId );
views.put( tableId, connectedViews );
//TODO(FF): see if this actually works... (does it seperate correctly?) (views not handles yet correctly in snapshot)
//get all materialized views from the list of views and materialized views
List<LogicalMaterializedView> connMatView = connectedViews.stream().filter( v -> v instanceof LogicalMaterializedView ).map( v -> (LogicalMaterializedView) v ).collect( Collectors.toList() );
//get all views from the list of views and materialized views
List<LogicalView> connView = connectedViews.stream().filter( v -> v instanceof LogicalView ).map( v -> v ).collect( Collectors.toList() );
//safes the views and materialized views in the maps
views.put( tableId, connView );
materializedViews.put( tableId, connMatView );

//cols
List<LogicalColumn> tableColumns = snapshot.rel().getColumns( tableId );
Expand All @@ -126,6 +144,19 @@ private void getRelSchema() {
List<LogicalKey> tableKeys = snapshot.rel().getTableKeys( tableId );
keysPerTable.put( tableId, tableKeys );

//indexes
//TODO(FF): indexes are also safed as keys... (they are part of the keys list...) maybe i have to safe keys seperately as pks and fks... but am i missing keys? LogicalGenericKey, was cha das alles sii??
// keyToIndexes = snapshot.rel().getKeys().stream().collect( Collectors.toMap( k -> k, k -> snapshot.rel().getIndexes( k ) ) );
//keyToIndexes maps keyid to idx... (to know which key is an idx). Do i have to remove them from the key list? - see when building it to insert back? (for loop over all keys?) how do i get keyToIndexes map? havent figured out yet
List<LogicalIndex> tableIndexes = snapshot.rel().getIndexes();
logicalIndex1.put( tableId, tableIndexes );

// Get the keyToIndexes map from the snapshot. maybe with the following?
//TODO(FF): still need to test it, since intellij again didnt recognize map and list...
List<LogicalIndex> logicalIdx = snapshot.rel().getIndexes( tableId, false );
logicalIndex2.put( tableId, logicalIdx );


}

}
Expand All @@ -145,6 +176,7 @@ private void getRelSchema() {
*/
private void getGraphSchema() {


}

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/*
* Copyright 2019-2023 The Polypheny Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.polypheny.db.backup.datainserter;

public class EnterSchema {
}

0 comments on commit c19fd0e

Please sign in to comment.