Skip to content

Commit

Permalink
adjusted doc result
Browse files Browse the repository at this point in the history
  • Loading branch information
datomo committed Sep 10, 2023
1 parent d79f94b commit 7c9cdf1
Show file tree
Hide file tree
Showing 7 changed files with 44 additions and 72 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -142,11 +142,11 @@ static <T> Bindable<T> getBindable( ClassDeclaration expr, String s, int fieldCo
/**
* Converts a bindable over scalar values into an array bindable, with each row as an array of 1 element.
*/
public static ArrayBindable box( final Bindable<?> bindable ) {
public static ArrayBindable<PolyValue> box( final Bindable<?> bindable ) {
if ( bindable instanceof ArrayBindable ) {
return (ArrayBindable) bindable;
return (ArrayBindable<PolyValue>) bindable;
}
return new ArrayBindable() {
return new ArrayBindable<>() {
@Override
public Class<PolyValue[]> getElementType() {
return PolyValue[].class;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,9 @@ private static AlgNode handleDocumentEntity( AlgOptRuleCall call, Scan<?> scan,

private AlgNode handleRelationalEntity( AlgOptRuleCall call, Scan<?> scan, AllocationEntity alloc ) {
AlgNode alg = AdapterManager.getInstance().getAdapter( alloc.adapterId ).getRelScan( alloc.id, call.builder() );
alg = attachReorder( alg, scan, call.builder() );
if ( scan.getModel() == scan.entity.namespaceType ) {
alg = attachReorder( alg, scan, call.builder() );
}

if ( scan.getModel() != scan.entity.namespaceType ) {
// cross-model queries need a transformer first, we let another rule handle that
Expand Down
29 changes: 1 addition & 28 deletions core/src/main/java/org/polypheny/db/languages/QueryLanguage.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,6 @@

package org.polypheny.db.languages;

import com.google.gson.TypeAdapter;
import com.google.gson.stream.JsonReader;
import com.google.gson.stream.JsonWriter;
import java.io.IOException;
import java.util.List;
import java.util.Locale;
import java.util.Objects;
Expand All @@ -32,19 +28,14 @@
import org.polypheny.db.prepare.Context;
import org.polypheny.db.processing.Processor;

@Getter
public class QueryLanguage {

@Getter
private final NamespaceType namespaceType;
@Getter
private final String serializedName;
@Getter
private final ParserFactory factory;
@Getter
private final Supplier<Processor> processorSupplier;
@Getter
private final BiFunction<Context, Snapshot, Validator> validatorSupplier;
@Getter
private final List<String> otherNames;


Expand Down Expand Up @@ -74,22 +65,4 @@ public static boolean containsLanguage( String name ) {
return LanguageManager.getLanguages().stream().anyMatch( l -> Objects.equals( l.serializedName, normalized ) );
}


public static TypeAdapter<QueryLanguage> getSerializer() {

return new TypeAdapter<>() {

@Override
public void write( JsonWriter out, QueryLanguage value ) throws IOException {
out.value( value.serializedName );
}


@Override
public QueryLanguage read( JsonReader in ) throws IOException {
return QueryLanguage.from( in.nextString() );
}
};
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public class RelationalExploreResult extends RelationalResult {
builder.header( rel.header );
builder.currentPage( rel.currentPage );
builder.highestPage( rel.highestPage );
builder.hasMoreRows( rel.hasMoreRows );
builder.hasMoreRows( rel.hasMore );
builder.table( rel.table );
builder.tables( rel.tables );
builder.request( rel.request );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,7 @@ private static DocResult getDocResult( Statement statement, QueryRequest request
}

return DocResult.builder()
.header( implementation.rowType.getFieldList().stream().map( FieldDefinition::of ).toArray( FieldDefinition[]::new ) )
.data( data.stream().map( LanguageCrud::toJson ).toArray( String[]::new ) )
.query( query )
.xid( transaction.getXid().toString() )
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,7 @@

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.JsonSerializer;
import com.fasterxml.jackson.databind.SerializerProvider;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.google.gson.Gson;
import java.io.IOException;
import lombok.EqualsAndHashCode;
import lombok.Value;
import lombok.experimental.NonFinal;
Expand All @@ -44,14 +39,6 @@
@NonFinal
public class RelationalResult extends Result<String[], UiColumnDefinition> {

/**
* Information for the pagination: what current page is being displayed
*/
public int currentPage;
/**
* Information for the pagination: how many pages there can be in total
*/
public int highestPage;
/**
* Table from which the data has been fetched
*/
Expand All @@ -74,17 +61,6 @@ public class RelationalResult extends Result<String[], UiColumnDefinition> {
*/
public ResultType type;

/**
* language type of result MQL/SQL/CQL
*/
@JsonSerialize(using = LanguageSerializer.class)
public QueryLanguage language = QueryLanguage.from( "sql" );

/**
* Indicate that only a subset of the specified query is being displayed.
*/
public boolean hasMoreRows;


@JsonCreator
public RelationalResult(
Expand All @@ -103,16 +79,13 @@ public RelationalResult(
@JsonProperty("UIRequest") UIRequest request,
@JsonProperty("int") int affectedRows,
@JsonProperty("ResultType") ResultType type,
@JsonProperty("hasMoreRows") boolean hasMoreRows ) {
super( namespaceType, namespaceName, data, header, exception, query, xid, error );
this.currentPage = currentPage;
this.highestPage = highestPage;
@JsonProperty("hasMoreRows") boolean hasMore ) {
super( namespaceType, namespaceName, data, header, exception, query, xid, error, currentPage, highestPage, hasMore );
this.table = table;
this.tables = tables;
this.request = request;
this.affectedRows = affectedRows;
this.type = type;
this.hasMoreRows = hasMoreRows;
}


Expand Down Expand Up @@ -217,14 +190,4 @@ public B hasMoreRows( boolean hasMoreRows ) {
}


private static class LanguageSerializer extends JsonSerializer<QueryLanguage> {

@Override
public void serialize( QueryLanguage value, JsonGenerator gen, SerializerProvider serializers ) throws IOException {
gen.writeString( value.getSerializedName() );
}

}


}
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,17 @@

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

import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.JsonSerializer;
import com.fasterxml.jackson.databind.SerializerProvider;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import java.io.IOException;
import lombok.AllArgsConstructor;
import lombok.Value;
import lombok.experimental.NonFinal;
import lombok.experimental.SuperBuilder;
import org.polypheny.db.catalog.logistic.NamespaceType;
import org.polypheny.db.languages.QueryLanguage;


@Value
Expand Down Expand Up @@ -57,6 +63,23 @@ public abstract class Result<E, F> {
* Error message if a query failed
*/
public String error;
/**
* Information for the pagination: what current page is being displayed
*/
public int currentPage;
/**
* Information for the pagination: how many pages there can be in total
*/
public int highestPage;
/**
* Indicate that only a subset of the specified query is being displayed.
*/
public boolean hasMore;
/**
* language type of result MQL/SQL/CQL
*/
@JsonSerialize(using = LanguageSerializer.class)
public QueryLanguage language = QueryLanguage.from( "sql" );


/**
Expand All @@ -78,4 +101,14 @@ public static abstract class ResultBuilder<E, F, C extends Result<E, F>, B exten

}


private static class LanguageSerializer extends JsonSerializer<QueryLanguage> {

@Override
public void serialize( QueryLanguage value, JsonGenerator gen, SerializerProvider serializers ) throws IOException {
gen.writeString( value.getSerializedName() );
}

}

}

0 comments on commit 7c9cdf1

Please sign in to comment.