@@ -35,7 +35,8 @@ inline int64_t getFieldOffset(int64_t nullBitsetWidthInBytes, int32_t index) {
35
35
inline bool isNull (uint8_t * buffer_address, int32_t index) {
36
36
int64_t mask = 1L << (index & 0x3f ); // mod 64 and shift
37
37
int64_t wordOffset = (index >> 6 ) * 8 ;
38
- int64_t value = *((int64_t *)(buffer_address + wordOffset));
38
+ int64_t * valuePtr = buffer_address + wordOffset;
39
+ int64_t value = *static_cast <int64_t *>(valuePtr);
39
40
return (value & mask) != 0 ;
40
41
}
41
42
@@ -51,7 +52,8 @@ int32_t getTotalStringSize(
51
52
continue ;
52
53
}
53
54
54
- int64_t offsetAndSize = *(int64_t *)(memoryAddress + offsets[pos] + fieldOffset);
55
+ int64_t * offsetAndSizePtr = reinterpret_cast <int64_t *>(memoryAddress + offsets[pos] + fieldOffset);
56
+ int64_t offsetAndSize = *(offsetAndSizePtr);
55
57
int32_t length = static_cast <int32_t >(offsetAndSize);
56
58
if (!StringView::isInline (length)) {
57
59
size += length;
@@ -98,11 +100,12 @@ VectorPtr createFlatVector<TypeKind::HUGEINT>(
98
100
auto column = BaseVector::create<FlatVector<int128_t >>(type, numRows, pool);
99
101
auto rawValues = column->mutableRawValues <uint8_t >();
100
102
auto typeWidth = sizeof (int128_t );
101
- auto shift = __builtin_ctz (( uint32_t ) typeWidth);
103
+ auto shift = __builtin_ctz (static_cast < uint32_t >( typeWidth) );
102
104
for (auto pos = 0 ; pos < numRows; pos++) {
103
105
if (!isNull (memoryAddress + offsets[pos], columnIdx)) {
104
106
uint8_t * destptr = rawValues + (pos << shift);
105
- int64_t offsetAndSize = *(int64_t *)(memoryAddress + offsets[pos] + fieldOffset);
107
+ int64_t * offsetAndSizePtr = reinterpret_cast <int64_t *>(memoryAddress + offsets[pos] + fieldOffset);
108
+ int64_t offsetAndSize = *offsetAndSizePtr;
106
109
int32_t length = static_cast <int32_t >(offsetAndSize);
107
110
int32_t wordoffset = static_cast <int32_t >(offsetAndSize >> 32 );
108
111
uint8_t bytesValue[length];
@@ -111,7 +114,7 @@ VectorPtr createFlatVector<TypeKind::HUGEINT>(
111
114
for (int k = length - 1 ; k >= 0 ; k--) {
112
115
bytesValue2[length - 1 - k] = bytesValue[k];
113
116
}
114
- if (int8_t (bytesValue[0 ]) < 0 ) {
117
+ if (static_cast < int8_t > (bytesValue[0 ]) < 0 ) {
115
118
memset (bytesValue2 + length, 255 , 16 - length);
116
119
}
117
120
memcpy (destptr, bytesValue2, typeWidth);
@@ -135,7 +138,8 @@ VectorPtr createFlatVector<TypeKind::BOOLEAN>(
135
138
auto rawValues = column->mutableRawValues <uint64_t >();
136
139
for (auto pos = 0 ; pos < numRows; pos++) {
137
140
if (!isNull (memoryAddress + offsets[pos], columnIdx)) {
138
- bool value = *(bool *)(memoryAddress + offsets[pos] + fieldOffset);
141
+ bool * valuePtr = reinterpret_cast <bool *>(memoryAddress + offsets[pos] + fieldOffset);
142
+ bool value = *valuePtr;
139
143
bits::setBit (rawValues, pos, value);
140
144
} else {
141
145
column->setNull (pos, true );
@@ -156,7 +160,8 @@ VectorPtr createFlatVector<TypeKind::TIMESTAMP>(
156
160
auto column = BaseVector::create<FlatVector<Timestamp>>(type, numRows, pool);
157
161
for (auto pos = 0 ; pos < numRows; pos++) {
158
162
if (!isNull (memoryAddress + offsets[pos], columnIdx)) {
159
- int64_t value = *(int64_t *)(memoryAddress + offsets[pos] + fieldOffset);
163
+ int64_t * valuePtr = static_cast <int64_t *>(memoryAddress + offsets[pos] + fieldOffset);
164
+ int64_t value = *(valuePtr);
160
165
column->set (pos, Timestamp::fromMicros (value));
161
166
} else {
162
167
column->setNull (pos, true );
@@ -178,7 +183,8 @@ VectorPtr createFlatVectorStringView(
178
183
char * rawBuffer = column->getRawStringBufferWithSpace (size, true );
179
184
for (auto pos = 0 ; pos < numRows; pos++) {
180
185
if (!isNull (memoryAddress + offsets[pos], columnIdx)) {
181
- int64_t offsetAndSize = *(int64_t *)(memoryAddress + offsets[pos] + fieldOffset);
186
+ int64_t * offsetAndSizePtr = reinterpret_cast <int64_t *>(memoryAddress + offsets[pos] + fieldOffset);
187
+ int64_t offsetAndSize = *offsetAndSizePtr;
182
188
int32_t length = static_cast <int32_t >(offsetAndSize);
183
189
int32_t wordoffset = static_cast <int32_t >(offsetAndSize >> 32 );
184
190
auto valueSrcPtr = memoryAddress + offsets[pos] + wordoffset;
0 commit comments