Skip to content

Commit

Permalink
added executor pool for concurrently setting the poly algebra, and ad…
Browse files Browse the repository at this point in the history
…ded handling for concurrent delays for testing
  • Loading branch information
datomo committed Dec 10, 2024
1 parent 710e639 commit 2be6caa
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
import com.fasterxml.jackson.databind.node.ObjectNode;
import com.google.common.collect.ImmutableList;
import java.util.List;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import lombok.extern.slf4j.Slf4j;
import org.polypheny.db.algebra.AlgNode;
import org.polypheny.db.algebra.AlgRoot;
Expand Down Expand Up @@ -50,6 +52,8 @@
@Slf4j
public class UiRoutingPageUtil {

private static final ExecutorService executorService = Executors.newFixedThreadPool( 10 );


public static void outputSingleResult( Plan plan, InformationManager queryAnalyzer, long stmtIdx, boolean attachTextualPlan ) {
addPhysicalPlanPage( plan.optimalNode(), queryAnalyzer, stmtIdx, attachTextualPlan );
Expand All @@ -65,7 +69,7 @@ public static void outputSingleResult( Plan plan, InformationManager queryAnalyz


public static void addPhysicalPlanPage( AlgNode optimalNode, InformationManager queryAnalyzer, long stmtIdx, boolean attachTextualPlan ) {
new Thread( () -> addRoutedPolyPlanPage( optimalNode, queryAnalyzer, stmtIdx, true, attachTextualPlan ) ).start();
executorService.submit( () -> addRoutedPolyPlanPage( optimalNode, queryAnalyzer, stmtIdx, true, attachTextualPlan ) );
}


Expand Down
33 changes: 21 additions & 12 deletions dbms/src/test/java/org/polypheny/db/polyalg/PolyAlgParsingTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@
import org.polypheny.db.algebra.polyalg.parser.nodes.PolyAlgNode;
import org.polypheny.db.algebra.type.AlgDataTypeFactory;
import org.polypheny.db.catalog.Catalog;
import org.polypheny.db.catalog.exceptions.GenericRuntimeException;
import org.polypheny.db.catalog.logistic.DataModel;
import org.polypheny.db.catalog.snapshot.Snapshot;
import org.polypheny.db.cypher.CypherTestTemplate;
Expand Down Expand Up @@ -85,7 +84,6 @@ public class PolyAlgParsingTest {

@BeforeAll
public static void start() throws SQLException {
//noinspection ResultOfMethodCallIgnored
testHelper = TestHelper.getInstance();
addTestData();

Expand Down Expand Up @@ -187,21 +185,33 @@ private static void testQueryRoundTrip( String query, QueryLanguage ql, String n
String result = getResultAsString( executedContexts, ql.dataModel() );

String logical = null, allocation = null, physical = null;
for ( Information info : transaction.getQueryAnalyzer().getInformationArray() ) {
if ( info instanceof InformationPolyAlg polyInfo ) {
switch ( PlanType.valueOf( polyInfo.planType ) ) {
case LOGICAL -> logical = polyInfo.getTextualPolyAlg();
case ALLOCATION -> allocation = polyInfo.getTextualPolyAlg();
case PHYSICAL -> physical = polyInfo.getTextualPolyAlg();

int tries = 3;
try {
// plans are serialized in a separate thread, which might take some time
for ( int i = 0; i < tries; i++ ) {
for ( Information info : transaction.getQueryAnalyzer().getInformationArray() ) {
if ( info instanceof InformationPolyAlg polyInfo ) {
switch ( PlanType.valueOf( polyInfo.planType ) ) {
case LOGICAL -> logical = polyInfo.getTextualPolyAlg();
case ALLOCATION -> allocation = polyInfo.getTextualPolyAlg();
case PHYSICAL -> physical = polyInfo.getTextualPolyAlg();
}
}
}
if ( logical != null && allocation != null && physical != null ) {
break;
}
Thread.sleep( 500 );
}
}
try {

assertNotNull( logical );
assertNotNull( allocation );
assertNotNull( physical ); // Physical is not yet tested further since it is only partially implemented

}finally {
} catch ( InterruptedException e ) {
throw new RuntimeException( e );
} finally {
transaction.commit(); // execute PolyAlg creates new transaction, as long as only DQLs are tested like this
}
if ( transactionManager.getNumberOfActiveTransactions() > 0 ) {
Expand All @@ -215,7 +225,6 @@ private static void testQueryRoundTrip( String query, QueryLanguage ql, String n
String resultFromAllocation = executePolyAlg( allocation, PlanType.ALLOCATION, ql );
assertEquals( result, resultFromAllocation, "Result from query does not match result when executing the allocation plan." );


}


Expand Down

0 comments on commit 2be6caa

Please sign in to comment.