From 87eb87537936234ae539e39d67f458b5aa0ebae0 Mon Sep 17 00:00:00 2001 From: Gagan Goel Date: Fri, 12 May 2023 19:45:02 +0000 Subject: [PATCH] MCOL-5491 Enable StringStore for long strings in JSON_ARRAYAGG processing. This patch is the JSON_ARRAYAGG clone of the changes done in MCOL-5429 where we enabled usage of StringStore for long strings in GROUP_CONCAT() processing to reduce memory footprint of PrimProc and thus avoiding a potential OS triggered OOM crash. --- dbcon/joblist/jsonarrayagg.cpp | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/dbcon/joblist/jsonarrayagg.cpp b/dbcon/joblist/jsonarrayagg.cpp index 1de18d0c1..c979e5ef6 100644 --- a/dbcon/joblist/jsonarrayagg.cpp +++ b/dbcon/joblist/jsonarrayagg.cpp @@ -260,6 +260,14 @@ void JsonArrayInfo::mapColumns(const RowGroup& projRG) (*k)->fRowGroup = RowGroup(oids.size(), pos, oids, keys, types, csNums, scale, precision, projRG.getStringTableThreshold(), false); + + // MCOL-5491/MCOL-5429 Use stringstore if the datatype of the + // json_arrayagg/group_concat field is a long string. + if ((*k)->fRowGroup.hasLongString()) + { + (*k)->fRowGroup.setUseStringTable(true); + } + (*k)->fMapping = makeMapping(projRG, (*k)->fRowGroup); } } @@ -311,9 +319,24 @@ void JsonArrayAggregatAgUM::initialize() fConcator->initialize(fGroupConcat); - fGroupConcat->fRowGroup.initRow(&fRow, true); - fData.reset(new uint8_t[fRow.getSize()]); - fRow.setData(rowgroup::Row::Pointer(fData.get())); + // MCOL-5491/MCOL-5429 Use stringstore if the datatype of the + // json_arrayagg/group_concat field is a long string. + if (fGroupConcat->fRowGroup.hasLongString()) + { + fRowGroup = fGroupConcat->fRowGroup; + fRowGroup.setUseStringTable(true); + fRowRGData.reinit(fRowGroup, 1); + fRowGroup.setData(&fRowRGData); + fRowGroup.resetRowGroup(0); + fRowGroup.initRow(&fRow); + fRowGroup.getRow(0, &fRow); + } + else + { + fGroupConcat->fRowGroup.initRow(&fRow, true); + fData.reset(new uint8_t[fRow.getSize()]); + fRow.setData(rowgroup::Row::Pointer(fData.get())); + } } void JsonArrayAggregatAgUM::processRow(const rowgroup::Row& inRow)