/
ColumnarVectorWrapperDirectWithInvertedIndex.java
163 lines (134 loc) · 4.7 KB
/
ColumnarVectorWrapperDirectWithInvertedIndex.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.carbondata.core.scan.result.vector.impl.directread;
import java.math.BigDecimal;
import org.apache.carbondata.core.metadata.datatype.DataType;
import org.apache.carbondata.core.scan.result.vector.CarbonColumnVector;
/**
* Column vector for column pages which has inverted index, so it uses inverted index
* before filling to actual vector
*/
public class ColumnarVectorWrapperDirectWithInvertedIndex extends AbstractCarbonColumnarVector {
protected int[] invertedIndex;
protected boolean isnullBitsExists;
public ColumnarVectorWrapperDirectWithInvertedIndex(CarbonColumnVector columnVector,
int[] invertedIndex, boolean isnullBitsExists) {
super(columnVector);
this.invertedIndex = invertedIndex;
this.isnullBitsExists = isnullBitsExists;
}
@Override
public void putBoolean(int rowId, boolean value) {
columnVector.putBoolean(invertedIndex[rowId], value);
}
@Override
public void putFloat(int rowId, float value) {
columnVector.putFloat(invertedIndex[rowId], value);
}
@Override
public void putShort(int rowId, short value) {
columnVector.putShort(invertedIndex[rowId], value);
}
@Override
public void putInt(int rowId, int value) {
columnVector.putInt(invertedIndex[rowId], value);
}
@Override
public void putLong(int rowId, long value) {
columnVector.putLong(invertedIndex[rowId], value);
}
@Override
public void putDecimal(int rowId, BigDecimal value, int precision) {
columnVector.putDecimal(invertedIndex[rowId], value, precision);
}
@Override
public void putDouble(int rowId, double value) {
columnVector.putDouble(invertedIndex[rowId], value);
}
@Override
public void putByteArray(int rowId, byte[] value) {
columnVector.putByteArray(invertedIndex[rowId], value);
}
@Override
public void putByteArray(int rowId, int offset, int length, byte[] value) {
columnVector.putByteArray(invertedIndex[rowId], offset, length, value);
}
@Override
public void putByte(int rowId, byte value) {
columnVector.putByte(invertedIndex[rowId], value);
}
@Override
public void putNull(int rowId) {
if (isnullBitsExists) {
columnVector.putNull(rowId);
} else {
columnVector.putNull(invertedIndex[rowId]);
}
}
@Override
public void putNotNull(int rowId) {
// nothing to do
}
@Override
public void setCarbonDataFileWrittenVersion(String carbonDataFileWrittenVersion) {
this.columnVector.setCarbonDataFileWrittenVersion(carbonDataFileWrittenVersion);
}
@Override
public void putFloats(int rowId, int count, float[] src, int srcIndex) {
for (int i = srcIndex; i < count; i++) {
columnVector.putFloat(invertedIndex[rowId++], src[i]);
}
}
@Override
public void putShorts(int rowId, int count, short[] src, int srcIndex) {
for (int i = srcIndex; i < count; i++) {
columnVector.putShort(invertedIndex[rowId++], src[i]);
}
}
@Override
public void putInts(int rowId, int count, int[] src, int srcIndex) {
for (int i = srcIndex; i < count; i++) {
columnVector.putInt(invertedIndex[rowId++], src[i]);
}
}
@Override
public void putLongs(int rowId, int count, long[] src, int srcIndex) {
for (int i = srcIndex; i < count; i++) {
columnVector.putLong(invertedIndex[rowId++], src[i]);
}
}
@Override
public void putDoubles(int rowId, int count, double[] src, int srcIndex) {
for (int i = srcIndex; i < count; i++) {
columnVector.putDouble(invertedIndex[rowId++], src[i]);
}
}
@Override
public void putBytes(int rowId, int count, byte[] src, int srcIndex) {
for (int i = srcIndex; i < count; i++) {
columnVector.putByte(invertedIndex[rowId++], src[i]);
}
}
@Override
public DataType getBlockDataType() {
return columnVector.getBlockDataType();
}
@Override
public void putArray(int rowId, int offset, int length) {
columnVector.putArray(invertedIndex[rowId], offset, length);
}
}