MCPcopy Create free account
hub / github.com/MariaDB/server / CalculateArray

Method CalculateArray

storage/connect/tabjson.cpp:1963–2060  ·  view source on GitHub ↗

/ CalculateArray: */ /

Source from the content-addressed store, hash-verified

1961/* CalculateArray: */
1962/***********************************************************************/
1963PVAL JSONCOL::CalculateArray(PGLOBAL g, PJAR arp, int n)
1964{
1965 int i, ars, nv = 0, nextsame = Tjp->NextSame;
1966 bool err;
1967 OPVAL op = Nodes[n].Op;
1968 PVAL val[2], vp = Nodes[n].Valp;
1969 PJVAL jvrp, jvp;
1970 JVALUE jval;
1971
1972 vp->Reset();
1973 ars = MY_MIN(Tjp->Limit, arp->size());
1974
1975 if (trace(1))
1976 htrc("CalculateArray: size=%d op=%d nextsame=%d\n",
1977 ars, op, nextsame);
1978
1979 for (i = 0; i < ars; i++) {
1980 jvrp = arp->GetArrayValue(i);
1981
1982 if (trace(1))
1983 htrc("i=%d nv=%d\n", i, nv);
1984
1985 if (!jvrp->IsNull() || (op == OP_CNC && GetJsonNull())) do {
1986 if (jvrp->IsNull()) {
1987 jvrp->Strp = PlugDup(g, GetJsonNull());
1988 jvrp->DataType = TYPE_STRG;
1989 jvp = jvrp;
1990 } else if (n < Nod - 1 && jvrp->GetJson()) {
1991 Tjp->NextSame = nextsame;
1992 jval.SetValue(g, GetColumnValue(g, jvrp->GetJson(), n + 1));
1993 jvp = &jval;
1994 } else
1995 jvp = jvrp;
1996
1997 if (trace(1))
1998 htrc("jvp=%s null=%d\n",
1999 jvp->GetString(g), jvp->IsNull() ? 1 : 0);
2000
2001 if (!nv++) {
2002 SetJsonValue(g, vp, jvp);
2003 continue;
2004 } else
2005 SetJsonValue(g, MulVal, jvp);
2006
2007 if (!MulVal->IsNull()) {
2008 switch (op) {
2009 case OP_CNC:
2010 if (Nodes[n].CncVal) {
2011 val[0] = Nodes[n].CncVal;
2012 err = vp->Compute(g, val, 1, op);
2013 } // endif CncVal
2014
2015 val[0] = MulVal;
2016 err = vp->Compute(g, val, 1, op);
2017 break;
2018// case OP_NUM:
2019 case OP_SEP:
2020 val[0] = Nodes[n].Valp;

Callers

nothing calls this directly

Calls 12

GetJsonNullFunction · 0.85
PlugDupFunction · 0.85
ComputeMethod · 0.80
htrcFunction · 0.70
ResetMethod · 0.45
sizeMethod · 0.45
GetArrayValueMethod · 0.45
IsNullMethod · 0.45
GetJsonMethod · 0.45
SetValueMethod · 0.45
GetStringMethod · 0.45
GetCharStringMethod · 0.45

Tested by

no test coverage detected