48 uint32 indexTableSize = records;
50 if (
uint32((*maxIdResult)[0].GetUInt64()) > records)
51 indexTableSize =
uint32((*maxIdResult)[0].GetUInt64());
53 if (indexTableSize > records)
55 char** tmpIdxTable =
new char*[indexTableSize];
56 memset(tmpIdxTable, 0, indexTableSize *
sizeof(
char*));
57 memcpy(tmpIdxTable, indexTable, records *
sizeof(
char*));
59 indexTable = tmpIdxTable;
62 char* tempDataTable =
new char[result->GetRowCount() * recordSize];
63 memset(tempDataTable, 0, result->GetRowCount() * recordSize);
66 stringPool.reserve(std::max<uint64>(stringPool.capacity(), stringPool.size() + stringFields * result->GetRowCount() + 1));
68 std::size_t newRecords = 0;
72 Field* fields = result->Fetch();
79 char* dataValue = indexTable[indexValue];
82 newIndexes[newRecords] = indexValue;
83 dataValue = &tempDataTable[newRecords++ * recordSize];
90 *((
uint32*)(&dataValue[offset])) = indexValue;
102 *((
float*)(&dataValue[offset])) = fields[f].GetFloat();
106 *((
int32*)(&dataValue[offset])) = fields[f].GetInt32();
110 *((
int8*)(&dataValue[offset])) = fields[f].GetInt8();
114 *((
int16*)(&dataValue[offset])) = fields[f].GetInt16();
118 *((
int64*)(&dataValue[offset])) = fields[f].GetInt64();
125 for (
char const*& localeStr : slot->
Str)
130 stringPool.push_back(str);
137 char const** slot = (
char const**)(&dataValue[offset]);
140 if (
char* str =
AddString(slot, fields[f].GetStringView()))
141 stringPool.push_back(str);
145 offset +=
sizeof(
char*);
157 ASSERT(offset == recordSize);
158 }
while (result->NextRow());
162 delete[] tempDataTable;
168 char* dataTable =
new char[newRecords * recordSize];
169 memcpy(dataTable, tempDataTable, newRecords * recordSize);
172 for (std::size_t i = 0; i < newRecords; ++i)
174 uint32 newId = newIndexes[i];
175 indexTable[newId] = &dataTable[i * recordSize];
176 minId = std::min(minId, newId);
179 delete[] tempDataTable;
182 records = indexTableSize;
197 if (result->GetFieldCount() != stringFields + 1 )
203 stringPool.reserve(std::max<uint64>(stringPool.capacity(), stringPool.size() + stringFields * result->GetRowCount() + 1));
207 Field* fields = result->Fetch();
209 uint32 stringFieldNumInRecord = 0;
212 if (indexValue >= records)
216 if (
char* dataValue = indexTable[indexValue])
225 for (
uint32 x = 0; x < fieldCount; ++x)
249 stringPool.push_back(str);
251 ++stringFieldNumInRecord;
256 offset +=
sizeof(
char*);
267 ASSERT(offset == recordSize);
272 }
while (result->NextRow());