diff --git a/dbms/src/main/java/org/polypheny/db/backup/BackupManager.java b/dbms/src/main/java/org/polypheny/db/backup/BackupManager.java index bbb2169764..66a790af45 100644 --- a/dbms/src/main/java/org/polypheny/db/backup/BackupManager.java +++ b/dbms/src/main/java/org/polypheny/db/backup/BackupManager.java @@ -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 ); diff --git a/dbms/src/main/java/org/polypheny/db/backup/datagatherer/GatherSchema.java b/dbms/src/main/java/org/polypheny/db/backup/datagatherer/GatherSchema.java index 895941c478..6f0f4d9dc3 100644 --- a/dbms/src/main/java/org/polypheny/db/backup/datagatherer/GatherSchema.java +++ b/dbms/src/main/java/org/polypheny/db/backup/datagatherer/GatherSchema.java @@ -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; @@ -53,8 +54,11 @@ public class GatherSchema { //table id, list of views for the table ImmutableMap> views; + ImmutableMap> materializedViews; ImmutableMap> columns; ImmutableMap> keysPerTable; + ImmutableMap> logicalIndexes; + // index -> can only be created per (one) table public GatherSchema() { } @@ -90,15 +94,22 @@ private void getSnapshot() { * Gets the tables, views, columns, keys, indexes, constraints and nodes from the snapshot */ private void getRelSchema() { - HashMap> tables = new HashMap<>(); - HashMap> views = new HashMap<>(); - HashMap> columns = new HashMap<>(); - HashMap> constraints = new HashMap<>(); - HashMap> keysPerTable = new HashMap<>(); + //TODO(FF): differentiate between views and materialized views (safe them seperately) + Map> tables = new HashMap<>(); + Map> views = new HashMap<>(); + Map> materializedViews = new HashMap<>(); + Map> columns = new HashMap<>(); + Map> constraints = new HashMap<>(); + Map> keysPerTable = new HashMap<>(); + Map> logicalIndex1 = new HashMap<>(); + Map> logicalIndex2 = new HashMap<>(); //List getConnectedViews( long id ); + List 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 @@ -115,7 +126,14 @@ private void getRelSchema() { //views List 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 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 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 tableColumns = snapshot.rel().getColumns( tableId ); @@ -126,6 +144,19 @@ private void getRelSchema() { List 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 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 logicalIdx = snapshot.rel().getIndexes( tableId, false ); + logicalIndex2.put( tableId, logicalIdx ); + + } } @@ -145,6 +176,7 @@ private void getRelSchema() { */ private void getGraphSchema() { + } /** diff --git a/dbms/src/main/java/org/polypheny/db/backup/datainserter/EnterSchema.java b/dbms/src/main/java/org/polypheny/db/backup/datainserter/EnterSchema.java new file mode 100644 index 0000000000..9390ed95dd --- /dev/null +++ b/dbms/src/main/java/org/polypheny/db/backup/datainserter/EnterSchema.java @@ -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 { +}