(TransactionId tid, ZExpression wx, LogicalPlan lp)
| 49 | } |
| 50 | |
| 51 | void processExpression(TransactionId tid, ZExpression wx, LogicalPlan lp) |
| 52 | throws simpledb.ParsingException, IOException, ParseException { |
| 53 | if (wx.getOperator().equals("AND")) { |
| 54 | for (int i = 0; i < wx.nbOperands(); i++) { |
| 55 | if (!(wx.getOperand(i) instanceof ZExpression)) { |
| 56 | throw new simpledb.ParsingException( |
| 57 | "Nested queries are currently unsupported."); |
| 58 | } |
| 59 | ZExpression newWx = (ZExpression) wx.getOperand(i); |
| 60 | processExpression(tid, newWx, lp); |
| 61 | |
| 62 | } |
| 63 | } else if (wx.getOperator().equals("OR")) { |
| 64 | throw new simpledb.ParsingException( |
| 65 | "OR expressions currently unsupported."); |
| 66 | } else { |
| 67 | // this is a binary expression comparing two constants |
| 68 | @SuppressWarnings("unchecked") |
| 69 | List<ZExp> ops = wx.getOperands(); |
| 70 | if (ops.size() != 2) { |
| 71 | throw new simpledb.ParsingException( |
| 72 | "Only simple binary expresssions of the form A op B are currently supported."); |
| 73 | } |
| 74 | |
| 75 | boolean isJoin = false; |
| 76 | Predicate.Op op = getOp(wx.getOperator()); |
| 77 | |
| 78 | boolean op1const = ops.get(0) instanceof ZConstant; // otherwise |
| 79 | // is a |
| 80 | // Query |
| 81 | boolean op2const = ops.get(1) instanceof ZConstant; // otherwise |
| 82 | // is a |
| 83 | // Query |
| 84 | if (op1const && op2const) { |
| 85 | isJoin = ((ZConstant) ops.get(0)).getType() == ZConstant.COLUMNNAME |
| 86 | && ((ZConstant) ops.get(1)).getType() == ZConstant.COLUMNNAME; |
| 87 | } else if (ops.get(0) instanceof ZQuery |
| 88 | || ops.get(1) instanceof ZQuery) { |
| 89 | isJoin = true; |
| 90 | } else if (ops.get(0) instanceof ZExpression |
| 91 | || ops.get(1) instanceof ZExpression) { |
| 92 | throw new simpledb.ParsingException( |
| 93 | "Only simple binary expresssions of the form A op B are currently supported, where A or B are fields, constants, or subqueries."); |
| 94 | } else |
| 95 | isJoin = false; |
| 96 | |
| 97 | if (isJoin) { // join node |
| 98 | |
| 99 | String tab1field = "", tab2field = ""; |
| 100 | |
| 101 | if (!op1const) { // left op is a nested query |
| 102 | // generate a virtual table for the left op |
| 103 | // this isn't a valid ZQL query |
| 104 | } else { |
| 105 | tab1field = ((ZConstant) ops.get(0)).getValue(); |
| 106 | |
| 107 | } |
| 108 |
no test coverage detected