Skip to content

Instantly share code, notes, and snippets.

@julianhyde
Created April 21, 2014 18:18
Show Gist options
  • Save julianhyde/11151386 to your computer and use it in GitHub Desktop.
Save julianhyde/11151386 to your computer and use it in GitHub Desktop.
Invalid java code generated by Optiq for TPC-H query 14
public static class Record4_0 implements java.io.Serializable {
public Double f0;
public long f1;
public Double f2;
public long f3;
public Record4_0(Double f0, long f1, Double f2, long f3) {
this.f0 = f0;
this.f1 = f1;
this.f2 = f2;
this.f3 = f3;
}
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (!(o instanceof Record4_0)) {
return false;
}
return net.hydromatic.optiq.runtime.Utilities.equal(this.f0, ((Record4_0) o).f0) && this.f1 == ((Record4_0) o).f1 && net.hydromatic.optiq.runtime.Utilities.equal(this.f2, ((Record4_0) o).f2) && this.f3 == ((Record4_0) o).f3;
}
public int hashCode() {
int h = 0;
h = net.hydromatic.optiq.runtime.Utilities.hash(h, this.f0);
h = net.hydromatic.optiq.runtime.Utilities.hash(h, this.f1);
h = net.hydromatic.optiq.runtime.Utilities.hash(h, this.f2);
h = net.hydromatic.optiq.runtime.Utilities.hash(h, this.f3);
return h;
}
public int compareTo(Record4_0 that) {
int c;
c = net.hydromatic.optiq.runtime.Utilities.compareNullsLast(this.f0, that.f0);
if (c != 0) {
return c;
}
c = net.hydromatic.optiq.runtime.Utilities.compare(this.f1, that.f1);
if (c != 0) {
return c;
}
c = net.hydromatic.optiq.runtime.Utilities.compareNullsLast(this.f2, that.f2);
if (c != 0) {
return c;
}
c = net.hydromatic.optiq.runtime.Utilities.compare(this.f3, that.f3);
if (c != 0) {
return c;
}
return 0;
}
public String toString() {
return "{f0=" + this.f0 + ", f1=" + this.f1 + ", f2=" + this.f2 + ", f3=" + this.f3 + "}";
}
}
net.hydromatic.optiq.DataContext root;
public net.hydromatic.linq4j.Enumerable bind(final net.hydromatic.optiq.DataContext root0) {
root = root0;
final net.hydromatic.linq4j.Enumerable _inputEnumerable = net.hydromatic.optiq.Schemas.queryable(root, root.getRootSchema().getSubSchema("TPCH_01"), java.lang.Object[].class, "PART").asEnumerable();
final net.hydromatic.linq4j.AbstractEnumerable left = new net.hydromatic.linq4j.AbstractEnumerable(){
public net.hydromatic.linq4j.Enumerator enumerator() {
return new net.hydromatic.linq4j.Enumerator(){
public final net.hydromatic.linq4j.Enumerator inputEnumerator = _inputEnumerable.enumerator();
public void reset() {
inputEnumerator.reset();
}
public boolean moveNext() {
return inputEnumerator.moveNext();
}
public void close() {
inputEnumerator.close();
}
public Object current() {
final Object[] current = (Object[]) inputEnumerator.current();
return new Object[] {
(Long) current[0],
current[4] == null ? (String) null : current[4].toString()};
}
};
}
};
final net.hydromatic.linq4j.Enumerable _inputEnumerable0 = net.hydromatic.optiq.Schemas.queryable(root, root.getRootSchema().getSubSchema("TPCH_01"), java.lang.Object[].class, "LINEITEM").asEnumerable();
final net.hydromatic.linq4j.AbstractEnumerable right = new net.hydromatic.linq4j.AbstractEnumerable(){
public net.hydromatic.linq4j.Enumerator enumerator() {
return new net.hydromatic.linq4j.Enumerator(){
public final net.hydromatic.linq4j.Enumerator inputEnumerator = _inputEnumerable0.enumerator();
public void reset() {
inputEnumerator.reset();
}
public boolean moveNext() {
while (inputEnumerator.moveNext()) {
final java.sql.Date inp10_ = (java.sql.Date) ((Object[]) inputEnumerator.current())[10];
final int v = net.hydromatic.optiq.runtime.SqlFunctions.toInt(inp10_);
if (inp10_ != null && v >= 8978 && (inp10_ != null && v < $L4J$C$8978_1)) {
return true;
}
}
return false;
}
public void close() {
inputEnumerator.close();
}
public Object current() {
final Object[] current = (Object[]) inputEnumerator.current();
return new Object[] {
(Long) current[1],
(Double) current[5],
(Double) current[6],
(java.sql.Date) current[10]};
}
static final int $L4J$C$8978_1 = $L4J$C$8978_1;
};
}
};
final net.hydromatic.linq4j.Enumerable _inputEnumerable1 = left.join(right, new net.hydromatic.linq4j.function.Function1() {
public Long apply(Object[] v1) {
return (Long) v1[0];
}
public Object apply(Object v1) {
return apply(
(Object[]) v1);
}
}
, new net.hydromatic.linq4j.function.Function1() {
public Long apply(Object[] v1) {
return (Long) v1[0];
}
public Object apply(Object v1) {
return apply(
(Object[]) v1);
}
}
, new net.hydromatic.linq4j.function.Function2() {
public Object[] apply(Object[] left, Object[] right) {
return new Object[] {
left[0],
left[1] == null ? (String) null : left[1].toString(),
right[0],
right[1],
right[2],
right[3]};
}
public Object[] apply(Object left, Object right) {
return apply(
(Object[]) left,
(Object[]) right);
}
}
);
final net.hydromatic.linq4j.AbstractEnumerable child = new net.hydromatic.linq4j.AbstractEnumerable(){
public net.hydromatic.linq4j.Enumerator enumerator() {
return new net.hydromatic.linq4j.Enumerator(){
public final net.hydromatic.linq4j.Enumerator inputEnumerator = _inputEnumerable1.enumerator();
public void reset() {
inputEnumerator.reset();
}
public boolean moveNext() {
return inputEnumerator.moveNext();
}
public void close() {
inputEnumerator.close();
}
public Object current() {
final Object[] current = (Object[]) inputEnumerator.current();
final Double inp3_ = (Double) current[3];
final Double inp4_ = (Double) current[4];
final String inp1_ = current[1] == null ? (String) null : current[1].toString();
return new Object[] {
inp1_ != null && net.hydromatic.optiq.runtime.SqlFunctions.like(inp1_, "PROMO%") ? (inp3_ == null || inp4_ == null ? (Double) null : Double.valueOf(inp3_.doubleValue() * (1.0D - inp4_.doubleValue()))) : Double.valueOf(0.0D),
inp3_ == null || inp4_ == null ? (Double) null : Double.valueOf(inp3_.doubleValue() * (1.0D - inp4_.doubleValue()))};
}
};
}
};
final net.hydromatic.linq4j.Enumerable _inputEnumerable2 = net.hydromatic.linq4j.Linq4j.singletonEnumerable(child.aggregate(new net.hydromatic.linq4j.function.Function0() {
public Object apply() {
return new Record4_0(
Double.valueOf(0.0D),
0L,
Double.valueOf(0.0D),
0L);
}
}
.apply(), new net.hydromatic.linq4j.function.Function2() {
public Record4_0 apply(Record4_0 acc, Object[] in) {
if ((Double) in[0] != null) {
acc.f0 = acc.f0 + (Double) in[0];
}
if ((Double) in[0] != null) {
acc.f1 = acc.f1 + 1L;
}
if ((Double) in[1] != null) {
acc.f2 = acc.f2 + (Double) in[1];
}
if ((Double) in[1] != null) {
acc.f3 = acc.f3 + 1L;
}
return acc;
}
public Record4_0 apply(Object acc, Object in) {
return apply(
(Record4_0) acc,
(Object[]) in);
}
}
, new net.hydromatic.linq4j.function.Function1() {
public Object[] apply(Record4_0 acc) {
return new Object[] {
acc.f0,
acc.f1,
acc.f2,
acc.f3};
}
public Object apply(Object acc) {
return apply(
(Record4_0) acc);
}
}
));
return new net.hydromatic.linq4j.AbstractEnumerable(){
public net.hydromatic.linq4j.Enumerator enumerator() {
return new net.hydromatic.linq4j.Enumerator(){
public final net.hydromatic.linq4j.Enumerator inputEnumerator = _inputEnumerable2.enumerator();
public void reset() {
inputEnumerator.reset();
}
public boolean moveNext() {
return inputEnumerator.moveNext();
}
public void close() {
inputEnumerator.close();
}
public Object current() {
final Object[] current = (Object[]) inputEnumerator.current();
final Double inp0_ = (Double) current[0];
final Double inp2_ = (Double) current[2];
return net.hydromatic.optiq.runtime.SqlFunctions.toLong(current[1]) == 0L || inp0_ == null || (net.hydromatic.optiq.runtime.SqlFunctions.toLong(current[3]) == 0L || inp2_ == null) ? (Double) null : Double.valueOf($L4J$C$net_hydromatic_optiq_runtime_SqlFunctions_toDouble_new_java_mat2df88c74 * inp0_.doubleValue() / inp2_.doubleValue());
}
static final java.math.BigDecimal $L4J$C$new_java_math_BigDecimal_100_00_ = new java.math.BigDecimal(
"100.00");
static final double $L4J$C$net_hydromatic_optiq_runtime_SqlFunctions_toDouble_new_java_mat2df88c74 = net.hydromatic.optiq.runtime.SqlFunctions.toDouble($L4J$C$new_java_math_BigDecimal_100_00_);
};
}
};
}
public java.lang.reflect.Type getElementType() {
return java.lang.Double.class;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment