m-chrzan.xyz
aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/pl/edu/mimuw
diff options
context:
space:
mode:
authorMagdalena Grodzińska <mag.grodzinska@gmail.com>2020-01-12 16:54:51 +0100
committerMagdalena Grodzińska <mag.grodzinska@gmail.com>2020-01-12 16:54:51 +0100
commit091c5f1c6f52f46734b3faf7c08ea95551e3ab74 (patch)
tree2f72ee3a754289ee677bf36401cbcabd29c29a85 /src/main/java/pl/edu/mimuw
parente01887358628321b423dbbc5be5bc5d7e2504d99 (diff)
Add query serialization
Diffstat (limited to 'src/main/java/pl/edu/mimuw')
-rw-r--r--src/main/java/pl/edu/mimuw/cloudatlas/agent/modules/UDUPSerializer.java23
-rw-r--r--src/main/java/pl/edu/mimuw/cloudatlas/model/ValueQuery.java2
2 files changed, 24 insertions, 1 deletions
diff --git a/src/main/java/pl/edu/mimuw/cloudatlas/agent/modules/UDUPSerializer.java b/src/main/java/pl/edu/mimuw/cloudatlas/agent/modules/UDUPSerializer.java
index d0dc03f..3b7e633 100644
--- a/src/main/java/pl/edu/mimuw/cloudatlas/agent/modules/UDUPSerializer.java
+++ b/src/main/java/pl/edu/mimuw/cloudatlas/agent/modules/UDUPSerializer.java
@@ -6,6 +6,7 @@ import com.esotericsoftware.kryo.io.Input;
import com.esotericsoftware.kryo.io.Output;
import org.assertj.core.data.MapEntry;
import pl.edu.mimuw.cloudatlas.agent.messages.*;
+import pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.Program;
import pl.edu.mimuw.cloudatlas.model.*;
import java.io.ByteArrayInputStream;
@@ -133,6 +134,27 @@ public class UDUPSerializer {
}
});
+ kryo.register(ValueQuery.class, new Serializer() {
+ @Override
+ public void write(Kryo kryo, Output output, Object object) {
+ ValueQuery vq = (ValueQuery) object;
+ kryo.writeObject(output, vq.getCode());
+ }
+
+ @Override
+ public Object read(Kryo kryo, Input input, Class type) {
+ String code = kryo.readObject(input, String.class);
+ ValueQuery vq = null;
+ try {
+ vq = new ValueQuery(code);
+ } catch (Exception e) {
+ System.out.println("Value query deserialization failed");
+ e.printStackTrace();
+ }
+ return vq;
+ }
+ });
+
// model
kryo.register(Value.class);
kryo.register(ValueBoolean.class);
@@ -141,7 +163,6 @@ public class UDUPSerializer {
kryo.register(ValueDouble.class);
kryo.register(ValueInt.class);
kryo.register(ValueNull.class);
- kryo.register(ValueQuery.class);
kryo.register(ValueSet.class);
kryo.register(ValueString.class);
kryo.register(ValueTime.class);
diff --git a/src/main/java/pl/edu/mimuw/cloudatlas/model/ValueQuery.java b/src/main/java/pl/edu/mimuw/cloudatlas/model/ValueQuery.java
index 82e1602..6d233ea 100644
--- a/src/main/java/pl/edu/mimuw/cloudatlas/model/ValueQuery.java
+++ b/src/main/java/pl/edu/mimuw/cloudatlas/model/ValueQuery.java
@@ -32,6 +32,8 @@ public class ValueQuery extends Value {
this.query = null;
}
+ public String getCode() { return code; }
+
public Program getQuery() {
return query;
}