1 23 24 package org.objectweb.medor.query.lib; 25 26 import org.objectweb.medor.api.Field; 27 import org.objectweb.medor.api.MedorException; 28 import org.objectweb.medor.expression.api.Expression; 29 import org.objectweb.medor.query.api.OperationType; 30 import org.objectweb.medor.query.api.QueryTree; 31 import org.objectweb.medor.query.api.QueryTreeField; 32 33 37 public class Cartesian extends BasicQueryNode { 38 public Cartesian() { 39 } 40 41 46 public Cartesian(QueryTree leftQT, 47 QueryTree rightQT, 48 String name) { 49 super(name); 50 Field[] leftFields = leftQT.getTupleStructure().getFields(); 52 Field[] rightFields = rightQT.getTupleStructure().getFields(); 53 try { 54 55 for (int i = 0; i < leftFields.length; i++) { 56 this.addPropagatedField( 57 leftFields[i].getName(), 58 leftFields[i].getType(), 59 new QueryTreeField[]{(QueryTreeField) leftFields[i]}); 60 } 61 for (int i = 0; i < rightFields.length; i++) { 62 this.addPropagatedField( 63 rightFields[i].getName(), 64 rightFields[i].getType(), 65 new QueryTreeField[]{(QueryTreeField) rightFields[i]}); 66 } 67 } 68 catch (MedorException e) { 69 } 70 int lsize = leftQT.getTupleStructure().getSize(); 72 int rsize = rightQT.getTupleStructure().getSize(); 73 indexes = new int[lsize + rsize]; 74 75 for (int i = 1; (i <= lsize); i++) { 76 indexes[i - 1] = i; 77 } 78 for (int i = lsize + 1; (i <= (lsize + rsize)); i++) { 79 indexes[i - 1] = i; 80 } 81 } 82 83 86 public void setQueryFilter(Expression f) { 87 throw new UnsupportedOperationException ("Cartesian products cannot be assigned a filter."); 88 } 89 90 public short getType() { 91 return OperationType.CARTESIAN; 92 } 93 } 94 | Popular Tags |