Review Board 1.7.22


remove redundant copy of arithmetic filter unit test testColOpScalarNumericFilterNullAndRepeatingLogic

Review Request #10906 - Created May 2, 2013 and updated

Eric Hanson
vectorization
HIVE-4477
Reviewers
hive
hive-git
remove redundant copy of arithmetic filter unit test testColOpScalarNumericFilterNullAndRepeatingLogic

 
ql/src/test/org/apache/hadoop/hive/ql/exec/vector/TestVectorFilterOperator.java
Revision 3ad6c7f New Change
[20] 26 lines
[+20]
27
import org.apache.hadoop.hive.ql.exec.vector.expressions.gen.FilterLongColGreaterLongScalar;
27
import org.apache.hadoop.hive.ql.exec.vector.expressions.gen.FilterLongColGreaterLongScalar;
28
import org.apache.hadoop.hive.ql.metadata.HiveException;
28
import org.apache.hadoop.hive.ql.metadata.HiveException;
29
import org.junit.Test;
29
import org.junit.Test;
30

    
   
30

   
31
public class TestVectorFilterOperator {
31
public class TestVectorFilterOperator {

    
   
32
  

    
   
33
  /*

    
   
34
   * Fundamental logic and performance tests for vector filters belong here.

    
   
35
   * 

    
   
36
   * For tests about filters to cover specific operator and data type combinations,

    
   
37
   * see also the other filter tests under org.apache.hadoop.hive.ql.exec.vector.expressions

    
   
38
   */
32

    
   
39

   
33
  public static class FakeDataReader {
40
  public static class FakeDataReader {
34
    int size;
41
    int size;
35
    VectorizedRowBatch vrg;
42
    VectorizedRowBatch vrg;
36
    int currentSize = 0;
43
    int currentSize = 0;
37
    private final int numCols;
44
    private final int numCols;
38
    private final int len = 1024;
45
    private final int len = 1024;
39

    
   
46

   
40
    public FakeDataReader(int size, int numCols) {
47
    public FakeDataReader(int size, int numCols) {
41
      this.size = size;
48
      this.size = size;
42
      this.numCols = numCols;
49
      this.numCols = numCols;
43
      vrg = new VectorizedRowBatch(numCols, len);
50
      vrg = new VectorizedRowBatch(numCols, len);
44
      for (int i =0; i < numCols; i++) {
51
      for (int i = 0; i < numCols; i++) {
45
        try {
52
        try {
46
          Thread.sleep(2);
53
          Thread.sleep(2);
47
        } catch (InterruptedException e) {
54
        } catch (InterruptedException e) {
48

    
   
55

   
49
        }
56
        }
[+20] [20] 84 lines
[+20] [+] public void testBasicFilterLargeData() throws HiveException {
134
        }
141
        }
135
      }
142
      }
136
    }
143
    }
137
    long endTime1 = System.currentTimeMillis();
144
    long endTime1 = System.currentTimeMillis();
138
    System.out.println("testBaseFilterOperator base Op Time = "+(endTime1-startTime1));
145
    System.out.println("testBaseFilterOperator base Op Time = "+(endTime1-startTime1));
139

    
   

   
140
  }

   
141

    
   

   
142
  static VectorizedRowBatch getSimpleLongBatch()

   
143
  {

   
144
    VectorizedRowBatch batch = new VectorizedRowBatch(1);

   
145
    LongColumnVector lcv = new LongColumnVector();

   
146
    batch.cols[0] = lcv;

   
147
    long[] v = lcv.vector;

   
148

    
   

   
149
    v[0] = 0;

   
150
    v[1] = 1;

   
151
    v[2] = 2;

   
152
    v[3] = 3;

   
153
    batch.size = 4;

   
154

    
   

   
155
    return batch;

   
156
  }
146
  }
157

    
   

   
158
  @Test

   
159
  public void testColOpScalarNumericFilterNullAndRepeatingLogic()

   
160
  {

   
161
    // No nulls, not repeating

   
162
    FilterLongColGreaterLongScalar f = new FilterLongColGreaterLongScalar(0, 1); // col > 1

   
163
    VectorizedRowBatch batch = getSimpleLongBatch();

   
164
    batch.cols[0].noNulls = true;

   
165
    batch.cols[0].isRepeating = false;

   
166
    f.evaluate(batch);

   
167
    // only last 2 rows qualify

   
168
    Assert.assertEquals(2, batch.size);

   
169
    // show that their positions are recorded

   
170
    Assert.assertTrue(batch.selectedInUse);

   
171
    Assert.assertEquals(2, batch.selected[0]);

   
172
    Assert.assertEquals(3, batch.selected[1]);

   
173

    
   

   
174
    // make everything qualify and ensure selected is not in use

   
175
    f = new FilterLongColGreaterLongScalar(0, -1); // col > -1

   
176
    batch = getSimpleLongBatch();

   
177
    f.evaluate(batch);

   
178
    Assert.assertFalse(batch.selectedInUse);

   
179
    Assert.assertEquals(4, batch.size);

   
180

    
   

   
181
    // has nulls, not repeating

   
182
    batch = getSimpleLongBatch();

   
183
    f = new FilterLongColGreaterLongScalar(0, 1); // col > 1

   
184
    batch.cols[0].noNulls = false;

   
185
    batch.cols[0].isRepeating = false;

   
186
    batch.cols[0].isNull[3] = true;

   
187
    f.evaluate(batch);

   
188
    Assert.assertTrue(batch.selectedInUse);

   
189
    Assert.assertEquals(1, batch.size);

   
190
    Assert.assertEquals(2, batch.selected[0]);

   
191

    
   

   
192
    // no nulls, is repeating

   
193
    batch = getSimpleLongBatch();

   
194
    f = new FilterLongColGreaterLongScalar(0, -1); // col > -1

   
195
    batch.cols[0].noNulls = true;

   
196
    batch.cols[0].isRepeating = true;

   
197
    f.evaluate(batch);

   
198
    Assert.assertFalse(batch.selectedInUse);

   
199
    Assert.assertEquals(4, batch.size); // everything qualifies (4 rows, all with value -1)

   
200

    
   

   
201
    // has nulls, is repeating

   
202
    batch = getSimpleLongBatch();

   
203
    batch.cols[0].noNulls = false;

   
204
    batch.cols[0].isRepeating = true;

   
205
    batch.cols[0].isNull[0] = true;

   
206
    f.evaluate(batch);

   
207
    Assert.assertEquals(0, batch.size); // all values are null so none qualify

   
208
  }

   
209

    
   

   
210
}
147
}
211

    
   
148

   
  1. ql/src/test/org/apache/hadoop/hive/ql/exec/vector/TestVectorFilterOperator.java: Loading...