diff --git a/core/src/main/java/org/polypheny/db/algebra/AlgCollation.java b/core/src/main/java/org/polypheny/db/algebra/AlgCollation.java index 64cbc6be54..ebf793a4b4 100644 --- a/core/src/main/java/org/polypheny/db/algebra/AlgCollation.java +++ b/core/src/main/java/org/polypheny/db/algebra/AlgCollation.java @@ -34,6 +34,7 @@ package org.polypheny.db.algebra; +import io.activej.serializer.annotations.SerializeClass; import java.io.Serializable; import java.util.List; import org.polypheny.db.plan.AlgMultipleTrait; @@ -44,6 +45,7 @@ *

* An ordering consists of a list of one or more column ordinals and the direction of the ordering. */ +@SerializeClass(subclasses = { AlgCollationImpl.class }) public interface AlgCollation extends AlgMultipleTrait, Serializable { /** diff --git a/core/src/main/java/org/polypheny/db/algebra/AlgCollationImpl.java b/core/src/main/java/org/polypheny/db/algebra/AlgCollationImpl.java index 59176486e4..59a7bb3d83 100644 --- a/core/src/main/java/org/polypheny/db/algebra/AlgCollationImpl.java +++ b/core/src/main/java/org/polypheny/db/algebra/AlgCollationImpl.java @@ -37,7 +37,10 @@ import com.google.common.base.Preconditions; import com.google.common.collect.ImmutableList; import com.google.common.collect.UnmodifiableIterator; +import io.activej.serializer.annotations.Deserialize; +import io.activej.serializer.annotations.Serialize; import java.util.Iterator; +import java.util.List; import javax.annotation.Nonnull; import lombok.Getter; import org.polypheny.db.plan.AlgMultipleTrait; @@ -53,11 +56,12 @@ @Getter public class AlgCollationImpl implements AlgCollation { - private final ImmutableList fieldCollations; + @Serialize + public final ImmutableList fieldCollations; - protected AlgCollationImpl( ImmutableList fieldCollations ) { - this.fieldCollations = fieldCollations; + public AlgCollationImpl( @Deserialize("fieldCollations") List fieldCollations ) { + this.fieldCollations = ImmutableList.copyOf( fieldCollations ); Preconditions.checkArgument( Util.isDistinct( AlgCollations.ordinals( fieldCollations ) ), "fields must be distinct" ); } @@ -147,6 +151,5 @@ public String toString() { } } - } diff --git a/core/src/main/java/org/polypheny/db/algebra/AlgFieldCollation.java b/core/src/main/java/org/polypheny/db/algebra/AlgFieldCollation.java index f27db30331..27ad0eabb4 100644 --- a/core/src/main/java/org/polypheny/db/algebra/AlgFieldCollation.java +++ b/core/src/main/java/org/polypheny/db/algebra/AlgFieldCollation.java @@ -34,6 +34,8 @@ package org.polypheny.db.algebra; +import io.activej.serializer.annotations.Deserialize; +import io.activej.serializer.annotations.Serialize; import java.io.Serializable; import java.util.Objects; import lombok.Getter; @@ -177,17 +179,20 @@ public enum NullDirection { * 0-based index of field being sorted. */ @Getter - private final int fieldIndex; + @Serialize + public final int fieldIndex; /** * Direction of sorting. */ @Getter + @Serialize public final Direction direction; /** * Direction of sorting of nulls. */ + @Serialize public final NullDirection nullDirection; @@ -210,7 +215,7 @@ public AlgFieldCollation( int fieldIndex, Direction direction ) { /** * Creates a field collation. */ - public AlgFieldCollation( int fieldIndex, Direction direction, NullDirection nullDirection ) { + public AlgFieldCollation( @Deserialize("fieldIndex") int fieldIndex, @Deserialize("direction") Direction direction, @Deserialize("nullDirection") NullDirection nullDirection ) { this.fieldIndex = fieldIndex; this.direction = Objects.requireNonNull( direction ); this.nullDirection = Objects.requireNonNull( nullDirection ); diff --git a/core/src/main/java/org/polypheny/db/catalog/entity/logical/LogicalMaterializedView.java b/core/src/main/java/org/polypheny/db/catalog/entity/logical/LogicalMaterializedView.java index 58748a2989..9e0674fb3e 100644 --- a/core/src/main/java/org/polypheny/db/catalog/entity/logical/LogicalMaterializedView.java +++ b/core/src/main/java/org/polypheny/db/catalog/entity/logical/LogicalMaterializedView.java @@ -44,14 +44,29 @@ public class LogicalMaterializedView extends LogicalView { public boolean ordered; + public LogicalMaterializedView( + long id, + String name, + long namespaceId, + String query, + AlgCollation algCollation, + Map> underlyingTables, + QueryLanguage language, + MaterializedCriteria materializedCriteria, + boolean ordered + ) { + this( id, name, namespaceId, query, algCollation, underlyingTables, language.serializedName(), materializedCriteria, ordered ); + } + + public LogicalMaterializedView( @Deserialize("id") long id, @Deserialize("name") String name, @Deserialize("namespaceId") long namespaceId, - @Deserialize("entityType") String query, + @Deserialize("query") String query, @Deserialize("algCollation") AlgCollation algCollation, @Deserialize("underlyingTables") Map> underlyingTables, - @Deserialize("language") QueryLanguage language, + @Deserialize("sLanguage") String sLanguage, @Deserialize("materializedCriteria") MaterializedCriteria materializedCriteria, @Deserialize("ordered") boolean ordered ) { @@ -63,7 +78,7 @@ public LogicalMaterializedView( query, algCollation, underlyingTables, - language ); + sLanguage ); Map> map = new HashMap<>(); for ( Entry> e : underlyingTables.entrySet() ) { diff --git a/core/src/main/java/org/polypheny/db/catalog/entity/logical/LogicalView.java b/core/src/main/java/org/polypheny/db/catalog/entity/logical/LogicalView.java index 852f8b3953..bcb250bbf7 100644 --- a/core/src/main/java/org/polypheny/db/catalog/entity/logical/LogicalView.java +++ b/core/src/main/java/org/polypheny/db/catalog/entity/logical/LogicalView.java @@ -51,6 +51,7 @@ public class LogicalView extends LogicalTable { @Serialize public ImmutableMap> underlyingTables; @Serialize + public String sLanguage; public QueryLanguage language; @Serialize public AlgCollation algCollation; @@ -58,6 +59,19 @@ public class LogicalView extends LogicalTable { public String query; + public LogicalView( + long id, + String name, + long namespaceId, + EntityType entityType, + String query, + AlgCollation algCollation, + Map> underlyingTables, + QueryLanguage language ) { + this( id, name, namespaceId, entityType, query, algCollation, underlyingTables, language.serializedName() ); + } + + public LogicalView( @Deserialize("id") long id, @Deserialize("name") String name, @@ -66,7 +80,7 @@ public LogicalView( @Deserialize("query") String query, @Deserialize("algCollation") AlgCollation algCollation, @Deserialize("underlyingTables") Map> underlyingTables, - @Deserialize("language") QueryLanguage language ) { + @Deserialize("sLanguage") String sLanguage ) { super( id, name, @@ -77,7 +91,8 @@ public LogicalView( this.query = query; this.algCollation = algCollation; this.underlyingTables = ImmutableMap.copyOf( underlyingTables ); - this.language = language; + this.sLanguage = sLanguage; + this.language = QueryLanguage.from( sLanguage ); } diff --git a/core/src/main/java/org/polypheny/db/catalog/impl/logical/RelationalCatalog.java b/core/src/main/java/org/polypheny/db/catalog/impl/logical/RelationalCatalog.java index 568eedd67e..395887e8ae 100644 --- a/core/src/main/java/org/polypheny/db/catalog/impl/logical/RelationalCatalog.java +++ b/core/src/main/java/org/polypheny/db/catalog/impl/logical/RelationalCatalog.java @@ -20,6 +20,7 @@ import io.activej.serializer.BinarySerializer; import io.activej.serializer.annotations.Deserialize; import io.activej.serializer.annotations.Serialize; +import io.activej.serializer.annotations.SerializeClass; import java.beans.PropertyChangeSupport; import java.sql.Timestamp; import java.util.HashSet; @@ -80,7 +81,7 @@ public class RelationalCatalog implements PolySerializable, LogicalRelationalCat @Serialize @JsonProperty - public Map tables; + public Map tables; @Serialize @JsonProperty