m-chrzan.xyz
aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/pl/edu/mimuw/cloudatlas
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/pl/edu/mimuw/cloudatlas')
-rw-r--r--src/main/java/pl/edu/mimuw/cloudatlas/interpreter/Interpreter.java9
-rw-r--r--src/main/java/pl/edu/mimuw/cloudatlas/interpreter/ResultColumn.java16
-rw-r--r--src/main/java/pl/edu/mimuw/cloudatlas/model/ValueDuration.java8
3 files changed, 23 insertions, 10 deletions
diff --git a/src/main/java/pl/edu/mimuw/cloudatlas/interpreter/Interpreter.java b/src/main/java/pl/edu/mimuw/cloudatlas/interpreter/Interpreter.java
index 289f99d..6129f48 100644
--- a/src/main/java/pl/edu/mimuw/cloudatlas/interpreter/Interpreter.java
+++ b/src/main/java/pl/edu/mimuw/cloudatlas/interpreter/Interpreter.java
@@ -329,8 +329,13 @@ public class Interpreter {
}
public Result visit(CondExprAndC expr, Environment env) {
- // TODO
- throw new UnsupportedOperationException("CondExprAndC Not yet implemented");
+ try {
+ Result left = expr.condexpr_1.accept(new CondExprInterpreter(), env);
+ Result right = expr.condexpr_2.accept(new CondExprInterpreter(), env);
+ return left.and(right);
+ } catch(Exception exception) {
+ throw new InsideQueryException(PrettyPrinter.print(expr), exception);
+ }
}
public Result visit(CondExprNotC expr, Environment env) {
diff --git a/src/main/java/pl/edu/mimuw/cloudatlas/interpreter/ResultColumn.java b/src/main/java/pl/edu/mimuw/cloudatlas/interpreter/ResultColumn.java
index b551955..1c0db30 100644
--- a/src/main/java/pl/edu/mimuw/cloudatlas/interpreter/ResultColumn.java
+++ b/src/main/java/pl/edu/mimuw/cloudatlas/interpreter/ResultColumn.java
@@ -4,6 +4,7 @@ import java.util.ArrayList;
import java.util.List;
import pl.edu.mimuw.cloudatlas.model.Type;
+import pl.edu.mimuw.cloudatlas.model.TypePrimitive;
import pl.edu.mimuw.cloudatlas.model.TypeCollection;
import pl.edu.mimuw.cloudatlas.model.Value;
import pl.edu.mimuw.cloudatlas.model.ValueBoolean;
@@ -100,7 +101,7 @@ class ResultColumn extends Result {
@Override
public Result random(int size) {
- return new ResultColumn(
+ return new ResultSingle(
randomList(
new ValueList(
column,
@@ -124,13 +125,18 @@ class ResultColumn extends Result {
@Override
public ResultSingle isNull() {
- throw new UnsupportedOperationException("Operation isNull not supported yet.");
- // return new ResultSingle(new ValueBoolean(value.isNull()));
+ return new ResultSingle(new ValueBoolean(true));
}
@Override
public Type getType() {
- throw new UnsupportedOperationException("Operation getType not supported yet.");
- // return value.getType();
+ Type type = TypePrimitive.NULL;
+ for (Value value : column) {
+ if (value.getType() != TypePrimitive.NULL) {
+ type = value.getType();
+ }
+ }
+
+ return type;
}
}
diff --git a/src/main/java/pl/edu/mimuw/cloudatlas/model/ValueDuration.java b/src/main/java/pl/edu/mimuw/cloudatlas/model/ValueDuration.java
index 7a74776..ad14a30 100644
--- a/src/main/java/pl/edu/mimuw/cloudatlas/model/ValueDuration.java
+++ b/src/main/java/pl/edu/mimuw/cloudatlas/model/ValueDuration.java
@@ -264,9 +264,9 @@ public class ValueDuration extends ValueSimple<Long> {
remainingUnits /= 24;
long days = remainingUnits;
- return (positive ? "+" : "-") + Long.toString(days) + " " + Long.toString(hours)
- + ":" + Long.toString(minutes) + ":" + Long.toString(seconds) + "." +
- Long.toString(milliseconds);
+ return (positive ? "+" : "-") + String.format("%d %02d:%02d:%02d.%03d",
+ days, hours, minutes, seconds, milliseconds
+ );
}
@Override
@@ -274,6 +274,8 @@ public class ValueDuration extends ValueSimple<Long> {
switch(type.getPrimaryType()) {
case STRING:
return getValue() == null? ValueString.NULL_STRING : new ValueString(makeString());
+ case INT:
+ return new ValueInt(getValue() == null? null : getValue());
case DURATION:
return this;
default: