492 if (fieldCount != result->GetFieldCount())
504 size_t stringHoldersRecordPoolSize = stringFields * stringHolderSize;
508 size_t stringHoldersPoolSize = stringHoldersRecordPoolSize * result->GetRowCount();
509 stringHolders =
new char[stringHoldersPoolSize];
512 for (
size_t i = 0; i < stringHoldersPoolSize /
sizeof(
char*); ++i)
513 ((
char const**)stringHolders)[i] =
nullStr;
516 stringHolders =
nullptr;
523 indexTableSize = (*result)[indexField].GetUInt32() + 1;
524 if (indexTableSize < records)
525 indexTableSize = records;
528 indexTableSize = records + result->GetRowCount();
530 if (indexTableSize > records)
532 char** tmpIdxTable =
new char*[indexTableSize];
533 memset(tmpIdxTable, 0, indexTableSize *
sizeof(
char*));
534 memcpy(tmpIdxTable, indexTable, records *
sizeof(
char*));
536 indexTable = tmpIdxTable;
539 char* tempDataTable =
new char[result->GetRowCount() * recordSize];
546 Field* fields = result->Fetch();
548 uint32 stringFieldNumInRecord = 0;
552 indexValue = fields[indexField].
GetUInt32();
554 indexValue = records + rec;
557 char* dataValue = indexTable[indexValue];
560 newIndexes[newRecords] = indexValue;
561 dataValue = &tempDataTable[newRecords++ * recordSize];
564 for (
uint32 f = 0; f < fieldCount; f++)
569 *((
float*)(&dataValue[offset])) = fields[f].GetFloat();
574 *((
int32*)(&dataValue[offset])) = fields[f].GetInt32();
578 *((
int8*)(&dataValue[offset])) = fields[f].GetInt8();
582 *((
int64*)(&dataValue[offset])) = fields[f].GetInt64();
588 *slot = (
LocalizedString*)(&stringHolders[stringHoldersRecordPoolSize * rec + stringHolderSize * stringFieldNumInRecord]);
593 stringPool.push_back(str);
595 ++stringFieldNumInRecord;
596 offset +=
sizeof(
char*);
601 char const** slot = (
char const**)(&dataValue[offset]);
602 *slot = (
char*)(&stringHolders[stringHoldersRecordPoolSize * rec + stringHolderSize * stringFieldNumInRecord]);
606 if (
char* str =
AddString(slot, fields[f].GetString()))
607 stringPool.push_back(str);
609 ++stringFieldNumInRecord;
610 offset +=
sizeof(
char*);
616 ASSERT(offset == recordSize);
618 }
while (result->NextRow());
622 delete[] tempDataTable;
628 char* dataTable =
new char[newRecords * recordSize];
629 memcpy(dataTable, tempDataTable, newRecords * recordSize);
632 for (
uint32 i = 0; i < newRecords; ++i)
633 indexTable[newIndexes[i]] = &dataTable[i * recordSize];
635 delete[] tempDataTable;
638 records = indexTableSize;
void format(BasicFormatter< Char > &f, const Char *&format_str, const T &value)
Definition: format.h:2963
int8_t int8
Definition: Define.h:148
std::shared_ptr< PreparedResultSet > PreparedQueryResult
Definition: QueryResult.h:107
static char const *const nullStr
Definition: DB2StorageLoader.cpp:341
int64_t int64
Definition: Define.h:145
Class used to access individual fields of database query result.
Definition: Field.h:56
static uint32 GetFormatStringFieldCount(const char *format)
Definition: DB2StorageLoader.cpp:245
int32_t int32
Definition: Define.h:146
uint32_t uint32
Definition: Define.h:150
HotfixDatabaseWorkerPool HotfixDatabase
Accessor to the hotfix database.
Definition: DatabaseEnv.cpp:23
PreparedStatement * GetPreparedStatement(PreparedStatementIndex index)
Definition: DatabaseWorkerPool.h:263
QueryResult Query(const char *sql, T *connection=nullptr)
Definition: DatabaseWorkerPool.cpp:113
uint32 GetUInt32() const
Definition: Field.h:146
#define ASSERT
Definition: Errors.h:55
static char * AddString(char const **holder, std::string const &value)
Definition: DB2StorageLoader.cpp:710
static uint32 GetFormatRecordSize(const char *format, int32 *index_pos=NULL)
Definition: DB2StorageLoader.cpp:207
std::string GetString() const
Definition: Field.h:276