MySQL 5.6.14 Source Code Document
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
QueryBigIntegerTypesTest.java
1 /*
2  Copyright 2010 Sun Microsystems, Inc.
3  All rights reserved. Use is subject to license terms.
4 
5  This program is free software; you can redistribute it and/or modify
6  it under the terms of the GNU General Public License as published by
7  the Free Software Foundation; version 2 of the License.
8 
9  This program is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  GNU General Public License for more details.
13 
14  You should have received a copy of the GNU General Public License
15  along with this program; if not, write to the Free Software
16  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
17 */
18 
19 package testsuite.clusterj;
20 
21 import java.math.BigDecimal;
22 import java.math.BigInteger;
23 
24 import testsuite.clusterj.model.BigIntegerTypes;
25 import testsuite.clusterj.model.IdBase;
26 
28 
29  @Override
30  public Class getInstanceType() {
31  return BigIntegerTypes.class;
32  }
33 
34  @Override
35  void createInstances(int number) {
36  createAllBigIntegerTypesInstances(number);
37  }
38 
61  public void test() {
62  btreeIndexScanDecimal();
63  hashIndexScanDecimal();
64  bothIndexScanDecimal();
65  noneIndexScanDecimal();
66  failOnError();
67  }
68 
69  public void btreeIndexScanDecimal() {
70  equalQuery("decimal_null_btree", "idx_decimal_null_btree", getBigInteger(8), 8);
71  greaterEqualQuery("decimal_null_btree", "idx_decimal_null_btree", getBigInteger(7), 7, 8, 9);
72  greaterThanQuery("decimal_null_btree", "idx_decimal_null_btree", getBigInteger(6), 7, 8, 9);
73  lessEqualQuery("decimal_null_btree", "idx_decimal_null_btree", getBigInteger(4), 4, 3, 2, 1, 0);
74  lessThanQuery("decimal_null_btree", "idx_decimal_null_btree", getBigInteger(4), 3, 2, 1, 0);
75  betweenQuery("decimal_null_btree", "idx_decimal_null_btree", getBigInteger(4), getBigInteger(6), 4, 5, 6);
76  greaterEqualAndLessEqualQuery("decimal_null_btree", "idx_decimal_null_btree", getBigInteger(4), getBigInteger(6), 4, 5, 6);
77  greaterThanAndLessEqualQuery("decimal_null_btree", "idx_decimal_null_btree", getBigInteger(4), getBigInteger(6), 5, 6);
78  greaterEqualAndLessThanQuery("decimal_null_btree", "idx_decimal_null_btree", getBigInteger(4), getBigInteger(6), 4, 5);
79  greaterThanAndLessThanQuery("decimal_null_btree", "idx_decimal_null_btree", getBigInteger(4), getBigInteger(6), 5);
80  }
81 
82  public void hashIndexScanDecimal() {
83  equalQuery("decimal_null_hash", "idx_decimal_null_hash", getBigInteger(8), 8);
84  greaterEqualQuery("decimal_null_hash", "none", getBigInteger(7), 7, 8, 9);
85  greaterThanQuery("decimal_null_hash", "none", getBigInteger(6), 7, 8, 9);
86  lessEqualQuery("decimal_null_hash", "none", getBigInteger(4), 4, 3, 2, 1, 0);
87  lessThanQuery("decimal_null_hash", "none", getBigInteger(4), 3, 2, 1, 0);
88  betweenQuery("decimal_null_hash", "none", getBigInteger(4), getBigInteger(6), 4, 5, 6);
89  greaterEqualAndLessEqualQuery("decimal_null_hash", "none", getBigInteger(4), getBigInteger(6), 4, 5, 6);
90  greaterThanAndLessEqualQuery("decimal_null_hash", "none", getBigInteger(4), getBigInteger(6), 5, 6);
91  greaterEqualAndLessThanQuery("decimal_null_hash", "none", getBigInteger(4), getBigInteger(6), 4, 5);
92  greaterThanAndLessThanQuery("decimal_null_hash", "none", getBigInteger(4), getBigInteger(6), 5);
93  }
94 
95  public void bothIndexScanDecimal() {
96  equalQuery("decimal_null_both", "idx_decimal_null_both", getBigInteger(8), 8);
97  greaterEqualQuery("decimal_null_both", "idx_decimal_null_both", getBigInteger(7), 7, 8, 9);
98  greaterThanQuery("decimal_null_both", "idx_decimal_null_both", getBigInteger(6), 7, 8, 9);
99  lessEqualQuery("decimal_null_both", "idx_decimal_null_both", getBigInteger(4), 4, 3, 2, 1, 0);
100  lessThanQuery("decimal_null_both", "idx_decimal_null_both", getBigInteger(4), 3, 2, 1, 0);
101  betweenQuery("decimal_null_both", "idx_decimal_null_both", getBigInteger(4), getBigInteger(6), 4, 5, 6);
102  greaterEqualAndLessEqualQuery("decimal_null_both", "idx_decimal_null_both", getBigInteger(4), getBigInteger(6), 4, 5, 6);
103  greaterThanAndLessEqualQuery("decimal_null_both", "idx_decimal_null_both", getBigInteger(4), getBigInteger(6), 5, 6);
104  greaterEqualAndLessThanQuery("decimal_null_both", "idx_decimal_null_both", getBigInteger(4), getBigInteger(6), 4, 5);
105  greaterThanAndLessThanQuery("decimal_null_both", "idx_decimal_null_both", getBigInteger(4), getBigInteger(6), 5);
106  }
107 
108  public void noneIndexScanDecimal() {
109  equalQuery("decimal_null_none", "none", getBigInteger(8), 8);
110  greaterEqualQuery("decimal_null_none", "none", getBigInteger(7), 7, 8, 9);
111  greaterThanQuery("decimal_null_none", "none", getBigInteger(6), 7, 8, 9);
112  lessEqualQuery("decimal_null_none", "none", getBigInteger(4), 4, 3, 2, 1, 0);
113  lessThanQuery("decimal_null_none", "none", getBigInteger(4), 3, 2, 1, 0);
114  betweenQuery("decimal_null_none", "none", getBigInteger(4), getBigInteger(6), 4, 5, 6);
115  greaterEqualAndLessEqualQuery("decimal_null_none", "none", getBigInteger(4), getBigInteger(6), 4, 5, 6);
116  greaterThanAndLessEqualQuery("decimal_null_none", "none", getBigInteger(4), getBigInteger(6), 5, 6);
117  greaterEqualAndLessThanQuery("decimal_null_none", "none", getBigInteger(4), getBigInteger(6), 4, 5);
118  greaterThanAndLessThanQuery("decimal_null_none", "none", getBigInteger(4), getBigInteger(6), 5);
119  }
120 
121 
122  private void createAllBigIntegerTypesInstances(int number) {
123  for (int i = 0; i < number; ++i) {
124  BigIntegerTypes instance = session.newInstance(BigIntegerTypes.class);
125  instance.setId(i);
126  instance.setDecimal_null_hash(getBigInteger(i));
127  instance.setDecimal_null_btree(getBigInteger(i));
128  instance.setDecimal_null_both(getBigInteger(i));
129  instance.setDecimal_null_none(getBigInteger(i));
130  instances.add(instance);
131  }
132  }
133 
139  protected BigInteger getBigInteger(int number) {
140  return BigInteger.valueOf(number * 10000);
141  }
142 
147  @Override
148  protected void printResultInstance(IdBase instance) {
149  if (instance instanceof BigIntegerTypes) {
150  BigIntegerTypes bigIntegerTypes = (BigIntegerTypes)instance;
151 // System.out.println(toString(bigIntegerTypes));
152  }
153  }
154 
155  public static String toString(IdBase idBase) {
156  BigIntegerTypes instance = (BigIntegerTypes)idBase;
157  StringBuffer buffer = new StringBuffer("BigIntegerTypes id: ");
158  buffer.append(instance.getId());
159  buffer.append("; decimal_null_both: ");
160  buffer.append(instance.getDecimal_null_both().toString());
161  buffer.append("; decimal_null_btree: ");
162  buffer.append(instance.getDecimal_null_btree().toString());
163  buffer.append("; decimal_null_hash: ");
164  buffer.append(instance.getDecimal_null_hash().toString());
165  buffer.append("; decimal_null_none: ");
166  buffer.append(instance.getDecimal_null_none().toString());
167  return buffer.toString();
168  }
169 }