Skip to content

Commit a7f9610

Browse files
Only upsert once for each distinct character group (#714)
* Only upsert once for each distinct character group * .Q.fu optimisation. Co-authored-by: Ryan Cheale <ryan.cheale@dataintellect.com> * Reduced changes to upserttopartition --------- Co-authored-by: Ryan Cheale <ryan.cheale@dataintellect.com>
1 parent 3e506ef commit a7f9610

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

code/processes/wdb.q

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,8 @@ upserttopartition:{[dir;tablename;tabdata;pt;expttype;expt;writedownmode]
144144
` sv .Q.par[dir;pt;tablename],(`$"_"^.Q.an .Q.an?"_" sv string `TORQNULLSYMBOL^ ensuresymlist[expt]),`];
145145
.lg.o[`save;"saving ",(string tablename)," data to partition ",string directory];
146146
/- selecting rows of table with matching partition
147-
r:?[tabdata;$[writedownmode in `partbyenum`partbyfirstchar;enlist(in;first expttype;expt);{(x;y;(),z)}[in;;]'[expttype;expt]];0b;()];
147+
r:?[tabdata;$[writedownmode in `partbyenum`partbyfirstchar;enlist(in;first expttype;enlist expt);
148+
{(x;y;(),z)}[in;;]'[expttype;expt]];0b;()];
148149
/- upsert selected data matched on partition to specific directory
149150
.[upsert;(directory;r);{[e] .lg.e[`savetablesbypart;"Failed to save table to disk : ",e];'e}];
150151
.lg.o[`track;"appending details to partsizes"];
@@ -168,6 +169,8 @@ savetablesbypart:{[dir;pt;forcesave;tablename;writedownmode]
168169
if[writedownmode~`partbyenum;.merge.checkenumerabletype[tablename;extrapartitiontype]];
169170
/- get list of distinct combinations for partition directories
170171
extrapartitions:.merge.getextrapartitions[tablename;extrapartitiontype];
172+
if[writedownmode~`partbyfirstchar;
173+
extrapartitions:value extrapartitions group .Q.fu[{first each string x}; extrapartitions:raze extrapartitions]];
171174
/- enumerate data to be upserted
172175
enumdata:.Q.en[hdbsettings[`hdbdir];0!.save.manipulate[tablename;`. tablename]];
173176
.lg.o[`save;"enumerated ",(string tablename)," table"];

0 commit comments

Comments
 (0)