Skip to content

Commit

Permalink
fixes for jdbs output
Browse files Browse the repository at this point in the history
  • Loading branch information
datomo committed Oct 5, 2023
1 parent e73ef2d commit 806747a
Show file tree
Hide file tree
Showing 44 changed files with 162 additions and 841 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ private static void nodePropertiesTableInsert( DataContext context, List<Functio
if ( !node.properties.isEmpty() ) {
context.addParameterValues( 0, idType, Collections.nCopies( node.properties.size(), node.id ) );
context.addParameterValues( 1, labelType, new ArrayList<>( node.properties.keySet() ) );
context.addParameterValues( 2, valueType, new ArrayList<>( node.properties.values().stream().map( e -> PolyString.of( e.toJson() ) ).collect( Collectors.toList() ) ) );
context.addParameterValues( 2, valueType, new ArrayList<>( node.properties.values().stream().map( e -> PolyString.of( e.toJsonOrNull() ) ).collect( Collectors.toList() ) ) );
drainInserts( enumerables.get( i ), node.properties.size() );
context.resetParameterValues();
}
Expand Down
3 changes: 2 additions & 1 deletion core/src/main/java/org/polypheny/db/functions/Functions.java
Original file line number Diff line number Diff line change
Expand Up @@ -3189,12 +3189,13 @@ public static PolyValue itemOptional( Map<PolyValue, PolyValue> object, PolyValu
}


@SuppressWarnings("unused")
public static List<?> reparse( PolyType innerType, Long dimension, String stringValue ) {
//Type conversionType = PolyTypeUtil.createNestedListType( dimension, innerType );
if ( stringValue == null ) {
return null;
}
return PolyValue.GSON.fromJson( stringValue, PolyList.class );
return PolyValue.readJsonOrNull( stringValue, PolyList.class ).asList();
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,16 @@

package org.polypheny.db.type.entity;

import com.google.gson.JsonDeserializationContext;
import com.google.gson.JsonDeserializer;
import com.google.gson.JsonElement;
import com.google.gson.JsonParseException;
import com.google.gson.JsonPrimitive;
import com.google.gson.JsonSerializationContext;
import com.google.gson.JsonSerializer;
import com.fasterxml.jackson.annotation.JsonProperty;
import io.activej.serializer.BinaryInput;
import io.activej.serializer.BinaryOutput;
import io.activej.serializer.BinarySerializer;
import io.activej.serializer.CompatibilityLevel;
import io.activej.serializer.CorruptedDataException;
import io.activej.serializer.SimpleSerializerDef;
import java.lang.reflect.Type;
import io.activej.serializer.annotations.Deserialize;
import io.activej.serializer.annotations.Serialize;
import io.activej.serializer.annotations.SerializeNullable;
import java.math.BigDecimal;
import java.math.MathContext;
import java.util.Objects;
Expand All @@ -47,10 +43,13 @@
@Slf4j
public class PolyBigDecimal extends PolyNumber {

@JsonProperty
@Serialize
@SerializeNullable
public BigDecimal value;


public PolyBigDecimal( BigDecimal value ) {
public PolyBigDecimal( @JsonProperty @Deserialize("value") BigDecimal value ) {
super( PolyType.DECIMAL );
this.value = value;
}
Expand Down Expand Up @@ -246,20 +245,4 @@ public PolyBigDecimal decode( BinaryInput in ) throws CorruptedDataException {
}


public static class PolyBigDecimalSerializer implements JsonDeserializer<PolyBigDecimal>, JsonSerializer<PolyBigDecimal> {


@Override
public PolyBigDecimal deserialize( JsonElement json, Type typeOfT, JsonDeserializationContext context ) throws JsonParseException {
return PolyBigDecimal.of( json.getAsBigDecimal() );
}


@Override
public JsonElement serialize( PolyBigDecimal src, Type typeOfSrc, JsonSerializationContext context ) {
return new JsonPrimitive( src.value );
}

}

}
23 changes: 0 additions & 23 deletions core/src/main/java/org/polypheny/db/type/entity/PolyBinary.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,6 @@

package org.polypheny.db.type.entity;

import com.google.gson.JsonDeserializationContext;
import com.google.gson.JsonDeserializer;
import com.google.gson.JsonElement;
import com.google.gson.JsonParseException;
import com.google.gson.JsonPrimitive;
import com.google.gson.JsonSerializationContext;
import com.google.gson.JsonSerializer;
import java.lang.reflect.Type;
import lombok.EqualsAndHashCode;
import lombok.Value;
import org.apache.calcite.avatica.util.ByteString;
Expand Down Expand Up @@ -123,19 +115,4 @@ public int getBitCount() {
}


public static class PolyBinarySerializer implements JsonSerializer<PolyBinary>, JsonDeserializer<PolyBinary> {

@Override
public JsonElement serialize( PolyBinary src, Type typeOfSrc, JsonSerializationContext context ) {
return new JsonPrimitive( src.value.toBase64String() );
}


@Override
public PolyBinary deserialize( JsonElement json, Type typeOfT, JsonDeserializationContext context ) throws JsonParseException {
return PolyBinary.of( ByteString.ofBase64( json.getAsString() ) );
}

}

}
28 changes: 3 additions & 25 deletions core/src/main/java/org/polypheny/db/type/entity/PolyBoolean.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,7 @@

package org.polypheny.db.type.entity;

import com.google.gson.JsonDeserializationContext;
import com.google.gson.JsonDeserializer;
import com.google.gson.JsonElement;
import com.google.gson.JsonParseException;
import com.google.gson.JsonPrimitive;
import com.google.gson.JsonSerializationContext;
import com.google.gson.JsonSerializer;
import com.fasterxml.jackson.annotation.JsonProperty;
import io.activej.serializer.BinaryInput;
import io.activej.serializer.BinaryOutput;
import io.activej.serializer.BinarySerializer;
Expand All @@ -32,7 +26,6 @@
import io.activej.serializer.annotations.Deserialize;
import io.activej.serializer.annotations.Serialize;
import io.activej.serializer.annotations.SerializeNullable;
import java.lang.reflect.Type;
import lombok.EqualsAndHashCode;
import lombok.Value;
import org.apache.calcite.linq4j.tree.Expression;
Expand All @@ -51,11 +44,12 @@ public class PolyBoolean extends PolyValue {
public static final PolyBoolean FALSE = PolyBoolean.of( false );

@Serialize
@JsonProperty
@SerializeNullable
public Boolean value;


public PolyBoolean( @Deserialize("value") Boolean value ) {
public PolyBoolean( @JsonProperty @Deserialize("value") Boolean value ) {
super( PolyType.BOOLEAN );
this.value = value;
}
Expand Down Expand Up @@ -131,22 +125,6 @@ public PolyBoolean decode( BinaryInput in ) throws CorruptedDataException {
}


public static class PolyBooleanSerializer implements JsonSerializer<PolyBoolean>, JsonDeserializer<PolyBoolean> {

@Override
public PolyBoolean deserialize( JsonElement json, Type typeOfT, JsonDeserializationContext context ) throws JsonParseException {
return PolyBoolean.of( json.getAsBoolean() );
}


@Override
public JsonElement serialize( PolyBoolean src, Type typeOfSrc, JsonSerializationContext context ) {
return new JsonPrimitive( src.value );
}

}


@Override
public PolySerializable copy() {
return null;
Expand Down
23 changes: 0 additions & 23 deletions core/src/main/java/org/polypheny/db/type/entity/PolyDate.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,6 @@

package org.polypheny.db.type.entity;

import com.google.gson.JsonDeserializationContext;
import com.google.gson.JsonDeserializer;
import com.google.gson.JsonElement;
import com.google.gson.JsonParseException;
import com.google.gson.JsonPrimitive;
import com.google.gson.JsonSerializationContext;
import com.google.gson.JsonSerializer;
import java.lang.reflect.Type;
import java.util.Date;
import lombok.EqualsAndHashCode;
import lombok.Getter;
Expand Down Expand Up @@ -103,21 +95,6 @@ public Expression asExpression() {
}


public static class PolyDateSerializer implements JsonSerializer<PolyDate>, JsonDeserializer<PolyDate> {

@Override
public JsonElement serialize( PolyDate src, Type typeOfSrc, JsonSerializationContext context ) {
return new JsonPrimitive( src.milliSinceEpoch );
}


@Override
public PolyDate deserialize( JsonElement json, Type typeOfT, JsonDeserializationContext context ) throws JsonParseException {
return PolyDate.of( json.getAsLong() );
}

}


@Override
public PolySerializable copy() {
Expand Down
24 changes: 0 additions & 24 deletions core/src/main/java/org/polypheny/db/type/entity/PolyDouble.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,6 @@

package org.polypheny.db.type.entity;

import com.google.gson.JsonDeserializationContext;
import com.google.gson.JsonDeserializer;
import com.google.gson.JsonElement;
import com.google.gson.JsonParseException;
import com.google.gson.JsonPrimitive;
import com.google.gson.JsonSerializationContext;
import com.google.gson.JsonSerializer;
import io.activej.serializer.BinaryInput;
import io.activej.serializer.BinaryOutput;
import io.activej.serializer.BinarySerializer;
Expand All @@ -31,7 +24,6 @@
import io.activej.serializer.SimpleSerializerDef;
import io.activej.serializer.annotations.Deserialize;
import io.activej.serializer.annotations.Serialize;
import java.lang.reflect.Type;
import java.math.BigDecimal;
import lombok.EqualsAndHashCode;
import org.apache.calcite.linq4j.tree.Expression;
Expand Down Expand Up @@ -188,22 +180,6 @@ public PolyDouble decode( BinaryInput in ) throws CorruptedDataException {
}


public static class PolyDoubleSerializer implements JsonDeserializer<PolyDouble>, JsonSerializer<PolyDouble> {

@Override
public PolyDouble deserialize( JsonElement json, Type typeOfT, JsonDeserializationContext context ) throws JsonParseException {
return PolyDouble.of( json.getAsDouble() );
}


@Override
public JsonElement serialize( PolyDouble src, Type typeOfSrc, JsonSerializationContext context ) {
return new JsonPrimitive( src.value );
}

}


@Override
public String toString() {
return value.toString();
Expand Down
23 changes: 0 additions & 23 deletions core/src/main/java/org/polypheny/db/type/entity/PolyFloat.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,6 @@

package org.polypheny.db.type.entity;

import com.google.gson.JsonDeserializationContext;
import com.google.gson.JsonDeserializer;
import com.google.gson.JsonElement;
import com.google.gson.JsonParseException;
import com.google.gson.JsonPrimitive;
import com.google.gson.JsonSerializationContext;
import com.google.gson.JsonSerializer;
import io.activej.serializer.BinaryInput;
import io.activej.serializer.BinaryOutput;
import io.activej.serializer.BinarySerializer;
Expand All @@ -31,7 +24,6 @@
import io.activej.serializer.SimpleSerializerDef;
import io.activej.serializer.annotations.Deserialize;
import io.activej.serializer.annotations.Serialize;
import java.lang.reflect.Type;
import java.math.BigDecimal;
import lombok.EqualsAndHashCode;
import org.apache.calcite.linq4j.tree.Expression;
Expand Down Expand Up @@ -185,21 +177,6 @@ public PolyFloat decode( BinaryInput in ) throws CorruptedDataException {
}


public static class PolyFloatSerializer implements JsonSerializer<PolyFloat>, JsonDeserializer<PolyFloat> {

@Override
public JsonElement serialize( PolyFloat src, Type typeOfSrc, JsonSerializationContext context ) {
return new JsonPrimitive( src.value );
}


@Override
public PolyFloat deserialize( JsonElement json, Type typeOfT, JsonDeserializationContext context ) throws JsonParseException {
return PolyFloat.of( json.getAsFloat() );
}

}


@Override
public String toString() {
Expand Down
28 changes: 3 additions & 25 deletions core/src/main/java/org/polypheny/db/type/entity/PolyInteger.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,7 @@

package org.polypheny.db.type.entity;

import com.google.gson.JsonDeserializationContext;
import com.google.gson.JsonDeserializer;
import com.google.gson.JsonElement;
import com.google.gson.JsonParseException;
import com.google.gson.JsonPrimitive;
import com.google.gson.JsonSerializationContext;
import com.google.gson.JsonSerializer;
import com.fasterxml.jackson.annotation.JsonProperty;
import io.activej.serializer.BinaryInput;
import io.activej.serializer.BinaryOutput;
import io.activej.serializer.BinarySerializer;
Expand All @@ -31,7 +25,6 @@
import io.activej.serializer.SimpleSerializerDef;
import io.activej.serializer.annotations.Deserialize;
import io.activej.serializer.annotations.Serialize;
import java.lang.reflect.Type;
import java.math.BigDecimal;
import java.math.MathContext;
import java.util.Objects;
Expand All @@ -49,10 +42,11 @@ public class PolyInteger extends PolyNumber {

public static final PolyInteger ZERO = PolyInteger.of( 0 );
@Serialize
@JsonProperty
public Integer value;


public PolyInteger( @Deserialize("value") Integer value ) {
public PolyInteger( @JsonProperty @Deserialize("value") Integer value ) {
super( PolyType.INTEGER );
this.value = value;
}
Expand Down Expand Up @@ -242,22 +236,6 @@ public PolyInteger decode( BinaryInput in ) throws CorruptedDataException {
}


public static class PolyIntegerSerializer implements JsonSerializer<PolyInteger>, JsonDeserializer<PolyInteger> {

@Override
public PolyInteger deserialize( JsonElement json, Type typeOfT, JsonDeserializationContext context ) throws JsonParseException {
return PolyInteger.of( json.getAsInt() );
}


@Override
public JsonElement serialize( PolyInteger src, Type typeOfSrc, JsonSerializationContext context ) {
return new JsonPrimitive( src.value );
}

}


@Override
public String toString() {
return value.toString();
Expand Down
Loading

0 comments on commit 806747a

Please sign in to comment.