diff --git a/src/qir/QIRTypes.java b/src/qir/QIRTypes.java index f3f1c35734d66509a1f1d705a68a908d67ddc274..4bb243e2917978d121f230d828553c874fc6664a 100644 --- a/src/qir/QIRTypes.java +++ b/src/qir/QIRTypes.java @@ -12,9 +12,9 @@ import qir.ast.QIRTruffleNode; import qir.ast.data.QIRLcons; import qir.ast.data.QIRList; import qir.ast.data.QIRLnil; -import qir.ast.data.QIRTcons; -import qir.ast.data.QIRTnil; -import qir.ast.data.QIRTuple; +import qir.ast.data.QIRRcons; +import qir.ast.data.QIRRnil; +import qir.ast.data.QIRRecord; import qir.ast.expression.QIRBigNumber; import qir.ast.expression.QIRBoolean; import qir.ast.expression.QIRDouble; @@ -23,7 +23,7 @@ import qir.ast.expression.QIRNumber; import qir.ast.expression.QIRString; @TypeSystem({QIRNumber.class, QIRBigNumber.class, QIRDouble.class, QIRBoolean.class, QIRString.class, QIRNull.class, QIRLambda.class, QIRExternal.class, QIRTruffleNode.class, QIRLnil.class, - QIRLcons.class, QIRList.class, QIRTnil.class, QIRTcons.class, QIRTuple.class}) + QIRLcons.class, QIRList.class, QIRRnil.class, QIRRcons.class, QIRRecord.class}) public abstract class QIRTypes { @ImplicitCast @TruffleBoundary diff --git a/src/qir/ast/QIRNode.java b/src/qir/ast/QIRNode.java index 0e0c39cdeaaaf589753b3f6c6d0e62490b596d52..b1742136c7ba47eec0fa16857b972e7b04808db9 100644 --- a/src/qir/ast/QIRNode.java +++ b/src/qir/ast/QIRNode.java @@ -10,7 +10,7 @@ import com.oracle.truffle.api.source.SourceSection; import qir.QIRTypes; import qir.QIRTypesGen; import qir.ast.data.QIRList; -import qir.ast.data.QIRTuple; +import qir.ast.data.QIRRecord; import qir.ast.expression.QIRBoolean; import qir.ast.expression.QIRNumber; import qir.ast.expression.QIRString; @@ -60,8 +60,8 @@ public abstract class QIRNode extends Node { return QIRTypesGen.expectQIRList(executeGeneric(frame)); } - public final QIRTuple executeTuple(VirtualFrame frame) throws UnexpectedResultException { - return QIRTypesGen.expectQIRTuple(executeGeneric(frame)); + public final QIRRecord executeRecord(VirtualFrame frame) throws UnexpectedResultException { + return QIRTypesGen.expectQIRRecord(executeGeneric(frame)); } /** diff --git a/src/qir/ast/data/QIRTcons.java b/src/qir/ast/data/QIRRcons.java similarity index 67% rename from src/qir/ast/data/QIRTcons.java rename to src/qir/ast/data/QIRRcons.java index 87ebe3db1e51cb621b2f592581bf3ecf22e038be..7400735b53804e521632a80d454d28cefc57b87e 100644 --- a/src/qir/ast/data/QIRTcons.java +++ b/src/qir/ast/data/QIRRcons.java @@ -8,23 +8,23 @@ import qir.driver.IQIRVisitor; import qir.util.QIRAny; /** - * {@link QIRTcons} represents a non-empty {@link QIRTuple}. + * {@link QIRRcons} represents a non-empty {@link QIRRecord}. */ -public final class QIRTcons extends QIRTuple { +public final class QIRRcons extends QIRRecord { /** - * The name of the first field in the {@link QIRTuple}. + * The name of the first field in the {@link QIRRecord}. */ private final String id; /** - * The value of the first field in the {@link QIRTuple}. + * The value of the first field in the {@link QIRRecord}. */ @Child private QIRNode value; /** - * The rest of the {@link QIRTuple}. + * The rest of the {@link QIRRecord}. */ @Child private QIRNode tail; - public QIRTcons(final SourceSection source, final String id, final QIRNode value, final QIRNode tail) { + public QIRRcons(final SourceSection source, final String id, final QIRNode value, final QIRNode tail) { super(source); this.id = id; this.value = value; @@ -52,14 +52,14 @@ public final class QIRTcons extends QIRTuple { public boolean equals(Object other) { if (other instanceof QIRAny) return true; - if (!(other instanceof QIRTcons)) + if (!(other instanceof QIRRcons)) return false; - return id.equals(((QIRTcons) other).id) && value.equals(((QIRTcons) other).value) && tail.equals(((QIRTcons) other).tail); + return id.equals(((QIRRcons) other).id) && value.equals(((QIRRcons) other).value) && tail.equals(((QIRRcons) other).tail); } @Override public QIRNode executeGeneric(VirtualFrame frame) { - return new QIRTcons(sourceSection, id, value.executeGeneric(frame), tail.executeGeneric(frame)); + return new QIRRcons(sourceSection, id, value.executeGeneric(frame), tail.executeGeneric(frame)); } @Override diff --git a/src/qir/ast/data/QIRTdestr.java b/src/qir/ast/data/QIRRdestr.java similarity index 67% rename from src/qir/ast/data/QIRTdestr.java rename to src/qir/ast/data/QIRRdestr.java index 4b5e05d2ea9470a19ba0286fd9b7144914d0297e..5752f1aa2ce66c57ab8ffa2f333eea11f50dea9e 100644 --- a/src/qir/ast/data/QIRTdestr.java +++ b/src/qir/ast/data/QIRRdestr.java @@ -9,19 +9,19 @@ import qir.util.QIRAny; import qir.util.QIRException; /** - * {@link QIRTdestr} represents an access to a field in a {@link QIRTuple}. + * {@link QIRRdestr} represents an access to a field in a {@link QIRRecord}. */ -public final class QIRTdestr extends QIRNode { +public final class QIRRdestr extends QIRNode { /** - * The {@link QIRTuple} to access. + * The {@link QIRRecord} to access. */ @Child private QIRNode tuple; /** - * The name of the field to look for in the {@link QIRTuple}. + * The name of the field to look for in the {@link QIRRecord}. */ private final String colName; - public QIRTdestr(final SourceSection source, final QIRNode tuple, final String colName) { + public QIRRdestr(final SourceSection source, final QIRNode tuple, final String colName) { super(source); this.tuple = tuple; this.colName = colName; @@ -44,9 +44,9 @@ public final class QIRTdestr extends QIRNode { public boolean equals(Object other) { if (other instanceof QIRAny) return true; - if (!(other instanceof QIRTdestr)) + if (!(other instanceof QIRRdestr)) return false; - return tuple.equals(((QIRTdestr) other).tuple) && colName.equals(((QIRTdestr) other).colName); + return tuple.equals(((QIRRdestr) other).tuple) && colName.equals(((QIRRdestr) other).colName); } @Override @@ -56,11 +56,11 @@ public final class QIRTdestr extends QIRNode { // TODO: Should we allow this in QIR? if (t instanceof QIRLcons && ((QIRLcons) t).getTail() == QIRLnil.getInstance()) t = ((QIRLcons) t).getValue(); - if (!(t instanceof QIRTuple)) + if (!(t instanceof QIRRecord)) throw new QIRException("Expected tuple for lhs of tuple destructor."); - for (QIRNode current = t; current instanceof QIRTcons; current = ((QIRTcons) current).getTail()) - if (colName.equals(((QIRTcons) current).getId())) - return ((QIRTcons) current).getValue(); + for (QIRNode current = t; current instanceof QIRRcons; current = ((QIRRcons) current).getTail()) + if (colName.equals(((QIRRcons) current).getId())) + return ((QIRRcons) current).getValue(); throw new QIRException("Typing error: destructor of tuple could not find " + colName + " in tuple " + t + "."); } diff --git a/src/qir/ast/data/QIRTuple.java b/src/qir/ast/data/QIRRecord.java similarity index 62% rename from src/qir/ast/data/QIRTuple.java rename to src/qir/ast/data/QIRRecord.java index f64f5a3359715bfd3f3acebee3b1f5c0936d20ab..00da67be72e030b495d78ea45ccfc0759994344d 100644 --- a/src/qir/ast/data/QIRTuple.java +++ b/src/qir/ast/data/QIRRecord.java @@ -6,10 +6,10 @@ import qir.ast.QIRNode; import qir.driver.IQIRVisitor; /** - * {@link QIRTuple} is the generic representation of a tuple in QIR. + * {@link QIRRecord} is the generic representation of a tuple in QIR. */ -public abstract class QIRTuple extends QIRNode { - public QIRTuple(final SourceSection source) { +public abstract class QIRRecord extends QIRNode { + public QIRRecord(final SourceSection source) { super(source); } diff --git a/src/qir/ast/data/QIRTnil.java b/src/qir/ast/data/QIRRnil.java similarity index 60% rename from src/qir/ast/data/QIRTnil.java rename to src/qir/ast/data/QIRRnil.java index 72d7796eec6cc07638eb0591980faccad8afccb4..766eb7905bbdf1fb917549fa5d9e71f1732cb966 100644 --- a/src/qir/ast/data/QIRTnil.java +++ b/src/qir/ast/data/QIRRnil.java @@ -7,19 +7,19 @@ import qir.driver.IQIRVisitor; import qir.util.QIRAny; /** - * {@link QIRTnil} represents the empty {@link QIRTuple}, it is therefore a singleton. + * {@link QIRRnil} represents the empty {@link QIRRecord}, it is therefore a singleton. */ -public final class QIRTnil extends QIRTuple { - private QIRTnil() { +public final class QIRRnil extends QIRRecord { + private QIRRnil() { super(null); } /** - * The unique representation of the empty {@link QIRTuple}. + * The unique representation of the empty {@link QIRRecord}. */ - private static final QIRTnil instance = new QIRTnil(); + private static final QIRRnil instance = new QIRRnil(); - public static final QIRTnil getInstance() { + public static final QIRRnil getInstance() { return instance; } @@ -30,7 +30,7 @@ public final class QIRTnil extends QIRTuple { @Override public boolean equals(Object other) { - return other == QIRTnil.instance || other == QIRAny.instance; + return other == QIRRnil.instance || other == QIRAny.instance; } @Override diff --git a/src/qir/ast/operator/QIRJoin.java b/src/qir/ast/operator/QIRJoin.java index 5436f018f1dd1a2ec5e57fd3b49719839413ebfe..ce30e9d2e401a459f64ce2f66948ffa0fb45d830 100644 --- a/src/qir/ast/operator/QIRJoin.java +++ b/src/qir/ast/operator/QIRJoin.java @@ -12,8 +12,8 @@ import qir.ast.QIRNode; import qir.ast.data.QIRLcons; import qir.ast.data.QIRList; import qir.ast.data.QIRLnil; -import qir.ast.data.QIRTcons; -import qir.ast.data.QIRTnil; +import qir.ast.data.QIRRcons; +import qir.ast.data.QIRRnil; import qir.driver.IQIRVisitor; import qir.util.QIRAny; import qir.util.QIRException; @@ -89,14 +89,14 @@ public final class QIRJoin extends QIROperator { for (QIRNode r = rhs; r instanceof QIRLcons; r = ((QIRLcons) r).getTail()) { try { if (new QIRApply(null, new QIRApply(null, f, ((QIRLcons) l).getValue()), ((QIRLcons) r).getValue()).executeBoolean(frame).isTrue()) { - final Deque<QIRTcons> s = new ArrayDeque<>(); - QIRNode res = QIRTnil.getInstance(); - for (QIRNode t = ((QIRLcons) l).getValue(); t instanceof QIRTcons; t = ((QIRTcons) t).getTail()) - s.push((QIRTcons) t); - for (QIRNode t = ((QIRLcons) r).getValue(); t instanceof QIRTcons; t = ((QIRTcons) t).getTail()) - s.push((QIRTcons) t); - for (QIRTcons t : s) - res = new QIRTcons(t.getSourceSection(), t.getId(), t.getValue(), res); + final Deque<QIRRcons> s = new ArrayDeque<>(); + QIRNode res = QIRRnil.getInstance(); + for (QIRNode t = ((QIRLcons) l).getValue(); t instanceof QIRRcons; t = ((QIRRcons) t).getTail()) + s.push((QIRRcons) t); + for (QIRNode t = ((QIRLcons) r).getValue(); t instanceof QIRRcons; t = ((QIRRcons) t).getTail()) + s.push((QIRRcons) t); + for (QIRRcons t : s) + res = new QIRRcons(t.getSourceSection(), t.getId(), t.getValue(), res); tmp.push(res); } } catch (UnexpectedResultException e) { diff --git a/src/qir/driver/IQIRVisitor.java b/src/qir/driver/IQIRVisitor.java index 7c048e40ddaf78bb422537af01e05b0fd6991f69..5eef74d3ac92009b45385f712b49f9f207f85a37 100644 --- a/src/qir/driver/IQIRVisitor.java +++ b/src/qir/driver/IQIRVisitor.java @@ -76,11 +76,11 @@ public interface IQIRVisitor<T> { public abstract T visit(final QIRLdestr qirLdestr); - public abstract T visit(final QIRTnil qirTnil); + public abstract T visit(final QIRRnil qirTnil); - public abstract T visit(final QIRTcons qirTcons); + public abstract T visit(final QIRRcons qirTcons); - public abstract T visit(final QIRTdestr qirTdestr); + public abstract T visit(final QIRRdestr qirTdestr); public abstract T visit(final QIRString qirString); diff --git a/src/qir/driver/QIRDriver.java b/src/qir/driver/QIRDriver.java index b8d246dbd6aa42596ed08763aae915e1612c6d4d..cbc67eac1fa84b46f91eddb665afec721ca3d3d4 100644 --- a/src/qir/driver/QIRDriver.java +++ b/src/qir/driver/QIRDriver.java @@ -14,8 +14,8 @@ import qir.ast.QIRVariable; */ public class QIRDriver { /** - * Executes a QIR query. First, the query is normalized using the {@link QIRGreedyReduceVisitor} - * module, then the query is translated by the {@link QIRCompileVisitor} module into a query written + * Executes a QIR query. First, the query is normalized using the {@link QIRGreedyNormalizationVisitor} + * module, then the query is translated by the {@link QIRGenericTranslationVisitor} module into a query written * in the different languages understandable by the different data providers, finally it is run by * the {@link QIREvaluationVisitor} module. * @@ -23,7 +23,7 @@ public class QIRDriver { * @return The results of the query */ public static final QIRNode run(final QIRNode query) { - return query.accept(new QIRGreedyReduceVisitor()).accept(QIRCompileVisitor.instance).executeGeneric(Truffle.getRuntime().createVirtualFrame(new Object[]{}, new FrameDescriptor())); + return query.accept(new QIRGreedyNormalizationVisitor()).accept(QIRGenericTranslationVisitor.instance).executeGeneric(Truffle.getRuntime().createVirtualFrame(new Object[]{}, new FrameDescriptor())); } /** diff --git a/src/qir/driver/QIRFreeVarsVisitor.java b/src/qir/driver/QIRFreeVarsVisitor.java index d6f931eeceb8ec7e5791655c6a1ebadbad6112a5..9ec947751f167501e64d1b4c692ba96b37b5e3e8 100644 --- a/src/qir/driver/QIRFreeVarsVisitor.java +++ b/src/qir/driver/QIRFreeVarsVisitor.java @@ -200,18 +200,18 @@ final class QIRFreeVarsVisitor implements IQIRVisitor<Map<String, QIRVariable>> } @Override - public final Map<String, QIRVariable> visit(final QIRTnil qirTnil) { + public final Map<String, QIRVariable> visit(final QIRRnil qirTnil) { return freeVariables; } @Override - public final Map<String, QIRVariable> visit(final QIRTcons qirTcons) { + public final Map<String, QIRVariable> visit(final QIRRcons qirTcons) { qirTcons.getValue().accept(this); return qirTcons.getTail().accept(this); } @Override - public final Map<String, QIRVariable> visit(final QIRTdestr qirTdestr) { + public final Map<String, QIRVariable> visit(final QIRRdestr qirTdestr) { return qirTdestr.getTuple().accept(this); } diff --git a/src/qir/driver/QIRCompileVisitor.java b/src/qir/driver/QIRGenericTranslationVisitor.java similarity index 94% rename from src/qir/driver/QIRCompileVisitor.java rename to src/qir/driver/QIRGenericTranslationVisitor.java index a64d48ba520beaeaead4ed67ce11efc6bc878c53..0f4cfa3d0448fdc71b487ce8d14c91a8f7f096a8 100644 --- a/src/qir/driver/QIRCompileVisitor.java +++ b/src/qir/driver/QIRGenericTranslationVisitor.java @@ -10,13 +10,13 @@ import qir.ast.operator.*; import qir.util.QIRException; /** - * {@link QIRCompileVisitor} represents the translation from QIR to an executable QIR tree. + * {@link QIRGenericTranslationVisitor} represents the translation from QIR to an executable QIR tree. */ -final class QIRCompileVisitor implements IQIRVisitor<QIRNode> { - private QIRCompileVisitor() { +final class QIRGenericTranslationVisitor implements IQIRVisitor<QIRNode> { + private QIRGenericTranslationVisitor() { } - public static final QIRCompileVisitor instance = new QIRCompileVisitor(); + public static final QIRGenericTranslationVisitor instance = new QIRGenericTranslationVisitor(); @Override public final QIRNode visit(final QIRProject qirProject) { @@ -234,18 +234,18 @@ final class QIRCompileVisitor implements IQIRVisitor<QIRNode> { } @Override - public final QIRNode visit(final QIRTnil qirTnil) { + public final QIRNode visit(final QIRRnil qirTnil) { return qirTnil; } @Override - public final QIRNode visit(final QIRTcons qirTcons) { - return new QIRTcons(qirTcons.getSourceSection(), qirTcons.getId(), qirTcons.getValue().accept(this), qirTcons.getTail().accept(this)); + public final QIRNode visit(final QIRRcons qirTcons) { + return new QIRRcons(qirTcons.getSourceSection(), qirTcons.getId(), qirTcons.getValue().accept(this), qirTcons.getTail().accept(this)); } @Override - public final QIRNode visit(final QIRTdestr qirTdestr) { - return new QIRTdestr(qirTdestr.getSourceSection(), qirTdestr.getTuple().accept(this), qirTdestr.getColName()); + public final QIRNode visit(final QIRRdestr qirTdestr) { + return new QIRRdestr(qirTdestr.getSourceSection(), qirTdestr.getTuple().accept(this), qirTdestr.getColName()); } @Override diff --git a/src/qir/driver/QIRGreedyReduceVisitor.java b/src/qir/driver/QIRGreedyNormalizationVisitor.java similarity index 93% rename from src/qir/driver/QIRGreedyReduceVisitor.java rename to src/qir/driver/QIRGreedyNormalizationVisitor.java index 148f6522cc470b22dd2b5588778d9050c0998c4d..53abed5fc7f38c80f000ad76b3058300912a3295 100644 --- a/src/qir/driver/QIRGreedyReduceVisitor.java +++ b/src/qir/driver/QIRGreedyNormalizationVisitor.java @@ -11,10 +11,10 @@ import qir.ast.expression.relational.*; import qir.ast.operator.*; /** - * {@link QIRGreedyReduceVisitor} is the QIR greedy normalization module. TODO: Check behavior if + * {@link QIRGreedyNormalizationVisitor} is the QIR greedy normalization module. TODO: Check behavior if * reduction fails, especially in ldestr. */ -final class QIRGreedyReduceVisitor implements IQIRVisitor<QIRNode> { +final class QIRGreedyNormalizationVisitor implements IQIRVisitor<QIRNode> { private final HashMap<String, QIRNode> env = new HashMap<>(); @Override @@ -224,24 +224,24 @@ final class QIRGreedyReduceVisitor implements IQIRVisitor<QIRNode> { } @Override - public final QIRNode visit(final QIRTnil qirTnil) { + public final QIRNode visit(final QIRRnil qirTnil) { return qirTnil; } @Override - public final QIRNode visit(final QIRTcons qirTcons) { - return new QIRTcons(qirTcons.getSourceSection(), qirTcons.getId(), qirTcons.getValue().accept(this), qirTcons.getTail().accept(this)); + public final QIRNode visit(final QIRRcons qirTcons) { + return new QIRRcons(qirTcons.getSourceSection(), qirTcons.getId(), qirTcons.getValue().accept(this), qirTcons.getTail().accept(this)); } @Override - public final QIRNode visit(final QIRTdestr qirTdestr) { + public final QIRNode visit(final QIRRdestr qirTdestr) { final QIRNode tuple = qirTdestr.getTuple().accept(this); final String colName = qirTdestr.getColName(); - for (QIRNode current = tuple; current instanceof QIRTcons; current = ((QIRTcons) current).getTail()) - if (colName == ((QIRTcons) current).getId()) - return ((QIRTcons) current).getValue(); - return new QIRTdestr(qirTdestr.getSourceSection(), tuple, colName); + for (QIRNode current = tuple; current instanceof QIRRcons; current = ((QIRRcons) current).getTail()) + if (colName == ((QIRRcons) current).getId()) + return ((QIRRcons) current).getValue(); + return new QIRRdestr(qirTdestr.getSourceSection(), tuple, colName); } @Override diff --git a/src/qir/driver/QIRTranslator.java b/src/qir/driver/QIRTranslator.java index b9b8eff9fa57379fd2337f0c115f2ba6fa06fc05..8bc3539c7f59361d89cbb9ca7b77375b17b0d4cd 100644 --- a/src/qir/driver/QIRTranslator.java +++ b/src/qir/driver/QIRTranslator.java @@ -167,17 +167,17 @@ public abstract class QIRTranslator<T> implements IQIRVisitor<T> { } @Override - public T visit(final QIRTnil qirTnil) { + public T visit(final QIRRnil qirTnil) { throw new QIRException(this.getClass().getSimpleName() + " error: unsupported QIR node " + qirTnil.getClass().getSimpleName() + "."); } @Override - public T visit(final QIRTcons qirTcons) { + public T visit(final QIRRcons qirTcons) { throw new QIRException(this.getClass().getSimpleName() + " error: unsupported QIR node " + qirTcons.getClass().getSimpleName() + "."); } @Override - public T visit(final QIRTdestr qirTdestr) { + public T visit(final QIRRdestr qirTdestr) { throw new QIRException(this.getClass().getSimpleName() + " error: unsupported QIR node " + qirTdestr.getClass().getSimpleName() + "."); } diff --git a/src/qir/driver/hbase/HBaseDriver.java b/src/qir/driver/hbase/HBaseDriver.java index d1a5fc03bcfc77defe9bddb7c07a16d3528ddf81..f30c1491222777e0b3728be7842b08b247cc226e 100644 --- a/src/qir/driver/hbase/HBaseDriver.java +++ b/src/qir/driver/hbase/HBaseDriver.java @@ -20,9 +20,9 @@ import qir.ast.QIRNode; import qir.ast.data.QIRLcons; import qir.ast.data.QIRList; import qir.ast.data.QIRLnil; -import qir.ast.data.QIRTcons; -import qir.ast.data.QIRTnil; -import qir.ast.data.QIRTuple; +import qir.ast.data.QIRRcons; +import qir.ast.data.QIRRnil; +import qir.ast.data.QIRRecord; import qir.ast.expression.QIRDouble; import qir.ast.expression.QIRNumber; import qir.ast.expression.QIRString; @@ -86,14 +86,14 @@ public final class HBaseDriver extends DBDriver<HBaseQuery> { @Override public QIRList run(final HBaseQuery query) throws QIRException { final ResultScanner rs; - final Deque<QIRTuple> tmp = new ArrayDeque<>(); + final Deque<QIRRecord> tmp = new ArrayDeque<>(); QIRList result = QIRLnil.getInstance(); QIRNode data; try (final Table table = conn.getTable(TableName.valueOf(query.tableName))) { rs = table.getScanner(query.scan); for (Result r = rs.next(); r != null; r = rs.next()) { - QIRTuple newTuple = QIRTnil.getInstance(); + QIRRecord newTuple = QIRRnil.getInstance(); for (final Cell cell : r.listCells()) { final String value = Bytes.toString(CellUtil.cloneValue(cell)); try { @@ -105,7 +105,7 @@ public final class HBaseDriver extends DBDriver<HBaseQuery> { data = new QIRString(null, value); } } - newTuple = new QIRTcons(null, Bytes.toString(CellUtil.cloneQualifier(cell)), data, newTuple); + newTuple = new QIRRcons(null, Bytes.toString(CellUtil.cloneQualifier(cell)), data, newTuple); } tmp.push(newTuple); } diff --git a/src/qir/driver/hbase/QIRHBaseQueryVisitor.java b/src/qir/driver/hbase/QIRHBaseQueryVisitor.java index 189c9fb45b5dd5fb40810624c6fe48f386b277a0..5bd5cc90ac799314109fd8e1aef48ffb3ebb36cd 100644 --- a/src/qir/driver/hbase/QIRHBaseQueryVisitor.java +++ b/src/qir/driver/hbase/QIRHBaseQueryVisitor.java @@ -35,12 +35,12 @@ final class QIRHBaseQueryVisitor extends QIRTranslator<HBaseQuery> { @Override public final HBaseQuery visit(QIRProject qirProject) { - if (!(qirProject.getFormatter() instanceof QIRLambda && ((QIRLambda) qirProject.getFormatter()).getBody() instanceof QIRTcons)) + if (!(qirProject.getFormatter() instanceof QIRLambda && ((QIRLambda) qirProject.getFormatter()).getBody() instanceof QIRRcons)) throw new QIRException("QIR HBase Project not implemented for formatter type: " + qirProject.getFormatter().getClass()); final HBaseQuery child = qirProject.getChild().accept(this); - for (QIRNode formatter = ((QIRLambda) qirProject.getFormatter()).getBody(); formatter instanceof QIRTcons; formatter = ((QIRTcons) formatter).getTail()) - child.scan.addColumn("default".getBytes(), ((QIRTcons) formatter).accept(QIRHBaseValueVisitor.instance).getBytes()); + for (QIRNode formatter = ((QIRLambda) qirProject.getFormatter()).getBody(); formatter instanceof QIRRcons; formatter = ((QIRRcons) formatter).getTail()) + child.scan.addColumn("default".getBytes(), ((QIRRcons) formatter).accept(QIRHBaseValueVisitor.instance).getBytes()); return child; } diff --git a/src/qir/driver/hbase/QIRHBaseValueVisitor.java b/src/qir/driver/hbase/QIRHBaseValueVisitor.java index d411c66ad700cc25ebbec155906401086498e5c5..328be06f4cfb89e6602b7f053472d7e88ebb9896 100644 --- a/src/qir/driver/hbase/QIRHBaseValueVisitor.java +++ b/src/qir/driver/hbase/QIRHBaseValueVisitor.java @@ -52,7 +52,7 @@ final class QIRHBaseValueVisitor extends QIRTranslator<String> { } @Override - public final String visit(final QIRTcons qirTcons) { + public final String visit(final QIRRcons qirTcons) { final String value = qirTcons.getValue().accept(this); if (value != qirTcons.getId()) @@ -61,7 +61,7 @@ final class QIRHBaseValueVisitor extends QIRTranslator<String> { } @Override - public final String visit(final QIRTdestr qirTdestr) { + public final String visit(final QIRRdestr qirTdestr) { return qirTdestr.getColName(); } } \ No newline at end of file diff --git a/src/qir/driver/sql/QIRHiveStringVisitor.java b/src/qir/driver/sql/QIRHiveStringVisitor.java index 824b0758935451a7541eecc5a0c19590e76aa13c..0260ae5f796ad813672ab9287e99f01a109a313d 100644 --- a/src/qir/driver/sql/QIRHiveStringVisitor.java +++ b/src/qir/driver/sql/QIRHiveStringVisitor.java @@ -14,7 +14,7 @@ import qir.ast.QIRTruffleNode; import qir.ast.QIRVariable; import qir.ast.data.QIRLcons; import qir.ast.data.QIRLnil; -import qir.ast.data.QIRTdestr; +import qir.ast.data.QIRRdestr; import qir.ast.operator.QIROperator; import qir.util.QIRException; @@ -40,7 +40,7 @@ public class QIRHiveStringVisitor extends QIRSQLStringVisitor { final Map<String, QIRNode> ids = new HashMap<>(); final String lName = ((QIRTruffleNode) fun).getLanguageName(); final String array = args.stream().map(arg -> { - if (arg instanceof QIRVariable || arg instanceof QIRTdestr) + if (arg instanceof QIRVariable || arg instanceof QIRRdestr) return arg.accept(this); final String id = genFreshId(); ids.put(id, arg); @@ -83,7 +83,7 @@ public class QIRHiveStringVisitor extends QIRSQLStringVisitor { } @Override - public final String visit(final QIRTdestr qirTdestr) { + public final String visit(final QIRRdestr qirTdestr) { QIRNode tuple = qirTdestr.getTuple(); if (tuple instanceof QIROperator) diff --git a/src/qir/driver/sql/QIRSQLStringVisitor.java b/src/qir/driver/sql/QIRSQLStringVisitor.java index 35635ba23440f60859df5d7f0833cd80bc621e0b..33f1a42beed765dab369ef4e5da886a01c6f9199 100644 --- a/src/qir/driver/sql/QIRSQLStringVisitor.java +++ b/src/qir/driver/sql/QIRSQLStringVisitor.java @@ -178,7 +178,7 @@ class QIRSQLStringVisitor extends QIRTranslator<String> { final Map<String, QIRNode> ids = new HashMap<>(); final String lName = ((QIRTruffleNode) fun).getLanguageName(); final String array = args.stream().map(arg -> { - if (arg instanceof QIRVariable || arg instanceof QIRTdestr) + if (arg instanceof QIRVariable || arg instanceof QIRRdestr) return lName + ".translateTo" + lName + "(" + arg.accept(this) + ")"; final String id = genFreshId(); ids.put(id, arg); @@ -314,12 +314,12 @@ class QIRSQLStringVisitor extends QIRTranslator<String> { * @param qirTnil Unique instance of the empty tuple in QIR. */ @Override - public final String visit(final QIRTnil qirTnil) { + public final String visit(final QIRRnil qirTnil) { return ""; } @Override - public final String visit(final QIRTcons qirTcons) { + public final String visit(final QIRRcons qirTcons) { final String id = qirTcons.getId(); String value = qirTcons.getValue().accept(this); final String tail = qirTcons.getTail().accept(this); @@ -331,7 +331,7 @@ class QIRSQLStringVisitor extends QIRTranslator<String> { } @Override - public String visit(final QIRTdestr qirTdestr) { + public String visit(final QIRRdestr qirTdestr) { QIRNode tuple = qirTdestr.getTuple(); if (tuple instanceof QIRVariable) diff --git a/src/qir/driver/sql/SQLStringDriver.java b/src/qir/driver/sql/SQLStringDriver.java index d968a4958d7bb7ca260b2dcb006fedb3bba8f3f6..608db88cba80214caa5253bf7fe27628959828ad 100644 --- a/src/qir/driver/sql/SQLStringDriver.java +++ b/src/qir/driver/sql/SQLStringDriver.java @@ -16,9 +16,9 @@ import qir.ast.QIRNode; import qir.ast.data.QIRLcons; import qir.ast.data.QIRList; import qir.ast.data.QIRLnil; -import qir.ast.data.QIRTcons; -import qir.ast.data.QIRTnil; -import qir.ast.data.QIRTuple; +import qir.ast.data.QIRRcons; +import qir.ast.data.QIRRnil; +import qir.ast.data.QIRRecord; import qir.ast.expression.*; import qir.util.QIRException; @@ -36,12 +36,12 @@ abstract class SQLStringDriver extends SQLDriver<String> { try { final Statement stmt = conn.createStatement(); final ResultSet rs = stmt.executeQuery(query); - final Deque<QIRTuple> tmp = new ArrayDeque<>(); + final Deque<QIRRecord> tmp = new ArrayDeque<>(); QIRList result = QIRLnil.getInstance(); QIRNode data; while (rs.next()) { - QIRTuple newTuple = QIRTnil.getInstance(); + QIRRecord newTuple = QIRRnil.getInstance(); for (int i = rs.getMetaData().getColumnCount(); i >= 1; i--) { int type = rs.getMetaData().getColumnType(i); switch (type) { @@ -89,7 +89,7 @@ abstract class SQLStringDriver extends SQLDriver<String> { data = new QIRString(null, rs.getString(i)); break; } - newTuple = new QIRTcons(null, rs.getMetaData().getColumnLabel(i).replaceFirst(".*\\.", ""), data, newTuple); + newTuple = new QIRRcons(null, rs.getMetaData().getColumnLabel(i).replaceFirst(".*\\.", ""), data, newTuple); } tmp.push(newTuple); }