Skip to content

Commit

Permalink
some debugging, some process solutions...
Browse files Browse the repository at this point in the history
  • Loading branch information
flurfis committed Nov 15, 2023
1 parent 0ed22cb commit 8cba602
Show file tree
Hide file tree
Showing 4 changed files with 238 additions and 52 deletions.
2 changes: 1 addition & 1 deletion dbms/src/main/java/org/polypheny/db/PolyphenyDb.java
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,7 @@ public void join( final long millis ) throws InterruptedException {
Catalog catalog = startCatalog();

// Start backup management
BackupManager backupManager = BackupManager.setAndGetInstance( new BackupManager() );
BackupManager backupManager = BackupManager.setAndGetInstance( new BackupManager( transactionManager ) );

// Initialize interface manager
QueryInterfaceManager.initialize( transactionManager, authenticator );
Expand Down
9 changes: 7 additions & 2 deletions dbms/src/main/java/org/polypheny/db/backup/BackupManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import org.polypheny.db.backup.datainserter.InsertSchema;
import org.polypheny.db.catalog.exceptions.GenericRuntimeException;
import org.polypheny.db.information.*;
import org.polypheny.db.transaction.TransactionManager;


@Slf4j
Expand All @@ -32,10 +33,13 @@ public class BackupManager {
private InformationPage informationPage;
private InformationGroup informationGroupOverview;
private BupInformationObject bupInformationObject;
public static TransactionManager transactionManager = null;
//private final Logger logger;


public BackupManager() {
public BackupManager( TransactionManager transactionManager ) {
this.transactionManager = transactionManager;

informationPage = new InformationPage( "Backup Tasks" );
informationPage.fullWidth();
informationGroupOverview = new InformationGroup( informationPage, "Overview" );
Expand Down Expand Up @@ -96,9 +100,10 @@ public void startDataGathering() {


private void startInserting() {
InsertSchema insertSchema = new InsertSchema();
InsertSchema insertSchema = new InsertSchema(transactionManager);

insertSchema.start(bupInformationObject);
log.info( "inserting done" );
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
package org.polypheny.db.backup;

import com.google.common.collect.ImmutableMap;
import io.activej.serializer.annotations.Deserialize;
import io.activej.serializer.annotations.Serialize;
import lombok.Getter;
import lombok.Setter;
import org.polypheny.db.catalog.entity.LogicalConstraint;
Expand Down Expand Up @@ -44,14 +46,16 @@ public class BupInformationObject {
ImmutableMap<Long, BupSuperEntity<LogicalNamespace>> bupGraphNamespaces;
@Getter @Setter
ImmutableMap<Long, BupSuperEntity<LogicalNamespace>> bupDocNamespaces;
@Getter @Setter
ImmutableMap<Long, BupSuperEntity<LogicalNamespace>> bupNamespaces;

/*//TODO(FF): adjust (also to gather schema...there it is per table right now)
@Getter @Setter
List<LogicalView> views;
@Getter @Setter
List<LogicalMaterializedView> materializedViews;
*/

//TODO(FF): make it private(all)
//namespace id, list of entities for the namespace
@Getter @Setter
ImmutableMap<Long, List<LogicalView>> views;
Expand Down Expand Up @@ -117,9 +121,10 @@ public ImmutableMap<Long, BupSuperEntity<LogicalNamespace>> transformNamespacesT

ImmutableMap<Long, BupSuperEntity<LogicalNamespace>> resultMap;
Map<Long, BupSuperEntity<LogicalNamespace>> tempNS = new HashMap<>();
BupSuperEntity<LogicalNamespace> nsBupObj = new BupSuperEntity<>();


for (LogicalNamespace ns : namespaces ) {
BupSuperEntity<LogicalNamespace> nsBupObj = new BupSuperEntity<>();
nsBupObj.setEntityObject( ns );
nsBupObj.setNameForQuery( ns.name );
tempNS.put( ns.id, nsBupObj );
Expand All @@ -133,14 +138,14 @@ public ImmutableMap<Long, List<BupSuperEntity<LogicalEntity>>> transformLogicalE

ImmutableMap<Long, List<BupSuperEntity<LogicalEntity>>> resultMap;
Map<Long, List<BupSuperEntity<LogicalEntity>>> tempMap = new HashMap<>();
BupSuperEntity<LogicalEntity> tempBupEntity = new BupSuperEntity<>();

//go through each element from entityMap, and for each list go through each element and transform it to a BupSuperEntity
for ( Map.Entry<Long, List<LogicalEntity>> entry : entityMap.entrySet() ) {
List<LogicalEntity> entityList = entry.getValue();
List<BupSuperEntity<LogicalEntity>> bupEntityList = new ArrayList<>();

for ( LogicalEntity entity : entityList ) {
BupSuperEntity<LogicalEntity> tempBupEntity = new BupSuperEntity<>();
tempBupEntity.setEntityObject( entity );
tempBupEntity.setToBeInserted( toBeInserted );
tempBupEntity.setNameForQuery( entity.name );
Expand All @@ -158,14 +163,14 @@ public ImmutableMap<Long, List<BupSuperEntity<LogicalEntity>>> transformLogicalE

ImmutableMap<Long, List<BupSuperEntity<LogicalEntity>>> resultMap;
Map<Long, List<BupSuperEntity<LogicalEntity>>> tempMap = new HashMap<>();
BupSuperEntity<LogicalEntity> tempBupEntity = new BupSuperEntity<>();

//go through each element from entityMap, and for each list go through each element and transform it to a BupSuperEntity
for ( Map.Entry<Long, List<LogicalEntity>> entry : entityMap.entrySet() ) {
List<LogicalEntity> entityList = entry.getValue();
List<BupSuperEntity<LogicalEntity>> bupEntityList = new ArrayList<>();

for ( LogicalEntity entity : entityList ) {
BupSuperEntity<LogicalEntity> tempBupEntity = new BupSuperEntity<>();
tempBupEntity.setEntityObject( entity );
tempBupEntity.setToBeInserted( true );
tempBupEntity.setNameForQuery( entity.name );
Expand All @@ -179,4 +184,53 @@ public ImmutableMap<Long, List<BupSuperEntity<LogicalEntity>>> transformLogicalE
return resultMap;
}

public ImmutableMap<Long, List<BupSuperEntity<LogicalTable>>> tempTableTransformation( ImmutableMap<Long, List<LogicalTable>> entityMap, Boolean toBeInserted) {

ImmutableMap<Long, List<BupSuperEntity<LogicalTable>>> resultMap;
Map<Long, List<BupSuperEntity<LogicalTable>>> tempMap = new HashMap<>();

//go through each element from entityMap, and for each list go through each element and transform it to a BupSuperEntity
for ( Map.Entry<Long, List<LogicalTable>> entry : entityMap.entrySet() ) {
List<LogicalTable> entityList = entry.getValue();
List<BupSuperEntity<LogicalTable>> bupEntityList = new ArrayList<>();

for ( LogicalTable entity : entityList ) {
BupSuperEntity<LogicalTable> tempBupEntity = new BupSuperEntity<>();
tempBupEntity.setEntityObject( entity );
tempBupEntity.setToBeInserted( toBeInserted );
tempBupEntity.setNameForQuery( entity.name );
bupEntityList.add( tempBupEntity );
}
tempMap.put( entry.getKey(), bupEntityList );

}

resultMap = ImmutableMap.copyOf( tempMap );
return resultMap;
}

public void transformationManager () {
//ImmutableMap<Long, List<LogicalEntity>> entityMap = getTables();
//transformLogicalEntitiesToBupSuperEntity( getTables(), true );
//TODO: testen ob es mit ganzem angabekladatch funktioniert (past me, what?)
}

public List<BupSuperEntity<LogicalEntity>> transformLogigalEntityToSuperEntity( List<LogicalEntity> entityList) {


//go through each element from entityMap, and for each list go through each element and transform it to a BupSuperEntity
List<BupSuperEntity<LogicalEntity>> bupEntityList = new ArrayList<>();

for ( LogicalEntity entity : entityList ) {
BupSuperEntity<LogicalEntity> tempBupEntity = new BupSuperEntity<>();
tempBupEntity.setEntityObject( entity );
tempBupEntity.setToBeInserted( true );
tempBupEntity.setNameForQuery( entity.name );
bupEntityList.add( tempBupEntity );
}

return bupEntityList;

}

}
Loading

0 comments on commit 8cba602

Please sign in to comment.