Skip to content

Commit

Permalink
fixed no results for all tests and graph visuals in ui
Browse files Browse the repository at this point in the history
  • Loading branch information
datomo authored and danylokravchenko committed Dec 11, 2023
1 parent 5649a83 commit 2be35a0
Show file tree
Hide file tree
Showing 16 changed files with 110 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ private void registerStatusRoutes( Javalin webuiServer ) {

webuiServer.get( PREFIX_KEY + "/transactions-active", this::getActiveTransactions );

webuiServer.get( PREFIX_KEY + "/transactions-total", this::getTransactionCount );
webuiServer.get( PREFIX_KEY + "/transactions-since-restart", this::getTransactionRestart );

webuiServer.get( PREFIX_KEY + "/cache-implementation", this::getImplementationCacheSize );

Expand All @@ -84,7 +84,7 @@ private void registerStatusRoutes( Javalin webuiServer ) {
}


private void getTransactionCount( Context context ) {
private void getTransactionRestart( Context context ) {
context.result( String.valueOf( transactionManager.getNumberOfTotalTransactions() ) );
}

Expand Down
9 changes: 5 additions & 4 deletions plugins/cypher-language/src/main/codegen/CypherParser.jj
Original file line number Diff line number Diff line change
Expand Up @@ -1758,14 +1758,15 @@ CypherClause MatchClause() :
Token t;
Token whereToken = null;
boolean optional = false;
List<CypherPattern> patterns;
List<CypherHint> hints;
List<CypherPattern> patterns = List.of();
boolean fullScan = false;
List<CypherHint> hints = List.of();
CypherWhere where = null;
}
{
( optionalT=<OPTIONAL> { optional = true; } )? t=<MATCH> patterns=PatternList() hints=Hints() ( where=WhereClause() )?
( optionalT=<OPTIONAL> { optional = true; } )? t=<MATCH> ("(*)" {fullScan = true;} | patterns=PatternList() hints=Hints()) ( where=WhereClause() )?
{
return CypherFactory.createMatch( pos( optionalT != null ? optionalT : t ), optional, patterns, pos( t.next ), hints, where );
return CypherFactory.createMatch( pos( optionalT != null ? optionalT : t ), optional, patterns, pos( t.next ), hints, where, fullScan );
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,10 @@ static CypherClause createDelete( ParserPos pos, boolean detach, List<CypherExpr
return new CypherDelete( pos, detach, list );
}

static CypherClause createMatch( ParserPos pos, boolean optional, List<CypherPattern> patterns, ParserPos pos1, List<CypherHint> hints, CypherWhere where ) {
static CypherClause createMatch( ParserPos pos, boolean optional, List<CypherPattern> patterns, ParserPos pos1, List<CypherHint> hints, CypherWhere where, boolean fullScan ) {
if ( fullScan ) {
return new CypherFull( pos );
}
return new CypherMatch( pos, optional, patterns, pos1, hints, where, false );
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/*
* 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.cypher;

import org.polypheny.db.cypher.clause.CypherClause;
import org.polypheny.db.languages.ParserPos;

public class CypherFull extends CypherClause {

public CypherFull( ParserPos pos ) {
super( pos );
}


@Override
public boolean isFullScan() {
return true;
}


@Override
public CypherKind getCypherKind() {
return CypherKind.FULL;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,11 @@ public Kind getKind() {
public abstract CypherKind getCypherKind();


public boolean isFullScan() {
return false;
}


@Override
public Node clone( ParserPos pos ) {
return null;
Expand Down Expand Up @@ -161,6 +166,7 @@ public enum CypherKind {
REL_PATTERN,
SHORTEST_PATTERN,
LITERAL,
FULL,
SET_ITEM
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ public AlgRoot convert( CypherNode query, ParsedQueryContext parsedContext, AlgO

LogicalEntity entity = getEntity( namespaceId );

if ( parsedContext.getQuery().trim().equals( "*" ) ) {
if ( query.isFullScan() ) {
// simple full graph scan
return AlgRoot.of( buildFullScan( (LogicalGraph) entity ), Kind.SELECT );
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,12 @@ public CypherSingleQuery( ParserPos pos, List<CypherClause> clauses ) {
}


@Override
public boolean isFullScan() {
return clauses.stream().anyMatch( CypherNode::isFullScan );
}


public CypherSingleQuery( List<CypherClause> clauses ) {
this( ParserPos.ZERO, clauses );
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@
import org.polypheny.db.type.PolyType;
import org.polypheny.db.type.entity.PolyValue;
import org.polypheny.db.type.entity.graph.PolyGraph;
import org.polypheny.db.type.entity.relational.PolyMap;
import org.polypheny.db.util.PolyMode;
import org.polypheny.db.webui.Crud;
import org.polypheny.db.webui.TemporalFileManager;
Expand Down Expand Up @@ -181,7 +182,6 @@ public static void commitAndFinish( List<ExecutedContext> executedContexts, Info
}
}


if ( queryAnalyzer != null ) {
Crud.attachQueryAnalyzer( queryAnalyzer, executionTime, commitStatus, results.size() );
}
Expand All @@ -205,13 +205,18 @@ public static PolyGraph getGraph( String namespace, TransactionManager manager,
Transaction transaction = Crud.getTransaction( false, false, manager, Catalog.defaultUserId, Catalog.defaultNamespaceId, "getGraph" );
ImplementationContext context = LanguageManager.getINSTANCE().anyPrepareQuery(
QueryContext.builder()
.query( "MATCH (*) RETURN n" )
.query( "MATCH (*) RETURN *" )
.language( language )
.origin( transaction.getOrigin() )
.namespaceId( getNamespaceIdOrDefault( namespace ) )
.transactionManager( manager )
.informationTarget( i -> i.setSession( session ) )
.build(), transaction.createStatement() ).get( 0 );

if ( context.getException().isPresent() ) {
return new PolyGraph( PolyMap.of( new HashMap<>() ), PolyMap.of( new HashMap<>() ) );
}

ResultIterator iterator = context.execute( transaction.createStatement() ).getIterator();
List<List<PolyValue>> res = iterator.getNextBatch();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,13 @@
package org.polypheny.db.webui.models.requests;


import lombok.experimental.SuperBuilder;
import lombok.extern.jackson.Jacksonized;
import org.polypheny.db.webui.models.UIAlgNode;


@Jacksonized
@SuperBuilder
public class AlgRequest extends UIRequest {

public UIAlgNode topNode;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,12 @@
package org.polypheny.db.webui.models.requests;


import lombok.experimental.SuperBuilder;
import lombok.extern.jackson.Jacksonized;
import org.polypheny.db.webui.models.catalog.UiColumnDefinition;


@SuperBuilder
@Jacksonized
public class ColumnRequest extends UIRequest {

public UiColumnDefinition oldColumn;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,12 @@
package org.polypheny.db.webui.models.requests;


import lombok.experimental.SuperBuilder;
import lombok.extern.jackson.Jacksonized;
import org.polypheny.db.webui.models.catalog.UiColumnDefinition;


@Jacksonized
@SuperBuilder
public class ExploreTables extends UIRequest{

public Integer id;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,15 @@
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Value;
import lombok.experimental.SuperBuilder;
import lombok.extern.jackson.Jacksonized;


@EqualsAndHashCode(callSuper = true)
@Getter
@Value
@Jacksonized
@SuperBuilder
public class GraphRequest extends QueryRequest {

public List<String> nodeIds;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,11 @@

package org.polypheny.db.webui.models.requests;

import lombok.experimental.SuperBuilder;
import lombok.extern.jackson.Jacksonized;

@SuperBuilder
@Jacksonized
public class QueryExplorationRequest extends UIRequest {

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,11 @@
import com.fasterxml.jackson.annotation.JsonAlias;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.experimental.SuperBuilder;
import lombok.extern.jackson.Jacksonized;

@Jacksonized
@SuperBuilder
public class QueryRequest extends UIRequest {


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,12 @@


import java.util.List;
import lombok.experimental.SuperBuilder;
import lombok.extern.jackson.Jacksonized;
import org.polypheny.db.catalog.logistic.DataModel;

@Jacksonized
@SuperBuilder
public class SchemaTreeRequest extends UIRequest {

public String routerLinkRoot;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,57 +17,68 @@
package org.polypheny.db.webui.models.requests;


import com.fasterxml.jackson.annotation.JsonProperty;
import java.util.Map;
import lombok.Builder;
import lombok.experimental.SuperBuilder;
import lombok.extern.jackson.Jacksonized;
import org.polypheny.db.webui.models.SortState;


/**
* Required to parse a request coming from the UI using Gson
*/
@SuperBuilder(toBuilder = true)
@Jacksonized
public class UIRequest extends RequestModel {


/**
* The name of the table the data should be fetched from
*/
@JsonProperty
public Long entityId;


@JsonProperty
public String namespace;

/**
* Information about the pagination,
* what current page should be loaded
*/
@Builder.Default
@JsonProperty
public int currentPage = 1;

/**
* Data that should be inserted
*/
@JsonProperty
public Map<String, String> data;

/**
* For each column: If it should be filtered empty string if it should not be filtered
*/
@JsonProperty
public Map<String, String> filter;

/**
* For each column: If and how it should be sorted
*/
@JsonProperty
public Map<String, SortState> sortState;

/**
* Request to fetch a result without a limit. Default false.
*/
@JsonProperty
public boolean noLimit;

/**
* The time interval of the diagram should be fetched from.
*/
@JsonProperty
public String selectInterval;


Expand Down

0 comments on commit 2be35a0

Please sign in to comment.