Skip to content

Commit

Permalink
Sync protofiles & update interval serialization
Browse files Browse the repository at this point in the history
  • Loading branch information
gartens committed Apr 9, 2024
1 parent 0bde3f4 commit c62d791
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 55 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
@NonFinal
public class PolyInterval extends PolyValue {

@Getter
@NotNull
public Long millis;

Expand Down Expand Up @@ -165,7 +166,7 @@ public PolyNumber getLeap( IntervalQualifier intervalQualifier ) {
}


public record MonthsMilliseconds(long months, long milliseconds) {
private record MonthsMilliseconds(long months, long milliseconds) {

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import java.util.Map;
import java.util.stream.Collectors;
import org.apache.commons.lang3.NotImplementedException;
import org.polypheny.db.catalog.exceptions.GenericRuntimeException;
import org.polypheny.db.protointerface.proto.ProtoBigDecimal;
import org.polypheny.db.protointerface.proto.ProtoBinary;
import org.polypheny.db.protointerface.proto.ProtoBoolean;
Expand All @@ -42,16 +41,16 @@
import org.polypheny.db.protointerface.proto.ProtoTimestamp;
import org.polypheny.db.protointerface.proto.ProtoValue;
import org.polypheny.db.type.PolyType;
import org.polypheny.db.type.entity.PolyList;
import org.polypheny.db.type.entity.numerical.PolyBigDecimal;
import org.polypheny.db.type.entity.PolyBinary;
import org.polypheny.db.type.entity.PolyBoolean;
import org.polypheny.db.type.entity.numerical.PolyLong;
import org.polypheny.db.type.entity.temporal.PolyDate;
import org.polypheny.db.type.entity.numerical.PolyDouble;
import org.polypheny.db.type.entity.numerical.PolyFloat;
import org.polypheny.db.type.entity.numerical.PolyInteger;
import org.polypheny.db.type.entity.PolyInterval;
import org.polypheny.db.type.entity.PolyList;
import org.polypheny.db.type.entity.PolyLong;
import org.polypheny.db.type.entity.PolyNull;
import org.polypheny.db.type.entity.PolyString;
import org.polypheny.db.type.entity.temporal.PolyTime;
Expand Down Expand Up @@ -113,25 +112,11 @@ public static ProtoValue serialize( PolyValue polyValue ) {
return serializeAsProtoDate( polyValue.asDate() );
case TIME:
// used by PolyTime
case TIME_WITH_LOCAL_TIME_ZONE:
return serializeAsProtoTime( polyValue.asTime() );
case TIMESTAMP:
// used by PolyTimeStamp
case TIMESTAMP_WITH_LOCAL_TIME_ZONE:
return serializeAsProtoTimestamp( polyValue.asTimestamp() );
case INTERVAL_SECOND:
case INTERVAL_MINUTE_SECOND:
case INTERVAL_MINUTE:
case INTERVAL_HOUR_SECOND:
case INTERVAL_HOUR_MINUTE:
case INTERVAL_HOUR:
case INTERVAL_DAY_SECOND:
case INTERVAL_DAY_MINUTE:
case INTERVAL_DAY_HOUR:
case INTERVAL_DAY:
case INTERVAL_MONTH:
case INTERVAL_YEAR_MONTH:
case INTERVAL_YEAR:
case INTERVAL:
return serializeAsProtoInterval( polyValue.asInterval() );
case CHAR:
case VARCHAR:
Expand Down Expand Up @@ -219,32 +204,9 @@ private static ProtoValue serializeAsProtoFile( PolyBlob polyBlob ) {
}


private static ProtoInterval getInterval( PolyInterval polyInterval ) {
switch ( polyInterval.getType() ) {
case INTERVAL_SECOND:
case INTERVAL_MINUTE_SECOND:
case INTERVAL_MINUTE:
case INTERVAL_HOUR_SECOND:
case INTERVAL_HOUR_MINUTE:
case INTERVAL_HOUR:
case INTERVAL_DAY_SECOND:
case INTERVAL_DAY_MINUTE:
case INTERVAL_DAY_HOUR:
case INTERVAL_DAY:
return ProtoInterval.newBuilder().setMilliseconds( polyInterval.getValue().longValue() ).build();
case INTERVAL_MONTH:
case INTERVAL_YEAR_MONTH:
case INTERVAL_YEAR:
return ProtoInterval.newBuilder().setMonths( polyInterval.getValue().longValue() ).build();
default:
throw new GenericRuntimeException( "Invalid type for PolyInterval: " + polyInterval.getType().getTypeName() );
}
}


private static ProtoValue serializeAsProtoInterval( PolyInterval polyInterval ) {
return ProtoValue.newBuilder()
.setInterval( getInterval( polyInterval ) )
.setInterval( ProtoInterval.newBuilder().setMonths( polyInterval.getMonths() ).setMilliseconds( polyInterval.getMillis() ).build() )
.build();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,15 +51,15 @@ message ConnectionProperties {
}

/*
The ConnectionCheckRequest message in combination with the corresponding remot procedure call is utilized to verify the current state of an established connection.
The ConnectionCheckRequest message in combination with the corresponding remote procedure call is utilized to verify the current state of an established connection.
It acts as a simple “ping” request, enabling clients to ascertain if the server is responsive and if the connection is still valid.
This message does not contain any fields. It simply acts as an indicator to prompt the server for a ConnectionCheckResponse.
*/
message DisconnectRequest {
}

/*
The ConnectionCheckRequest message in combination with the corresponding remot procedure call is utilized to verify the current state of an established connection.
The ConnectionCheckRequest message in combination with the corresponding remote procedure call is utilized to verify the current state of an established connection.
It acts as a simple “ping” request, enabling clients to ascertain if the server is responsive and if the connection is still valid.
*/
message ConnectionCheckRequest {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ message Request {
CommitRequest commit_request = 33;
RollbackRequest rollback_request = 34;
ConnectionPropertiesUpdateRequest connection_properties_update_request = 35;
CloseResultRequest close_result_request = 36;
CloseResultRequest close_result_response = 36;
}
}

Expand Down
13 changes: 4 additions & 9 deletions plugins/proto-interface/src/main/proto/polyprism/value.proto
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ The value is reconstructed by calculating unscaled_value * 10 ^ -scale.
*/
message ProtoBigDecimal {
// The scale of the BigDecimal.
uint32 scale = 1;
int32 scale = 1;
// The precision of the BigDecimal.
uint32 precision = 2;
// The unscaled value of the BigDecimal.
Expand Down Expand Up @@ -253,16 +253,11 @@ message ProtoTimestamp {
}

/*
Represents an interval value. Intervals ar specified either in months or milliseconds. The applicable unit is determined
by the field set in the message. Only one of the fields is set.
Represents an interval value.
*/
message ProtoInterval {
oneof unit {
// Contains the duration of the interval in milliseconds if milliseconds where chosen as the unit of time for that interval.
int64 milliseconds = 1;
// Contains the duration of the interval in months if months where chosen as the unit of time for that interval.
int64 months = 2;
}
int64 milliseconds = 1;
int64 months = 2;
}

/*
Expand Down

0 comments on commit c62d791

Please sign in to comment.