From e32290490cfba7525187318c84c94ce07359ec26 Mon Sep 17 00:00:00 2001 From: Ben McDonald <46734217+bmcdonald3@users.noreply.github.com> Date: Fri, 4 Aug 2023 12:06:29 -0700 Subject: [PATCH] Closes #2633: Resolve Arkouda deprecation warnings for 1.32 to date (#2632) * Add IO compat for string casting * Switch to map.setOrReplace * Fix %jt warnings * Replace %t format specifier with %jt * Update test * Fix quote stripping for bigint printing * Fix missing var args formatJson in 130 * Fix make test hang * Add jsonToTupleCompat * Add readfCompat function * Add jsonToPdarray compat * Add review feedback from Pierce --- METRICS.md | 4 +- arkouda/pdarrayclass.py | 7 +- src/ArgSortMsg.chpl | 14 +- src/AryUtil.chpl | 12 +- src/BigIntMsg.chpl | 10 +- src/BinOp.chpl | 50 +- src/BroadcastMsg.chpl | 8 +- src/CSVMsg.chpl | 65 +-- src/Cast.chpl | 16 +- src/CastMsg.chpl | 2 +- src/CommandMap.chpl | 7 +- src/ConcatenateMsg.chpl | 28 +- src/DataFrameIndexingMsg.chpl | 45 +- src/EfuncMsg.chpl | 8 +- src/EncodingMsg.chpl | 2 +- src/ExternalIntegration.chpl | 42 +- src/FileIO.chpl | 29 +- src/FlattenMsg.chpl | 14 +- src/GenSymIO.chpl | 21 +- src/HDF5Msg.chpl | 661 ++++++++++++------------ src/HashMsg.chpl | 14 +- src/Histogram.chpl | 2 +- src/HistogramMsg.chpl | 10 +- src/In1dMsg.chpl | 2 +- src/IndexingMsg.chpl | 111 ++-- src/JoinEqWithDTMsg.chpl | 12 +- src/Logging.chpl | 21 +- src/MemoryMgmt.chpl | 4 +- src/Merge.chpl | 14 +- src/Message.chpl | 48 +- src/MetricsMsg.chpl | 34 +- src/MsgProcessing.chpl | 68 +-- src/MultiTypeSymEntry.chpl | 12 +- src/MultiTypeSymbolTable.chpl | 71 +-- src/OperatorMsg.chpl | 96 ++-- src/ParquetMsg.chpl | 81 +-- src/RadixSortLSD.chpl | 4 +- src/RandMsg.chpl | 22 +- src/ReductionMsg.chpl | 80 +-- src/RegistrationMsg.chpl | 134 ++--- src/SegStringSort.chpl | 18 +- src/SegmentedComputation.chpl | 4 +- src/SegmentedMsg.chpl | 137 ++--- src/SegmentedString.chpl | 22 +- src/SequenceMsg.chpl | 12 +- src/ServerConfig.chpl | 15 +- src/ServerDaemon.chpl | 105 ++-- src/ServerErrorStrings.chpl | 25 +- src/ServerErrors.chpl | 7 +- src/SipHash.chpl | 14 +- src/SortMsg.chpl | 6 +- src/StatsMsg.chpl | 67 +-- src/StatusMsg.chpl | 5 +- src/TimeClassMsg.chpl | 24 +- src/Unique.chpl | 4 +- src/UniqueMsg.chpl | 2 +- src/compat/e-130/ArkoudaIOCompat.chpl | 50 ++ src/compat/e-130/ArkoudaMapCompat.chpl | 7 + src/compat/eq-131/ArkoudaIOCompat.chpl | 50 ++ src/compat/eq-131/ArkoudaMapCompat.chpl | 4 + src/compat/gt-131/ArkoudaIOCompat.chpl | 52 ++ tests/operator_tests.py | 25 +- 62 files changed, 1357 insertions(+), 1183 deletions(-) create mode 100644 src/compat/e-130/ArkoudaIOCompat.chpl create mode 100644 src/compat/e-130/ArkoudaMapCompat.chpl create mode 100644 src/compat/eq-131/ArkoudaIOCompat.chpl create mode 100644 src/compat/gt-131/ArkoudaIOCompat.chpl diff --git a/METRICS.md b/METRICS.md index 4f50036e6d..a1f49dee6b 100644 --- a/METRICS.md +++ b/METRICS.md @@ -30,7 +30,7 @@ Measurement metrics are generated in the MeasurementsTable class: } proc set(metric: string, measurement: real) { - this.measurements.addOrSet(metric, measurement); + this.measurements.addOrReplace(metric, measurement); } ``` @@ -40,7 +40,7 @@ Count metrics are captured in the Counter Table: ``` proc set(metric: string, count: int) { - this.counts.addOrSet(metric,count); + this.counts.addOrReplace(metric,count); } proc increment(metric: string, increment: int=1) { diff --git a/arkouda/pdarrayclass.py b/arkouda/pdarrayclass.py index a5653d8197..c5c62a51fe 100755 --- a/arkouda/pdarrayclass.py +++ b/arkouda/pdarrayclass.py @@ -102,8 +102,11 @@ def unescape(s): dtname, value = msg.split(maxsplit=1) mydtype = dtype(dtname) if mydtype == bigint: - # we have to strip off quotes - return int(value[1:-1]) + # we have to strip off quotes prior to 1.32 + if value[0] == "\"": + return int(value[1:-1]) + else: + return int(value) if mydtype == npbool: if value == "True": return mydtype.type(True) diff --git a/src/ArgSortMsg.chpl b/src/ArgSortMsg.chpl index 2168957ac8..2677be07b0 100644 --- a/src/ArgSortMsg.chpl +++ b/src/ArgSortMsg.chpl @@ -158,7 +158,7 @@ module ArgSortMsg deltaIV = argsortDefault(newa); } otherwise { throw getErrorWithContext( - msg="Unsupported DataType: %t".format(dtype2str(g.dtype)), + msg="Unsupported DataType: %?".doFormat(dtype2str(g.dtype)), lineNumber=getLineNumber(), routineName=getRoutineName(), moduleName=getModuleName(), @@ -218,7 +218,7 @@ module ArgSortMsg algorithm = algoName: SortingAlgorithm; } catch { throw getErrorWithContext( - msg="Unrecognized sorting algorithm: %s".format(algoName), + msg="Unrecognized sorting algorithm: %s".doFormat(algoName), lineNumber=getLineNumber(), routineName=getRoutineName(), moduleName=getModuleName(), @@ -230,7 +230,7 @@ module ArgSortMsg var arrNames = msgArgs.get("arr_names").getList(n); var arrTypes = msgArgs.get("arr_types").getList(n); asLogger.debug(getModuleName(),getRoutineName(),getLineNumber(), - "number of arrays: %i arrNames: %t, arrTypes: %t".format(n,arrNames, arrTypes)); + "number of arrays: %i arrNames: %?, arrTypes: %?".doFormat(n,arrNames, arrTypes)); var (arrSize, hasStr, names, types) = validateArraysSameLength(n, arrNames, arrTypes, st); // If there were no string arrays, merge the arrays into a single array and sort @@ -311,7 +311,7 @@ module ArgSortMsg } otherwise { throw getErrorWithContext( - msg="Unrecognized sorting algorithm: %s".format(algorithm:string), + msg="Unrecognized sorting algorithm: %s".doFormat(algorithm:string), lineNumber=getLineNumber(), routineName=getRoutineName(), moduleName=getModuleName(), @@ -320,7 +320,7 @@ module ArgSortMsg } } try! asLogger.debug(getModuleName(),getRoutineName(),getLineNumber(), - "argsort time = %i".format(Time.timeSinceEpoch().totalSeconds() - t1)); + "argsort time = %i".doFormat(Time.timeSinceEpoch().totalSeconds() - t1)); return iv; } @@ -336,7 +336,7 @@ module ArgSortMsg algorithm = algoName: SortingAlgorithm; } catch { throw getErrorWithContext( - msg="Unrecognized sorting algorithm: %s".format(algoName), + msg="Unrecognized sorting algorithm: %s".doFormat(algoName), lineNumber=getLineNumber(), routineName=getRoutineName(), moduleName=getModuleName(), @@ -347,7 +347,7 @@ module ArgSortMsg // get next symbol name var ivname = st.nextName(); asLogger.debug(getModuleName(),getRoutineName(),getLineNumber(), - "cmd: %s name: %s ivname: %s".format(cmd, name, ivname)); + "cmd: %s name: %s ivname: %s".doFormat(cmd, name, ivname)); var objtype = msgArgs.getValueOf("objType").toUpper(): ObjType; select objtype { diff --git a/src/AryUtil.chpl b/src/AryUtil.chpl index 11c1cc27ad..f53ffcad44 100644 --- a/src/AryUtil.chpl +++ b/src/AryUtil.chpl @@ -35,9 +35,9 @@ module AryUtil */ proc formatAry(A):string throws { if A.size <= printThresh { - return "%t".format(A); + return "%?".doFormat(A); } else { - return "%t ... %t".format(A[A.domain.low..A.domain.low+2], + return "%? ... %?".doFormat(A[A.domain.low..A.domain.low+2], A[A.domain.high-2..A.domain.high]); } } @@ -146,7 +146,7 @@ module AryUtil proc validateArraysSameLength(n:int, names:[] string, types: [] string, st: borrowed SymTab) throws { // Check that fields contains the stated number of arrays if (names.size != n) { - var errorMsg = "Expected %i arrays but got %i".format(n, names.size); + var errorMsg = "Expected %i arrays but got %i".doFormat(n, names.size); auLogger.error(getModuleName(),getRoutineName(),getLineNumber(),errorMsg); throw new owned ErrorWithContext(errorMsg, getLineNumber(), @@ -155,7 +155,7 @@ module AryUtil "ArgumentError"); } if (types.size != n) { - var errorMsg = "Expected %i types but got %i".format(n, types.size); + var errorMsg = "Expected %i types but got %i".doFormat(n, types.size); auLogger.error(getModuleName(),getRoutineName(),getLineNumber(),errorMsg); throw new owned ErrorWithContext(errorMsg, getLineNumber(), @@ -201,7 +201,7 @@ module AryUtil thisSize = segs.size; } otherwise { - var errorMsg = "Unrecognized object type: %s".format(objtype); + var errorMsg = "Unrecognized object type: %s".doFormat(objtype); auLogger.error(getModuleName(),getRoutineName(),getLineNumber(),errorMsg); throw new owned ErrorWithContext(errorMsg, getLineNumber(), @@ -215,7 +215,7 @@ module AryUtil size = thisSize; } else { if (thisSize != size) { - var errorMsg = "Arrays must all be same size; expected size %t, got size %t".format(size, thisSize); + var errorMsg = "Arrays must all be same size; expected size %?, got size %?".doFormat(size, thisSize); auLogger.error(getModuleName(),getRoutineName(),getLineNumber(),errorMsg); throw new owned ErrorWithContext(errorMsg, getLineNumber(), diff --git a/src/BigIntMsg.chpl b/src/BigIntMsg.chpl index f064d8641f..76db2423c3 100644 --- a/src/BigIntMsg.chpl +++ b/src/BigIntMsg.chpl @@ -12,7 +12,7 @@ module BigIntMsg { use List; use ArkoudaListCompat; - + use ArkoudaIOCompat; private config const logLevel = ServerConfig.logLevel; private config const logChannel = ServerConfig.logChannel; @@ -50,7 +50,7 @@ module BigIntMsg { var retname = st.nextName(); st.addEntry(retname, new shared SymEntry(bigIntArray, max_bits)); var syment = toSymEntry(getGenericTypedArrayEntry(retname, st), bigint); - repMsg = "created %s".format(st.attrib(retname)); + repMsg = "created %s".doFormat(st.attrib(retname)); biLogger.debug(getModuleName(),getRoutineName(),getLineNumber(),repMsg); return new MsgTuple(repMsg, MsgType.NORMAL); } @@ -74,7 +74,7 @@ module BigIntMsg { low = tmp:uint; var retname = st.nextName(); st.addEntry(retname, new shared SymEntry(low)); - retList.pushBack("created %s".format(st.attrib(retname))); + retList.pushBack("created %s".doFormat(st.attrib(retname))); all_zero = true; forall t in tmp with (&& reduce all_zero) { @@ -82,7 +82,7 @@ module BigIntMsg { all_zero &&= (t == 0 || t == -1); } } - var repMsg = "%jt".format(retList); + var repMsg = formatJson(retList); biLogger.debug(getModuleName(), getRoutineName(), getLineNumber(), repMsg); return new MsgTuple(repMsg, MsgType.NORMAL); } @@ -101,7 +101,7 @@ module BigIntMsg { select gEnt.dtype { when DType.BigInt { - var repMsg = "%jt".format(toSymEntry(gEnt, bigint).max_bits); + var repMsg = formatJson(toSymEntry(gEnt, bigint).max_bits); biLogger.debug(getModuleName(), getRoutineName(), getLineNumber(), repMsg); return new MsgTuple(repMsg, MsgType.NORMAL); } diff --git a/src/BinOp.chpl b/src/BinOp.chpl index 5506786fe0..eabf964538 100644 --- a/src/BinOp.chpl +++ b/src/BinOp.chpl @@ -174,7 +174,7 @@ module BinOp } } } - var repMsg = "created %s".format(st.attrib(rname)); + var repMsg = "created %s".doFormat(st.attrib(rname)); return new MsgTuple(repMsg, MsgType.NORMAL); } // Since we know that both `l` and `r` are of type `int` and that @@ -261,7 +261,7 @@ module BinOp } } } - var repMsg = "created %s".format(st.attrib(rname)); + var repMsg = "created %s".doFormat(st.attrib(rname)); return new MsgTuple(repMsg, MsgType.NORMAL); } else if (e.etype == int && r.etype == uint) || @@ -291,7 +291,7 @@ module BinOp return new MsgTuple(errorMsg, MsgType.ERROR); } } - var repMsg = "created %s".format(st.attrib(rname)); + var repMsg = "created %s".doFormat(st.attrib(rname)); return new MsgTuple(repMsg, MsgType.NORMAL); } else if (l.etype == uint && r.etype == int) || (l.etype == int && r.etype == uint) { @@ -308,7 +308,7 @@ module BinOp return new MsgTuple(errorMsg, MsgType.ERROR); } } - var repMsg = "created %s".format(st.attrib(rname)); + var repMsg = "created %s".doFormat(st.attrib(rname)); return new MsgTuple(repMsg, MsgType.NORMAL); } // If either RHS or LHS type is real, the same operations are supported and the @@ -349,7 +349,7 @@ module BinOp return new MsgTuple(errorMsg, MsgType.ERROR); } } - var repMsg = "created %s".format(st.attrib(rname)); + var repMsg = "created %s".doFormat(st.attrib(rname)); return new MsgTuple(repMsg, MsgType.NORMAL); } else if ((l.etype == uint && r.etype == real) || (l.etype == real && r.etype == uint)) { select op { @@ -386,7 +386,7 @@ module BinOp return new MsgTuple(errorMsg, MsgType.ERROR); } } - var repMsg = "created %s".format(st.attrib(rname)); + var repMsg = "created %s".doFormat(st.attrib(rname)); return new MsgTuple(repMsg, MsgType.NORMAL); } else if ((l.etype == int && r.etype == bool) || (l.etype == bool && r.etype == int)) { select op { @@ -408,7 +408,7 @@ module BinOp return new MsgTuple(errorMsg, MsgType.ERROR); } } - var repMsg = "created %s".format(st.attrib(rname)); + var repMsg = "created %s".doFormat(st.attrib(rname)); return new MsgTuple(repMsg, MsgType.NORMAL); } else if ((l.etype == uint && r.etype == bool) || (l.etype == bool && r.etype == uint)) { select op { @@ -427,7 +427,7 @@ module BinOp return new MsgTuple(errorMsg, MsgType.ERROR); } } - var repMsg = "created %s".format(st.attrib(rname)); + var repMsg = "created %s".doFormat(st.attrib(rname)); return new MsgTuple(repMsg, MsgType.NORMAL); } else if ((l.etype == real && r.etype == bool) || (l.etype == bool && r.etype == real)) { select op { @@ -446,7 +446,7 @@ module BinOp return new MsgTuple(errorMsg, MsgType.ERROR); } } - var repMsg = "created %s".format(st.attrib(rname)); + var repMsg = "created %s".doFormat(st.attrib(rname)); return new MsgTuple(repMsg, MsgType.NORMAL); } var errorMsg = notImplementedError(pn,l.dtype,op,r.dtype); @@ -554,7 +554,7 @@ module BinOp } } } - var repMsg = "created %s".format(st.attrib(rname)); + var repMsg = "created %s".doFormat(st.attrib(rname)); return new MsgTuple(repMsg, MsgType.NORMAL); } // Since we know that both `l` and `r` are of type `int` and that @@ -632,7 +632,7 @@ module BinOp } } - var repMsg = "created %s".format(st.attrib(rname)); + var repMsg = "created %s".doFormat(st.attrib(rname)); return new MsgTuple(repMsg, MsgType.NORMAL); } else if (e.etype == int && val.type == uint) || @@ -666,7 +666,7 @@ module BinOp return new MsgTuple(errorMsg, MsgType.ERROR); } } - var repMsg = "created %s".format(st.attrib(rname)); + var repMsg = "created %s".doFormat(st.attrib(rname)); return new MsgTuple(repMsg, MsgType.NORMAL); } // If either RHS or LHS type is real, the same operations are supported and the @@ -705,7 +705,7 @@ module BinOp return new MsgTuple(errorMsg, MsgType.ERROR); } } - var repMsg = "created %s".format(st.attrib(rname)); + var repMsg = "created %s".doFormat(st.attrib(rname)); return new MsgTuple(repMsg, MsgType.NORMAL); } else if e.etype == real && ((l.etype == uint && val.type == int) || (l.etype == int && val.type == uint)) { @@ -722,7 +722,7 @@ module BinOp return new MsgTuple(errorMsg, MsgType.ERROR); } } - var repMsg = "created %s".format(st.attrib(rname)); + var repMsg = "created %s".doFormat(st.attrib(rname)); return new MsgTuple(repMsg, MsgType.NORMAL); } else if ((l.etype == uint && val.type == real) || (l.etype == real && val.type == uint)) { @@ -758,7 +758,7 @@ module BinOp return new MsgTuple(errorMsg, MsgType.ERROR); } } - var repMsg = "created %s".format(st.attrib(rname)); + var repMsg = "created %s".doFormat(st.attrib(rname)); return new MsgTuple(repMsg, MsgType.NORMAL); } else if ((l.etype == int && val.type == bool) || (l.etype == bool && val.type == int)) { select op { @@ -780,7 +780,7 @@ module BinOp return new MsgTuple(errorMsg, MsgType.ERROR); } } - var repMsg = "created %s".format(st.attrib(rname)); + var repMsg = "created %s".doFormat(st.attrib(rname)); return new MsgTuple(repMsg, MsgType.NORMAL); } else if ((l.etype == real && val.type == bool) || (l.etype == bool && val.type == real)) { select op { @@ -799,7 +799,7 @@ module BinOp return new MsgTuple(errorMsg, MsgType.ERROR); } } - var repMsg = "created %s".format(st.attrib(rname)); + var repMsg = "created %s".doFormat(st.attrib(rname)); return new MsgTuple(repMsg, MsgType.NORMAL); } var errorMsg = unrecognizedTypeError(pn, "("+dtype2str(l.dtype)+","+dtype2str(dtype)+")"); @@ -907,7 +907,7 @@ module BinOp } } } - var repMsg = "created %s".format(st.attrib(rname)); + var repMsg = "created %s".doFormat(st.attrib(rname)); return new MsgTuple(repMsg, MsgType.NORMAL); } // Since we know that both `l` and `r` are of type `int` and that @@ -990,7 +990,7 @@ module BinOp } } - var repMsg = "created %s".format(st.attrib(rname)); + var repMsg = "created %s".doFormat(st.attrib(rname)); return new MsgTuple(repMsg, MsgType.NORMAL); } else if (e.etype == int && val.type == uint) || @@ -1024,7 +1024,7 @@ module BinOp return new MsgTuple(errorMsg, MsgType.ERROR); } } - var repMsg = "created %s".format(st.attrib(rname)); + var repMsg = "created %s".doFormat(st.attrib(rname)); return new MsgTuple(repMsg, MsgType.NORMAL); } // If either RHS or LHS type is real, the same operations are supported and the @@ -1063,7 +1063,7 @@ module BinOp return new MsgTuple(errorMsg, MsgType.ERROR); } } - var repMsg = "created %s".format(st.attrib(rname)); + var repMsg = "created %s".doFormat(st.attrib(rname)); return new MsgTuple(repMsg, MsgType.NORMAL); } else if e.etype == real && ((r.etype == uint && val.type == int) || (r.etype == int && val.type == uint)) { @@ -1080,7 +1080,7 @@ module BinOp return new MsgTuple(errorMsg, MsgType.ERROR); } } - var repMsg = "created %s".format(st.attrib(rname)); + var repMsg = "created %s".doFormat(st.attrib(rname)); return new MsgTuple(repMsg, MsgType.NORMAL); } else if ((r.etype == uint && val.type == real) || (r.etype == real && val.type == uint)) { @@ -1116,7 +1116,7 @@ module BinOp return new MsgTuple(errorMsg, MsgType.ERROR); } } - var repMsg = "created %s".format(st.attrib(rname)); + var repMsg = "created %s".doFormat(st.attrib(rname)); return new MsgTuple(repMsg, MsgType.NORMAL); } else if ((r.etype == int && val.type == bool) || (r.etype == bool && val.type == int)) { select op { @@ -1138,7 +1138,7 @@ module BinOp return new MsgTuple(errorMsg, MsgType.ERROR); } } - var repMsg = "created %s".format(st.attrib(rname)); + var repMsg = "created %s".doFormat(st.attrib(rname)); return new MsgTuple(repMsg, MsgType.NORMAL); } else if ((r.etype == real && val.type == bool) || (r.etype == bool && val.type == real)) { select op { @@ -1157,7 +1157,7 @@ module BinOp return new MsgTuple(errorMsg, MsgType.ERROR); } } - var repMsg = "created %s".format(st.attrib(rname)); + var repMsg = "created %s".doFormat(st.attrib(rname)); return new MsgTuple(repMsg, MsgType.NORMAL); } var errorMsg = unrecognizedTypeError(pn, "("+dtype2str(dtype)+","+dtype2str(r.dtype)+")"); diff --git a/src/BroadcastMsg.chpl b/src/BroadcastMsg.chpl index feb7a4b0f9..3592d9cf98 100644 --- a/src/BroadcastMsg.chpl +++ b/src/BroadcastMsg.chpl @@ -90,7 +90,7 @@ module BroadcastMsg { res.a = broadcast(perm.a, segs.a, vals.a); } otherwise { - throw new owned ErrorWithContext("Values array has unsupported dtype %s".format(gv.dtype:string), + throw new owned ErrorWithContext("Values array has unsupported dtype %s".doFormat(gv.dtype:string), getLineNumber(), getRoutineName(), getModuleName(), @@ -127,7 +127,7 @@ module BroadcastMsg { res.a = broadcast(segs.a, vals.a, size); } otherwise { - throw new owned ErrorWithContext("Values array has unsupported dtype %s".format(gv.dtype:string), + throw new owned ErrorWithContext("Values array has unsupported dtype %s".doFormat(gv.dtype:string), getLineNumber(), getRoutineName(), getModuleName(), @@ -167,12 +167,12 @@ module BroadcastMsg { const perm = toSymEntry(gp, int); var (vals, offs) = broadcast(perm.a, segs.a, sE); var res = getSegString(offs, vals, st); - repMsg = "created %s".format(st.attrib(res.name)) + "+created bytes.size %t".format(res.nBytes); + repMsg = "created %s".doFormat(st.attrib(res.name)) + "+created bytes.size %?".doFormat(res.nBytes); } else { var (vals, offs) = broadcast(segs.a, sE, size); var res = getSegString(offs, vals, st); - repMsg = "created %s".format(st.attrib(res.name)) + "+created bytes.size %t".format(res.nBytes); + repMsg = "created %s".doFormat(st.attrib(res.name)) + "+created bytes.size %?".doFormat(res.nBytes); } bmLogger.debug(getModuleName(),getRoutineName(),getLineNumber(),repMsg); diff --git a/src/CSVMsg.chpl b/src/CSVMsg.chpl index 39ccdec650..27dc7e2c78 100644 --- a/src/CSVMsg.chpl +++ b/src/CSVMsg.chpl @@ -19,6 +19,7 @@ module CSVMsg { use ArkoudaFileCompat; use ArkoudaListCompat; + use ArkoudaIOCompat; const CSV_HEADER_OPEN = "**HEADER**"; const CSV_HEADER_CLOSE = "*/HEADER/*"; @@ -45,10 +46,10 @@ module CSVMsg { // Attempt to interpret filename as a glob expression and ls the first result var tmp = glob(filename); csvLogger.debug(getModuleName(),getRoutineName(),getLineNumber(), - "glob-expanded filename: %s to size: %i files".format(filename, tmp.size)); + "glob-expanded filename: %s to size: %i files".doFormat(filename, tmp.size)); if tmp.size <= 0 { - var errorMsg = "Cannot retrieve filename from glob expression %s, check file name or format".format(filename); + var errorMsg = "Cannot retrieve filename from glob expression %s, check file name or format".doFormat(filename); csvLogger.error(getModuleName(),getRoutineName(),getLineNumber(),errorMsg); return new MsgTuple(errorMsg, MsgType.ERROR); } @@ -59,7 +60,7 @@ module CSVMsg { // Check to see if the file exists. If not, return an error message if !exists(filename) { - var errorMsg = "File %s does not exist in a location accessible to Arkouda".format(filename); + var errorMsg = "File %s does not exist in a location accessible to Arkouda".doFormat(filename); csvLogger.error(getModuleName(),getRoutineName(),getLineNumber(),errorMsg); return new MsgTuple(errorMsg,MsgType.ERROR); } @@ -77,7 +78,7 @@ module CSVMsg { var column_names = lines[idx].split(col_delim); reader.close(); csvFile.close(); - return new MsgTuple("%jt".format(column_names), MsgType.NORMAL); + return new MsgTuple(formatJson(column_names), MsgType.NORMAL); } @@ -92,14 +93,14 @@ module CSVMsg { filenames[i] = generateFilename(prefix, extension, i); } - csvLogger.debug(getModuleName(),getRoutineName(),getLineNumber(), "Identified %i files for provided name, %s".format(filenames.size, filename)); + csvLogger.debug(getModuleName(),getRoutineName(),getLineNumber(), "Identified %i files for provided name, %s".doFormat(filenames.size, filename)); - var matchingFilenames = glob("%s_LOCALE*%s".format(prefix, extension)); + var matchingFilenames = glob("%s_LOCALE*%s".doFormat(prefix, extension)); var filesExist: bool = matchingFilenames.size > 0; if !overwrite && filesExist { throw getErrorWithContext( - msg="Filenames for the provided name exist. Overwrite must be set to true in order to save with the name %s".format(filename), + msg="Filenames for the provided name exist. Overwrite must be set to true in order to save with the name %s".doFormat(filename), lineNumber=getLineNumber(), routineName=getRoutineName(), moduleName=getModuleName(), @@ -111,7 +112,7 @@ module CSVMsg { var existList = glob(fn); if overwrite && existList.size == 1 { remove(fn); - csvLogger.debug(getModuleName(),getRoutineName(),getLineNumber(), "Overwriting CSV File, %s".format(fn)); + csvLogger.debug(getModuleName(),getRoutineName(),getLineNumber(), "Overwriting CSV File, %s".doFormat(fn)); } } } @@ -143,7 +144,7 @@ module CSVMsg { } otherwise { throw getErrorWithContext( - msg="Invalid DType Found, %s".format(dtype2str(GSE.dtype)), + msg="Invalid DType Found, %s".doFormat(dtype2str(GSE.dtype)), lineNumber=getLineNumber(), routineName=getRoutineName(), moduleName=getModuleName(), @@ -189,7 +190,7 @@ module CSVMsg { } otherwise { throw getErrorWithContext( - msg="Invalid DType Found, %s".format(dtype2str(gse.dtype)), + msg="Invalid DType Found, %s".doFormat(dtype2str(gse.dtype)), lineNumber=getLineNumber(), routineName=getRoutineName(), moduleName=getModuleName(), @@ -243,7 +244,7 @@ module CSVMsg { } otherwise { throw getErrorWithContext( - msg="Data Type %s cannot be written to CSV.".format(dtypes[i]), + msg="Data Type %s cannot be written to CSV.".doFormat(dtypes[i]), lineNumber=getLineNumber(), routineName=getRoutineName(), moduleName=getModuleName(), @@ -267,7 +268,7 @@ module CSVMsg { // Verify that the file exists if !exists(filename) { throw getErrorWithContext( - msg="The file %s does not exist".format(filename), + msg="The file %s does not exist".doFormat(filename), lineNumber=getLineNumber(), routineName=getRoutineName(), moduleName=getModuleName(), @@ -306,10 +307,10 @@ module CSVMsg { forall (i, dset) in zip(0..#datasets.size, datasets) { var idx: int; var col_exists = columns.find(dset, idx); - csvLogger.debug(getModuleName(),getRoutineName(),getLineNumber(), "Column: %s, Exists: %jt, IDX: %i".format(dset, col_exists, idx)); + csvLogger.debug(getModuleName(),getRoutineName(),getLineNumber(), "Column: %s, Exists: ".doFormat(dset)+formatJson(col_exists)+", IDX: %i".doFormat(idx)); if !col_exists { throw getErrorWithContext( - msg="The dataset %s was not found in %s".format(dset, filename), + msg="The dataset %s was not found in %s".doFormat(dset, filename), lineNumber=getLineNumber(), routineName=getRoutineName(), moduleName=getModuleName(), @@ -333,7 +334,7 @@ module CSVMsg { for (filedom, filename, file_idx) in zip(locFiledoms, locFiles, 0..) { if (skips.contains(filename)) { csvLogger.debug(getModuleName(),getRoutineName(),getLineNumber(), - "File %s does not contain data for this dataset, skipping".format(filename)); + "File %s does not contain data for this dataset, skipping".doFormat(filename)); continue; } else { var csvFile = open(filename, ioMode.r); @@ -349,7 +350,7 @@ module CSVMsg { var colExists = column_names.find(dset, colidx); if !colExists{ throw getErrorWithContext( - msg="The dataset %s was not found in %s".format(dset, filename), + msg="The dataset %s was not found in %s".doFormat(dset, filename), lineNumber=getLineNumber(), routineName=getRoutineName(), moduleName=getModuleName(), @@ -379,7 +380,7 @@ module CSVMsg { if (!vf) { skips.add(fname); csvLogger.debug(getModuleName(),getRoutineName(),getLineNumber(), - "Adding invalid file to skips, %s".format(fname)); + "Adding invalid file to skips, %s".doFormat(fname)); continue; } subdoms[i] = {off..#ct}; @@ -447,12 +448,12 @@ module CSVMsg { data[low..#vbytes.size] = vbytes; } var ss = getSegString(str_offsets, data, st); - var rst = (dset, ObjType.STRINGS, "%s+%t".format(ss.name, ss.nBytes)); + var rst = (dset, ObjType.STRINGS, "%s+%?".doFormat(ss.name, ss.nBytes)); rtnData.pushBack(rst); } otherwise { throw getErrorWithContext( - msg="Data Type %s cannot be read into Arkouda.".format(dtypes[i]), + msg="Data Type %s cannot be read into Arkouda.".doFormat(dtypes[i]), lineNumber=getLineNumber(), routineName=getRoutineName(), moduleName=getModuleName(), @@ -489,7 +490,7 @@ module CSVMsg { data[low..#vbytes.size] = vbytes; } var ss = getSegString(str_offsets, data, st); - var rst = (dset, ObjType.STRINGS, "%s+%t".format(ss.name, ss.nBytes)); + var rst = (dset, ObjType.STRINGS, "%s+%?".doFormat(ss.name, ss.nBytes)); rtnData.pushBack(rst); } return rtnData; @@ -509,7 +510,7 @@ module CSVMsg { var n: int = 1000; var jsonfiles = msgArgs.getValueOf("filenames"); var files: string = if jsonfiles.size > 2*n then jsonfiles[0..#n]+'...'+jsonfiles[jsonfiles.size-n..#n] else jsonfiles; - var errorMsg = "Could not decode json filenames via tempfile (%i files: %s)".format(nfiles, files); + var errorMsg = "Could not decode json filenames via tempfile (%i files: %s)".doFormat(nfiles, files); csvLogger.error(getModuleName(),getRoutineName(),getLineNumber(),errorMsg); return new MsgTuple(errorMsg, MsgType.ERROR); } @@ -524,7 +525,7 @@ module CSVMsg { var n: int = 1000; var jsondsets = msgArgs.getValueOf("datasets"); var dsets: string = if jsondsets.size > 2*n then jsondsets[0..#n]+'...'+jsondsets[jsondsets.size-n..#n] else jsondsets; - var errorMsg = "Could not decode json dataset names via tempfile (%i files: %s)".format( + var errorMsg = "Could not decode json dataset names via tempfile (%i files: %s)".doFormat( ndsets, dsets); csvLogger.error(getModuleName(),getRoutineName(),getLineNumber(),errorMsg); return new MsgTuple(errorMsg, MsgType.ERROR); @@ -541,9 +542,9 @@ module CSVMsg { } var tmp = glob(filelist[0]); csvLogger.debug(getModuleName(),getRoutineName(),getLineNumber(), - "glob expanded %s to %i files".format(filelist[0], tmp.size)); + "glob expanded %s to %i files".doFormat(filelist[0], tmp.size)); if tmp.size == 0 { - var errorMsg = "The wildcarded filename %s either corresponds to files inaccessible to Arkouda or files of an invalid format".format(filelist[0]); + var errorMsg = "The wildcarded filename %s either corresponds to files inaccessible to Arkouda or files of an invalid format".doFormat(filelist[0]); csvLogger.error(getModuleName(),getRoutineName(),getLineNumber(),errorMsg); return new MsgTuple(errorMsg, MsgType.ERROR); } @@ -571,27 +572,27 @@ module CSVMsg { (row_cts[i], headers[i], dtypes) = get_info(fname, dsetlist, col_delim); data_types.pushBack(dtypes); } catch e: FileNotFoundError { - fileErrorMsg = "File %s not found".format(fname); + fileErrorMsg = "File %s not found".doFormat(fname); csvLogger.error(getModuleName(),getRoutineName(),getLineNumber(),fileErrorMsg); hadError = true; if !allowErrors { return new MsgTuple(fileErrorMsg, MsgType.ERROR); } } catch e: PermissionError { - fileErrorMsg = "Permission error %s opening %s".format(e.message(),fname); + fileErrorMsg = "Permission error %s opening %s".doFormat(e.message(),fname); csvLogger.error(getModuleName(),getRoutineName(),getLineNumber(),fileErrorMsg); hadError = true; if !allowErrors { return new MsgTuple(fileErrorMsg, MsgType.ERROR); } } catch e: DatasetNotFoundError { - fileErrorMsg = "1 or more Datasets not found in file %s".format(fname); + fileErrorMsg = "1 or more Datasets not found in file %s".doFormat(fname); csvLogger.error(getModuleName(),getRoutineName(),getLineNumber(),fileErrorMsg); hadError = true; if !allowErrors { return new MsgTuple(e.message(), MsgType.ERROR); } } catch e: SegStringError { - fileErrorMsg = "SegmentedString error: %s".format(e.message()); + fileErrorMsg = "SegmentedString error: %s".doFormat(e.message()); csvLogger.error(getModuleName(),getRoutineName(),getLineNumber(),fileErrorMsg); hadError = true; if !allowErrors { return new MsgTuple(fileErrorMsg, MsgType.ERROR); } } catch e : Error { - fileErrorMsg = "Other error in accessing file %s: %s".format(fname,e.message()); + fileErrorMsg = "Other error in accessing file %s: %s".doFormat(fname,e.message()); csvLogger.error(getModuleName(),getRoutineName(),getLineNumber(),fileErrorMsg); hadError = true; if !allowErrors { return new MsgTuple(fileErrorMsg, MsgType.ERROR); } @@ -613,18 +614,18 @@ module CSVMsg { for (isValid, fname, dt, rc, hh) in zip(validFiles, filenames, data_types, row_cts, headers) { if isValid { if (dtype != dt) { - var errorMsg = "Inconsistent dtypes in file %s".format(fname); + var errorMsg = "Inconsistent dtypes in file %s".doFormat(fname); csvLogger.error(getModuleName(),getRoutineName(),getLineNumber(),errorMsg); return new MsgTuple(errorMsg, MsgType.ERROR); } else if (hasHeader != hh){ - var errorMsg = "Inconsistent file formatting. %s has no header.".format(fname); + var errorMsg = "Inconsistent file formatting. %s has no header.".doFormat(fname); csvLogger.error(getModuleName(),getRoutineName(),getLineNumber(),errorMsg); return new MsgTuple(errorMsg, MsgType.ERROR); } } csvLogger.debug(getModuleName(),getRoutineName(),getLineNumber(), - "Verified all dtypes across files for file %s".format(fname)); + "Verified all dtypes across files for file %s".doFormat(fname)); } var rtnMsg: string; diff --git a/src/Cast.chpl b/src/Cast.chpl index 26136017ba..204ed3f1f7 100644 --- a/src/Cast.chpl +++ b/src/Cast.chpl @@ -21,10 +21,10 @@ module Cast { try { after.a = before.a : toType; } catch e: IllegalArgumentError { - var errorMsg = "bad value in cast from %s to %s".format(fromType:string, + var errorMsg = "bad value in cast from %s to %s".doFormat(fromType:string, toType:string); castLogger.error(getModuleName(),getRoutineName(),getLineNumber(),errorMsg); - return "Error: %s".format(errorMsg); + return "Error: %s".doFormat(errorMsg); } var returnMsg = "created " + st.attrib(name); @@ -44,9 +44,9 @@ module Cast { tmp = before.a:bigint; } } catch e: IllegalArgumentError { - var errorMsg = "bad value in cast from %s to bigint".format(fromType:string); + var errorMsg = "bad value in cast from %s to bigint".doFormat(fromType:string); castLogger.error(getModuleName(),getRoutineName(),getLineNumber(),errorMsg); - return "Error: %s".format(errorMsg); + return "Error: %s".doFormat(errorMsg); } var after = st.addEntry(name, new shared SymEntry(tmp)); @@ -64,20 +64,20 @@ module Cast { if fromType == real { try { forall (s, v) in zip(strings, before.a) { - s = "%.17r".format(v); + s = "%.17r".doFormat(v); } } catch e { var errorMsg = "could not convert float64 value to decimal representation"; castLogger.error(getModuleName(),getRoutineName(),getLineNumber(),errorMsg); - return "Error: %s".format(errorMsg); + return "Error: %s".doFormat(errorMsg); } } else { try { strings = [s in before.a] s : string; } catch e: IllegalArgumentError { - var errorMsg = "bad value in cast from %s to string".format(fromType:string); + var errorMsg = "bad value in cast from %s to string".doFormat(fromType:string); castLogger.error(getModuleName(),getRoutineName(),getLineNumber(),errorMsg); - return "Error: %s".format(errorMsg); + return "Error: %s".doFormat(errorMsg); } } const byteLengths = [s in strings] s.numBytes + 1; diff --git a/src/CastMsg.chpl b/src/CastMsg.chpl index f6387306c0..a06d6a433f 100644 --- a/src/CastMsg.chpl +++ b/src/CastMsg.chpl @@ -22,7 +22,7 @@ module CastMsg { var targetDtype = msgArgs.getValueOf("targetDtype"); var opt = msgArgs.getValueOf("opt"); castLogger.debug(getModuleName(),getRoutineName(),getLineNumber(), - "name: %s obgtype: %t targetDtype: %t opt: %t".format( + "name: %s obgtype: %? targetDtype: %? opt: %?".doFormat( name,objtype,targetDtype,opt)); select objtype { when ObjType.PDARRAY { diff --git a/src/CommandMap.chpl b/src/CommandMap.chpl index ca4fd55344..e6bbb762f2 100644 --- a/src/CommandMap.chpl +++ b/src/CommandMap.chpl @@ -3,6 +3,7 @@ module CommandMap { use MultiTypeSymbolTable; use ArkoudaFileCompat; + use ArkoudaIOCompat; use Map; /** @@ -74,8 +75,8 @@ module CommandMap { * Dump the combined contents of the command maps as a single json encoded string */ proc dumpCommandMap(): string throws { - var cm1:string = "%jt".format(commandMap); - var cm2:string = "%jt".format(commandMapBinary); + var cm1:string = formatJson(commandMap); + var cm2:string = formatJson(commandMapBinary); // Join these two together var idx_close = cm1.rfind("}"):int; return cm1(0..idx_close-1) + ", " + cm2(1..cm2.size-1); @@ -87,7 +88,7 @@ module CommandMap { usedModules.add(moduleMap[cmd]); repTuple = commandMap[cmd](cmd, msgArgs, st); } else { - repTuple = new MsgTuple("Unrecognized command: %s".format(cmd), MsgType.ERROR); + repTuple = new MsgTuple("Unrecognized command: %s".doFormat(cmd), MsgType.ERROR); } return repTuple; } diff --git a/src/ConcatenateMsg.chpl b/src/ConcatenateMsg.chpl index 241690b517..b80c77c75d 100644 --- a/src/ConcatenateMsg.chpl +++ b/src/ConcatenateMsg.chpl @@ -35,12 +35,12 @@ module ConcatenateMsg var names = msgArgs.get("names").getList(n); cmLogger.debug(getModuleName(),getRoutineName(), getLineNumber(), - "number of arrays: %i names: %t".format(n,names)); + "number of arrays: %i names: %?".doFormat(n,names)); // Check that fields contains the stated number of arrays if (n != names.size) { var errorMsg = incompatibleArgumentsError(pn, - "Expected %i arrays but got %i".format(n, names.size)); + "Expected %i arrays but got %i".doFormat(n, names.size)); cmLogger.error(getModuleName(),getRoutineName(),getLineNumber(),errorMsg); return new MsgTuple(errorMsg, MsgType.ERROR); } @@ -62,18 +62,18 @@ module ConcatenateMsg valSize = segString.nBytes; } catch e: Error { throw getErrorWithContext( - msg="lookup for %s failed".format(name), + msg="lookup for %s failed".doFormat(name), lineNumber=getLineNumber(), routineName=getRoutineName(), moduleName=getModuleName(), errorClass="UnknownSymbolError"); } cmLogger.debug(getModuleName(),getRoutineName(),getLineNumber(), - "name: %s".format(name)); + "name: %s".doFormat(name)); } when ObjType.PDARRAY { cmLogger.debug(getModuleName(),getRoutineName(),getLineNumber(), - "pdarray name %s".format(name)); + "pdarray name %s".doFormat(name)); } otherwise { var errorMsg = notImplementedError(pn, objtype: string); @@ -91,7 +91,7 @@ module ConcatenateMsg } else { // Check that all dtype's are the same across the list of arrays to concat if (dtype != entryDtype) { var errorMsg = incompatibleArgumentsError(pn, - "Expected %s dtype but got %s dtype".format(dtype2str(dtype), + "Expected %s dtype but got %s dtype".doFormat(dtype2str(dtype), dtype2str(entryDtype))); cmLogger.error(getModuleName(),getRoutineName(),getLineNumber(),errorMsg); return new MsgTuple(errorMsg,MsgType.ERROR); @@ -207,16 +207,16 @@ module ConcatenateMsg valStart += thisVals.size; } } - var repMsg = "created " + st.attrib(retString.name) + "+created bytes.size %t".format(retString.nBytes); + var repMsg = "created " + st.attrib(retString.name) + "+created bytes.size %?".doFormat(retString.nBytes); // var repMsg = "created " + st.attrib(retString.name) + "+created " + st.attrib(retString.name); cmLogger.debug(getModuleName(),getRoutineName(),getLineNumber(), - "created concatenated pdarray %s".format(st.attrib(retString.name))); + "created concatenated pdarray %s".doFormat(st.attrib(retString.name))); return new MsgTuple(repMsg, MsgType.NORMAL); } when ObjType.PDARRAY { var rname = st.nextName(); cmLogger.debug(getModuleName(),getRoutineName(),getLineNumber(), - "creating pdarray %s of type %t".format(rname,dtype)); + "creating pdarray %s of type %?".doFormat(rname,dtype)); select (dtype) { when DType.Int64 { // create array to copy into @@ -245,7 +245,7 @@ module ConcatenateMsg } } cmLogger.debug(getModuleName(),getRoutineName(),getLineNumber(), - "created concatenated pdarray: %s".format(st.attrib(rname))); + "created concatenated pdarray: %s".doFormat(st.attrib(rname))); } when DType.Float64 { // create array to copy into @@ -274,7 +274,7 @@ module ConcatenateMsg } } cmLogger.debug(getModuleName(),getRoutineName(),getLineNumber(), - "created concatenated pdarray: %s".format(st.attrib(rname))); + "created concatenated pdarray: %s".doFormat(st.attrib(rname))); } when DType.Bool { // create array to copy into @@ -303,7 +303,7 @@ module ConcatenateMsg } } cmLogger.debug(getModuleName(),getRoutineName(),getLineNumber(), - "created concatenated pdarray: %s".format(st.attrib(rname))); + "created concatenated pdarray: %s".doFormat(st.attrib(rname))); } when DType.UInt64 { // create array to copy into @@ -332,7 +332,7 @@ module ConcatenateMsg } } cmLogger.debug(getModuleName(),getRoutineName(),getLineNumber(), - "created concatenated pdarray: %s".format(st.attrib(rname))); + "created concatenated pdarray: %s".doFormat(st.attrib(rname))); } when DType.BigInt { // create array to copy into @@ -363,7 +363,7 @@ module ConcatenateMsg } st.addEntry(rname, new shared SymEntry(tmp, max_bits)); cmLogger.debug(getModuleName(),getRoutineName(),getLineNumber(), - "created concatenated pdarray: %s".format(st.attrib(rname))); + "created concatenated pdarray: %s".doFormat(st.attrib(rname))); } otherwise { var errorMsg = notImplementedError("concatenate",dtype); diff --git a/src/DataFrameIndexingMsg.chpl b/src/DataFrameIndexingMsg.chpl index ddf4173ca3..6c83202659 100644 --- a/src/DataFrameIndexingMsg.chpl +++ b/src/DataFrameIndexingMsg.chpl @@ -13,6 +13,7 @@ use MultiTypeSymEntry; use MultiTypeSymbolTable; + use ArkoudaIOCompat; private config const logLevel = ServerConfig.logLevel; private config const logChannel = ServerConfig.logChannel; @@ -29,18 +30,18 @@ if rtnName { return rname; } - var repMsg = "pdarray+%s+created %s".format(col, st.attrib(rname)); + var repMsg = "pdarray+%s+created %s".doFormat(col, st.attrib(rname)); return repMsg; } var idxMin = min reduce idx.a; var idxMax = max reduce idx.a; if idxMin < 0 { - var errorMsg = "Error: %s: OOBindex %i < 0".format(pn,idxMin); + var errorMsg = "Error: %s: OOBindex %i < 0".doFormat(pn,idxMin); dfiLogger.error(getModuleName(),getRoutineName(),getLineNumber(),errorMsg); throw new owned IllegalArgumentError(errorMsg); } if idxMax >= columnVals.size { - var errorMsg = "Error: %s: OOBindex %i > %i".format(pn,idxMin,columnVals.size-1); + var errorMsg = "Error: %s: OOBindex %i > %i".doFormat(pn,idxMin,columnVals.size-1); dfiLogger.error(getModuleName(),getRoutineName(),getLineNumber(),errorMsg); throw new owned IllegalArgumentError(errorMsg); } @@ -56,7 +57,7 @@ return rname; } - var repMsg = "%s+%s+created %s".format(objType, col, st.attrib(rname)); + var repMsg = "%s+%s+created %s".doFormat(objType, col, st.attrib(rname)); return repMsg; } @@ -92,7 +93,7 @@ var v_name = st.nextName(); st.addEntry(v_name, new shared SymEntry(rvals)); - return "SegArray+%s+created %s+created %s".format(col, st.attrib(s_name), st.attrib(v_name)); + return "SegArray+%s+created %s+created %s".doFormat(col, st.attrib(s_name), st.attrib(v_name)); } proc dataframeBatchIndexingMsg(cmd: string, msgArgs: borrowed MessageArgs, st: borrowed SymTab): MsgTuple throws { @@ -113,7 +114,7 @@ if ele_parts[0] == "Categorical" { ref codes_name = ele_parts[2]; ref categories_name = ele_parts[3]; - dfiLogger.debug(getModuleName(),getRoutineName(),getLineNumber(),"Element at %i is Categorical\nCodes Name: %s, Categories Name: %s".format(i, codes_name, categories_name)); + dfiLogger.debug(getModuleName(),getRoutineName(),getLineNumber(),"Element at %i is Categorical\nCodes Name: %s, Categories Name: %s".doFormat(i, codes_name, categories_name)); var gCode: borrowed GenSymEntry = getGenericTypedArrayEntry(codes_name, st); var code_vals = toSymEntry(gCode, int); @@ -125,42 +126,42 @@ throw new IllegalArgumentError(repTup.msg); } - rpm = "%jt".format("Strings+%s+%s".format(col_name, repTup.msg)); + rpm = formatJson("Strings+%s+%s".doFormat(col_name, repTup.msg)); } else if ele_parts[0] == "Strings"{ - dfiLogger.debug(getModuleName(),getRoutineName(),getLineNumber(),"Element at %i is Strings. Name: %s".format(i, ele_parts[2])); + dfiLogger.debug(getModuleName(),getRoutineName(),getLineNumber(),"Element at %i is Strings. Name: %s".doFormat(i, ele_parts[2])); var repTup = segPdarrayIndex(ObjType.STRINGS, ele_parts[2], msgArgs.getValueOf("idx_name"), DType.UInt8, st); if repTup.msgType == MsgType.ERROR { throw new IllegalArgumentError(repTup.msg); } - rpm = "%jt".format("Strings+%s+%s".format(col_name, repTup.msg)); + rpm = formatJson("Strings+%s+%s".doFormat(col_name, repTup.msg)); } else if ele_parts[0] == "pdarray" || ele_parts[0] == "IPv4" || ele_parts[0] == "Fields" || ele_parts[0] == "Datetime" || ele_parts[0] == "BitVector"{ - dfiLogger.debug(getModuleName(),getRoutineName(),getLineNumber(),"Element at %i is pdarray. Name: %s".format(i, ele_parts[2])); + dfiLogger.debug(getModuleName(),getRoutineName(),getLineNumber(),"Element at %i is pdarray. Name: %s".doFormat(i, ele_parts[2])); var gCol: borrowed GenSymEntry = getGenericTypedArrayEntry(ele_parts[2], st); select (gCol.dtype) { when (DType.Int64) { var col_vals = toSymEntry(gCol, int); - rpm = "%jt".format(dfIdxHelper(idx, col_vals, st, col_name, ele_parts[0])); + rpm = formatJson(dfIdxHelper(idx, col_vals, st, col_name, ele_parts[0])); } when (DType.UInt64) { var col_vals = toSymEntry(gCol, uint); - rpm = "%jt".format(dfIdxHelper(idx, col_vals, st, col_name, ele_parts[0])); + rpm = formatJson(dfIdxHelper(idx, col_vals, st, col_name, ele_parts[0])); } when (DType.Bool) { var col_vals = toSymEntry(gCol, bool); - rpm = "%jt".format(dfIdxHelper(idx, col_vals, st, col_name, ele_parts[0])); + rpm = formatJson(dfIdxHelper(idx, col_vals, st, col_name, ele_parts[0])); } when (DType.Float64){ var col_vals = toSymEntry(gCol, real); - rpm = "%jt".format(dfIdxHelper(idx, col_vals, st, col_name, ele_parts[0])); + rpm = formatJson(dfIdxHelper(idx, col_vals, st, col_name, ele_parts[0])); } when (DType.BigInt){ var col_vals = toSymEntry(gCol, bigint); - rpm = "%jt".format(dfIdxHelper(idx, col_vals, st, col_name, ele_parts[0])); + rpm = formatJson(dfIdxHelper(idx, col_vals, st, col_name, ele_parts[0])); } otherwise { var errorMsg = notImplementedError(pn,dtype2str(gCol.dtype)); @@ -170,10 +171,10 @@ } } else if ele_parts[0] == "SegArray" { - dfiLogger.debug(getModuleName(),getRoutineName(),getLineNumber(),"Element at %i is SegArray".format(i)); + dfiLogger.debug(getModuleName(),getRoutineName(),getLineNumber(),"Element at %i is SegArray".doFormat(i)); ref segments_name = ele_parts[2]; ref values_name = ele_parts[3]; - dfiLogger.debug(getModuleName(),getRoutineName(),getLineNumber(),"Segments Name: %s, Values Name: %s".format(segments_name, values_name)); + dfiLogger.debug(getModuleName(),getRoutineName(),getLineNumber(),"Segments Name: %s, Values Name: %s".doFormat(segments_name, values_name)); var gSeg: borrowed GenSymEntry = getGenericTypedArrayEntry(segments_name, st); var segments = toSymEntry(gSeg, int); @@ -181,19 +182,19 @@ select(gVal.dtype){ when(DType.Int64){ var values = toSymEntry(gVal, int); - rpm = "%jt".format(df_seg_array_idx(idx, segments, values, col_name, st)); + rpm = formatJson(df_seg_array_idx(idx, segments, values, col_name, st)); } when(DType.UInt64){ var values = toSymEntry(gVal, uint); - rpm = "%jt".format(df_seg_array_idx(idx, segments, values, col_name, st)); + rpm = formatJson(df_seg_array_idx(idx, segments, values, col_name, st)); } when(DType.Float64){ var values = toSymEntry(gVal, real); - rpm = "%jt".format(df_seg_array_idx(idx, segments, values, col_name, st)); + rpm = formatJson(df_seg_array_idx(idx, segments, values, col_name, st)); } when(DType.Bool){ var values = toSymEntry(gVal, bool); - rpm = "%jt".format(df_seg_array_idx(idx, segments, values, col_name, st)); + rpm = formatJson(df_seg_array_idx(idx, segments, values, col_name, st)); } otherwise { var errorMsg = notImplementedError(pn,dtype2str(gVal.dtype)); @@ -208,7 +209,7 @@ throw new IllegalArgumentError(errorMsg); } } - repMsg = "[%s]".format(",".join(repMsgList)); + repMsg = "[%s]".doFormat(",".join(repMsgList)); dfiLogger.debug(getModuleName(),getRoutineName(),getLineNumber(),repMsg); return new MsgTuple(repMsg, MsgType.NORMAL); } diff --git a/src/EfuncMsg.chpl b/src/EfuncMsg.chpl index bf9c25217a..6631044dda 100644 --- a/src/EfuncMsg.chpl +++ b/src/EfuncMsg.chpl @@ -53,7 +53,7 @@ module EfuncMsg var gEnt: borrowed GenSymEntry = getGenericTypedArrayEntry(name, st); eLogger.debug(getModuleName(),getRoutineName(),getLineNumber(), - "cmd: %s efunc: %s pdarray: %s".format(cmd,efunc,st.attrib(name))); + "cmd: %s efunc: %s pdarray: %s".doFormat(cmd,efunc,st.attrib(name))); select (gEnt.dtype) { when (DType.Int64) { @@ -847,7 +847,7 @@ module EfuncMsg var name1 = msgArgs.getValueOf("condition"); var name2 = msgArgs.getValueOf("a"); eLogger.debug(getModuleName(),getRoutineName(),getLineNumber(), - "cmd: %s efunc: %s scalar: %s dtype: %s name1: %s name2: %s rname: %s".format( + "cmd: %s efunc: %s scalar: %s dtype: %s name1: %s name2: %s rname: %s".doFormat( cmd,efunc,msgArgs.getValueOf("scalar"),dtype,name1,name2,rname)); var g1: borrowed GenSymEntry = getGenericTypedArrayEntry(name1, st); @@ -961,7 +961,7 @@ module EfuncMsg var name1 = msgArgs.getValueOf("condition"); var name2 = msgArgs.getValueOf("b"); eLogger.debug(getModuleName(),getRoutineName(),getLineNumber(), - "cmd: %s efunc: %s scalar: %s dtype: %s name1: %s name2: %s rname: %s".format( + "cmd: %s efunc: %s scalar: %s dtype: %s name1: %s name2: %s rname: %s".doFormat( cmd,efunc,msgArgs.getValueOf("scalar"),dtype,name1,name2,rname)); var g1: borrowed GenSymEntry = getGenericTypedArrayEntry(name1, st); @@ -1075,7 +1075,7 @@ module EfuncMsg var name1 = msgArgs.getValueOf("condition"); eLogger.debug(getModuleName(),getRoutineName(),getLineNumber(), - "cmd: %s efunc: %s scalar1: %s dtype1: %s scalar2: %s name: %s rname: %s".format( + "cmd: %s efunc: %s scalar1: %s dtype1: %s scalar2: %s name: %s rname: %s".doFormat( cmd,efunc,msgArgs.getValueOf("a"),dtype,msgArgs.getValueOf("b"),name1,rname)); var g1: borrowed GenSymEntry = getGenericTypedArrayEntry(name1, st); diff --git a/src/EncodingMsg.chpl b/src/EncodingMsg.chpl index 645ed2cb7a..3ed3cf3386 100644 --- a/src/EncodingMsg.chpl +++ b/src/EncodingMsg.chpl @@ -31,7 +31,7 @@ module EncodingMsg { var (offsets, vals) = encodeDecode(stringsObj, toEncoding, fromEncoding); var encodedStrings = getSegString(offsets, vals, st); - repMsg = "created " + st.attrib(encodedStrings.name) + "+created bytes.size %t".format(encodedStrings.nBytes); + repMsg = "created " + st.attrib(encodedStrings.name) + "+created bytes.size %?".doFormat(encodedStrings.nBytes); emLogger.debug(getModuleName(), getRoutineName(), getLineNumber(), repMsg); return new MsgTuple(repMsg, MsgType.NORMAL); diff --git a/src/ExternalIntegration.chpl b/src/ExternalIntegration.chpl index 9e24e68033..c1cc406bcc 100644 --- a/src/ExternalIntegration.chpl +++ b/src/ExternalIntegration.chpl @@ -80,7 +80,7 @@ module ExternalIntegration { hostip.split(); } catch (e: Error) { throw new IllegalArgumentError( - "invalid hostname -> ip address entry in /etc/hosts %t".format( + "invalid hostname -> ip address entry in /etc/hosts %?".doFormat( e)); } } @@ -208,26 +208,26 @@ module ExternalIntegration { Curl.curl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, this.requestType:string); eiLogger.debug(getModuleName(),getRoutineName(),getLineNumber(), - "Configured HttpChannel for type %s format %s".format( + "Configured HttpChannel for type %s format %s".doFormat( this.requestType, this.requestFormat)); eiLogger.debug(getModuleName(),getRoutineName(),getLineNumber(), - "Executing Http request with payload %s".format(payload)); + "Executing Http request with payload %s".doFormat(payload)); var ret = Curl.curl_easy_perform(curl); if ret == 0 { eiLogger.debug(getModuleName(),getRoutineName(),getLineNumber(), - "Successfully executed Http request with payload %s".format(payload)); + "Successfully executed Http request with payload %s".doFormat(payload)); } else { if ret == 22 { throw getErrorWithContext(getLineNumber(),getRoutineName(),getModuleName(), - "invalid request to overwrite existing entry with payload %s. Delete the existing entry first".format(payload), + "invalid request to overwrite existing entry with payload %s. Delete the existing entry first".doFormat(payload), "ExternalSystemError"); } else { throw getErrorWithContext(getLineNumber(),getRoutineName(),getModuleName(), - "request with payload %s returned error code %i".format(payload,ret), + "request with payload %s returned error code %i".doFormat(payload,ret), "ExternalSystemError"); } } @@ -332,20 +332,20 @@ module ExternalIntegration { proc generateEndpointCreateUrl() : string throws { var k8sHost = ServerConfig.getEnv('K8S_HOST'); var namespace = ServerConfig.getEnv('NAMESPACE'); - return '%s/api/v1/namespaces/%s/endpoints'.format(k8sHost,namespace); + return '%s/api/v1/namespaces/%s/endpoints'.doFormat(k8sHost,namespace); } proc generateEndpointUpdateUrl() : string throws { var k8sHost = ServerConfig.getEnv('K8S_HOST'); var namespace = ServerConfig.getEnv('NAMESPACE'); var name = ServerConfig.getEnv('ENDPOINT_NAME'); - return '%s/api/v1/namespaces/%s/endpoints/%s'.format(k8sHost,namespace,name); + return '%s/api/v1/namespaces/%s/endpoints/%s'.doFormat(k8sHost,namespace,name); } proc generateServiceCreateUrl() : string throws { var k8sHost = ServerConfig.getEnv('K8S_HOST'); var namespace = ServerConfig.getEnv(name='NAMESPACE',default='default'); - return '%s/api/v1/namespaces/%s/services'.format(k8sHost,namespace); + return '%s/api/v1/namespaces/%s/services'.doFormat(k8sHost,namespace); } proc registerAsInternalService(appName: string, serviceName: string, servicePort: int, @@ -354,14 +354,14 @@ module ExternalIntegration { var servicePayload = "".join('{"apiVersion": "v1","kind": "Service","metadata": ', '{"name": "%s"},"spec": {"ports": [{"port": %i,' , '"protocol": "TCP","targetPort": %i}],"selector":', - ' {"app":"%s"}}}').format( + ' {"app":"%s"}}}').doFormat( serviceName, servicePort, targetPort, appName); eiLogger.debug(getModuleName(),getRoutineName(),getLineNumber(), - "Registering internal service via payload %s and url %s".format( + "Registering internal service via payload %s and url %s".doFormat( servicePayload,serviceUrl)); var channel = getExternalChannel(new HttpChannelParams( @@ -379,7 +379,7 @@ module ExternalIntegration { channel.write(servicePayload); eiLogger.debug(getModuleName(),getRoutineName(),getLineNumber(), - "Registered internal service via payload %s and url %s".format( + "Registered internal service via payload %s and url %s".doFormat( servicePayload,serviceUrl)); } @@ -394,12 +394,12 @@ module ExternalIntegration { var serviceUrl = generateServiceCreateUrl(); var servicePayload = "".join('{"apiVersion": "v1","kind": "Service","metadata": ', '{"name": "%s"},"spec": {"ports": [{"port": %i,', - '"protocol": "TCP","targetPort": %i}]}}').format( + '"protocol": "TCP","targetPort": %i}]}}').doFormat( serviceName, servicePort, serviceTargetPort); eiLogger.debug(getModuleName(),getRoutineName(),getLineNumber(), - "Registering external service via payload %s and url %s".format( + "Registering external service via payload %s and url %s".doFormat( servicePayload,serviceUrl)); var channel = getExternalChannel(new HttpChannelParams( @@ -416,7 +416,7 @@ module ExternalIntegration { channel.write(servicePayload); eiLogger.debug(getModuleName(),getRoutineName(),getLineNumber(), - "Registered external service via payload %s and url %s".format( + "Registered external service via payload %s and url %s".doFormat( servicePayload,serviceUrl)); // Create Kubernetes Endpoints @@ -424,7 +424,7 @@ module ExternalIntegration { var endpointPayload = "".join('{"kind": "Endpoints","apiVersion": "v1",', ' "metadata": {"name": "%s"}, "subsets": ', '[{"addresses": [{"ip": "%s"}],"ports": ', - '[{"port": %i, "protocol": "TCP"}]}]}').format( + '[{"port": %i, "protocol": "TCP"}]}]}').doFormat( serviceName, getConnectHostIp(), servicePort); @@ -442,12 +442,12 @@ module ExternalIntegration { sslKeyPasswd=ServerConfig.getEnv('KEY_PASSWD'))); eiLogger.debug(getModuleName(),getRoutineName(),getLineNumber(), - "Registering endpoint via payload %s and url %s".format( + "Registering endpoint via payload %s and url %s".doFormat( endpointPayload,endpointUrl)); channel.write(endpointPayload); eiLogger.debug(getModuleName(),getRoutineName(),getLineNumber(), - "Registered endpoint via payload %s and endpointUrl %s".format( + "Registered endpoint via payload %s and endpointUrl %s".doFormat( endpointPayload,endpointUrl)); } } @@ -461,7 +461,7 @@ module ExternalIntegration { proc generateServiceDeleteUrl(serviceName: string) throws { var k8sHost = ServerConfig.getEnv('K8S_HOST'); var namespace = ServerConfig.getEnv('NAMESPACE'); - return '%s/api/v1/namespaces/%s/services/%s'.format(k8sHost,namespace,serviceName); + return '%s/api/v1/namespaces/%s/services/%s'.doFormat(k8sHost,namespace,serviceName); } var url = generateServiceDeleteUrl(serviceName); @@ -478,7 +478,7 @@ module ExternalIntegration { sslKeyPasswd=ServerConfig.getEnv('KEY_PASSWD'))); channel.write('{}'); eiLogger.debug(getModuleName(),getRoutineName(),getLineNumber(), - "Deregistered service %s from Kubernetes via url %s".format(serviceName, + "Deregistered service %s from Kubernetes via url %s".doFormat(serviceName, url)); } @@ -540,7 +540,7 @@ module ExternalIntegration { when SystemType.KUBERNETES { deregisterFromKubernetes(serviceName); eiLogger.debug(getModuleName(),getRoutineName(),getLineNumber(), - "Deregistered service %s from Kubernetes".format(serviceName)); + "Deregistered service %s from Kubernetes".doFormat(serviceName)); } otherwise { eiLogger.debug(getModuleName(),getRoutineName(),getLineNumber(), diff --git a/src/FileIO.chpl b/src/FileIO.chpl index 64f6fe2c05..9a1680faf9 100644 --- a/src/FileIO.chpl +++ b/src/FileIO.chpl @@ -14,6 +14,7 @@ module FileIO { use ArkoudaFileCompat; use ArkoudaRangeCompat; + use ArkoudaIOCompat; use ServerConfig, Logging, CommandMap; private config const logLevel = ServerConfig.logLevel; @@ -144,7 +145,7 @@ module FileIO { filenames[i] = generateFilename(prefix, extension, i); } fioLogger.debug(getModuleName(),getRoutineName(),getLineNumber(), - "generateFilenames targetLocales.size %i, filenames.size %i".format(targetLocalesSize, filenames.size)); + "generateFilenames targetLocales.size %i, filenames.size %i".doFormat(targetLocalesSize, filenames.size)); return filenames; } @@ -154,8 +155,8 @@ module FileIO { * the user along with a file index and extension. */ proc generateFilename(prefix : string, extension : string, idx : int) : string throws { - var suffix = '%04i'.format(idx); - return "%s_LOCALE%s%s".format(prefix, suffix, extension); + var suffix = '%04i'.doFormat(idx); + return "%s_LOCALE%s%s".doFormat(prefix, suffix, extension); } /* @@ -164,7 +165,7 @@ module FileIO { * being overwritten. */ proc getMatchingFilenames(prefix : string, extension : string) throws { - return glob("%s_LOCALE*%s".format(prefix, extension)); + return glob("%s_LOCALE*%s".doFormat(prefix, extension)); } /* @@ -247,7 +248,7 @@ module FileIO { f.close(); } catch e { throw getErrorWithContext( - msg=e:string, + msg=formatString(e), getLineNumber(), getRoutineName(), getModuleName(), @@ -269,7 +270,7 @@ module FileIO { var tmp = glob(filename); if tmp.size <= 0 { - var errorMsg = "Cannot retrieve filename from glob expression %s, check file name or format".format(filename); + var errorMsg = "Cannot retrieve filename from glob expression %s, check file name or format".doFormat(filename); return new MsgTuple(errorMsg, MsgType.ERROR); } @@ -278,7 +279,7 @@ module FileIO { } if !exists(filename) { - var errorMsg = "File %s does not exist in a location accessible to Arkouda".format(filename); + var errorMsg = "File %s does not exist in a location accessible to Arkouda".doFormat(filename); return new MsgTuple(errorMsg,MsgType.ERROR); } @@ -313,7 +314,7 @@ module FileIO { var tmp = glob(filename); if tmp.size <= 0 { - var errorMsg = "Cannot retrieve filename from glob expression %s, check file name or format".format(filename); + var errorMsg = "Cannot retrieve filename from glob expression %s, check file name or format".doFormat(filename); return new MsgTuple(errorMsg, MsgType.ERROR); } @@ -321,9 +322,9 @@ module FileIO { filename = tmp[tmp.domain.first]; } fioLogger.debug(getModuleName(),getRoutineName(),getLineNumber(), - "FILENAME: %s".format(filename)); + "FILENAME: %s".doFormat(filename)); if !exists(filename) { - var errorMsg = "File %s does not exist in a location accessible to Arkouda".format(filename); + var errorMsg = "File %s does not exist in a location accessible to Arkouda".doFormat(filename); return new MsgTuple(errorMsg,MsgType.ERROR); } @@ -354,7 +355,7 @@ module FileIO { var n: int = 1000; var jsonfiles = msgArgs.getValueOf("filenames"); var files: string = if jsonfiles.size > 2*n then jsonfiles[0..#n]+'...'+jsonfiles[jsonfiles.size-n..#n] else jsonfiles; - var errorMsg = "Could not decode json filenames via tempfile (%i files: %s)".format(nfiles, files); + var errorMsg = "Could not decode json filenames via tempfile (%i files: %s)".doFormat(nfiles, files); fioLogger.error(getModuleName(),getRoutineName(),getLineNumber(),errorMsg); return new MsgTuple(errorMsg, MsgType.ERROR); } @@ -370,9 +371,9 @@ module FileIO { } var tmp = glob(filelist[0]); fioLogger.debug(getModuleName(),getRoutineName(),getLineNumber(), - "glob expanded %s to %i files".format(filelist[0], tmp.size)); + "glob expanded %s to %i files".doFormat(filelist[0], tmp.size)); if tmp.size == 0 { - var errorMsg = "The wildcarded filename %s either corresponds to files inaccessible to Arkouda or files of an invalid format".format(filelist[0]); + var errorMsg = "The wildcarded filename %s either corresponds to files inaccessible to Arkouda or files of an invalid format".doFormat(filelist[0]); fioLogger.error(getModuleName(),getRoutineName(),getLineNumber(),errorMsg); return new MsgTuple(errorMsg, MsgType.ERROR); } @@ -384,6 +385,6 @@ module FileIO { // assumes that we are providing filenames = filelist; } - return new MsgTuple("%jt".format(filenames), MsgType.NORMAL); + return new MsgTuple(formatJson(filenames), MsgType.NORMAL); } } diff --git a/src/FlattenMsg.chpl b/src/FlattenMsg.chpl index 5edd615684..c0a18ded94 100644 --- a/src/FlattenMsg.chpl +++ b/src/FlattenMsg.chpl @@ -26,14 +26,14 @@ module FlattenMsg { const strings = getSegString(msgArgs.getValueOf("values"), st); var (off, val, segs) = strings.flatten(delim, returnSegs, regex); var stringsObj = getSegString(off, val, st); - repMsg = "created %s+created bytes.size %t".format(st.attrib(stringsObj.name), stringsObj.nBytes); + repMsg = "created %s+created bytes.size %?".doFormat(st.attrib(stringsObj.name), stringsObj.nBytes); if returnSegs { const optName: string = st.nextName(); st.addEntry(optName, new shared SymEntry(segs)); - repMsg += "+created %s".format(st.attrib(optName)); + repMsg += "+created %s".doFormat(st.attrib(optName)); } } otherwise { - throw new owned ErrorWithContext("Not implemented for objtype %s".format(objtype), + throw new owned ErrorWithContext("Not implemented for objtype %s".doFormat(objtype), getLineNumber(), getRoutineName(), getModuleName(), @@ -60,7 +60,7 @@ module FlattenMsg { const pattern: string = msgArgs.getValueOf("pattern"); fmLogger.debug(getModuleName(), getRoutineName(), getLineNumber(), - "cmd: %s objtype: %t".format(cmd, objtype)); + "cmd: %s objtype: %?".doFormat(cmd, objtype)); select objtype { when "Matcher" { @@ -68,14 +68,14 @@ module FlattenMsg { const strings = getSegString(name, st); var (off, val, segs) = strings.split(pattern, maxsplit, returnSegs); var retString = getSegString(off, val, st); - repMsg = "created " + st.attrib(retString.name) + "+created bytes.size %t".format(retString.nBytes); + repMsg = "created " + st.attrib(retString.name) + "+created bytes.size %?".doFormat(retString.nBytes); if returnSegs { st.addEntry(optName, new shared SymEntry(segs)); - repMsg += "+created %s".format(st.attrib(optName)); + repMsg += "+created %s".doFormat(st.attrib(optName)); } } otherwise { - throw new owned ErrorWithContext("Not implemented for objtype %s".format(objtype), + throw new owned ErrorWithContext("Not implemented for objtype %s".doFormat(objtype), getLineNumber(), getRoutineName(), getModuleName(), diff --git a/src/GenSymIO.chpl b/src/GenSymIO.chpl index cf82cc9951..383db2901e 100644 --- a/src/GenSymIO.chpl +++ b/src/GenSymIO.chpl @@ -17,11 +17,12 @@ module GenSymIO { use ServerConfig; use SegmentedString; use Map; + use ArkoudaMapCompat; use ArkoudaListCompat; use ArkoudaStringBytesCompat; use ArkoudaCTypesCompat; - + use ArkoudaIOCompat; private config const logLevel = ServerConfig.logLevel; private config const logChannel = ServerConfig.logChannel; @@ -54,7 +55,7 @@ module GenSymIO { overMemLimit(2*size); gsLogger.debug(getModuleName(),getRoutineName(),getLineNumber(), - "dtype: %t size: %i".format(dtype,size)); + "dtype: %? size: %i".doFormat(dtype,size)); proc bytesToSymEntry(size:int, type t, st: borrowed SymTab, ref data:bytes): string throws { var entry = new shared SymEntry(size, t); @@ -76,7 +77,7 @@ module GenSymIO { } else if dtype == DType.UInt8 { rname = bytesToSymEntry(size, uint(8), st, data); } else { - msg = "Unhandled data type %s".format(msgArgs.getValueOf("dtype")); + msg = "Unhandled data type %s".doFormat(msgArgs.getValueOf("dtype")); msgType = MsgType.ERROR; gsLogger.error(getModuleName(),getRoutineName(),getLineNumber(),msg); } @@ -93,7 +94,7 @@ module GenSymIO { st.addEntry(oname, offsetsEntry); msg = "created " + st.attrib(oname) + "+created " + st.attrib(rname); } else { - throw new Error("Unsupported Type %s".format(g.entryType)); + throw new Error("Unsupported Type %s".doFormat(g.entryType)); } } catch e: Error { @@ -138,7 +139,7 @@ module GenSymIO { var arrayBytes: bytes; var abstractEntry = st.lookup(msgArgs.getValueOf("array")); if !abstractEntry.isAssignableTo(SymbolEntryType.TypedArraySymEntry) { - var errorMsg = "Error: Unhandled SymbolEntryType %s".format(abstractEntry.entryType); + var errorMsg = "Error: Unhandled SymbolEntryType %s".doFormat(abstractEntry.entryType); gsLogger.error(getModuleName(),getRoutineName(),getLineNumber(),errorMsg); return errorMsg.encode(); // return as bytes } @@ -165,7 +166,7 @@ module GenSymIO { } else if entry.dtype == DType.UInt8 { arrayBytes = distArrToBytes(toSymEntry(entry, uint(8)).a); } else { - var errorMsg = "Error: Unhandled dtype %s".format(entry.dtype); + var errorMsg = "Error: Unhandled dtype %s".doFormat(entry.dtype); gsLogger.error(getModuleName(),getRoutineName(),getLineNumber(),errorMsg); return errorMsg.encode(); // return as bytes } @@ -224,13 +225,13 @@ module GenSymIO { } var reply: map(string, string) = new map(string, string); - reply.add("items", "%jt".format(items)); + reply.add("items", formatJson(items)); if allowErrors && !fileErrors.isEmpty() { // If configured, build the allowErrors portion reply.add("allow_errors", "true"); reply.add("file_error_count", fileErrorCount:string); - reply.add("file_errors", "%jt".format(fileErrors)); + reply.add("file_errors", formatJson(fileErrors)); } - return "%jt".format(reply); + return formatJson(reply); } /* @@ -249,7 +250,7 @@ module GenSymIO { for kv in key_value { // split to 2 components key: value var x = kv.split(": "); - m.addOrSet(x[0], x[1]); + m.addOrReplace(x[0], x[1]); } return m; } diff --git a/src/HDF5Msg.chpl b/src/HDF5Msg.chpl index 1b0ebcc4d9..1d3b2e57db 100644 --- a/src/HDF5Msg.chpl +++ b/src/HDF5Msg.chpl @@ -31,6 +31,7 @@ module HDF5Msg { use ArkoudaListCompat; use ArkoudaStringBytesCompat; use ArkoudaCTypesCompat; + use ArkoudaIOCompat; private config const logLevel = ServerConfig.logLevel; @@ -103,7 +104,7 @@ module HDF5Msg { proc validateWriteMode(mode: int) throws { if (mode != APPEND && mode != TRUNCATE) { throw getErrorWithContext( - msg="Unknown write mode %i found.".format(mode), + msg="Unknown write mode %i found.".doFormat(mode), lineNumber=getLineNumber(), routineName=getRoutineName(), moduleName=getModuleName(), @@ -122,8 +123,8 @@ module HDF5Msg { var extension: string; (prefix,extension) = getFileMetadata(filename); - const f = "%s%s".format(prefix, extension); - var matchingFilenames = glob("%s*%s".format(prefix, extension)); + const f = "%s%s".doFormat(prefix, extension); + var matchingFilenames = glob("%s*%s".doFormat(prefix, extension)); var fileExists: bool = matchingFilenames.size > 0; if (mode == TRUNCATE || (mode == APPEND && !fileExists)) { @@ -141,7 +142,7 @@ module HDF5Msg { } if file_id < 0 { // Negative file_id means error - throw getErrorWithContext(msg="The file %s cannot be created".format(f), + throw getErrorWithContext(msg="The file %s cannot be created".doFormat(f), lineNumber=getLineNumber(), routineName=getRoutineName(), moduleName=getModuleName(), @@ -179,9 +180,9 @@ module HDF5Msg { filenames[i] = generateFilename(prefix, extension, i); } fioLogger.debug(getModuleName(),getRoutineName(),getLineNumber(), - "generateFilenames targetLocales.size %i, filenames.size %i".format(targetSize, filenames.size)); + "generateFilenames targetLocales.size %i, filenames.size %i".doFormat(targetSize, filenames.size)); - var matchingFilenames = glob("%s_LOCALE*%s".format(prefix, extension)); + var matchingFilenames = glob("%s_LOCALE*%s".doFormat(prefix, extension)); var filesExist: bool = matchingFilenames.size > 0; if (mode == TRUNCATE || (mode == APPEND && !filesExist)) { @@ -203,7 +204,7 @@ module HDF5Msg { if file_id < 0 { // Negative file_id means error throw getErrorWithContext( - msg="The file %s cannot be created".format(fn), + msg="The file %s cannot be created".doFormat(fn), lineNumber=getLineNumber(), routineName=getRoutineName(), moduleName=getModuleName(), @@ -254,7 +255,7 @@ module HDF5Msg { } otherwise { throw getErrorWithContext( - msg="Unsupported Index DType %s".format(dtype2str(gse.dtype)), + msg="Unsupported Index DType %s".doFormat(dtype2str(gse.dtype)), lineNumber=getLineNumber(), routineName=getRoutineName(), moduleName=getModuleName(), @@ -273,7 +274,7 @@ module HDF5Msg { var del_status: int = C_HDF5.H5Ldelete(file_id, dset_name.localize().c_str(), C_HDF5.H5P_DEFAULT); if del_status < 0 { throw getErrorWithContext( - msg="Unable to overwrite dataset named %s in %s.".format(dset_name, filename), + msg="Unable to overwrite dataset named %s in %s.".doFormat(dset_name, filename), lineNumber=getLineNumber(), routineName=getRoutineName(), moduleName=getModuleName(), @@ -282,7 +283,7 @@ module HDF5Msg { } else if dset_exists > 0 { throw getErrorWithContext( - msg=" Dataset named %s already exists in %s. If you would like to overwrite the group please use update_hdf.".format(dset_name, filename), + msg=" Dataset named %s already exists in %s. If you would like to overwrite the group please use update_hdf.".doFormat(dset_name, filename), lineNumber=getLineNumber(), routineName=getRoutineName(), moduleName=getModuleName(), @@ -290,7 +291,7 @@ module HDF5Msg { } else if dset_exists < 0 { throw getErrorWithContext( - msg="Failure validating the status of dataset named %s.".format(dset_name), + msg="Failure validating the status of dataset named %s.".doFormat(dset_name), lineNumber=getLineNumber(), routineName=getRoutineName(), moduleName=getModuleName(), @@ -308,20 +309,20 @@ module HDF5Msg { var del_status: int = C_HDF5.H5Ldelete(file_id, group.localize().c_str(), C_HDF5.H5P_DEFAULT); if del_status < 0 { throw getErrorWithContext( - msg="Unable to overwrite group named %s in %s.".format(group, filename), + msg="Unable to overwrite group named %s in %s.".doFormat(group, filename), lineNumber=getLineNumber(), routineName=getRoutineName(), moduleName=getModuleName(), errorClass="RuntimeError"); } // recreate the group to write overwrite data too - var groupId: C_HDF5.hid_t = C_HDF5.H5Gcreate2(file_id, "/%s".format(group).c_str(), + var groupId: C_HDF5.hid_t = C_HDF5.H5Gcreate2(file_id, "/%s".doFormat(group).c_str(), C_HDF5.H5P_DEFAULT, C_HDF5.H5P_DEFAULT, C_HDF5.H5P_DEFAULT); C_HDF5.H5Gclose(groupId); } else if group_exists > 0 { throw getErrorWithContext( - msg="A group named %s already exists in %s. If you would like to overwrite the group please use update_hdf.".format(group, filename), + msg="A group named %s already exists in %s. If you would like to overwrite the group please use update_hdf.".doFormat(group, filename), lineNumber=getLineNumber(), routineName=getRoutineName(), moduleName=getModuleName(), @@ -329,7 +330,7 @@ module HDF5Msg { } else if group_exists < 0 { throw getErrorWithContext( - msg="Failure validating the status of group named %s.".format(group), + msg="Failure validating the status of group named %s.".doFormat(group), lineNumber=getLineNumber(), routineName=getRoutineName(), moduleName=getModuleName(), @@ -337,7 +338,7 @@ module HDF5Msg { } else { // create the group - var groupId: C_HDF5.hid_t = C_HDF5.H5Gcreate2(file_id, "/%s".format(group).c_str(), + var groupId: C_HDF5.hid_t = C_HDF5.H5Gcreate2(file_id, "/%s".doFormat(group).c_str(), C_HDF5.H5P_DEFAULT, C_HDF5.H5P_DEFAULT, C_HDF5.H5P_DEFAULT); C_HDF5.H5Gclose(groupId); } @@ -612,7 +613,7 @@ module HDF5Msg { */ proc writeLocalDset(file_id: C_HDF5.hid_t, dset_name: string, A, dimension: int, type t) throws{ h5Logger.debug(getModuleName(),getRoutineName(),getLineNumber(), - "Writing dataset, %s".format(dset_name)); + "Writing dataset, %s".doFormat(dset_name)); // Convert the Chapel dtype to HDF5 var dtype_id: C_HDF5.hid_t = getDataType(t); @@ -628,7 +629,7 @@ module HDF5Msg { coforall (loc, idx) in zip(A.targetLocales(), filenames.domain) do on loc { const localeFilename = filenames[idx]; h5Logger.debug(getModuleName(),getRoutineName(),getLineNumber(), - "%s exists? %t".format(localeFilename, exists(localeFilename))); + "%s exists? %?".doFormat(localeFilename, exists(localeFilename))); var file_id = C_HDF5.H5Fopen(localeFilename.c_str(), C_HDF5.H5F_ACC_RDWR, C_HDF5.H5P_DEFAULT); defer { // Close the file on scope exit @@ -695,7 +696,7 @@ module HDF5Msg { var file_id = C_HDF5.H5Fopen(f.c_str(), C_HDF5.H5F_ACC_RDWR, C_HDF5.H5P_DEFAULT); if file_id < 0 { // HF5open returns negative value on failure C_HDF5.H5Fclose(file_id); - var errorMsg = "Failure accessing file %s.".format(f); + var errorMsg = "Failure accessing file %s.".doFormat(f); throw getErrorWithContext( msg=errorMsg, lineNumber=getLineNumber(), @@ -754,8 +755,8 @@ module HDF5Msg { // write limbs for (i, l) in zip(0..#limbs.size, limbs) { var local_limb: [0..#l.size] uint = l.a; - writeLocalDset(file_id, "%s/Limb_%i".format(dset_name, i), c_ptrTo(local_limb), l.size, uint); - writeArkoudaMetaData(file_id, "%s/Limb_%i".format(dset_name, i), objType, getDataType(uint)); + writeLocalDset(file_id, "%s/Limb_%i".doFormat(dset_name, i), c_ptrTo(local_limb), l.size, uint); + writeArkoudaMetaData(file_id, "%s/Limb_%i".doFormat(dset_name, i), objType, getDataType(uint)); } } otherwise { @@ -805,7 +806,7 @@ module HDF5Msg { coforall (loc, idx) in zip(limbs[0].a.targetLocales(), filenames.domain) with (ref max_bits, ref num_limbs) do on loc { const localeFilename = filenames[idx]; h5Logger.debug(getModuleName(),getRoutineName(),getLineNumber(), - "%s exists? %t".format(localeFilename, exists(localeFilename))); + "%s exists? %?".doFormat(localeFilename, exists(localeFilename))); var file_id = C_HDF5.H5Fopen(localeFilename.c_str(), C_HDF5.H5F_ACC_RDWR, C_HDF5.H5P_DEFAULT); defer { // Close the file on scope exit @@ -823,7 +824,7 @@ module HDF5Msg { // write limbs for (i, l) in zip(0..#limbs.size, limbs) { var local_limb: [0..#l.size] uint = l.a; - writeDistDset(filenames, "/%s/Limb_%i".format(dset_name, i), "pdarray", overwrite, l.a, st); + writeDistDset(filenames, "/%s/Limb_%i".doFormat(dset_name, i), "pdarray", overwrite, l.a, st); } } otherwise { @@ -839,7 +840,7 @@ module HDF5Msg { } otherwise { throw getErrorWithContext( - msg="Unknown file format. Expecting 0 (single file) or 1 (file per locale). Found %i".format(file_format), + msg="Unknown file format. Expecting 0 (single file) or 1 (file per locale). Found %i".doFormat(file_format), lineNumber=getLineNumber(), routineName=getRoutineName(), moduleName=getModuleName(), @@ -924,7 +925,7 @@ module HDF5Msg { var file_id = C_HDF5.H5Fopen(f.c_str(), C_HDF5.H5F_ACC_RDWR, C_HDF5.H5P_DEFAULT); if file_id < 0 { // HF5open returns negative value on failure C_HDF5.H5Fclose(file_id); - var errorMsg = "Failure accessing file %s.".format(f); + var errorMsg = "Failure accessing file %s.".doFormat(f); throw getErrorWithContext( msg=errorMsg, lineNumber=getLineNumber(), @@ -977,8 +978,8 @@ module HDF5Msg { // write limbs for (i, l) in zip(0..#limbs.size, limbs) { var local_limb: [0..#l.size] uint = l.a; - writeLocalDset(file_id, "%s/Limb_%i".format(dset_name, i), c_ptrTo(local_limb), l.size, uint); - writeArkoudaMetaData(file_id, "%s/Limb_%i".format(dset_name, i), objType, getDataType(uint)); + writeLocalDset(file_id, "%s/Limb_%i".doFormat(dset_name, i), c_ptrTo(local_limb), l.size, uint); + writeArkoudaMetaData(file_id, "%s/Limb_%i".doFormat(dset_name, i), objType, getDataType(uint)); } dtype = getHDF5Type(uint); } @@ -1028,7 +1029,7 @@ module HDF5Msg { coforall (loc, idx) in zip(limbs[0].a.targetLocales(), filenames.domain) with (ref max_bits, ref num_limbs) do on loc { const localeFilename = filenames[idx]; h5Logger.debug(getModuleName(),getRoutineName(),getLineNumber(), - "%s exists? %t".format(localeFilename, exists(localeFilename))); + "%s exists? %?".doFormat(localeFilename, exists(localeFilename))); var file_id = C_HDF5.H5Fopen(localeFilename.c_str(), C_HDF5.H5F_ACC_RDWR, C_HDF5.H5P_DEFAULT); defer { // Close the file on scope exit @@ -1044,7 +1045,7 @@ module HDF5Msg { // write limbs for (i, l) in zip(0..#limbs.size, limbs) { var local_limb: [0..#l.size] uint = l.a; - writeDistDset(filenames, "/%s/Limb_%i".format(dset_name, i), "pdarray", overwrite, l.a, st); + writeDistDset(filenames, "/%s/Limb_%i".doFormat(dset_name, i), "pdarray", overwrite, l.a, st); } } otherwise { @@ -1060,7 +1061,7 @@ module HDF5Msg { } otherwise { throw getErrorWithContext( - msg="Unknown file format. Expecting 0 (single file) or 1 (file per locale). Found %i".format(file_format), + msg="Unknown file format. Expecting 0 (single file) or 1 (file per locale). Found %i".doFormat(file_format), lineNumber=getLineNumber(), routineName=getRoutineName(), moduleName=getModuleName(), @@ -1085,10 +1086,10 @@ module HDF5Msg { var zero = 0: uint(64); // create empty values dataset - C_HDF5.H5LTmake_dataset_WAR(fileId, "/%s/%s".format(group, SEGMENTED_VALUE_NAME).c_str(), 1, + C_HDF5.H5LTmake_dataset_WAR(fileId, "/%s/%s".doFormat(group, SEGMENTED_VALUE_NAME).c_str(), 1, c_ptrTo(zero), ctype, nil); - dset_id = C_HDF5.H5Dopen(fileId, "/%s/%s".format(group, SEGMENTED_VALUE_NAME).c_str(), C_HDF5.H5P_DEFAULT); + dset_id = C_HDF5.H5Dopen(fileId, "/%s/%s".doFormat(group, SEGMENTED_VALUE_NAME).c_str(), C_HDF5.H5P_DEFAULT); // Create the attribute space var attrSpaceId: C_HDF5.hid_t = C_HDF5.H5Screate(C_HDF5.H5S_SCALAR); @@ -1105,10 +1106,10 @@ module HDF5Msg { if (writeOffsets) { // create empty segments dataset - C_HDF5.H5LTmake_dataset_WAR(fileId, "/%s/%s".format(group, SEGMENTED_OFFSET_NAME).c_str(), 1, + C_HDF5.H5LTmake_dataset_WAR(fileId, "/%s/%s".doFormat(group, SEGMENTED_OFFSET_NAME).c_str(), 1, c_ptrTo(zero), getHDF5Type(int), nil); - dset_id = C_HDF5.H5Dopen(fileId, "/%s/%s".format(group, SEGMENTED_OFFSET_NAME).c_str(), C_HDF5.H5P_DEFAULT); + dset_id = C_HDF5.H5Dopen(fileId, "/%s/%s".doFormat(group, SEGMENTED_OFFSET_NAME).c_str(), C_HDF5.H5P_DEFAULT); attrSpaceId = C_HDF5.H5Screate(C_HDF5.H5S_SCALAR); attr_id = C_HDF5.H5Acreate2(dset_id, "ObjType".c_str(), getHDF5Type(int), attrSpaceId, C_HDF5.H5P_DEFAULT, C_HDF5.H5P_DEFAULT); @@ -1137,10 +1138,10 @@ module HDF5Msg { */ private proc writeSegmentedComponentToHdf(fileId: int, group: string, component: string, items: [] ?etype) throws { var numItems = items.size: uint(64); - C_HDF5.H5LTmake_dataset_WAR(fileId, "/%s/%s".format(group, component).c_str(), 1, + C_HDF5.H5LTmake_dataset_WAR(fileId, "/%s/%s".doFormat(group, component).c_str(), 1, c_ptrTo(numItems), getDataType(etype), c_ptrTo(items)); - writeArkoudaMetaData(fileId, "%s/%s".format(group, component), "pdarray", getDataType(etype)); + writeArkoudaMetaData(fileId, "%s/%s".doFormat(group, component), "pdarray", getDataType(etype)); } /* @@ -1169,7 +1170,7 @@ module HDF5Msg { var file_id = C_HDF5.H5Fopen(f.c_str(), C_HDF5.H5F_ACC_RDWR, C_HDF5.H5P_DEFAULT); if file_id < 0 { // HF5open returns negative value on failure C_HDF5.H5Fclose(file_id); - var errorMsg = "Failure accessing file %s.".format(f); + var errorMsg = "Failure accessing file %s.".doFormat(f); throw getErrorWithContext( msg=errorMsg, lineNumber=getLineNumber(), @@ -1193,7 +1194,7 @@ module HDF5Msg { } otherwise { throw getErrorWithContext( - msg="Unknown file format. Expecting 0 (single file) or 1 (file per locale). Found %i".format(file_format), + msg="Unknown file format. Expecting 0 (single file) or 1 (file per locale). Found %i".doFormat(file_format), lineNumber=getLineNumber(), routineName=getRoutineName(), moduleName=getModuleName(), @@ -1204,36 +1205,36 @@ module HDF5Msg { proc writeSegmentedLocalDset(file_id: C_HDF5.hid_t, group: string, vals, segs, write_offsets: bool, type t, max_bits: int = -1) throws { h5Logger.debug(getModuleName(),getRoutineName(),getLineNumber(), - "Writing group, %s".format(group)); + "Writing group, %s".doFormat(group)); var dtype_id: C_HDF5.hid_t = if t == bigint then getDataType(uint) else getDataType(t); if t == bigint { // SegArray with BigInt values var limbs = bigintToUint(vals); - writeBigIntMetaData(file_id, "%s/%s".format(group, SEGMENTED_VALUE_NAME), max_bits, limbs.size); - writeArkoudaMetaData(file_id, "%s/%s".format(group, SEGMENTED_VALUE_NAME), "pdarray", dtype_id); + writeBigIntMetaData(file_id, "%s/%s".doFormat(group, SEGMENTED_VALUE_NAME), max_bits, limbs.size); + writeArkoudaMetaData(file_id, "%s/%s".doFormat(group, SEGMENTED_VALUE_NAME), "pdarray", dtype_id); // write limbs for (i, l) in zip(0..#limbs.size, limbs) { var local_limb: [0..#l.size] uint = l.a; - writeLocalDset(file_id, "%s/%s/Limb_%i".format(group, SEGMENTED_VALUE_NAME, i), c_ptrTo(local_limb), l.size, uint); - writeArkoudaMetaData(file_id, "%s/%s/Limb_%i".format(group, SEGMENTED_VALUE_NAME, i), "pdarray", getDataType(uint)); + writeLocalDset(file_id, "%s/%s/Limb_%i".doFormat(group, SEGMENTED_VALUE_NAME, i), c_ptrTo(local_limb), l.size, uint); + writeArkoudaMetaData(file_id, "%s/%s/Limb_%i".doFormat(group, SEGMENTED_VALUE_NAME, i), "pdarray", getDataType(uint)); } } else { // SegArray with standard numeric or bool values or standard Strings entry var vd = vals.size:C_HDF5.hsize_t; var localVals: [0..#vals.size] t = vals.a; - C_HDF5.H5LTmake_dataset(file_id, "%s/%s".format(group, SEGMENTED_VALUE_NAME).c_str(), 1:c_int, vd, dtype_id, c_ptrTo(localVals)); - writeArkoudaMetaData(file_id, "%s/%s".format(group, SEGMENTED_VALUE_NAME), "pdarray", dtype_id); + C_HDF5.H5LTmake_dataset(file_id, "%s/%s".doFormat(group, SEGMENTED_VALUE_NAME).c_str(), 1:c_int, vd, dtype_id, c_ptrTo(localVals)); + writeArkoudaMetaData(file_id, "%s/%s".doFormat(group, SEGMENTED_VALUE_NAME), "pdarray", dtype_id); } if write_offsets { var localSegs: [0..#segs.size] int = segs.a; var sd = segs.size:C_HDF5.hsize_t; - C_HDF5.H5LTmake_dataset(file_id, "%s/%s".format(group, SEGMENTED_OFFSET_NAME).c_str(), 1:c_int, sd, getDataType(int), c_ptrTo(localSegs)); - writeArkoudaMetaData(file_id, "%s/%s".format(group, SEGMENTED_OFFSET_NAME), "pdarray", getDataType(int)); + C_HDF5.H5LTmake_dataset(file_id, "%s/%s".doFormat(group, SEGMENTED_OFFSET_NAME).c_str(), 1:c_int, sd, getDataType(int), c_ptrTo(localSegs)); + writeArkoudaMetaData(file_id, "%s/%s".doFormat(group, SEGMENTED_OFFSET_NAME), "pdarray", getDataType(int)); } } @@ -1242,22 +1243,22 @@ module HDF5Msg { */ proc writeNestedSegmentedLocalDset(file_id: C_HDF5.hid_t, group: string, vals, segs, write_offsets: bool, type t) throws { h5Logger.debug(getModuleName(),getRoutineName(),getLineNumber(), - "Writing group, %s".format(group)); + "Writing group, %s".doFormat(group)); var dtype_id: C_HDF5.hid_t = getDataType(t); - writeArkoudaMetaData(file_id, "%s/%s".format(group, SEGMENTED_VALUE_NAME), "Strings", dtype_id); + writeArkoudaMetaData(file_id, "%s/%s".doFormat(group, SEGMENTED_VALUE_NAME), "Strings", dtype_id); // write the strings value object ref strVals = vals.bytesEntry; ref strSegs = vals.offsetsEntry; - writeSegmentedLocalDset(file_id, "%s/%s".format(group, SEGMENTED_VALUE_NAME), strVals, strSegs, write_offsets, t); + writeSegmentedLocalDset(file_id, "%s/%s".doFormat(group, SEGMENTED_VALUE_NAME), strVals, strSegs, write_offsets, t); // write the offsets of the SegArray - This needs to always be written var localSegs: [0..#segs.size] int = segs.a; var sd = segs.size:C_HDF5.hsize_t; - C_HDF5.H5LTmake_dataset(file_id, "%s/%s".format(group, SEGMENTED_OFFSET_NAME).c_str(), 1:c_int, sd, getDataType(int), c_ptrTo(localSegs)); - writeArkoudaMetaData(file_id, "%s/%s".format(group, SEGMENTED_OFFSET_NAME), "pdarray", getDataType(int)); + C_HDF5.H5LTmake_dataset(file_id, "%s/%s".doFormat(group, SEGMENTED_OFFSET_NAME).c_str(), 1:c_int, sd, getDataType(int), c_ptrTo(localSegs)); + writeArkoudaMetaData(file_id, "%s/%s".doFormat(group, SEGMENTED_OFFSET_NAME), "pdarray", getDataType(int)); } proc writeSegmentedDistDset(filenames: [] string, group: string, objType: string, overwrite: bool, values, segments, st: borrowed SymTab, type t, max_bits: int = -1) throws { @@ -1267,7 +1268,7 @@ module HDF5Msg { var dtype: C_HDF5.hid_t = if t == bigint then getDataType(uint) else getDataType(t); const localeFilename = filenames[idx]; h5Logger.debug(getModuleName(),getRoutineName(),getLineNumber(), - "%s exists? %t".format(localeFilename, exists(localeFilename))); + "%s exists? %?".doFormat(localeFilename, exists(localeFilename))); var file_id = C_HDF5.H5Fopen(localeFilename.c_str(), C_HDF5.H5F_ACC_RDWR, C_HDF5.H5P_DEFAULT); defer { // Close the file on scope exit @@ -1284,7 +1285,7 @@ module HDF5Msg { if (locDom.isEmpty() || locDom.size <= 0) { h5Logger.debug(getModuleName(),getRoutineName(),getLineNumber(), "write1DDistStringsAggregators: locale.id %i has empty locDom.size %i, will get empty dataset." - .format(loc.id, locDom.size)); + .doFormat(loc.id, locDom.size)); writeNilSegmentedGroupToHdf(file_id, group, true, dtype); } else { // write the segments @@ -1306,13 +1307,13 @@ module HDF5Msg { var limbs = bigintToUint(localVals); // create the group - validateGroup(file_id, localeFilename, "%s/%s".format(group, SEGMENTED_VALUE_NAME), false); // stored as group - group uses the dataset name - writeBigIntMetaData(file_id, "%s/%s".format(group, SEGMENTED_VALUE_NAME), max_bits, limbs.size); - writeArkoudaMetaData(file_id, "%s/%s".format(group, SEGMENTED_VALUE_NAME), "pdarray", dtype); + validateGroup(file_id, localeFilename, "%s/%s".doFormat(group, SEGMENTED_VALUE_NAME), false); // stored as group - group uses the dataset name + writeBigIntMetaData(file_id, "%s/%s".doFormat(group, SEGMENTED_VALUE_NAME), max_bits, limbs.size); + writeArkoudaMetaData(file_id, "%s/%s".doFormat(group, SEGMENTED_VALUE_NAME), "pdarray", dtype); // write limbs for (i, l) in zip(0..#limbs.size, limbs) { - writeSegmentedComponentToHdf(file_id, "%s/%s".format(group, SEGMENTED_VALUE_NAME), "Limb_%i".format(i), l); + writeSegmentedComponentToHdf(file_id, "%s/%s".doFormat(group, SEGMENTED_VALUE_NAME), "Limb_%i".doFormat(i), l); } } else { @@ -1341,7 +1342,7 @@ module HDF5Msg { var dtype: C_HDF5.hid_t = getDataType(t); const localeFilename = filenames[idx]; h5Logger.debug(getModuleName(),getRoutineName(),getLineNumber(), - "%s exists? %t".format(localeFilename, exists(localeFilename))); + "%s exists? %?".doFormat(localeFilename, exists(localeFilename))); var file_id = C_HDF5.H5Fopen(localeFilename.c_str(), C_HDF5.H5F_ACC_RDWR, C_HDF5.H5P_DEFAULT); defer { // Close the file on scope exit @@ -1358,7 +1359,7 @@ module HDF5Msg { if (locDom.isEmpty() || locDom.size <= 0) { h5Logger.debug(getModuleName(),getRoutineName(),getLineNumber(), "write1DDistStringsAggregators: locale.id %i has empty locDom.size %i, will get empty dataset." - .format(loc.id, locDom.size)); + .doFormat(loc.id, locDom.size)); writeNilSegmentedGroupToHdf(file_id, group, true, dtype); } else { // create local copy of the string offsets (values) according to the locality of the SegArray Segments @@ -1389,14 +1390,14 @@ module HDF5Msg { } // create the group for SegString components - write the segments and offsets - validateGroup(file_id, localeFilename, "%s/%s".format(group, SEGMENTED_VALUE_NAME), overwrite); + validateGroup(file_id, localeFilename, "%s/%s".doFormat(group, SEGMENTED_VALUE_NAME), overwrite); localOffsets = localOffsets - startValIdx; - writeSegmentedComponentToHdf(file_id, "%s/%s".format(group, SEGMENTED_VALUE_NAME), SEGMENTED_OFFSET_NAME, localOffsets); - writeSegmentedComponentToHdf(file_id, "%s/%s".format(group, SEGMENTED_VALUE_NAME), SEGMENTED_VALUE_NAME, localVals); + writeSegmentedComponentToHdf(file_id, "%s/%s".doFormat(group, SEGMENTED_VALUE_NAME), SEGMENTED_OFFSET_NAME, localOffsets); + writeSegmentedComponentToHdf(file_id, "%s/%s".doFormat(group, SEGMENTED_VALUE_NAME), SEGMENTED_VALUE_NAME, localVals); } else { - validateGroup(file_id, localeFilename, "%s/%s".format(group, SEGMENTED_VALUE_NAME), overwrite); - writeNilSegmentedGroupToHdf(file_id, "%s/%s".format(group, SEGMENTED_VALUE_NAME), true, dtype); + validateGroup(file_id, localeFilename, "%s/%s".doFormat(group, SEGMENTED_VALUE_NAME), overwrite); + writeNilSegmentedGroupToHdf(file_id, "%s/%s".doFormat(group, SEGMENTED_VALUE_NAME), true, dtype); } } // write attributes for arkouda meta info @@ -1426,7 +1427,7 @@ module HDF5Msg { var file_id = C_HDF5.H5Fopen(f.c_str(), C_HDF5.H5F_ACC_RDWR, C_HDF5.H5P_DEFAULT); if file_id < 0 { // HF5open returns negative value on failure C_HDF5.H5Fclose(file_id); - var errorMsg = "Failure accessing file %s.".format(f); + var errorMsg = "Failure accessing file %s.".doFormat(f); throw getErrorWithContext( msg=errorMsg, lineNumber=getLineNumber(), @@ -1468,7 +1469,7 @@ module HDF5Msg { when (DType.BigInt) { var values = toSymEntry(valEnt, bigint); // create the group - validateGroup(file_id, f, "%s/%s".format(group, SEGMENTED_VALUE_NAME), overwrite); // stored as group - group uses the dataset name + validateGroup(file_id, f, "%s/%s".doFormat(group, SEGMENTED_VALUE_NAME), overwrite); // stored as group - group uses the dataset name //localize values and write dataset writeSegmentedLocalDset(file_id, group, values, segments, true, bigint); dtype = getDataType(uint); @@ -1476,14 +1477,14 @@ module HDF5Msg { when (DType.Strings){ var values = toSegStringSymEntry(valEnt); // create the group - validateGroup(file_id, f, "%s/%s".format(group, SEGMENTED_VALUE_NAME), overwrite); + validateGroup(file_id, f, "%s/%s".doFormat(group, SEGMENTED_VALUE_NAME), overwrite); //localize values and write dataset writeNestedSegmentedLocalDset(file_id, group, values, segments, true, uint(8)); dtype = getDataType(uint(8)); } otherwise { throw getErrorWithContext( - msg="Unsupported SegArray DType %s".format(dtype2str(valEnt.dtype)), + msg="Unsupported SegArray DType %s".doFormat(dtype2str(valEnt.dtype)), lineNumber=getLineNumber(), routineName=getRoutineName(), moduleName=getModuleName(), @@ -1523,7 +1524,7 @@ module HDF5Msg { } otherwise { throw getErrorWithContext( - msg="Unsupported SegArray DType %s".format(dtype2str(valEnt.dtype)), + msg="Unsupported SegArray DType %s".doFormat(dtype2str(valEnt.dtype)), lineNumber=getLineNumber(), routineName=getRoutineName(), moduleName=getModuleName(), @@ -1533,7 +1534,7 @@ module HDF5Msg { } otherwise { throw getErrorWithContext( - msg="Unknown file format. Expecting 0 (single file) or 1 (file per locale). Found %i".format(file_format), + msg="Unknown file format. Expecting 0 (single file) or 1 (file per locale). Found %i".doFormat(file_format), lineNumber=getLineNumber(), routineName=getRoutineName(), moduleName=getModuleName(), @@ -1545,18 +1546,18 @@ module HDF5Msg { proc writeLocalCategoricalRequiredData(file_id: C_HDF5.hid_t, f: string, group: string, codes, categories, naCodes, overwrite: bool) throws { // localize codes and write dataset var localCodes: [0..#codes.size] int = codes.a; - writeLocalDset(file_id, "/%s/%s".format(group, CODES_NAME), c_ptrTo(localCodes), codes.size, int); + writeLocalDset(file_id, "/%s/%s".doFormat(group, CODES_NAME), c_ptrTo(localCodes), codes.size, int); // ensure that the container for categories exists - validateGroup(file_id, f, "%s/%s".format(group, CATEGORIES_NAME), overwrite); + validateGroup(file_id, f, "%s/%s".doFormat(group, CATEGORIES_NAME), overwrite); //localize categories values and write dataset - writeSegmentedLocalDset(file_id, "/%s/%s".format(group, CATEGORIES_NAME), categories.values, categories.offsets, true, uint(8)); + writeSegmentedLocalDset(file_id, "/%s/%s".doFormat(group, CATEGORIES_NAME), categories.values, categories.offsets, true, uint(8)); // localize _akNAcode and write to dset var localNACodes: [0..#naCodes.size] int = naCodes.a; - writeLocalDset(file_id, "/%s/%s".format(group, NACODES_NAME), c_ptrTo(localNACodes), naCodes.size, int); + writeLocalDset(file_id, "/%s/%s".doFormat(group, NACODES_NAME), c_ptrTo(localNACodes), naCodes.size, int); } proc writeLocalCategoricalOptionalData(file_id: C_HDF5.hid_t, group: string, permutation: string, segments: string, st: borrowed SymTab) throws { @@ -1565,14 +1566,14 @@ module HDF5Msg { // localize permutation and write dataset var localPerm: [0..#perm.size] int = perm.a; - writeLocalDset(file_id, "/%s/%s".format(group, PERMUTATION_NAME), c_ptrTo(localPerm), perm.size, int); + writeLocalDset(file_id, "/%s/%s".doFormat(group, PERMUTATION_NAME), c_ptrTo(localPerm), perm.size, int); var segment_entry = st.lookup(segments); var segs = toSymEntry(toGenSymEntry(segment_entry), int); // localize segments and write dataset var localSegs: [0..#segs.size] int = segs.a; - writeLocalDset(file_id, "/%s/%s".format(group, SEGMENTS_NAME), c_ptrTo(localSegs), segs.size, int); + writeLocalDset(file_id, "/%s/%s".doFormat(group, SEGMENTS_NAME), c_ptrTo(localSegs), segs.size, int); } proc categorical_tohdfMsg(msgArgs: borrowed MessageArgs, st: borrowed SymTab) throws { @@ -1606,7 +1607,7 @@ module HDF5Msg { var file_id = C_HDF5.H5Fopen(f.c_str(), C_HDF5.H5F_ACC_RDWR, C_HDF5.H5P_DEFAULT); if file_id < 0 { // HF5open returns negative value on failure C_HDF5.H5Fclose(file_id); - var errorMsg = "Failure accessing file %s.".format(f); + var errorMsg = "Failure accessing file %s.".doFormat(f); throw getErrorWithContext( msg=errorMsg, lineNumber=getLineNumber(), @@ -1634,7 +1635,7 @@ module HDF5Msg { coforall (loc, idx) in zip(codes.a.targetLocales(), filenames.domain) do on loc { const localeFilename = filenames[idx]; h5Logger.debug(getModuleName(),getRoutineName(),getLineNumber(), - "%s exists? %t".format(localeFilename, exists(localeFilename))); + "%s exists? %?".doFormat(localeFilename, exists(localeFilename))); var file_id = C_HDF5.H5Fopen(localeFilename.c_str(), C_HDF5.H5F_ACC_RDWR, C_HDF5.H5P_DEFAULT); defer { // Close the file on scope exit @@ -1647,13 +1648,13 @@ module HDF5Msg { } // write codes - writeDistDset(filenames, "/%s/%s".format(group, CODES_NAME), "pdarray", overwrite, codes.a, st); + writeDistDset(filenames, "/%s/%s".doFormat(group, CODES_NAME), "pdarray", overwrite, codes.a, st); // write categories - writeSegmentedDistDset(filenames, "/%s/%s".format(group, CATEGORIES_NAME), "strings", overwrite, cats.values.a, cats.offsets.a, st, uint(8)); + writeSegmentedDistDset(filenames, "/%s/%s".doFormat(group, CATEGORIES_NAME), "strings", overwrite, cats.values.a, cats.offsets.a, st, uint(8)); // write NA Codes - writeDistDset(filenames, "/%s/%s".format(group, NACODES_NAME), "pdarray", overwrite, naCodes.a, st); + writeDistDset(filenames, "/%s/%s".doFormat(group, NACODES_NAME), "pdarray", overwrite, naCodes.a, st); // writes perms and segs if they exist if perm_seg_exist { @@ -1661,13 +1662,13 @@ module HDF5Msg { var perm = toSymEntry(toGenSymEntry(perm_entry), int); var segment_entry = st.lookup(msgArgs.getValueOf("segments")); var segs = toSymEntry(toGenSymEntry(segment_entry), int); - writeDistDset(filenames, "/%s/%s".format(group, PERMUTATION_NAME), "pdarray", overwrite, perm.a, st); - writeDistDset(filenames, "/%s/%s".format(group, SEGMENTS_NAME), "pdarray", overwrite, segs.a, st); + writeDistDset(filenames, "/%s/%s".doFormat(group, PERMUTATION_NAME), "pdarray", overwrite, perm.a, st); + writeDistDset(filenames, "/%s/%s".doFormat(group, SEGMENTS_NAME), "pdarray", overwrite, segs.a, st); } } otherwise { throw getErrorWithContext( - msg="Unknown file format. Expecting 0 (single file) or 1 (file per locale). Found %i".format(file_format), + msg="Unknown file format. Expecting 0 (single file) or 1 (file per locale). Found %i".doFormat(file_format), lineNumber=getLineNumber(), routineName=getRoutineName(), moduleName=getModuleName(), @@ -1709,7 +1710,7 @@ module HDF5Msg { var file_id = C_HDF5.H5Fopen(f.c_str(), C_HDF5.H5F_ACC_RDWR, C_HDF5.H5P_DEFAULT); if file_id < 0 { // HF5open returns negative value on failure C_HDF5.H5Fclose(file_id); - var errorMsg = "Failure accessing file %s.".format(f); + var errorMsg = "Failure accessing file %s.".doFormat(f); throw getErrorWithContext( msg=errorMsg, lineNumber=getLineNumber(), @@ -1722,16 +1723,16 @@ module HDF5Msg { validateGroup(file_id, f, group, overwrite); var localseg: [0..#segments.size] int = segments.a; - writeLocalDset(file_id, "/%s/%s".format(group, SEGMENTS_NAME), c_ptrTo(localseg), segments.size, int); - writeArkoudaMetaData(file_id, "/%s/%s".format(group, SEGMENTS_NAME), "pdarray", getDataType(int)); + writeLocalDset(file_id, "/%s/%s".doFormat(group, SEGMENTS_NAME), c_ptrTo(localseg), segments.size, int); + writeArkoudaMetaData(file_id, "/%s/%s".doFormat(group, SEGMENTS_NAME), "pdarray", getDataType(int)); var localperm: [0..#perm.size] int = perm.a; - writeLocalDset(file_id, "/%s/%s".format(group, PERMUTATION_NAME), c_ptrTo(localperm), perm.size, int); - writeArkoudaMetaData(file_id, "/%s/%s".format(group, PERMUTATION_NAME), "pdarray", getDataType(int)); + writeLocalDset(file_id, "/%s/%s".doFormat(group, PERMUTATION_NAME), c_ptrTo(localperm), perm.size, int); + writeArkoudaMetaData(file_id, "/%s/%s".doFormat(group, PERMUTATION_NAME), "pdarray", getDataType(int)); var localuki: [0..#uki.size] int = uki.a; - writeLocalDset(file_id, "/%s/%s".format(group, UKI_NAME), c_ptrTo(localuki), uki.size, int); - writeArkoudaMetaData(file_id, "/%s/%s".format(group, UKI_NAME), "pdarray", getDataType(int)); + writeLocalDset(file_id, "/%s/%s".doFormat(group, UKI_NAME), c_ptrTo(localuki), uki.size, int); + writeArkoudaMetaData(file_id, "/%s/%s".doFormat(group, UKI_NAME), "pdarray", getDataType(int)); // loop keys and create/write dataset for each for (i, name, ot, dt) in zip(0..#num_keys, key_names, key_objTypes, key_dtypes) { @@ -1745,7 +1746,7 @@ module HDF5Msg { // localize permutation and write dataset var localkey: [0..#key.size] int = key.a; - writeLocalDset(file_id, "/%s/KEY_%i".format(group, i), c_ptrTo(localkey), key.size, int); + writeLocalDset(file_id, "/%s/KEY_%i".doFormat(group, i), c_ptrTo(localkey), key.size, int); dtype = getDataType(int); } when DType.UInt64 { @@ -1754,7 +1755,7 @@ module HDF5Msg { // localize permutation and write dataset var localkey: [0..#key.size] uint = key.a; - writeLocalDset(file_id, "/%s/KEY_%i".format(group, i), c_ptrTo(localkey), key.size, uint); + writeLocalDset(file_id, "/%s/KEY_%i".doFormat(group, i), c_ptrTo(localkey), key.size, uint); dtype = getDataType(uint); } when DType.Float64 { @@ -1763,7 +1764,7 @@ module HDF5Msg { // localize permutation and write dataset var localkey: [0..#key.size] real = key.a; - writeLocalDset(file_id, "/%s/KEY_%i".format(group, i), c_ptrTo(localkey), key.size, real); + writeLocalDset(file_id, "/%s/KEY_%i".doFormat(group, i), c_ptrTo(localkey), key.size, real); dtype = getDataType(real); } when DType.Bool { @@ -1772,7 +1773,7 @@ module HDF5Msg { // localize permutation and write dataset var localkey: [0..#key.size] bool = key.a; - writeLocalDset(file_id, "/%s/KEY_%i".format(group, i), c_ptrTo(localkey), key.size, bool); + writeLocalDset(file_id, "/%s/KEY_%i".doFormat(group, i), c_ptrTo(localkey), key.size, bool); dtype = C_HDF5.H5T_NATIVE_HBOOL; } when DType.BigInt { @@ -1781,40 +1782,40 @@ module HDF5Msg { var limbs = bigintToUint(key); // create the group - validateGroup(file_id, f, "/%s/KEY_%i".format(group, i), overwrite); // stored as group - group uses the dataset name + validateGroup(file_id, f, "/%s/KEY_%i".doFormat(group, i), overwrite); // stored as group - group uses the dataset name var max_bits = key.max_bits; - writeBigIntMetaData(file_id, "/%s/KEY_%i".format(group, i), max_bits, limbs.size); + writeBigIntMetaData(file_id, "/%s/KEY_%i".doFormat(group, i), max_bits, limbs.size); // write limbs for (j, l) in zip(0..#limbs.size, limbs) { var local_limb: [0..#l.size] uint = l.a; - writeLocalDset(file_id, "%s/KEY_%i/Limb_%i".format(group, i, j), c_ptrTo(local_limb), l.size, uint); - writeArkoudaMetaData(file_id, "%s/KEY_%i/Limb_%i".format(group, i, j), "pdarray", getDataType(uint)); + writeLocalDset(file_id, "%s/KEY_%i/Limb_%i".doFormat(group, i, j), c_ptrTo(local_limb), l.size, uint); + writeArkoudaMetaData(file_id, "%s/KEY_%i/Limb_%i".doFormat(group, i, j), "pdarray", getDataType(uint)); } dtype = getDataType(uint); } otherwise { throw getErrorWithContext( - msg="Unsupported DType %s".format(str2dtype(dt)), + msg="Unsupported DType %s".doFormat(str2dtype(dt)), lineNumber=getLineNumber(), routineName=getRoutineName(), moduleName=getModuleName(), errorClass="IllegalArgumentError"); } } - writeArkoudaMetaData(file_id, "/%s/KEY_%i".format(group, i), "pdarray", dtype); + writeArkoudaMetaData(file_id, "/%s/KEY_%i".doFormat(group, i), "pdarray", dtype); } when ObjType.STRINGS { // create/overwrite the group - validateGroup(file_id, f, "%s/KEY_%i".format(group, i), overwrite); + validateGroup(file_id, f, "%s/KEY_%i".doFormat(group, i), overwrite); var key_entry: SegStringSymEntry = toSegStringSymEntry(st.lookup(name)); var key = new SegString("", key_entry); - writeSegmentedLocalDset(file_id, "/%s/KEY_%i".format(group, i), key.values, key.offsets, true, uint(8)); - writeArkoudaMetaData(file_id, "/%s/KEY_%i".format(group, i), "Strings", getHDF5Type(uint(8))); + writeSegmentedLocalDset(file_id, "/%s/KEY_%i".doFormat(group, i), key.values, key.offsets, true, uint(8)); + writeArkoudaMetaData(file_id, "/%s/KEY_%i".doFormat(group, i), "Strings", getHDF5Type(uint(8))); } when ObjType.CATEGORICAL { // create/overwrite the group - validateGroup(file_id, f, "%s/KEY_%i".format(group, i), overwrite); + validateGroup(file_id, f, "%s/KEY_%i".doFormat(group, i), overwrite); var cat_comps = jsonToMap(name); var codes_entry = st.lookup(cat_comps["codes"]); var codes = toSymEntry(toGenSymEntry(codes_entry), int); @@ -1822,16 +1823,16 @@ module HDF5Msg { var cats = new SegString("", cat_entry); var naCodes_entry = st.lookup(cat_comps["NA_codes"]); var naCodes = toSymEntry(toGenSymEntry(naCodes_entry), int); - writeLocalCategoricalRequiredData(file_id, f, "%s/KEY_%i".format(group, i), codes, cats, naCodes, overwrite); + writeLocalCategoricalRequiredData(file_id, f, "%s/KEY_%i".doFormat(group, i), codes, cats, naCodes, overwrite); if cat_comps.contains["permutation"] && cat_comps.contains["segments"] { - writeLocalCategoricalOptionalData(file_id, "%s/KEY_%i".format(group, i), cat_comps["permutation"], cat_comps["segments"], st); + writeLocalCategoricalOptionalData(file_id, "%s/KEY_%i".doFormat(group, i), cat_comps["permutation"], cat_comps["segments"], st); } - writeArkoudaMetaData(file_id, "/%s/KEY_%i".format(group, i), "Categorical", getHDF5Type(uint(8))); + writeArkoudaMetaData(file_id, "/%s/KEY_%i".doFormat(group, i), "Categorical", getHDF5Type(uint(8))); } otherwise { throw getErrorWithContext( - msg="Unsupported ObjType %s".format(ot: string), + msg="Unsupported ObjType %s".doFormat(ot: string), lineNumber=getLineNumber(), routineName=getRoutineName(), moduleName=getModuleName(), @@ -1851,7 +1852,7 @@ module HDF5Msg { coforall (loc, idx) in zip(perm.a.targetLocales(), filenames.domain) do on loc { const localeFilename = filenames[idx]; h5Logger.debug(getModuleName(),getRoutineName(),getLineNumber(), - "%s exists? %t".format(localeFilename, exists(localeFilename))); + "%s exists? %?".doFormat(localeFilename, exists(localeFilename))); var file_id = C_HDF5.H5Fopen(localeFilename.c_str(), C_HDF5.H5F_ACC_RDWR, C_HDF5.H5P_DEFAULT); defer { // Close the file on scope exit @@ -1864,13 +1865,13 @@ module HDF5Msg { } // write groupby.segments - writeDistDset(filenames, "/%s/%s".format(group, SEGMENTS_NAME), "pdarray", overwrite, segments.a, st); + writeDistDset(filenames, "/%s/%s".doFormat(group, SEGMENTS_NAME), "pdarray", overwrite, segments.a, st); //write groupby.permutation - writeDistDset(filenames, "/%s/%s".format(group, PERMUTATION_NAME), "pdarray", overwrite, perm.a, st); + writeDistDset(filenames, "/%s/%s".doFormat(group, PERMUTATION_NAME), "pdarray", overwrite, perm.a, st); // write groupby._uki - writeDistDset(filenames, "/%s/%s".format(group, UKI_NAME), "pdarray", overwrite, uki.a, st); + writeDistDset(filenames, "/%s/%s".doFormat(group, UKI_NAME), "pdarray", overwrite, uki.a, st); // loop keys and create/write dataset for each for (i, name, ot, dt) in zip(0..#num_keys, key_names, key_objTypes, key_dtypes) { @@ -1880,19 +1881,19 @@ module HDF5Msg { select str2dtype(dt) { when DType.Int64 { var e = toSymEntry(toGenSymEntry(entry), int); - writeDistDset(filenames, "%s/KEY_%i".format(group, i), ot: string, overwrite, e.a, st); + writeDistDset(filenames, "%s/KEY_%i".doFormat(group, i), ot: string, overwrite, e.a, st); } when DType.UInt64 { var e = toSymEntry(toGenSymEntry(entry), uint); - writeDistDset(filenames, "%s/KEY_%i".format(group, i), ot: string, overwrite, e.a, st); + writeDistDset(filenames, "%s/KEY_%i".doFormat(group, i), ot: string, overwrite, e.a, st); } when DType.Float64 { var e = toSymEntry(toGenSymEntry(entry), real); - writeDistDset(filenames, "%s/KEY_%i".format(group, i), ot: string, overwrite, e.a, st); + writeDistDset(filenames, "%s/KEY_%i".doFormat(group, i), ot: string, overwrite, e.a, st); } when DType.Bool { var e = toSymEntry(toGenSymEntry(entry), bool); - writeDistDset(filenames, "%s/KEY_%i".format(group, i), ot: string, overwrite, e.a, st); + writeDistDset(filenames, "%s/KEY_%i".doFormat(group, i), ot: string, overwrite, e.a, st); } when DType.BigInt { var e = toSymEntry(toGenSymEntry(entry), bigint); @@ -1904,7 +1905,7 @@ module HDF5Msg { coforall (loc, idx) in zip(limbs[0].a.targetLocales(), filenames.domain) with (ref max_bits, ref num_limbs) do on loc { const localeFilename = filenames[idx]; h5Logger.debug(getModuleName(),getRoutineName(),getLineNumber(), - "%s exists? %t".format(localeFilename, exists(localeFilename))); + "%s exists? %?".doFormat(localeFilename, exists(localeFilename))); var file_id = C_HDF5.H5Fopen(localeFilename.c_str(), C_HDF5.H5F_ACC_RDWR, C_HDF5.H5P_DEFAULT); defer { // Close the file on scope exit @@ -1912,20 +1913,20 @@ module HDF5Msg { } // create the group and generate metadata - validateGroup(file_id, localeFilename, "%s/KEY_%i".format(group, i), overwrite); - writeBigIntMetaData(file_id, "%s/KEY_%i".format(group, i), max_bits, num_limbs); - writeArkoudaMetaData(file_id, "%s/KEY_%i".format(group, i), "pdarray", getDataType(uint)); + validateGroup(file_id, localeFilename, "%s/KEY_%i".doFormat(group, i), overwrite); + writeBigIntMetaData(file_id, "%s/KEY_%i".doFormat(group, i), max_bits, num_limbs); + writeArkoudaMetaData(file_id, "%s/KEY_%i".doFormat(group, i), "pdarray", getDataType(uint)); } // write limbs for (j, l) in zip(0..#limbs.size, limbs) { var local_limb: [0..#l.size] uint = l.a; - writeDistDset(filenames, "/%s/KEY_%i/Limb_%i".format(group, i, j), "pdarray", overwrite, l.a, st); + writeDistDset(filenames, "/%s/KEY_%i/Limb_%i".doFormat(group, i, j), "pdarray", overwrite, l.a, st); } } otherwise { throw getErrorWithContext( - msg="Unsupported DType %s".format(str2dtype(dt)), + msg="Unsupported DType %s".doFormat(str2dtype(dt)), lineNumber=getLineNumber(), routineName=getRoutineName(), moduleName=getModuleName(), @@ -1938,7 +1939,7 @@ module HDF5Msg { var segString = new SegString("", entry); var valEntry = segString.values; var segEntry = segString.offsets; - writeSegmentedDistDset(filenames, "/%s/KEY_%i".format(group, i), ot: string, overwrite, valEntry.a, segEntry.a, st, uint(8)); + writeSegmentedDistDset(filenames, "/%s/KEY_%i".doFormat(group, i), ot: string, overwrite, valEntry.a, segEntry.a, st, uint(8)); } when ObjType.CATEGORICAL { var cat_comps = jsonToMap(name); @@ -1958,18 +1959,18 @@ module HDF5Msg { } // create the group and generate metadata - validateGroup(file_id, localeFilename, "%s/KEY_%i".format(group, i), overwrite); - writeArkoudaMetaData(file_id, "%s/KEY_%i".format(group, i), ot:string, getHDF5Type(uint(8))); + validateGroup(file_id, localeFilename, "%s/KEY_%i".doFormat(group, i), overwrite); + writeArkoudaMetaData(file_id, "%s/KEY_%i".doFormat(group, i), ot:string, getHDF5Type(uint(8))); } // write codes - writeDistDset(filenames, "/%s/KEY_%i/%s".format(group, i, CODES_NAME), "pdarray", overwrite, codes.a, st); + writeDistDset(filenames, "/%s/KEY_%i/%s".doFormat(group, i, CODES_NAME), "pdarray", overwrite, codes.a, st); // write categories - writeSegmentedDistDset(filenames, "/%s/KEY_%i/%s".format(group, i, CATEGORIES_NAME), "strings", overwrite, cats.values.a, cats.offsets.a, st, uint(8)); + writeSegmentedDistDset(filenames, "/%s/KEY_%i/%s".doFormat(group, i, CATEGORIES_NAME), "strings", overwrite, cats.values.a, cats.offsets.a, st, uint(8)); // write NA Codes - writeDistDset(filenames,"/%s/KEY_%i/%s".format(group, i, NACODES_NAME), "pdarray", overwrite, naCodes.a, st); + writeDistDset(filenames,"/%s/KEY_%i/%s".doFormat(group, i, NACODES_NAME), "pdarray", overwrite, naCodes.a, st); // writes perms and segs if they exist if cat_comps.contains["permutation"] && cat_comps.contains["segments"] { @@ -1977,13 +1978,13 @@ module HDF5Msg { var cat_perm = toSymEntry(toGenSymEntry(cat_perm_entry), int); var segment_entry = st.lookup(cat_comps["segments"]); var segs = toSymEntry(toGenSymEntry(segment_entry), int); - writeDistDset(filenames, "/%s/KEY_%i/%s".format(group, i, PERMUTATION_NAME), "pdarray", overwrite, cat_perm.a, st); - writeDistDset(filenames, "/%s/KEY_%i/%s".format(group, i, SEGMENTS_NAME), "pdarray", overwrite, segs.a, st); + writeDistDset(filenames, "/%s/KEY_%i/%s".doFormat(group, i, PERMUTATION_NAME), "pdarray", overwrite, cat_perm.a, st); + writeDistDset(filenames, "/%s/KEY_%i/%s".doFormat(group, i, SEGMENTS_NAME), "pdarray", overwrite, segs.a, st); } } otherwise { throw getErrorWithContext( - msg="Unsupported ObjType %s".format(ot: string), + msg="Unsupported ObjType %s".doFormat(ot: string), lineNumber=getLineNumber(), routineName=getRoutineName(), moduleName=getModuleName(), @@ -1994,7 +1995,7 @@ module HDF5Msg { } otherwise { throw getErrorWithContext( - msg="Unknown file format. Expecting 0 (single file) or 1 (file per locale). Found %i".format(file_format), + msg="Unknown file format. Expecting 0 (single file) or 1 (file per locale). Found %i".doFormat(file_format), lineNumber=getLineNumber(), routineName=getRoutineName(), moduleName=getModuleName(), @@ -2031,7 +2032,7 @@ module HDF5Msg { var file_id = C_HDF5.H5Fopen(f.c_str(), C_HDF5.H5F_ACC_RDWR, C_HDF5.H5P_DEFAULT); if file_id < 0 { // HF5open returns negative value on failure C_HDF5.H5Fclose(file_id); - var errorMsg = "Failure accessing file %s.".format(f); + var errorMsg = "Failure accessing file %s.".doFormat(f); throw getErrorWithContext( msg=errorMsg, lineNumber=getLineNumber(), @@ -2047,32 +2048,32 @@ module HDF5Msg { when DType.Int64 { var idx_col = toSymEntry(idx_gen, int); var localIdx: [0..#idx_col.size] int = idx_col.a; - writeLocalDset(file_id, "/%s/%s".format(group, INDEX_NAME), c_ptrTo(localIdx), idx_col.size, int); - writeArkoudaMetaData(file_id, "/%s/%s".format(group, INDEX_NAME), "pdarray", getDataType(int)); + writeLocalDset(file_id, "/%s/%s".doFormat(group, INDEX_NAME), c_ptrTo(localIdx), idx_col.size, int); + writeArkoudaMetaData(file_id, "/%s/%s".doFormat(group, INDEX_NAME), "pdarray", getDataType(int)); } when DType.UInt64 { var idx_col = toSymEntry(idx_gen, uint); var localIdx: [0..#idx_col.size] uint = idx_col.a; - writeLocalDset(file_id, "/%s/%s".format(group, INDEX_NAME), c_ptrTo(localIdx), idx_col.size, uint); - writeArkoudaMetaData(file_id, "/%s/%s".format(group, INDEX_NAME), "pdarray", getDataType(uint)); + writeLocalDset(file_id, "/%s/%s".doFormat(group, INDEX_NAME), c_ptrTo(localIdx), idx_col.size, uint); + writeArkoudaMetaData(file_id, "/%s/%s".doFormat(group, INDEX_NAME), "pdarray", getDataType(uint)); } when DType.Float64 { var idx_col = toSymEntry(idx_gen, real); var localIdx: [0..#idx_col.size] real = idx_col.a; - writeLocalDset(file_id, "/%s/%s".format(group, INDEX_NAME), c_ptrTo(localIdx), idx_col.size, real); - writeArkoudaMetaData(file_id, "/%s/%s".format(group, INDEX_NAME), "pdarray", getDataType(real)); + writeLocalDset(file_id, "/%s/%s".doFormat(group, INDEX_NAME), c_ptrTo(localIdx), idx_col.size, real); + writeArkoudaMetaData(file_id, "/%s/%s".doFormat(group, INDEX_NAME), "pdarray", getDataType(real)); } when DType.Strings { // ensure that the container for index exists - validateGroup(file_id, f, "%s/%s".format(group, INDEX_NAME), overwrite); + validateGroup(file_id, f, "%s/%s".doFormat(group, INDEX_NAME), overwrite); var key_entry: SegStringSymEntry = toSegStringSymEntry(idx_gen); var idx_col = new SegString("", key_entry); - writeSegmentedLocalDset(file_id, "/%s/%s".format(group, INDEX_NAME), idx_col.values, idx_col.offsets, true, uint(8)); - writeArkoudaMetaData(file_id, "/%s/%s".format(group, INDEX_NAME), "Strings", getHDF5Type(uint(8))); + writeSegmentedLocalDset(file_id, "/%s/%s".doFormat(group, INDEX_NAME), idx_col.values, idx_col.offsets, true, uint(8)); + writeArkoudaMetaData(file_id, "/%s/%s".doFormat(group, INDEX_NAME), "Strings", getHDF5Type(uint(8))); } otherwise { throw getErrorWithContext( - msg="Unsupported Index DType %s".format(dtype2str(idx_gen.dtype)), + msg="Unsupported Index DType %s".doFormat(dtype2str(idx_gen.dtype)), lineNumber=getLineNumber(), routineName=getRoutineName(), moduleName=getModuleName(), @@ -2092,7 +2093,7 @@ module HDF5Msg { // localize permutation and write dataset var localkey: [0..#key.size] int = key.a; - writeLocalDset(file_id, "/%s/%s".format(group, dset), c_ptrTo(localkey), key.size, int); + writeLocalDset(file_id, "/%s/%s".doFormat(group, dset), c_ptrTo(localkey), key.size, int); dtype = getDataType(int); } when DType.UInt64 { @@ -2101,7 +2102,7 @@ module HDF5Msg { // localize permutation and write dataset var localkey: [0..#key.size] uint = key.a; - writeLocalDset(file_id, "/%s/%s".format(group, dset), c_ptrTo(localkey), key.size, uint); + writeLocalDset(file_id, "/%s/%s".doFormat(group, dset), c_ptrTo(localkey), key.size, uint); dtype = getDataType(uint); } when DType.Float64 { @@ -2110,7 +2111,7 @@ module HDF5Msg { // localize permutation and write dataset var localkey: [0..#key.size] real = key.a; - writeLocalDset(file_id, "/%s/%s".format(group, dset), c_ptrTo(localkey), key.size, real); + writeLocalDset(file_id, "/%s/%s".doFormat(group, dset), c_ptrTo(localkey), key.size, real); dtype = getDataType(real); } when DType.Bool { @@ -2119,7 +2120,7 @@ module HDF5Msg { // localize permutation and write dataset var localkey: [0..#key.size] bool = key.a; - writeLocalDset(file_id, "/%s/%s".format(group, dset), c_ptrTo(localkey), key.size, bool); + writeLocalDset(file_id, "/%s/%s".doFormat(group, dset), c_ptrTo(localkey), key.size, bool); dtype = getDataType(bool); } when DType.BigInt { @@ -2128,21 +2129,21 @@ module HDF5Msg { var limbs = bigintToUint(key); // create the group - validateGroup(file_id, f, "/%s/%s".format(group, dset), overwrite); // stored as group - group uses the dataset name + validateGroup(file_id, f, "/%s/%s".doFormat(group, dset), overwrite); // stored as group - group uses the dataset name var max_bits = key.max_bits; - writeBigIntMetaData(file_id, "/%s/%s".format(group, dset), max_bits, limbs.size); + writeBigIntMetaData(file_id, "/%s/%s".doFormat(group, dset), max_bits, limbs.size); // write limbs for (i, l) in zip(0..#limbs.size, limbs) { var local_limb: [0..#l.size] uint = l.a; - writeLocalDset(file_id, "%s/%s/Limb_%i".format(group, dset, i), c_ptrTo(local_limb), l.size, uint); - writeArkoudaMetaData(file_id, "%s/%s/Limb_%i".format(group, dset, i), "pdarray", getDataType(uint)); + writeLocalDset(file_id, "%s/%s/Limb_%i".doFormat(group, dset, i), c_ptrTo(local_limb), l.size, uint); + writeArkoudaMetaData(file_id, "%s/%s/Limb_%i".doFormat(group, dset, i), "pdarray", getDataType(uint)); } dtype = getDataType(uint); } otherwise { throw getErrorWithContext( - msg="Unsupported pdarray DType %s".format(str2dtype(dt)), + msg="Unsupported pdarray DType %s".doFormat(str2dtype(dt)), lineNumber=getLineNumber(), routineName=getRoutineName(), moduleName=getModuleName(), @@ -2152,15 +2153,15 @@ module HDF5Msg { } when ObjType.STRINGS { // create/overwrite the group - validateGroup(file_id, f, "%s/%s".format(group, dset), overwrite); + validateGroup(file_id, f, "%s/%s".doFormat(group, dset), overwrite); var key_entry: SegStringSymEntry = toSegStringSymEntry(st.lookup(name)); var key = new SegString("", key_entry); - writeSegmentedLocalDset(file_id, "/%s/%s".format(group, dset), key.values, key.offsets, true, uint(8)); - writeArkoudaMetaData(file_id, "/%s/%s".format(group, dset), "Strings", getHDF5Type(uint(8))); + writeSegmentedLocalDset(file_id, "/%s/%s".doFormat(group, dset), key.values, key.offsets, true, uint(8)); + writeArkoudaMetaData(file_id, "/%s/%s".doFormat(group, dset), "Strings", getHDF5Type(uint(8))); } when ObjType.CATEGORICAL { // create/overwrite the group - validateGroup(file_id, f, "%s/%s".format(group, dset), overwrite); + validateGroup(file_id, f, "%s/%s".doFormat(group, dset), overwrite); var cat_comps = jsonToMap(name); var codes_entry = st.lookup(cat_comps["codes"]); var codes = toSymEntry(toGenSymEntry(codes_entry), int); @@ -2168,15 +2169,15 @@ module HDF5Msg { var cats = new SegString("", cat_entry); var naCodes_entry = st.lookup(cat_comps["NA_codes"]); var naCodes = toSymEntry(toGenSymEntry(naCodes_entry), int); - writeLocalCategoricalRequiredData(file_id, f, "%s/%s".format(group, dset), codes, cats, naCodes, overwrite); + writeLocalCategoricalRequiredData(file_id, f, "%s/%s".doFormat(group, dset), codes, cats, naCodes, overwrite); if cat_comps.contains["permutation"] && cat_comps.contains["segments"] { - writeLocalCategoricalOptionalData(file_id, "%s/%s".format(group, dset), cat_comps["permutation"], cat_comps["segments"], st); + writeLocalCategoricalOptionalData(file_id, "%s/%s".doFormat(group, dset), cat_comps["permutation"], cat_comps["segments"], st); } - writeArkoudaMetaData(file_id, "/%s/%s".format(group, dset), "Categorical", getHDF5Type(uint(8))); + writeArkoudaMetaData(file_id, "/%s/%s".doFormat(group, dset), "Categorical", getHDF5Type(uint(8))); } when ObjType.SEGARRAY { - validateGroup(file_id, f, "%s/%s".format(group, dset), overwrite); + validateGroup(file_id, f, "%s/%s".doFormat(group, dset), overwrite); var sa_comps = jsonToMap(name); var segments = toSymEntry(toGenSymEntry(st.lookup(sa_comps["segments"])), int); @@ -2186,31 +2187,31 @@ module HDF5Msg { when DType.Int64 { var values = toSymEntry(vals_entry, int); //localize values and write dataset - writeSegmentedLocalDset(file_id, "%s/%s".format(group, dset), values, segments, true, int); + writeSegmentedLocalDset(file_id, "%s/%s".doFormat(group, dset), values, segments, true, int); dtype = getDataType(int); } when DType.UInt64 { var values = toSymEntry(vals_entry, uint); //localize values and write dataset - writeSegmentedLocalDset(file_id, "%s/%s".format(group, dset), values, segments, true, uint); + writeSegmentedLocalDset(file_id, "%s/%s".doFormat(group, dset), values, segments, true, uint); dtype = getDataType(uint); } when DType.Float64 { var values = toSymEntry(vals_entry, real); //localize values and write dataset - writeSegmentedLocalDset(file_id, "%s/%s".format(group, dset), values, segments, true, real); + writeSegmentedLocalDset(file_id, "%s/%s".doFormat(group, dset), values, segments, true, real); dtype = getDataType(real); } when DType.Bool { var values = toSymEntry(vals_entry, bool); //localize values and write dataset - writeSegmentedLocalDset(file_id, "%s/%s".format(group, dset), values, segments, true, bool); + writeSegmentedLocalDset(file_id, "%s/%s".doFormat(group, dset), values, segments, true, bool); dtype = getDataType(bool); } when (DType.BigInt) { var values = toSymEntry(vals_entry, bigint); // create the group - validateGroup(file_id, f, "%s/%s/%s".format(group, dset, SEGMENTED_VALUE_NAME), overwrite); // stored as group - group uses the dataset name + validateGroup(file_id, f, "%s/%s/%s".doFormat(group, dset, SEGMENTED_VALUE_NAME), overwrite); // stored as group - group uses the dataset name //localize values and write dataset writeSegmentedLocalDset(file_id, group, values, segments, true, bigint); dtype = getDataType(uint); @@ -2218,14 +2219,14 @@ module HDF5Msg { when (DType.Strings){ var values = toSegStringSymEntry(vals_entry); // create the group - validateGroup(file_id, f, "%s/%s/%s".format(group, dset, SEGMENTED_VALUE_NAME), overwrite); + validateGroup(file_id, f, "%s/%s/%s".doFormat(group, dset, SEGMENTED_VALUE_NAME), overwrite); //localize values and write dataset - writeNestedSegmentedLocalDset(file_id, "%s/%s".format(group, dset), values, segments, true, uint(8)); + writeNestedSegmentedLocalDset(file_id, "%s/%s".doFormat(group, dset), values, segments, true, uint(8)); dtype = getDataType(uint(8)); } otherwise { throw getErrorWithContext( - msg="Unsupported SegArray DType %s".format(str2dtype(dt)), + msg="Unsupported SegArray DType %s".doFormat(str2dtype(dt)), lineNumber=getLineNumber(), routineName=getRoutineName(), moduleName=getModuleName(), @@ -2236,7 +2237,7 @@ module HDF5Msg { } otherwise { throw getErrorWithContext( - msg="Unsupported ObjType %s".format(ot: string), + msg="Unsupported ObjType %s".doFormat(ot: string), lineNumber=getLineNumber(), routineName=getRoutineName(), moduleName=getModuleName(), @@ -2256,7 +2257,7 @@ module HDF5Msg { coforall (loc, idx) in zip(Locales, filenames.domain) do on loc { const localeFilename = filenames[idx]; h5Logger.debug(getModuleName(),getRoutineName(),getLineNumber(), - "%s exists? %t".format(localeFilename, exists(localeFilename))); + "%s exists? %?".doFormat(localeFilename, exists(localeFilename))); var file_id = C_HDF5.H5Fopen(localeFilename.c_str(), C_HDF5.H5F_ACC_RDWR, C_HDF5.H5P_DEFAULT); defer { // Close the file on scope exit @@ -2271,26 +2272,26 @@ module HDF5Msg { select idx_gen.dtype { when DType.Int64 { var idx_col = toSymEntry(idx_gen, int); - writeDistDset(filenames, "/%s/%s".format(group, INDEX_NAME), "pdarray", overwrite, idx_col.a, st); + writeDistDset(filenames, "/%s/%s".doFormat(group, INDEX_NAME), "pdarray", overwrite, idx_col.a, st); } when DType.UInt64 { var idx_col = toSymEntry(idx_gen, uint); - writeDistDset(filenames, "/%s/%s".format(group, INDEX_NAME), "pdarray", overwrite, idx_col.a, st); + writeDistDset(filenames, "/%s/%s".doFormat(group, INDEX_NAME), "pdarray", overwrite, idx_col.a, st); } when DType.Float64 { var idx_col = toSymEntry(idx_gen, real); - writeDistDset(filenames, "/%s/%s".format(group, INDEX_NAME), "pdarray", overwrite, idx_col.a, st); + writeDistDset(filenames, "/%s/%s".doFormat(group, INDEX_NAME), "pdarray", overwrite, idx_col.a, st); } when DType.Strings { var key_entry: SegStringSymEntry = toSegStringSymEntry(idx_gen); var idx_col = new SegString("", key_entry); var valEntry = idx_col.values; var segEntry = idx_col.offsets; - writeSegmentedDistDset(filenames, "/%s/%s".format(group, INDEX_NAME), "Strings", overwrite, valEntry.a, segEntry.a, st, uint(8)); + writeSegmentedDistDset(filenames, "/%s/%s".doFormat(group, INDEX_NAME), "Strings", overwrite, valEntry.a, segEntry.a, st, uint(8)); } otherwise { throw getErrorWithContext( - msg="Unsupported Index DType %s".format(dtype2str(idx_gen.dtype)), + msg="Unsupported Index DType %s".doFormat(dtype2str(idx_gen.dtype)), lineNumber=getLineNumber(), routineName=getRoutineName(), moduleName=getModuleName(), @@ -2306,19 +2307,19 @@ module HDF5Msg { select str2dtype(dt) { when DType.Int64 { var e = toSymEntry(toGenSymEntry(entry), int); - writeDistDset(filenames, "%s/%s".format(group, dset), ot: string, overwrite, e.a, st); + writeDistDset(filenames, "%s/%s".doFormat(group, dset), ot: string, overwrite, e.a, st); } when DType.UInt64 { var e = toSymEntry(toGenSymEntry(entry), uint); - writeDistDset(filenames, "%s/%s".format(group, dset), ot: string, overwrite, e.a, st); + writeDistDset(filenames, "%s/%s".doFormat(group, dset), ot: string, overwrite, e.a, st); } when DType.Float64 { var e = toSymEntry(toGenSymEntry(entry), real); - writeDistDset(filenames, "%s/%s".format(group, dset), ot: string, overwrite, e.a, st); + writeDistDset(filenames, "%s/%s".doFormat(group, dset), ot: string, overwrite, e.a, st); } when DType.Bool { var e = toSymEntry(toGenSymEntry(entry), bool); - writeDistDset(filenames, "%s/%s".format(group, dset), ot: string, overwrite, e.a, st); + writeDistDset(filenames, "%s/%s".doFormat(group, dset), ot: string, overwrite, e.a, st); } when DType.BigInt { var e = toSymEntry(toGenSymEntry(entry), bigint); @@ -2330,7 +2331,7 @@ module HDF5Msg { coforall (loc, idx) in zip(limbs[0].a.targetLocales(), filenames.domain) with (ref max_bits, ref num_limbs) do on loc { const localeFilename = filenames[idx]; h5Logger.debug(getModuleName(),getRoutineName(),getLineNumber(), - "%s exists? %t".format(localeFilename, exists(localeFilename))); + "%s exists? %?".doFormat(localeFilename, exists(localeFilename))); var file_id = C_HDF5.H5Fopen(localeFilename.c_str(), C_HDF5.H5F_ACC_RDWR, C_HDF5.H5P_DEFAULT); defer { // Close the file on scope exit @@ -2338,20 +2339,20 @@ module HDF5Msg { } // create the group and generate metadata - validateGroup(file_id, localeFilename, "%s/%s".format(group, dset), overwrite); - writeBigIntMetaData(file_id, "%s/%s".format(group, dset), max_bits, num_limbs); - writeArkoudaMetaData(file_id, "%s/%s".format(group, dset), "pdarray", getDataType(uint)); + validateGroup(file_id, localeFilename, "%s/%s".doFormat(group, dset), overwrite); + writeBigIntMetaData(file_id, "%s/%s".doFormat(group, dset), max_bits, num_limbs); + writeArkoudaMetaData(file_id, "%s/%s".doFormat(group, dset), "pdarray", getDataType(uint)); } // write limbs for (i, l) in zip(0..#limbs.size, limbs) { var local_limb: [0..#l.size] uint = l.a; - writeDistDset(filenames, "/%s/%s/Limb_%i".format(group, dset, i), "pdarray", overwrite, l.a, st); + writeDistDset(filenames, "/%s/%s/Limb_%i".doFormat(group, dset, i), "pdarray", overwrite, l.a, st); } } otherwise { throw getErrorWithContext( - msg="Unsupported DType %s".format(str2dtype(dt)), + msg="Unsupported DType %s".doFormat(str2dtype(dt)), lineNumber=getLineNumber(), routineName=getRoutineName(), moduleName=getModuleName(), @@ -2364,7 +2365,7 @@ module HDF5Msg { var segString = new SegString("", entry); var valEntry = segString.values; var segEntry = segString.offsets; - writeSegmentedDistDset(filenames, "/%s/%s".format(group, dset), ot: string, overwrite, valEntry.a, segEntry.a, st, uint(8)); + writeSegmentedDistDset(filenames, "/%s/%s".doFormat(group, dset), ot: string, overwrite, valEntry.a, segEntry.a, st, uint(8)); } when ObjType.CATEGORICAL { var cat_comps = jsonToMap(name); @@ -2384,18 +2385,18 @@ module HDF5Msg { } // create the group and generate metadata - validateGroup(file_id, localeFilename, "%s/%s".format(group, dset), overwrite); - writeArkoudaMetaData(file_id, "%s/%s".format(group, dset), ot:string, getHDF5Type(uint(8))); + validateGroup(file_id, localeFilename, "%s/%s".doFormat(group, dset), overwrite); + writeArkoudaMetaData(file_id, "%s/%s".doFormat(group, dset), ot:string, getHDF5Type(uint(8))); } // write codes - writeDistDset(filenames, "/%s/%s/%s".format(group, dset, CODES_NAME), "pdarray", overwrite, codes.a, st); + writeDistDset(filenames, "/%s/%s/%s".doFormat(group, dset, CODES_NAME), "pdarray", overwrite, codes.a, st); // write categories - writeSegmentedDistDset(filenames, "/%s/%s/%s".format(group, dset, CATEGORIES_NAME), "strings", overwrite, cats.values.a, cats.offsets.a, st, uint(8)); + writeSegmentedDistDset(filenames, "/%s/%s/%s".doFormat(group, dset, CATEGORIES_NAME), "strings", overwrite, cats.values.a, cats.offsets.a, st, uint(8)); // write NA Codes - writeDistDset(filenames,"/%s/%s/%s".format(group, dset, NACODES_NAME), "pdarray", overwrite, naCodes.a, st); + writeDistDset(filenames,"/%s/%s/%s".doFormat(group, dset, NACODES_NAME), "pdarray", overwrite, naCodes.a, st); // writes perms and segs if they exist if cat_comps.contains["permutation"] && cat_comps.contains["segments"] { @@ -2403,8 +2404,8 @@ module HDF5Msg { var cat_perm = toSymEntry(toGenSymEntry(cat_perm_entry), int); var segment_entry = st.lookup(cat_comps["segments"]); var segs = toSymEntry(toGenSymEntry(segment_entry), int); - writeDistDset(filenames, "/%s/%s/%s".format(group, dset, PERMUTATION_NAME), "pdarray", overwrite, cat_perm.a, st); - writeDistDset(filenames, "/%s/%s/%s".format(group, dset, SEGMENTS_NAME), "pdarray", overwrite, segs.a, st); + writeDistDset(filenames, "/%s/%s/%s".doFormat(group, dset, PERMUTATION_NAME), "pdarray", overwrite, cat_perm.a, st); + writeDistDset(filenames, "/%s/%s/%s".doFormat(group, dset, SEGMENTS_NAME), "pdarray", overwrite, segs.a, st); } } when ObjType.SEGARRAY { @@ -2415,31 +2416,31 @@ module HDF5Msg { select vals_entry.dtype { when DType.Int64 { var values = toSymEntry(vals_entry, int); - writeSegmentedDistDset(filenames, "/%s/%s".format(group, dset), ot: string, overwrite, values.a, segments.a, st, int); + writeSegmentedDistDset(filenames, "/%s/%s".doFormat(group, dset), ot: string, overwrite, values.a, segments.a, st, int); } when DType.UInt64 { var values = toSymEntry(vals_entry, uint); - writeSegmentedDistDset(filenames, "/%s/%s".format(group, dset), ot: string, overwrite, values.a, segments.a, st, uint); + writeSegmentedDistDset(filenames, "/%s/%s".doFormat(group, dset), ot: string, overwrite, values.a, segments.a, st, uint); } when DType.Float64 { var values = toSymEntry(vals_entry, real); - writeSegmentedDistDset(filenames, "/%s/%s".format(group, dset), ot: string, overwrite, values.a, segments.a, st, real); + writeSegmentedDistDset(filenames, "/%s/%s".doFormat(group, dset), ot: string, overwrite, values.a, segments.a, st, real); } when DType.Bool { var values = toSymEntry(vals_entry, bool); - writeSegmentedDistDset(filenames, "/%s/%s".format(group, dset), ot: string, overwrite, values.a, segments.a, st, bool); + writeSegmentedDistDset(filenames, "/%s/%s".doFormat(group, dset), ot: string, overwrite, values.a, segments.a, st, bool); } when DType.BigInt { var values = toSymEntry(vals_entry, bigint); - writeSegmentedDistDset(filenames, "/%s/%s".format(group, dset), ot: string, overwrite, values.a, segments.a, st, bigint, values.max_bits); + writeSegmentedDistDset(filenames, "/%s/%s".doFormat(group, dset), ot: string, overwrite, values.a, segments.a, st, bigint, values.max_bits); } when DType.Strings { var values = toSegStringSymEntry(vals_entry); - writeNestedSegmentedDistDset(filenames, "/%s/%s".format(group, dset), ot: string, overwrite, values, segments.a, st, uint(8)); + writeNestedSegmentedDistDset(filenames, "/%s/%s".doFormat(group, dset), ot: string, overwrite, values, segments.a, st, uint(8)); } otherwise { throw getErrorWithContext( - msg="Unsupported SegArray DType %s".format(str2dtype(dt)), + msg="Unsupported SegArray DType %s".doFormat(str2dtype(dt)), lineNumber=getLineNumber(), routineName=getRoutineName(), moduleName=getModuleName(), @@ -2449,7 +2450,7 @@ module HDF5Msg { } otherwise { throw getErrorWithContext( - msg="Unsupported ObjType %s".format(ot: string), + msg="Unsupported ObjType %s".doFormat(ot: string), lineNumber=getLineNumber(), routineName=getRoutineName(), moduleName=getModuleName(), @@ -2461,7 +2462,7 @@ module HDF5Msg { } otherwise { throw getErrorWithContext( - msg="Unknown file format. Expecting 0 (single file) or 1 (file per locale). Found %i".format(file_format), + msg="Unknown file format. Expecting 0 (single file) or 1 (file per locale). Found %i".doFormat(file_format), lineNumber=getLineNumber(), routineName=getRoutineName(), moduleName=getModuleName(), @@ -2506,7 +2507,7 @@ module HDF5Msg { dataframe_tohdfMsg(msgArgs, st); } otherwise { - var errorMsg = "Unable to write object type %s to HDF5 file.".format(objType); + var errorMsg = "Unable to write object type %s to HDF5 file.".doFormat(objType); h5Logger.error(getModuleName(),getRoutineName(),getLineNumber(),errorMsg); return new MsgTuple(errorMsg, MsgType.ERROR); } @@ -2530,7 +2531,7 @@ module HDF5Msg { } var errorMsg="%s cannot be opened to check if hdf5, \ - check file permissions or format".format(filename); + check file permissions or format".doFormat(filename); throw getErrorWithContext( msg=errorMsg, lineNumber=getLineNumber(), @@ -2613,10 +2614,10 @@ module HDF5Msg { // Attempt to interpret filename as a glob expression and ls the first result var tmp = glob(filename); h5Logger.debug(getModuleName(),getRoutineName(),getLineNumber(), - "glob-expanded filename: %s to size: %i files".format(filename, tmp.size)); + "glob-expanded filename: %s to size: %i files".doFormat(filename, tmp.size)); if tmp.size <= 0 { - var errorMsg = "Cannot retrieve filename from glob expression %s, check file name or format".format(filename); + var errorMsg = "Cannot retrieve filename from glob expression %s, check file name or format".doFormat(filename); h5Logger.error(getModuleName(),getRoutineName(),getLineNumber(),errorMsg); return new MsgTuple(errorMsg, MsgType.ERROR); } @@ -2627,13 +2628,13 @@ module HDF5Msg { // Check to see if the file exists. If not, return an error message if !exists(filename) { - var errorMsg = "File %s does not exist in a location accessible to Arkouda".format(filename); + var errorMsg = "File %s does not exist in a location accessible to Arkouda".doFormat(filename); h5Logger.error(getModuleName(),getRoutineName(),getLineNumber(),errorMsg); return new MsgTuple(errorMsg,MsgType.ERROR); } if !isHdf5File(filename) { - var errorMsg = "File %s is not an HDF5 file".format(filename); + var errorMsg = "File %s is not an HDF5 file".doFormat(filename); h5Logger.error(getModuleName(),getRoutineName(),getLineNumber(),errorMsg); return new MsgTuple(errorMsg,MsgType.ERROR); } @@ -2645,9 +2646,9 @@ module HDF5Msg { repMsg = simulate_h5ls(file_id); var items = new list(repMsg.split(",")); // convert to json - repMsg = "%jt".format(items); + repMsg = formatJson(items); } catch e : Error { - var errorMsg = "Failed to process HDF5 file %t".format(e.message()); + var errorMsg = "Failed to process HDF5 file %?".doFormat(e.message()); h5Logger.error(getModuleName(),getRoutineName(),getLineNumber(),errorMsg); return new MsgTuple(errorMsg, MsgType.ERROR); } @@ -2670,7 +2671,7 @@ module HDF5Msg { if !isValid { skips.add(filename); h5Logger.debug(getModuleName(),getRoutineName(),getLineNumber(), - "Adding invalid file to skips, %s".format(filename)); + "Adding invalid file to skips, %s".doFormat(filename)); continue; } var file_id = C_HDF5.H5Fopen(filename.c_str(), C_HDF5.H5F_ACC_RDONLY, @@ -2688,12 +2689,12 @@ module HDF5Msg { if lengths[i] == 0 { skips.add(filename); h5Logger.debug(getModuleName(),getRoutineName(),getLineNumber(), - "Adding filename:%s to skips, dsetName:%s, dims[0]:%t".format(filename, dsetName, dims[0])); + "Adding filename:%s to skips, dsetName:%s, dims[0]:%?".doFormat(filename, dsetName, dims[0])); } } catch e: Error { throw getErrorWithContext( - msg="in getting dataset info %s".format(e.message()), + msg="in getting dataset info %s".doFormat(e.message()), lineNumber=getLineNumber(), routineName=getRoutineName(), moduleName=getModuleName(), @@ -2720,11 +2721,11 @@ module HDF5Msg { where (MyDmap == Dmap.blockDist || MyDmap == Dmap.defaultRectangular) { h5Logger.debug(getModuleName(),getRoutineName(),getLineNumber(), - "entry.a.targetLocales() = %t".format(A.targetLocales())); + "entry.a.targetLocales() = %?".doFormat(A.targetLocales())); h5Logger.debug(getModuleName(),getRoutineName(),getLineNumber(), - "Filedomains: %t".format(filedomains)); + "Filedomains: %?".doFormat(filedomains)); h5Logger.debug(getModuleName(),getRoutineName(),getLineNumber(), - "skips: %t".format(skips)); + "skips: %?".doFormat(skips)); coforall loc in A.targetLocales() do on loc { // Create local copies of args @@ -2739,7 +2740,7 @@ module HDF5Msg { if (skips.contains(filename)) { h5Logger.debug(getModuleName(),getRoutineName(),getLineNumber(), - "File %s does not contain data for this dataset, skipping".format(filename)); + "File %s does not contain data for this dataset, skipping".doFormat(filename)); } else { // Look for overlap between A's local subdomains and this file for locdom in A.localSubdomains() { @@ -2767,7 +2768,7 @@ module HDF5Msg { c_ptrTo(memStride), c_ptrTo(memCount), nil); h5Logger.debug(getModuleName(),getRoutineName(),getLineNumber(), - "Locale %t intersection %t dataset slice %t".format(loc,intersection, + "Locale %? intersection %? dataset slice %?".doFormat(loc,intersection, (intersection.low - filedom.low, intersection.high - filedom.low))); /* @@ -2820,7 +2821,7 @@ module HDF5Msg { * catch block after confirming the best way to handle HDF5 error */ h5Logger.error(getModuleName(),getRoutineName(),getLineNumber(), - "checking if isBoolDataset %t with file %s".format(e.message())); + "checking if isBoolDataset %? with file %s".doFormat(e.message())); } return boolDataset; } @@ -2850,7 +2851,7 @@ module HDF5Msg { * catch block after confirming the best way to handle HDF5 error */ h5Logger.error(getModuleName(),getRoutineName(),getLineNumber(), - "checking if bigIntDataset %t with file %s".format(e.message())); + "checking if bigIntDataset %? with file %s".doFormat(e.message())); } return bigIntDataset; } @@ -2889,7 +2890,7 @@ module HDF5Msg { d = vd.size; } else { h5Logger.debug(getModuleName(),getRoutineName(),getLineNumber(), - "fD:%t segments subdom:%t is malformed signaling no segment data in file, skipping".format(i, sd)); + "fD:%? segments subdom:%? is malformed signaling no segment data in file, skipping".doFormat(i, sd)); } } @@ -2925,7 +2926,7 @@ module HDF5Msg { } else{ // Return error that file does not have required attrs - var errorMsg = "Rank Attribute was not located in %s. This attribute is required to process multi-dimensional data.".format(filenames[0]); + var errorMsg = "Rank Attribute was not located in %s. This attribute is required to process multi-dimensional data.".doFormat(filenames[0]); h5Logger.error(getModuleName(),getRoutineName(),getLineNumber(),errorMsg); throw getErrorWithContext( msg=errorMsg, @@ -2944,7 +2945,7 @@ module HDF5Msg { } else { // Return error that file does not have required attrs - var errorMsg = "Shape Attribute was not located in %s. This attribute is required to process multi-dimensional data.".format(filenames[0]); + var errorMsg = "Shape Attribute was not located in %s. This attribute is required to process multi-dimensional data.".doFormat(filenames[0]); h5Logger.error(getModuleName(),getRoutineName(),getLineNumber(),errorMsg); throw getErrorWithContext( msg=errorMsg, @@ -2960,7 +2961,7 @@ module HDF5Msg { var sname = st.nextName(); st.addEntry(sname, new shared SymEntry(shape)); var rname = readPdarrayFromFile(filenames, dset, dataclass, bytesize, isSigned, validFiles, st); - return (dset, ObjType.ARRAYVIEW, "%s+%s".format(rname, sname)); + return (dset, ObjType.ARRAYVIEW, "%s+%s".doFormat(rname, sname)); } proc readBigIntPdarrayFromFile(filenames: [?fD] string, dset: string, dataclass, bytesize: int, isSigned: bool, validFiles: [] bool, st: borrowed SymTab): string throws { @@ -2970,7 +2971,7 @@ module HDF5Msg { obj_id = C_HDF5.H5Oopen(file_id, dset.c_str(), C_HDF5.H5P_DEFAULT); if obj_id < 0 { throw getErrorWithContext( - msg="Dataset, %s, not found.".format(dset), + msg="Dataset, %s, not found.".doFormat(dset), lineNumber=getLineNumber(), routineName=getRoutineName(), moduleName=getModuleName(), @@ -3006,9 +3007,9 @@ module HDF5Msg { var subdoms: [fD] domain(1); var skips = new set(string); var len: int; - (subdoms, len, skips) = get_subdoms(filenames, "%s/Limb_%i".format(dset, l), validFiles); + (subdoms, len, skips) = get_subdoms(filenames, "%s/Limb_%i".doFormat(dset, l), validFiles); var limb = new shared SymEntry(len, uint); - read_files_into_distributed_array(limb.a, subdoms, filenames, "%s/Limb_%i".format(dset, l), skips); + read_files_into_distributed_array(limb.a, subdoms, filenames, "%s/Limb_%i".doFormat(dset, l), skips); limbs.pushBack(limb); } @@ -3057,7 +3058,7 @@ module HDF5Msg { when C_HDF5.H5T_INTEGER { if (!isSigned && 8 == bytesize) { var entryUInt = new shared SymEntry(len, uint); - h5Logger.debug(getModuleName(),getRoutineName(),getLineNumber(), "Initialized uint entry for dataset %s".format(dset)); + h5Logger.debug(getModuleName(),getRoutineName(),getLineNumber(), "Initialized uint entry for dataset %s".doFormat(dset)); read_files_into_distributed_array(entryUInt.a, subdoms, filenames, dset, skips); rname = st.nextName(); if isBoolDataset(filenames[idx], dset) { @@ -3071,7 +3072,7 @@ module HDF5Msg { } else { var entryInt = new shared SymEntry(len, int); - h5Logger.debug(getModuleName(),getRoutineName(),getLineNumber(), "Initialized int entry for dataset %s".format(dset)); + h5Logger.debug(getModuleName(),getRoutineName(),getLineNumber(), "Initialized int entry for dataset %s".doFormat(dset)); read_files_into_distributed_array(entryInt.a, subdoms, filenames, dset, skips); rname = st.nextName(); if isBoolDataset(filenames[idx], dset) { @@ -3094,7 +3095,7 @@ module HDF5Msg { } otherwise { var errorMsg = "detected unhandled datatype: objType? pdarray, class %i, size %i, " + - "signed? %t".format(dataclass, bytesize, isSigned); + "signed? %?".doFormat(dataclass, bytesize, isSigned); h5Logger.error(getModuleName(),getRoutineName(),getLineNumber(),errorMsg); throw getErrorWithContext( msg=errorMsg, @@ -3127,7 +3128,7 @@ module HDF5Msg { (subdoms, len, skips) = get_subdoms(filenames, dset + "/" + SEGMENTED_VALUE_NAME, validFiles); if (bytesize != 1) || isSigned { - var errorMsg = "Error: detected unhandled datatype: objType? SegString, class %i, size %i, signed? %t".format( + var errorMsg = "Error: detected unhandled datatype: objType? SegString, class %i, size %i, signed? %?".doFormat( dataclass, bytesize, isSigned); h5Logger.error(getModuleName(),getRoutineName(),getLineNumber(),errorMsg); throw getErrorWithContext( @@ -3161,7 +3162,7 @@ module HDF5Msg { proc strings_readhdfMsg(filenames: [?fD] string, dset: string, dataclass, bytesize: int, isSigned: bool, calcStringOffsets: bool, validFiles: [] bool, st: borrowed SymTab): (string, ObjType, string) throws { var stringsEntry = readStringsFromFile(filenames, dset, dataclass, bytesize, isSigned, calcStringOffsets, validFiles, st); - return (dset, ObjType.STRINGS, "%s+%t".format(stringsEntry.name, stringsEntry.nBytes)); + return (dset, ObjType.STRINGS, "%s+%?".doFormat(stringsEntry.name, stringsEntry.nBytes)); } proc readSegArrayFromFile(filenames: [?fD] string, dset: string, dataclass, bytesize: int, isSigned: bool, calcStringOffsets: bool, validFiles: [] bool, st: borrowed SymTab) throws { @@ -3177,19 +3178,19 @@ module HDF5Msg { var (v, idx) = maxloc reduce zip(validFiles, validFiles.domain); var first_file = filenames[idx]; - if isStringsObject(first_file, "%s/%s".format(dset, SEGMENTED_VALUE_NAME)) { - (valSubdoms, len, vskips) = get_subdoms(filenames, "%s/%s/%s".format(dset, SEGMENTED_VALUE_NAME, SEGMENTED_OFFSET_NAME), validFiles); - var stringsEntry = readStringsFromFile(filenames, "%s/%s".format(dset, SEGMENTED_VALUE_NAME), dataclass, bytesize, isSigned, calcStringOffsets, validFiles, st); - rtnMap.add("values", "created %s+created bytes.size %t".format(st.attrib(stringsEntry.name), stringsEntry.nBytes)); + if isStringsObject(first_file, "%s/%s".doFormat(dset, SEGMENTED_VALUE_NAME)) { + (valSubdoms, len, vskips) = get_subdoms(filenames, "%s/%s/%s".doFormat(dset, SEGMENTED_VALUE_NAME, SEGMENTED_OFFSET_NAME), validFiles); + var stringsEntry = readStringsFromFile(filenames, "%s/%s".doFormat(dset, SEGMENTED_VALUE_NAME), dataclass, bytesize, isSigned, calcStringOffsets, validFiles, st); + rtnMap.add("values", "created %s+created bytes.size %?".doFormat(st.attrib(stringsEntry.name), stringsEntry.nBytes)); } else { - if isBigIntPdarray(first_file, "%s/%s".format(dset, SEGMENTED_VALUE_NAME)) { - (valSubdoms, len, vskips) = get_subdoms(filenames, "%s/%s/Limb_0".format(dset, SEGMENTED_VALUE_NAME), validFiles); + if isBigIntPdarray(first_file, "%s/%s".doFormat(dset, SEGMENTED_VALUE_NAME)) { + (valSubdoms, len, vskips) = get_subdoms(filenames, "%s/%s/Limb_0".doFormat(dset, SEGMENTED_VALUE_NAME), validFiles); } else { - (valSubdoms, len, vskips) = get_subdoms(filenames, "%s/%s".format(dset, SEGMENTED_VALUE_NAME), validFiles); + (valSubdoms, len, vskips) = get_subdoms(filenames, "%s/%s".doFormat(dset, SEGMENTED_VALUE_NAME), validFiles); } - var vname = readPdarrayFromFile(filenames, "%s/%s".format(dset, SEGMENTED_VALUE_NAME), dataclass, bytesize, isSigned, validFiles, st); + var vname = readPdarrayFromFile(filenames, "%s/%s".doFormat(dset, SEGMENTED_VALUE_NAME), dataclass, bytesize, isSigned, validFiles, st); rtnMap.add("values", "created " + st.attrib(vname)); } @@ -3206,7 +3207,7 @@ module HDF5Msg { proc segarray_readhdfMsg(filenames: [?fD] string, dset: string, dataclass, bytesize: int, isSigned: bool, calcStringOffsets: bool, validFiles: [] bool, st: borrowed SymTab): (string, ObjType, string) throws { var rtnMap = readSegArrayFromFile(filenames, dset, dataclass, bytesize, isSigned, calcStringOffsets, validFiles, st); - return (dset, ObjType.SEGARRAY, "%jt".format(rtnMap)); + return (dset, ObjType.SEGARRAY, formatJson(rtnMap)); } proc categorical_readhdfMsg(filenames: [?fD] string, dset: string, validFiles: [] bool, calcStringOffsets: bool, st: borrowed SymTab): (string, ObjType, string) throws { @@ -3215,40 +3216,40 @@ module HDF5Msg { var subdoms: [fD] domain(1); var skips = new set(string); var len: int; - (subdoms, len, skips) = get_subdoms(filenames, "%s/%s".format(dset, CODES_NAME), validFiles); + (subdoms, len, skips) = get_subdoms(filenames, "%s/%s".doFormat(dset, CODES_NAME), validFiles); // read codes into distributed array var codes = makeDistArray(len, int); - read_files_into_distributed_array(codes, subdoms, filenames, "%s/%s".format(dset, CODES_NAME), skips); + read_files_into_distributed_array(codes, subdoms, filenames, "%s/%s".doFormat(dset, CODES_NAME), skips); // create symEntry var codesName = st.nextName(); var codesEntry = new shared SymEntry(codes); st.addEntry(codesName, codesEntry); // read the categories - var (objTypeList, dataclass, bytesize, isSigned) = get_info(filenames[0], "%s/%s".format(dset, CATEGORIES_NAME), calcStringOffsets); - var cats = readStringsFromFile(filenames, "%s/%s".format(dset, CATEGORIES_NAME), dataclass, bytesize, isSigned, calcStringOffsets, validFiles, st); + var (objTypeList, dataclass, bytesize, isSigned) = get_info(filenames[0], "%s/%s".doFormat(dset, CATEGORIES_NAME), calcStringOffsets); + var cats = readStringsFromFile(filenames, "%s/%s".doFormat(dset, CATEGORIES_NAME), dataclass, bytesize, isSigned, calcStringOffsets, validFiles, st); // read _akNACodes var nacodes_subdoms: [fD] domain(1); var nacodes_skips = new set(string); var nacodes_len: int; - (nacodes_subdoms, nacodes_len, nacodes_skips) = get_subdoms(filenames, "%s/%s".format(dset, NACODES_NAME), validFiles); + (nacodes_subdoms, nacodes_len, nacodes_skips) = get_subdoms(filenames, "%s/%s".doFormat(dset, NACODES_NAME), validFiles); // read codes into distributed array var naCodes = makeDistArray(nacodes_len, int); - read_files_into_distributed_array(naCodes, nacodes_subdoms, filenames, "%s/%s".format(dset, NACODES_NAME), nacodes_skips); + read_files_into_distributed_array(naCodes, nacodes_subdoms, filenames, "%s/%s".doFormat(dset, NACODES_NAME), nacodes_skips); // create symEntry var naCodesName = st.nextName(); var naCodesEntry = new shared SymEntry(naCodes); st.addEntry(naCodesName, naCodesEntry); rtnMap.add("codes", "created " + st.attrib(codesEntry.name)); - rtnMap.add("categories", "created %s+created %t".format(st.attrib(cats.name), cats.nBytes)); + rtnMap.add("categories", "created %s+created %?".doFormat(st.attrib(cats.name), cats.nBytes)); rtnMap.add("_akNAcode", "created " + st.attrib(naCodesEntry.name)); // check first file for segments and permutation. If exist here should be everywhere var file_id = C_HDF5.H5Fopen(filenames[0].c_str(), C_HDF5.H5F_ACC_RDONLY, C_HDF5.H5P_DEFAULT); - var segments_exist = C_HDF5.H5Lexists(file_id, "%s/%s".format(dset, SEGMENTS_NAME).c_str(), C_HDF5.H5P_DEFAULT); - var perm_exists = C_HDF5.H5Lexists(file_id, "%s/%s".format(dset, PERMUTATION_NAME).c_str(), C_HDF5.H5P_DEFAULT); + var segments_exist = C_HDF5.H5Lexists(file_id, "%s/%s".doFormat(dset, SEGMENTS_NAME).c_str(), C_HDF5.H5P_DEFAULT); + var perm_exists = C_HDF5.H5Lexists(file_id, "%s/%s".doFormat(dset, PERMUTATION_NAME).c_str(), C_HDF5.H5P_DEFAULT); C_HDF5.H5Fclose(file_id); if segments_exist > 0 && perm_exists > 0 { @@ -3256,10 +3257,10 @@ module HDF5Msg { var segs_subdoms: [fD] domain(1); var segs_skips = new set(string); var segs_len: int; - (segs_subdoms, segs_len, segs_skips) = get_subdoms(filenames, "%s/%s".format(dset, SEGMENTS_NAME), validFiles); + (segs_subdoms, segs_len, segs_skips) = get_subdoms(filenames, "%s/%s".doFormat(dset, SEGMENTS_NAME), validFiles); // read segments into distributed array var segments = makeDistArray(segs_len, int); - read_files_into_distributed_array(segments, segs_subdoms, filenames, "%s/%s".format(dset, SEGMENTS_NAME), segs_skips); + read_files_into_distributed_array(segments, segs_subdoms, filenames, "%s/%s".doFormat(dset, SEGMENTS_NAME), segs_skips); var segName = st.nextName(); var segEntry = new shared SymEntry(segments); st.addEntry(segName, segEntry); @@ -3268,10 +3269,10 @@ module HDF5Msg { var perm_subdoms: [fD] domain(1); var perm_skips = new set(string); var perm_len: int; - (perm_subdoms, perm_len, perm_skips) = get_subdoms(filenames, "%s/%s".format(dset, PERMUTATION_NAME), validFiles); + (perm_subdoms, perm_len, perm_skips) = get_subdoms(filenames, "%s/%s".doFormat(dset, PERMUTATION_NAME), validFiles); // read permutation into distributed array var perm = makeDistArray(perm_len, int); - read_files_into_distributed_array(perm, perm_subdoms, filenames, "%s/%s".format(dset, PERMUTATION_NAME), perm_skips); + read_files_into_distributed_array(perm, perm_subdoms, filenames, "%s/%s".doFormat(dset, PERMUTATION_NAME), perm_skips); var permName = st.nextName(); var permEntry = new shared SymEntry(perm); st.addEntry(permName, permEntry); @@ -3279,7 +3280,7 @@ module HDF5Msg { rtnMap.add("segments", "created " + st.attrib(segEntry.name)); rtnMap.add("permutation", "created " + st.attrib(permEntry.name)); } - return (dset, ObjType.CATEGORICAL, "%jt".format(rtnMap)); + return (dset, ObjType.CATEGORICAL, formatJson(rtnMap)); } proc groupby_readhdfMsg(filenames: [?fD] string, dset: string, validFiles: [] bool, calcStringOffsets: bool, st: borrowed SymTab): (string, ObjType, string) throws { @@ -3288,9 +3289,9 @@ module HDF5Msg { var perm_subdoms: [fD] domain(1); var perm_skips = new set(string); var perm_len: int; - (perm_subdoms, perm_len, perm_skips) = get_subdoms(filenames, "%s/%s".format(dset, PERMUTATION_NAME), validFiles); + (perm_subdoms, perm_len, perm_skips) = get_subdoms(filenames, "%s/%s".doFormat(dset, PERMUTATION_NAME), validFiles); var perm = makeDistArray(perm_len, int); - read_files_into_distributed_array(perm, perm_subdoms, filenames, "%s/%s".format(dset, PERMUTATION_NAME), perm_skips); + read_files_into_distributed_array(perm, perm_subdoms, filenames, "%s/%s".doFormat(dset, PERMUTATION_NAME), perm_skips); // create symEntry var permName = st.nextName(); var permEntry = new shared SymEntry(perm); @@ -3299,9 +3300,9 @@ module HDF5Msg { var seg_subdoms: [fD] domain(1); var seg_skips = new set(string); var seg_len: int; - (seg_subdoms, seg_len, seg_skips) = get_subdoms(filenames, "%s/%s".format(dset, SEGMENTS_NAME), validFiles); + (seg_subdoms, seg_len, seg_skips) = get_subdoms(filenames, "%s/%s".doFormat(dset, SEGMENTS_NAME), validFiles); var segs = makeDistArray(seg_len, int); - read_files_into_distributed_array(segs, seg_subdoms, filenames, "%s/%s".format(dset, SEGMENTS_NAME), seg_skips); + read_files_into_distributed_array(segs, seg_subdoms, filenames, "%s/%s".doFormat(dset, SEGMENTS_NAME), seg_skips); // create symEntry var segName = st.nextName(); var segEntry = new shared SymEntry(segs); @@ -3310,9 +3311,9 @@ module HDF5Msg { var uki_subdoms: [fD] domain(1); var uki_skips = new set(string); var uki_len: int; - (uki_subdoms, uki_len, uki_skips) = get_subdoms(filenames, "%s/%s".format(dset, UKI_NAME), validFiles); + (uki_subdoms, uki_len, uki_skips) = get_subdoms(filenames, "%s/%s".doFormat(dset, UKI_NAME), validFiles); var uki = makeDistArray(uki_len, int); - read_files_into_distributed_array(uki, uki_subdoms, filenames, "%s/%s".format(dset, UKI_NAME), uki_skips); + read_files_into_distributed_array(uki, uki_subdoms, filenames, "%s/%s".doFormat(dset, UKI_NAME), uki_skips); // create symEntry var ukiName = st.nextName(); var ukiEntry = new shared SymEntry(uki); @@ -3328,7 +3329,7 @@ module HDF5Msg { obj_id = C_HDF5.H5Oopen(file_id, dset.c_str(), C_HDF5.H5P_DEFAULT); if obj_id < 0 { throw getErrorWithContext( - msg="Dataset, %s, not found.".format(dset), + msg="Dataset, %s, not found.".doFormat(dset), lineNumber=getLineNumber(), routineName=getRoutineName(), moduleName=getModuleName(), @@ -3360,31 +3361,31 @@ module HDF5Msg { var isSigned: bool; var readDset: string; var readCreate: string; - (keyObjType, dataclass, bytesize, isSigned) = get_info(filenames[0], "%s/KEY_%i".format(dset, k), calcStringOffsets); + (keyObjType, dataclass, bytesize, isSigned) = get_info(filenames[0], "%s/KEY_%i".doFormat(dset, k), calcStringOffsets); select keyObjType { when ObjType.PDARRAY { - var pda_name = readPdarrayFromFile(filenames, "%s/KEY_%i".format(dset, k), dataclass, bytesize, isSigned, validFiles, st); - readCreate = "created %s".format(st.attrib(pda_name)); + var pda_name = readPdarrayFromFile(filenames, "%s/KEY_%i".doFormat(dset, k), dataclass, bytesize, isSigned, validFiles, st); + readCreate = "created %s".doFormat(st.attrib(pda_name)); } when ObjType.STRINGS { - var segString = readStringsFromFile(filenames, "%s/KEY_%i".format(dset, k), dataclass, bytesize, isSigned, calcStringOffsets, validFiles, st); - readCreate = "created %s+created %t".format(st.attrib(segString.name), segString.nBytes); + var segString = readStringsFromFile(filenames, "%s/KEY_%i".doFormat(dset, k), dataclass, bytesize, isSigned, calcStringOffsets, validFiles, st); + readCreate = "created %s+created %?".doFormat(st.attrib(segString.name), segString.nBytes); } when ObjType.CATEGORICAL { - (readDset, _, readCreate) = categorical_readhdfMsg(filenames, "%s/KEY_%i".format(dset, k), validFiles, calcStringOffsets, st); + (readDset, _, readCreate) = categorical_readhdfMsg(filenames, "%s/KEY_%i".doFormat(dset, k), validFiles, calcStringOffsets, st); } otherwise { throw getErrorWithContext( - msg="Unsupported GroupBy key type, %s".format(keyObjType: string), + msg="Unsupported GroupBy key type, %s".doFormat(keyObjType: string), lineNumber=getLineNumber(), routineName=getRoutineName(), moduleName=getModuleName(), errorClass="TypeError"); } } - rtnMap.add("KEY_%i".format(k), "%s+|+%s".format(keyObjType: string, readCreate)); + rtnMap.add("KEY_%i".doFormat(k), "%s+|+%s".doFormat(keyObjType: string, readCreate)); } - return (dset, ObjType.GROUPBY, "%jt".format(rtnMap)); + return (dset, ObjType.GROUPBY, formatJson(rtnMap)); } proc dataframe_readhdfMsg(filenames: [?fD] string, dset: string, validFiles: [] bool, calcStringOffsets: bool, st: borrowed SymTab): (string, ObjType, string) throws { @@ -3394,7 +3395,7 @@ module HDF5Msg { var group_id: C_HDF5.hid_t = C_HDF5.H5Oopen(file_id, dset.c_str(), C_HDF5.H5P_DEFAULT); if group_id < 0 { throw getErrorWithContext( - msg="Dataset, %s, not found.".format(dset), + msg="Dataset, %s, not found.".doFormat(dset), lineNumber=getLineNumber(), routineName=getRoutineName(), moduleName=getModuleName(), @@ -3413,35 +3414,35 @@ module HDF5Msg { var isSigned: bool; var readDset: string; var readCreate: string; - (keyObjType, dataclass, bytesize, isSigned) = get_info(filenames[0], "%s/%s".format(dset, col), calcStringOffsets); + (keyObjType, dataclass, bytesize, isSigned) = get_info(filenames[0], "%s/%s".doFormat(dset, col), calcStringOffsets); select keyObjType { when ObjType.PDARRAY { - var pda_name = readPdarrayFromFile(filenames, "%s/%s".format(dset, col), dataclass, bytesize, isSigned, validFiles, st); - readCreate = "created %s".format(st.attrib(pda_name)); + var pda_name = readPdarrayFromFile(filenames, "%s/%s".doFormat(dset, col), dataclass, bytesize, isSigned, validFiles, st); + readCreate = "created %s".doFormat(st.attrib(pda_name)); } when ObjType.STRINGS { - var segString = readStringsFromFile(filenames, "%s/%s".format(dset, col), dataclass, bytesize, isSigned, calcStringOffsets, validFiles, st); - readCreate = "created %s+created %t".format(st.attrib(segString.name), segString.nBytes); + var segString = readStringsFromFile(filenames, "%s/%s".doFormat(dset, col), dataclass, bytesize, isSigned, calcStringOffsets, validFiles, st); + readCreate = "created %s+created %?".doFormat(st.attrib(segString.name), segString.nBytes); } when ObjType.CATEGORICAL { - (readDset, _, readCreate) = categorical_readhdfMsg(filenames, "%s/%s".format(dset, col), validFiles, calcStringOffsets, st); + (readDset, _, readCreate) = categorical_readhdfMsg(filenames, "%s/%s".doFormat(dset, col), validFiles, calcStringOffsets, st); } when ObjType.SEGARRAY { - var segMap = readSegArrayFromFile(filenames, "%s/%s".format(dset, col), dataclass, bytesize, isSigned, calcStringOffsets, validFiles, st); - readCreate = "%jt".format(segMap); + var segMap = readSegArrayFromFile(filenames, "%s/%s".doFormat(dset, col), dataclass, bytesize, isSigned, calcStringOffsets, validFiles, st); + readCreate = formatJson(segMap); } otherwise { throw getErrorWithContext( - msg="Unsupported DataFrame column type, %s".format(keyObjType: string), + msg="Unsupported DataFrame column type, %s".doFormat(keyObjType: string), lineNumber=getLineNumber(), routineName=getRoutineName(), moduleName=getModuleName(), errorClass="TypeError"); } } - rtnMap.add(col, "%s+|+%s".format(keyObjType: string, readCreate)); + rtnMap.add(col, "%s+|+%s".doFormat(keyObjType: string, readCreate)); } - return (dset, ObjType.DATAFRAME, "%jt".format(rtnMap)); + return (dset, ObjType.DATAFRAME, formatJson(rtnMap)); } /* @@ -3454,7 +3455,7 @@ module HDF5Msg { obj_id = C_HDF5.H5Oopen(file_id, dset.c_str(), C_HDF5.H5P_DEFAULT); if obj_id < 0 { throw getErrorWithContext( - msg="Dataset, %s, not found.".format(dset), + msg="Dataset, %s, not found.".doFormat(dset), lineNumber=getLineNumber(), routineName=getRoutineName(), moduleName=getModuleName(), @@ -3493,7 +3494,7 @@ module HDF5Msg { C_HDF5.H5P_DEFAULT); if (dset < 0) { throw getErrorWithContext( - msg="dataset %s does not exist".format(dsetName), + msg="dataset %s does not exist".doFormat(dsetName), lineNumber=getLineNumber(), routineName=getRoutineName(), moduleName=getModuleName(), @@ -3516,7 +3517,7 @@ module HDF5Msg { // Verify that the file exists if !exists(filename) { throw getErrorWithContext( - msg="The file %s does not exist".format(filename), + msg="The file %s does not exist".doFormat(filename), lineNumber=getLineNumber(), routineName=getRoutineName(), moduleName=getModuleName(), @@ -3530,7 +3531,7 @@ module HDF5Msg { */ if !isHdf5File(filename) { throw getErrorWithContext( - msg="%s is not an HDF5 file".format(filename), + msg="%s is not an HDF5 file".doFormat(filename), lineNumber=getLineNumber(), routineName=getRoutineName(), moduleName=getModuleName(), @@ -3543,7 +3544,7 @@ module HDF5Msg { if file_id < 0 { // HF5open returns negative value on failure C_HDF5.H5Fclose(file_id); throw getErrorWithContext( - msg="in accessing %s HDF5 file content".format(filename), + msg="in accessing %s HDF5 file content".doFormat(filename), lineNumber=getLineNumber(), routineName=getRoutineName(), moduleName=getModuleName(), @@ -3553,7 +3554,7 @@ module HDF5Msg { if C_HDF5.H5Lexists(file_id, dsetName.c_str(), C_HDF5.H5P_DEFAULT) <= 0 { C_HDF5.H5Fclose(file_id); throw getErrorWithContext( - msg="The dataset %s does not exist in the file %s".format(dsetName, + msg="The dataset %s does not exist in the file %s".doFormat(dsetName, filename), lineNumber=getLineNumber(), routineName=getRoutineName(), @@ -3575,7 +3576,7 @@ module HDF5Msg { if (offsetClass != C_HDF5.H5T_INTEGER) { throw getErrorWithContext( msg="dataset %s has incorrect one or more sub-datasets" + - " %s %s".format(dsetName,SEGMENTED_OFFSET_NAME,SEGMENTED_VALUE_NAME), + " %s %s".doFormat(dsetName,SEGMENTED_OFFSET_NAME,SEGMENTED_VALUE_NAME), lineNumber=getLineNumber(), routineName=getRoutineName(), moduleName=getModuleName(), @@ -3584,46 +3585,46 @@ module HDF5Msg { } var valueDset = dsetName + "/" + SEGMENTED_VALUE_NAME; if isStringsObject(filename, valueDset){ - (dataclass, bytesize, isSigned) = get_dataset_info(file_id, "%s/%s".format(valueDset, SEGMENTED_VALUE_NAME)); + (dataclass, bytesize, isSigned) = get_dataset_info(file_id, "%s/%s".doFormat(valueDset, SEGMENTED_VALUE_NAME)); } else if isBigIntPdarray(filename, valueDset) { - (dataclass, bytesize, isSigned) = get_dataset_info(file_id, "%s/%s".format(valueDset, "Limb_0")); + (dataclass, bytesize, isSigned) = get_dataset_info(file_id, "%s/%s".doFormat(valueDset, "Limb_0")); } else { try (dataclass, bytesize, isSigned) = try get_dataset_info(file_id, valueDset); } } else if objType == ObjType.CATEGORICAL { - (dataclass, bytesize, isSigned) = get_dataset_info(file_id, "%s/%s".format(dsetName, CODES_NAME)); + (dataclass, bytesize, isSigned) = get_dataset_info(file_id, "%s/%s".doFormat(dsetName, CODES_NAME)); } else if objType == ObjType.GROUPBY { // for groupby this information will not be used, but needs to be returned for the workflow - (dataclass, bytesize, isSigned) = get_dataset_info(file_id, "%s/%s".format(dsetName, PERMUTATION_NAME)); + (dataclass, bytesize, isSigned) = get_dataset_info(file_id, "%s/%s".doFormat(dsetName, PERMUTATION_NAME)); } else if objType == ObjType.DATAFRAME { // for dataframe this information will not be used, but needs to be returned for the workflow - var idx_objType = getObjType(file_id, "%s/%s".format(dsetName, INDEX_NAME)); + var idx_objType = getObjType(file_id, "%s/%s".doFormat(dsetName, INDEX_NAME)); if idx_objType == ObjType.PDARRAY { - (dataclass, bytesize, isSigned) = get_dataset_info(file_id, "%s/%s".format(dsetName, INDEX_NAME)); + (dataclass, bytesize, isSigned) = get_dataset_info(file_id, "%s/%s".doFormat(dsetName, INDEX_NAME)); } else if idx_objType == ObjType.STRINGS { if ( !calcStringOffsets ) { - var offsetDset = "%s/%s/%s".format(dsetName, INDEX_NAME, SEGMENTED_OFFSET_NAME); + var offsetDset = "%s/%s/%s".doFormat(dsetName, INDEX_NAME, SEGMENTED_OFFSET_NAME); var (offsetClass, offsetByteSize, offsetSign) = try get_dataset_info(file_id, offsetDset); if (offsetClass != C_HDF5.H5T_INTEGER) { throw getErrorWithContext( msg="dataset %s has incorrect one or more sub-datasets" + - " %s %s".format(dsetName,SEGMENTED_OFFSET_NAME,SEGMENTED_VALUE_NAME), + " %s %s".doFormat(dsetName,SEGMENTED_OFFSET_NAME,SEGMENTED_VALUE_NAME), lineNumber=getLineNumber(), routineName=getRoutineName(), moduleName=getModuleName(), errorClass='SegStringError'); } } - var valueDset = "%s/%s/%s".format(dsetName, INDEX_NAME, SEGMENTED_VALUE_NAME); + var valueDset = "%s/%s/%s".doFormat(dsetName, INDEX_NAME, SEGMENTED_VALUE_NAME); if isStringsObject(filename, valueDset){ - (dataclass, bytesize, isSigned) = get_dataset_info(file_id, "%s/%s".format(valueDset, SEGMENTED_VALUE_NAME)); + (dataclass, bytesize, isSigned) = get_dataset_info(file_id, "%s/%s".doFormat(valueDset, SEGMENTED_VALUE_NAME)); } else if isBigIntPdarray(filename, valueDset) { - (dataclass, bytesize, isSigned) = get_dataset_info(file_id, "%s/%s".format(valueDset, "Limb_0")); + (dataclass, bytesize, isSigned) = get_dataset_info(file_id, "%s/%s".doFormat(valueDset, "Limb_0")); } else { try (dataclass, bytesize, isSigned) = try get_dataset_info(file_id, valueDset); @@ -3640,14 +3641,14 @@ module HDF5Msg { } else { if isBigIntPdarray(filename, dsetName) { // for bigint pdarray this info is the same for all limbs - (dataclass, bytesize, isSigned) = get_dataset_info(file_id, "%s/%s".format(dsetName, "Limb_0")); + (dataclass, bytesize, isSigned) = get_dataset_info(file_id, "%s/%s".doFormat(dsetName, "Limb_0")); } else { (dataclass, bytesize, isSigned) = get_dataset_info(file_id, dsetName); } } } catch e : Error { throw getErrorWithContext( - msg="in get_info %s".format(e.message()), + msg="in get_info %s".doFormat(e.message()), lineNumber=getLineNumber(), routineName=getRoutineName(), moduleName=getModuleName(), @@ -3659,11 +3660,11 @@ module HDF5Msg { proc assign_tags(A, filedomains: [?FD] domain(1), filenames: [FD] string, dsetName: string, skips: set(string)) throws { h5Logger.debug(getModuleName(),getRoutineName(),getLineNumber(), - "entry.a.targetLocales() = %t".format(A.targetLocales())); + "entry.a.targetLocales() = %?".doFormat(A.targetLocales())); h5Logger.debug(getModuleName(),getRoutineName(),getLineNumber(), - "Filedomains: %t".format(filedomains)); + "Filedomains: %?".doFormat(filedomains)); h5Logger.debug(getModuleName(),getRoutineName(),getLineNumber(), - "skips: %t".format(skips)); + "skips: %?".doFormat(skips)); coforall loc in A.targetLocales() do on loc { // Create local copies of args @@ -3678,7 +3679,7 @@ module HDF5Msg { if (skips.contains(filename)) { h5Logger.debug(getModuleName(),getRoutineName(),getLineNumber(), - "File %s does not contain data for this dataset, skipping".format(filename)); + "File %s does not contain data for this dataset, skipping".doFormat(filename)); } else { // Look for overlap between A's local subdomains and this file for locdom in A.localSubdomains() { @@ -3764,7 +3765,7 @@ module HDF5Msg { var n: int = 1000; var jsondsets = msgArgs.getValueOf("dsets"); var dsets: string = if jsondsets.size > 2*n then jsondsets[0..#n]+'...'+jsondsets[jsondsets.size-n..#n] else jsondsets; - var errorMsg = "Could not decode json dataset names via tempfile (%i files: %s)".format( + var errorMsg = "Could not decode json dataset names via tempfile (%i files: %s)".doFormat( ndsets, dsets); h5Logger.error(getModuleName(),getRoutineName(),getLineNumber(),errorMsg); return new MsgTuple(errorMsg, MsgType.ERROR); @@ -3779,7 +3780,7 @@ module HDF5Msg { var n: int = 1000; var jsonfiles = msgArgs.getValueOf("filenames"); var files: string = if jsonfiles.size > 2*n then jsonfiles[0..#n]+'...'+jsonfiles[jsonfiles.size-n..#n] else jsonfiles; - var errorMsg = "Could not decode json filenames via tempfile (%i files: %s)".format(nfiles, files); + var errorMsg = "Could not decode json filenames via tempfile (%i files: %s)".doFormat(nfiles, files); h5Logger.error(getModuleName(),getRoutineName(),getLineNumber(),errorMsg); return new MsgTuple(errorMsg, MsgType.ERROR); } @@ -3795,9 +3796,9 @@ module HDF5Msg { } var tmp = glob(filelist[0]); h5Logger.debug(getModuleName(),getRoutineName(),getLineNumber(), - "glob expanded %s to %i files".format(filelist[0], tmp.size)); + "glob expanded %s to %i files".doFormat(filelist[0], tmp.size)); if tmp.size == 0 { - var errorMsg = "The wildcarded filename %s either corresponds to files inaccessible to Arkouda or files of an invalid format".format(filelist[0]); + var errorMsg = "The wildcarded filename %s either corresponds to files inaccessible to Arkouda or files of an invalid format".doFormat(filelist[0]); h5Logger.error(getModuleName(),getRoutineName(),getLineNumber(),errorMsg); return new MsgTuple(errorMsg, MsgType.ERROR); } @@ -3829,32 +3830,32 @@ module HDF5Msg { try { (objTypeList[i], dclasses[i], bytesizes[i], signFlags[i]) = get_info(fname, dsetName, calcStringOffsets); } catch e: FileNotFoundError { - fileErrorMsg = "File %s not found".format(fname); + fileErrorMsg = "File %s not found".doFormat(fname); h5Logger.error(getModuleName(),getRoutineName(),getLineNumber(),fileErrorMsg); hadError = true; if !allowErrors { return new MsgTuple(fileErrorMsg, MsgType.ERROR); } } catch e: PermissionError { - fileErrorMsg = "Permission error %s opening %s".format(e.message(),fname); + fileErrorMsg = "Permission error %s opening %s".doFormat(e.message(),fname); h5Logger.error(getModuleName(),getRoutineName(),getLineNumber(),fileErrorMsg); hadError = true; if !allowErrors { return new MsgTuple(fileErrorMsg, MsgType.ERROR); } } catch e: DatasetNotFoundError { - fileErrorMsg = "Dataset %s not found in file %s".format(dsetName,fname); + fileErrorMsg = "Dataset %s not found in file %s".doFormat(dsetName,fname); h5Logger.error(getModuleName(),getRoutineName(),getLineNumber(),fileErrorMsg); hadError = true; if !allowErrors { return new MsgTuple(fileErrorMsg, MsgType.ERROR); } } catch e: NotHDF5FileError { - fileErrorMsg = "The file %s is not an HDF5 file: %s".format(fname,e.message()); + fileErrorMsg = "The file %s is not an HDF5 file: %s".doFormat(fname,e.message()); h5Logger.error(getModuleName(),getRoutineName(),getLineNumber(),fileErrorMsg); hadError = true; if !allowErrors { return new MsgTuple(fileErrorMsg, MsgType.ERROR); } } catch e: SegStringError { - fileErrorMsg = "SegmentedString error: %s".format(e.message()); + fileErrorMsg = "SegmentedString error: %s".doFormat(e.message()); h5Logger.error(getModuleName(),getRoutineName(),getLineNumber(),fileErrorMsg); hadError = true; if !allowErrors { return new MsgTuple(fileErrorMsg, MsgType.ERROR); } } catch e : Error { - fileErrorMsg = "Other error in accessing file %s: %s".format(fname,e.message()); + fileErrorMsg = "Other error in accessing file %s: %s".doFormat(fname,e.message()); h5Logger.error(getModuleName(),getRoutineName(),getLineNumber(),fileErrorMsg); hadError = true; if !allowErrors { return new MsgTuple(fileErrorMsg, MsgType.ERROR); } @@ -3879,23 +3880,23 @@ module HDF5Msg { for (isValid, name, ot, dc, bs, sf) in zip(validFiles, filenames, objTypeList, dclasses, bytesizes, signFlags) { if isValid { if (ot != objType) { - var errorMsg = "Inconsistent objecttype in dataset %s of file %s. Expected: %s, Found: %s".format(dsetName, name, objType:string, ot:string); + var errorMsg = "Inconsistent objecttype in dataset %s of file %s. Expected: %s, Found: %s".doFormat(dsetName, name, objType:string, ot:string); h5Logger.error(getModuleName(),getRoutineName(),getLineNumber(),errorMsg); return new MsgTuple(errorMsg, MsgType.ERROR); } else if (dc != dataclass) { - var errorMsg = "Inconsistent dtype in dataset %s of file %s".format(dsetName, name); + var errorMsg = "Inconsistent dtype in dataset %s of file %s".doFormat(dsetName, name); h5Logger.error(getModuleName(),getRoutineName(),getLineNumber(),errorMsg); return new MsgTuple(errorMsg, MsgType.ERROR); } else if (strictTypes && ((bs != bytesize) || (sf != isSigned))) { - var errorMsg = "Inconsistent precision or sign in dataset %s of file %s\nWith strictTypes, mixing of precision and signedness not allowed (set strictTypes=False to suppress)".format(dsetName, name); + var errorMsg = "Inconsistent precision or sign in dataset %s of file %s\nWith strictTypes, mixing of precision and signedness not allowed (set strictTypes=False to suppress)".doFormat(dsetName, name); h5Logger.error(getModuleName(),getRoutineName(),getLineNumber(),errorMsg); return new MsgTuple(errorMsg, MsgType.ERROR); } } } h5Logger.debug(getModuleName(),getRoutineName(),getLineNumber(), - "Verified all dtypes across files for dataset %s".format(dsetName)); + "Verified all dtypes across files for dataset %s".doFormat(dsetName)); if tagData { h5Logger.debug(getModuleName(),getRoutineName(),getLineNumber(), "Tagging Data with File Code"); @@ -3934,7 +3935,7 @@ module HDF5Msg { } if allowErrors && fileErrorCount > 0 { h5Logger.debug(getModuleName(),getRoutineName(),getLineNumber(), - "allowErrors:true, fileErrorCount:%t".format(fileErrorCount)); + "allowErrors:true, fileErrorCount:%?".doFormat(fileErrorCount)); } var repMsg: string = _buildReadAllMsgJson(rtnData, allowErrors, fileErrorCount, fileErrors, st); h5Logger.debug(getModuleName(),getRoutineName(),getLineNumber(),repMsg); @@ -3957,10 +3958,10 @@ module HDF5Msg { // Attempt to interpret filename as a glob expression and ls the first result var tmp = glob(filename); h5Logger.debug(getModuleName(),getRoutineName(),getLineNumber(), - "glob-expanded filename: %s to size: %i files".format(filename, tmp.size)); + "glob-expanded filename: %s to size: %i files".doFormat(filename, tmp.size)); if tmp.size <= 0 { - var errorMsg = "Cannot retrieve filename from glob expression %s, check file name or format".format(filename); + var errorMsg = "Cannot retrieve filename from glob expression %s, check file name or format".doFormat(filename); h5Logger.error(getModuleName(),getRoutineName(),getLineNumber(),errorMsg); return new MsgTuple(errorMsg, MsgType.ERROR); } @@ -3971,13 +3972,13 @@ module HDF5Msg { // Check to see if the file exists. If not, return an error message if !exists(filename) { - var errorMsg = "File %s does not exist in a location accessible to Arkouda".format(filename); + var errorMsg = "File %s does not exist in a location accessible to Arkouda".doFormat(filename); h5Logger.error(getModuleName(),getRoutineName(),getLineNumber(),errorMsg); return new MsgTuple(errorMsg,MsgType.ERROR); } if !isHdf5File(filename) { - var errorMsg = "File %s is not an HDF5 file".format(filename); + var errorMsg = "File %s is not an HDF5 file".doFormat(filename); h5Logger.error(getModuleName(),getRoutineName(),getLineNumber(),errorMsg); return new MsgTuple(errorMsg,MsgType.ERROR); } @@ -4000,7 +4001,7 @@ module HDF5Msg { } else { throw getErrorWithContext( - msg="Unknown file formatting, %i.".format(file_format), + msg="Unknown file formatting, %i.".doFormat(file_format), lineNumber=getLineNumber(), routineName=getRoutineName(), moduleName=getModuleName(), @@ -4019,7 +4020,7 @@ module HDF5Msg { } } } catch e : Error { - var errorMsg = "Failed to process HDF5 file %t".format(e.message()); + var errorMsg = "Failed to process HDF5 file %?".doFormat(e.message()); h5Logger.error(getModuleName(),getRoutineName(),getLineNumber(),errorMsg); return new MsgTuple(errorMsg, MsgType.ERROR); } diff --git a/src/HashMsg.chpl b/src/HashMsg.chpl index 8e85c649b2..f958654ad2 100644 --- a/src/HashMsg.chpl +++ b/src/HashMsg.chpl @@ -14,6 +14,8 @@ module HashMsg { use UniqueMsg; use Map; + use ArkoudaIOCompat; + private config const logLevel = ServerConfig.logLevel; private config const logChannel = ServerConfig.logChannel; const hmLogger = new Logger(logLevel, logChannel); @@ -56,9 +58,9 @@ module HashMsg { var lowerName = st.nextName(); st.addEntry(lowerName, new shared SymEntry(lower)); var createdMap = new map(keyType=string,valType=string); - createdMap.add("upperHash", "created %s".format(st.attrib(upperName))); - createdMap.add("lowerHash", "created %s".format(st.attrib(lowerName))); - repMsg = "%jt".format(createdMap); + createdMap.add("upperHash", "created %s".doFormat(st.attrib(upperName))); + createdMap.add("lowerHash", "created %s".doFormat(st.attrib(lowerName))); + repMsg = formatJson(createdMap); hmLogger.debug(getModuleName(),getRoutineName(),getLineNumber(),repMsg); return new MsgTuple(repMsg, MsgType.NORMAL); } @@ -86,9 +88,9 @@ module HashMsg { st.addEntry(lowerName, new shared SymEntry(lower)); var createdMap = new map(keyType=string,valType=string); - createdMap.add("upperHash", "created %s".format(st.attrib(upperName))); - createdMap.add("lowerHash", "created %s".format(st.attrib(lowerName))); - var repMsg = "%jt".format(createdMap); + createdMap.add("upperHash", "created %s".doFormat(st.attrib(upperName))); + createdMap.add("lowerHash", "created %s".doFormat(st.attrib(lowerName))); + var repMsg = formatJson(createdMap); hmLogger.debug(getModuleName(),getRoutineName(),getLineNumber(),repMsg); return new MsgTuple(repMsg, MsgType.NORMAL); } diff --git a/src/Histogram.chpl b/src/Histogram.chpl index dcdc4e287e..20aee2200c 100644 --- a/src/Histogram.chpl +++ b/src/Histogram.chpl @@ -57,7 +57,7 @@ module Histogram // copy from atomic histogram to normal histogram [(e,ae) in zip(hist, atomicHist)] e = ae.read(); try! hgLogger.debug(getModuleName(),getRoutineName(),getLineNumber(), - "hist = %t".format(hist)); + "hist = %?".doFormat(hist)); return hist; } diff --git a/src/HistogramMsg.chpl b/src/HistogramMsg.chpl index 6de863863b..b5d437c225 100644 --- a/src/HistogramMsg.chpl +++ b/src/HistogramMsg.chpl @@ -31,7 +31,7 @@ module HistogramMsg // get next symbol name var rname = st.nextName(); hgmLogger.debug(getModuleName(),getRoutineName(),getLineNumber(), - "cmd: %s name: %s bins: %i rname: %s".format(cmd, name, bins, rname)); + "cmd: %s name: %s bins: %i rname: %s".doFormat(cmd, name, bins, rname)); var gEnt: borrowed GenSymEntry = getGenericTypedArrayEntry(name, st); @@ -42,23 +42,23 @@ module HistogramMsg var aMax = max reduce e.a; var binWidth:real = (aMax - aMin):real / bins:real; hgmLogger.debug(getModuleName(),getRoutineName(),getLineNumber(), - "binWidth %r".format(binWidth)); + "binWidth %r".doFormat(binWidth)); if (bins <= sBound) { hgmLogger.debug(getModuleName(),getRoutineName(),getLineNumber(), - "%t <= %t".format(bins,sBound)); + "%? <= %?".doFormat(bins,sBound)); var hist = histogramReduceIntent(e.a, aMin, aMax, bins, binWidth); st.addEntry(rname, new shared SymEntry(hist)); } else if (bins <= mBound) { hgmLogger.debug(getModuleName(),getRoutineName(),getLineNumber(), - "%t <= %t".format(bins,mBound)); + "%? <= %?".doFormat(bins,mBound)); var hist = histogramLocalAtomic(e.a, aMin, aMax, bins, binWidth); st.addEntry(rname, new shared SymEntry(hist)); } else { hgmLogger.debug(getModuleName(),getRoutineName(),getLineNumber(), - "%t > %t".format(bins,mBound)); + "%? > %?".doFormat(bins,mBound)); var hist = histogramGlobalAtomic(e.a, aMin, aMax, bins, binWidth); st.addEntry(rname, new shared SymEntry(hist)); } diff --git a/src/In1dMsg.chpl b/src/In1dMsg.chpl index a851aa2763..528e134e6f 100644 --- a/src/In1dMsg.chpl +++ b/src/In1dMsg.chpl @@ -40,7 +40,7 @@ module In1dMsg var gAr2: borrowed GenSymEntry = getGenericTypedArrayEntry(sname, st); iLogger.debug(getModuleName(),getRoutineName(),getLineNumber(), - "cmd: %s pdarray1: %s pdarray2: %s invert: %t new pdarray name: %t".format( + "cmd: %s pdarray1: %s pdarray2: %s invert: %? new pdarray name: %?".doFormat( cmd,st.attrib(name),st.attrib(sname),invert,rname)); select (gAr1.dtype, gAr2.dtype) { diff --git a/src/IndexingMsg.chpl b/src/IndexingMsg.chpl index 559564ad67..77723a97fc 100644 --- a/src/IndexingMsg.chpl +++ b/src/IndexingMsg.chpl @@ -21,21 +21,14 @@ module IndexingMsg use ArkoudaFileCompat; use ArkoudaBigIntCompat; use ArkoudaRangeCompat; + use ArkoudaIOCompat; private config const logLevel = ServerConfig.logLevel; private config const logChannel = ServerConfig.logChannel; const imLogger = new Logger(logLevel, logChannel); proc jsonToTuple(json: string, type t) throws { - var f = openMemFile(); defer { ensureClose(f); } - var w = f.writer(); - w.write(json); - w.close(); - var r = f.reader(); - var tup: t; - r.readf("%jt", tup); - r.close(); - return tup; + return jsonToTupleCompat(json, t); } proc arrayViewMixedIndexMsg(cmd: string, msgArgs: borrowed MessageArgs, st: borrowed SymTab): MsgTuple throws { @@ -44,7 +37,7 @@ module IndexingMsg const indexDimName = msgArgs.getValueOf("index_dim"); const dimProdName = msgArgs.getValueOf("dim_prod"); imLogger.debug(getModuleName(),getRoutineName(),getLineNumber(), - "%s %s %i %s %s".format(cmd, pdaName, ndim, dimProdName, msgArgs.getValueOf("coords"))); + "%s %s %i %s %s".doFormat(cmd, pdaName, ndim, dimProdName, msgArgs.getValueOf("coords"))); var dimProd: borrowed GenSymEntry = getGenericTypedArrayEntry(dimProdName, st); var dimProdEntry = toSymEntry(dimProd, int); @@ -94,7 +87,7 @@ module IndexingMsg var indiciesName = st.nextName(); var indicies = st.addEntry(indiciesName, * reduce dims, int); - imLogger.debug(getModuleName(),getRoutineName(),getLineNumber(), "rname = %s".format(indiciesName)); + imLogger.debug(getModuleName(),getRoutineName(),getLineNumber(), "rname = %s".doFormat(indiciesName)); // avoid dividing by 0 // if any dim is 0 we return an empty list @@ -106,10 +99,10 @@ module IndexingMsg recursiveIndexCalc(0,0,0); proc recursiveIndexCalc(depth: int, ind:int, sum:int) throws { for j in 0..#dims[depth] { - imLogger.debug(getModuleName(),getRoutineName(),getLineNumber(), "depth = %i".format(depth)); - imLogger.debug(getModuleName(),getRoutineName(),getLineNumber(), "j = %i".format(j)); - imLogger.debug(getModuleName(),getRoutineName(),getLineNumber(), "SUM: sum + scaledCoords[offsets[depth]+j] = %i".format(sum + scaledCoords[offsets[depth]+j])); - imLogger.debug(getModuleName(),getRoutineName(),getLineNumber(), "IND: ind + j*dim_prod[depth] = %i".format(ind+(j*dim_prod[depth]))); + imLogger.debug(getModuleName(),getRoutineName(),getLineNumber(), "depth = %i".doFormat(depth)); + imLogger.debug(getModuleName(),getRoutineName(),getLineNumber(), "j = %i".doFormat(j)); + imLogger.debug(getModuleName(),getRoutineName(),getLineNumber(), "SUM: sum + scaledCoords[offsets[depth]+j] = %i".doFormat(sum + scaledCoords[offsets[depth]+j])); + imLogger.debug(getModuleName(),getRoutineName(),getLineNumber(), "IND: ind + j*dim_prod[depth] = %i".doFormat(ind+(j*dim_prod[depth]))); if depth == ndim-1 then indicies.a[ind+(j*dim_prod[depth])] = sum+scaledCoords[offsets[depth]+j]; else recursiveIndexCalc(depth+1, ind+(j*dim_prod[depth]), sum+scaledCoords[offsets[depth]+j]); @@ -130,7 +123,7 @@ module IndexingMsg const pdaName = msgArgs.getValueOf("base"); const dimProdName = msgArgs.getValueOf("dim_prod"); const coordsName = msgArgs.getValueOf("coords"); - imLogger.debug(getModuleName(),getRoutineName(),getLineNumber(), "%s %s %s %s".format(cmd, pdaName, dimProdName, coordsName)); + imLogger.debug(getModuleName(),getRoutineName(),getLineNumber(), "%s %s %s %s".doFormat(cmd, pdaName, dimProdName, coordsName)); var dimProd: borrowed GenSymEntry = getGenericTypedArrayEntry(dimProdName, st); var dimProdEntry = toSymEntry(dimProd, int); @@ -175,7 +168,7 @@ module IndexingMsg const coordsName = msgArgs.getValueOf("coords"); const dtypeStr = msgArgs.getValueOf("dtype"); var value = msgArgs.getValueOf("value"); - imLogger.debug(getModuleName(),getRoutineName(),getLineNumber(), "%s %s %s %s".format(cmd, pdaName, dimProdName, coordsName)); + imLogger.debug(getModuleName(),getRoutineName(),getLineNumber(), "%s %s %s %s".doFormat(cmd, pdaName, dimProdName, coordsName)); var dimProd: borrowed GenSymEntry = getGenericTypedArrayEntry(dimProdName, st); var dimProdEntry = toSymEntry(dimProd, int); @@ -219,34 +212,34 @@ module IndexingMsg var idx = msgArgs.get("idx").getIntValue(); const name = msgArgs.getValueOf("array"); imLogger.debug(getModuleName(),getRoutineName(),getLineNumber(), - "%s %s %i".format(cmd, name, idx)); + "%s %s %i".doFormat(cmd, name, idx)); var gEnt: borrowed GenSymEntry = getGenericTypedArrayEntry(name, st); select (gEnt.dtype) { when (DType.Int64) { var e = toSymEntry(gEnt, int); - repMsg = "item %s %t".format(dtype2str(e.dtype),e.a[idx]); + repMsg = "item %s %?".doFormat(dtype2str(e.dtype),e.a[idx]); imLogger.debug(getModuleName(),getRoutineName(),getLineNumber(),repMsg); return new MsgTuple(repMsg, MsgType.NORMAL); } when (DType.UInt64) { var e = toSymEntry(gEnt, uint); - repMsg = "item %s %t".format(dtype2str(e.dtype),e.a[idx]); + repMsg = "item %s %?".doFormat(dtype2str(e.dtype),e.a[idx]); imLogger.debug(getModuleName(),getRoutineName(),getLineNumber(),repMsg); return new MsgTuple(repMsg, MsgType.NORMAL); } when (DType.Float64) { var e = toSymEntry(gEnt,real); - repMsg = "item %s %.17r".format(dtype2str(e.dtype),e.a[idx]); + repMsg = "item %s %.17r".doFormat(dtype2str(e.dtype),e.a[idx]); imLogger.debug(getModuleName(),getRoutineName(),getLineNumber(),repMsg); return new MsgTuple(repMsg, MsgType.NORMAL); } when (DType.Bool) { var e = toSymEntry(gEnt,bool); - repMsg = "item %s %t".format(dtype2str(e.dtype),e.a[idx]); + repMsg = "item %s %?".doFormat(dtype2str(e.dtype),e.a[idx]); repMsg = repMsg.replace("true","True"); // chapel to python bool repMsg = repMsg.replace("false","False"); // chapel to python bool @@ -255,7 +248,7 @@ module IndexingMsg } when (DType.BigInt) { var e = toSymEntry(gEnt,bigint); - repMsg = "item %s %t".format(dtype2str(e.dtype),e.a[idx]); + repMsg = "item %s %?".doFormat(dtype2str(e.dtype),e.a[idx]); imLogger.debug(getModuleName(),getRoutineName(),getLineNumber(),repMsg); return new MsgTuple(repMsg, MsgType.NORMAL); } @@ -294,7 +287,7 @@ module IndexingMsg var gEnt: borrowed GenSymEntry = getGenericTypedArrayEntry(name, st); imLogger.debug(getModuleName(),getRoutineName(),getLineNumber(), - "cmd: %s pdarray to slice: %s start: %i stop: %i stride: %i slice: %t new name: %s".format( + "cmd: %s pdarray to slice: %s start: %i stop: %i stride: %i slice: %? new name: %s".doFormat( cmd, st.attrib(name), start, stop, stride, slice, rname)); proc sliceHelper(type t) throws { @@ -349,7 +342,7 @@ module IndexingMsg var gIV: borrowed GenSymEntry = getGenericTypedArrayEntry(iname, st); imLogger.debug(getModuleName(),getRoutineName(),getLineNumber(), - "cmd: %s name: %s gX: %t gIV: %t".format( + "cmd: %s name: %s gX: %? gIV: %?".doFormat( cmd, name, st.attrib(name), st.attrib(iname))); // gather indexing by integer index vector @@ -365,12 +358,12 @@ module IndexingMsg var ivMin = min reduce iv.a; var ivMax = max reduce iv.a; if ivMin < 0 { - var errorMsg = "Error: %s: OOBindex %i < 0".format(pn,ivMin); + var errorMsg = "Error: %s: OOBindex %i < 0".doFormat(pn,ivMin); imLogger.error(getModuleName(),getRoutineName(),getLineNumber(),errorMsg); return new MsgTuple(errorMsg,MsgType.ERROR); } if ivMax >= e.size { - var errorMsg = "Error: %s: OOBindex %i > %i".format(pn,ivMin,e.size-1); + var errorMsg = "Error: %s: OOBindex %i > %i".doFormat(pn,ivMin,e.size-1); imLogger.error(getModuleName(),getRoutineName(),getLineNumber(),errorMsg); return new MsgTuple(errorMsg,MsgType.ERROR); } @@ -401,12 +394,12 @@ module IndexingMsg var ivMin = min reduce iv.a; var ivMax = max reduce iv.a; if ivMin < 0 { - var errorMsg = "Error: %s: OOBindex %i < 0".format(pn,ivMin); + var errorMsg = "Error: %s: OOBindex %i < 0".doFormat(pn,ivMin); imLogger.error(getModuleName(),getRoutineName(),getLineNumber(),errorMsg); return new MsgTuple(errorMsg,MsgType.ERROR); } if ivMax >= e.size { - var errorMsg = "Error: %s: OOBindex %i > %i".format(pn,ivMin,e.size-1); + var errorMsg = "Error: %s: OOBindex %i > %i".doFormat(pn,ivMin,e.size-1); imLogger.error(getModuleName(),getRoutineName(),getLineNumber(),errorMsg); return new MsgTuple(errorMsg,MsgType.ERROR); } @@ -439,7 +432,7 @@ module IndexingMsg var iv: [truth.a.domain] int = (+ scan truth.a); var pop = iv[iv.size-1]; imLogger.debug(getModuleName(),getRoutineName(),getLineNumber(), - "pop = %t last-scan = %t".format(pop,iv[iv.size-1])); + "pop = %? last-scan = %?".doFormat(pop,iv[iv.size-1])); var a = st.addEntry(rname, pop, XType); //[i in e.a.domain] if (truth.a[i] == true) {a.a[iv[i]-1] = e.a[i];}// iv[i]-1 for zero base index @@ -524,7 +517,7 @@ module IndexingMsg var valueArg = msgArgs.get("value"); imLogger.debug(getModuleName(),getRoutineName(),getLineNumber(), - "%s %s %i %s %s".format(cmd, name, idx, dtype2str(dtype), valueArg.getValue())); + "%s %s %i %s %s".doFormat(cmd, name, idx, dtype2str(dtype), valueArg.getValue())); var gEnt: borrowed GenSymEntry = getGenericTypedArrayEntry(name, st); @@ -651,7 +644,7 @@ module IndexingMsg } } - repMsg = "%s success".format(pn); + repMsg = "%s success".doFormat(pn); imLogger.debug(getModuleName(),getRoutineName(),getLineNumber(),repMsg); return new MsgTuple(repMsg, MsgType.NORMAL); } @@ -667,7 +660,7 @@ module IndexingMsg const dtype = if gX.dtype == DType.BigInt then DType.BigInt else str2dtype(msgArgs.getValueOf("dtype")); var value = msgArgs.getValueOf("value"); imLogger.debug(getModuleName(),getRoutineName(),getLineNumber(), - "cmd: %s gX: %s gIV: %s value: %s".format(cmd,st.attrib(name), + "cmd: %s gX: %s gIV: %s value: %s".doFormat(cmd,st.attrib(name), st.attrib(iname),value)); // scatter indexing by integer index vector @@ -677,12 +670,12 @@ module IndexingMsg var ivMin = min reduce iv.a; var ivMax = max reduce iv.a; if ivMin < 0 { - var errorMsg = "Error: %s: OOBindex %i < 0".format(pn,ivMin); + var errorMsg = "Error: %s: OOBindex %i < 0".doFormat(pn,ivMin); imLogger.error(getModuleName(),getRoutineName(),getLineNumber(),errorMsg); return new MsgTuple(errorMsg,MsgType.ERROR); } if ivMax >= e.size { - var errorMsg = "Error: %s: OOBindex %i > %i".format(pn,ivMax,e.size-1); + var errorMsg = "Error: %s: OOBindex %i > %i".doFormat(pn,ivMax,e.size-1); imLogger.error(getModuleName(),getRoutineName(),getLineNumber(),errorMsg); return new MsgTuple(errorMsg,MsgType.ERROR); } @@ -697,7 +690,7 @@ module IndexingMsg forall i in iva with (var agg = newDstAggregator(dtype), var locVal = val) { agg.copy(ea[i],locVal); } - var repMsg = "%s success".format(pn); + var repMsg = "%s success".doFormat(pn); imLogger.debug(getModuleName(),getRoutineName(),getLineNumber(),repMsg); return new MsgTuple(repMsg, MsgType.NORMAL); } @@ -709,12 +702,12 @@ module IndexingMsg var ivMin = min reduce iv.a; var ivMax = max reduce iv.a; if ivMin < 0 { - var errorMsg = "Error: %s: OOBindex %i < 0".format(pn,ivMin); + var errorMsg = "Error: %s: OOBindex %i < 0".doFormat(pn,ivMin); imLogger.error(getModuleName(),getRoutineName(),getLineNumber(),errorMsg); return new MsgTuple(errorMsg,MsgType.ERROR); } if ivMax >= e.size { - var errorMsg = "Error: %s: OOBindex %i > %i".format(pn,ivMax,e.size-1); + var errorMsg = "Error: %s: OOBindex %i > %i".doFormat(pn,ivMax,e.size-1); imLogger.error(getModuleName(),getRoutineName(),getLineNumber(),errorMsg); return new MsgTuple(errorMsg,MsgType.ERROR); } @@ -729,7 +722,7 @@ module IndexingMsg forall i in iva with (var agg = newDstAggregator(dtype), var locVal = val) { agg.copy(ea[i:int],locVal); } - var repMsg = "%s success".format(pn); + var repMsg = "%s success".doFormat(pn); imLogger.debug(getModuleName(),getRoutineName(),getLineNumber(),repMsg); return new MsgTuple(repMsg, MsgType.NORMAL); } @@ -739,7 +732,7 @@ module IndexingMsg var e = toSymEntry(gX,Xtype); var truth = toSymEntry(gIV,bool); if (e.size != truth.size) { - var errorMsg = "Error: %s: bool iv must be same size %i != %i".format(pn,e.size, + var errorMsg = "Error: %s: bool iv must be same size %i != %i".doFormat(pn,e.size, truth.size); imLogger.error(getModuleName(),getRoutineName(),getLineNumber(),errorMsg); return new MsgTuple(errorMsg,MsgType.ERROR); @@ -758,7 +751,7 @@ module IndexingMsg } } - var repMsg = "%s success".format(pn); + var repMsg = "%s success".doFormat(pn); imLogger.debug(getModuleName(),getRoutineName(),getLineNumber(),repMsg); return new MsgTuple(repMsg, MsgType.NORMAL); } @@ -832,7 +825,7 @@ module IndexingMsg if logLevel == LogLevel.DEBUG { imLogger.debug(getModuleName(),getRoutineName(),getLineNumber(), - "cmd: %s gX: %t gIV: %t gY: %t".format( + "cmd: %s gX: %? gIV: %? gY: %?".doFormat( cmd, st.attrib(name), st.attrib(iname), st.attrib(yname))); } @@ -843,7 +836,7 @@ module IndexingMsg proc ivInt64Helper(type t): MsgTuple throws { // add check to make sure IV and Y are same size if (gIV.size != gY.size) { - var errorMsg = "Error: %s: size mismatch %i %i".format(pn,gIV.size,gY.size); + var errorMsg = "Error: %s: size mismatch %i %i".doFormat(pn,gIV.size,gY.size); imLogger.error(getModuleName(),getRoutineName(),getLineNumber(),errorMsg); return new MsgTuple(errorMsg,MsgType.ERROR); } @@ -852,12 +845,12 @@ module IndexingMsg var ivMax = max reduce iv.a; var y = toSymEntry(gY,t); if ivMin < 0 { - var errorMsg = "Error: %s: OOBindex %i < 0".format(pn,ivMin); + var errorMsg = "Error: %s: OOBindex %i < 0".doFormat(pn,ivMin); imLogger.error(getModuleName(),getRoutineName(),getLineNumber(),errorMsg); return new MsgTuple(errorMsg,MsgType.ERROR); } if ivMax >= gX.size { - var errorMsg = "Error: %s: OOBindex %i > %i".format(pn,ivMax,gX.size-1); + var errorMsg = "Error: %s: OOBindex %i > %i".doFormat(pn,ivMax,gX.size-1); imLogger.error(getModuleName(),getRoutineName(),getLineNumber(),errorMsg); return new MsgTuple(errorMsg,MsgType.ERROR); } @@ -879,7 +872,7 @@ module IndexingMsg agg.copy(ea[i],v); } } - var repMsg = "%s success".format(pn); + var repMsg = "%s success".doFormat(pn); imLogger.debug(getModuleName(),getRoutineName(),getLineNumber(),repMsg); return new MsgTuple(repMsg, MsgType.NORMAL); } @@ -888,7 +881,7 @@ module IndexingMsg proc ivUInt64Helper(type t): MsgTuple throws { // add check to make sure IV and Y are same size if (gIV.size != gY.size) { - var errorMsg = "Error: %s: size mismatch %i %i".format(pn,gIV.size,gY.size); + var errorMsg = "Error: %s: size mismatch %i %i".doFormat(pn,gIV.size,gY.size); imLogger.error(getModuleName(),getRoutineName(),getLineNumber(),errorMsg); return new MsgTuple(errorMsg,MsgType.ERROR); } @@ -897,12 +890,12 @@ module IndexingMsg var ivMax = max reduce iv.a; var y = toSymEntry(gY,t); if ivMin < 0 { - var errorMsg = "Error: %s: OOBindex %i < 0".format(pn,ivMin); + var errorMsg = "Error: %s: OOBindex %i < 0".doFormat(pn,ivMin); imLogger.error(getModuleName(),getRoutineName(),getLineNumber(),errorMsg); return new MsgTuple(errorMsg,MsgType.ERROR); } if ivMax >= gX.size { - var errorMsg = "Error: %s: OOBindex %i > %i".format(pn,ivMax,gX.size-1); + var errorMsg = "Error: %s: OOBindex %i > %i".doFormat(pn,ivMax,gX.size-1); imLogger.error(getModuleName(),getRoutineName(),getLineNumber(),errorMsg); return new MsgTuple(errorMsg,MsgType.ERROR); } @@ -924,7 +917,7 @@ module IndexingMsg agg.copy(ea[i:int],v); } } - var repMsg = "%s success".format(pn); + var repMsg = "%s success".doFormat(pn); imLogger.debug(getModuleName(),getRoutineName(),getLineNumber(),repMsg); return new MsgTuple(repMsg, MsgType.NORMAL); } @@ -933,7 +926,7 @@ module IndexingMsg proc ivBoolHelper(type t): MsgTuple throws { // add check to make sure IV and Y are same size if (gIV.size != gX.size) { - var errorMsg = "Error: %s: size mismatch %i %i".format(pn,gIV.size,gX.size); + var errorMsg = "Error: %s: size mismatch %i %i".doFormat(pn,gIV.size,gX.size); imLogger.error(getModuleName(),getRoutineName(),getLineNumber(),errorMsg); return new MsgTuple(errorMsg,MsgType.ERROR); } @@ -943,10 +936,10 @@ module IndexingMsg var iv: [truth.a.domain] int = (+ scan truth.a); var pop = iv[iv.size-1]; imLogger.debug(getModuleName(),getRoutineName(),getLineNumber(), - "pop = %t last-scan = %t".format(pop,iv[iv.size-1])); + "pop = %? last-scan = %?".doFormat(pop,iv[iv.size-1])); var y = toSymEntry(gY,t); if (y.size != pop) { - var errorMsg = "Error: %s: pop size mismatch %i %i".format(pn,pop,y.size); + var errorMsg = "Error: %s: pop size mismatch %i %i".doFormat(pn,pop,y.size); imLogger.error(getModuleName(),getRoutineName(),getLineNumber(),errorMsg); return new MsgTuple(errorMsg,MsgType.ERROR); } @@ -974,7 +967,7 @@ module IndexingMsg } } } - var repMsg = "%s success".format(pn); + var repMsg = "%s success".doFormat(pn); imLogger.debug(getModuleName(),getRoutineName(),getLineNumber(),repMsg); return new MsgTuple(repMsg, MsgType.NORMAL); } @@ -1065,7 +1058,7 @@ module IndexingMsg var value = msgArgs.get("value"); imLogger.debug(getModuleName(),getRoutineName(),getLineNumber(), - "%s %s %i %i %i %s %s".format(cmd, name, start, stop, stride, + "%s %s %i %i %i %s %s".doFormat(cmd, name, start, stop, stride, dtype2str(dtype), value.getValue())); var gEnt: borrowed GenSymEntry = getGenericTypedArrayEntry(name, st); @@ -1193,7 +1186,7 @@ module IndexingMsg } } - repMsg = "%s success".format(pn); + repMsg = "%s success".doFormat(pn); imLogger.debug(getModuleName(),getRoutineName(),getLineNumber(),repMsg); return new MsgTuple(repMsg, MsgType.NORMAL); } @@ -1219,14 +1212,14 @@ module IndexingMsg else {slice = 1..0;} imLogger.debug(getModuleName(),getRoutineName(),getLineNumber(), - "%s %s %i %i %i %s".format(cmd, name, start, stop, stride, yname)); + "%s %s %i %i %i %s".doFormat(cmd, name, start, stop, stride, yname)); var gX: borrowed GenSymEntry = getGenericTypedArrayEntry(name, st); var gY: borrowed GenSymEntry = getGenericTypedArrayEntry(yname, st); // add check to make sure IV and Y are same size if (slice.size != gY.size) { - var errorMsg = "%s: size mismatch %i %i".format(pn,slice.size, gY.size); + var errorMsg = "%s: size mismatch %i %i".doFormat(pn,slice.size, gY.size); imLogger.error(getModuleName(),getRoutineName(),getLineNumber(),errorMsg); return new MsgTuple(errorMsg, MsgType.ERROR); } @@ -1356,7 +1349,7 @@ module IndexingMsg } } - repMsg = "%s success".format(pn); + repMsg = "%s success".doFormat(pn); imLogger.debug(getModuleName(),getRoutineName(),getLineNumber(),repMsg); return new MsgTuple(repMsg, MsgType.NORMAL); } diff --git a/src/JoinEqWithDTMsg.chpl b/src/JoinEqWithDTMsg.chpl index 214b1992ff..da2e83ed44 100644 --- a/src/JoinEqWithDTMsg.chpl +++ b/src/JoinEqWithDTMsg.chpl @@ -94,7 +94,7 @@ module JoinEqWithDTMsg resLimitPerLocale: int) throws { try! jeLogger.info(getModuleName(),getRoutineName(),getLineNumber(), - "resLimitPerLocale = %t".format(resLimitPerLocale)); + "resLimitPerLocale = %?".doFormat(resLimitPerLocale)); // allocate result arrays per locale var locResI: [PrivateSpace] [0..#resLimitPerLocale] int; @@ -114,7 +114,7 @@ module JoinEqWithDTMsg // return found flag and a range for the segment of that value(unique key) var (found, j_seg) = findMatch(a1[i], seg, ukeys, perm); try! jeLogger.debug(getModuleName(),getRoutineName(),getLineNumber(), - "a1: %t found: %t j_seq: %t".format(a1[i], found, j_seg)); + "a1: %? found: %? j_seq: %?".doFormat(a1[i], found, j_seg)); // if there is a matching value in ukeys if (found) { var t1_i = t1[i]; @@ -186,9 +186,9 @@ module JoinEqWithDTMsg var numResults: int = resEnds[resEnds.domain.high]; try! jeLogger.debug(getModuleName(),getRoutineName(),getLineNumber(), - "result ends: %t".format(resEnds)); + "result ends: %?".doFormat(resEnds)); try! jeLogger.info(getModuleName(),getRoutineName(),getLineNumber(), - "numResults = %i".format(numResults)); + "numResults = %i".doFormat(numResults)); // allocate result arrays var resI = makeDistArray(numResults, int); @@ -201,7 +201,7 @@ module JoinEqWithDTMsg var gEnd: int = resEnds[here.id] - 1; var gStart: int = resEnds[here.id] - locNumResults[here.id]; try! jeLogger.debug(getModuleName(),getRoutineName(),getLineNumber(), - "start: %t end: %t".format(gStart,gEnd)); + "start: %? end: %?".doFormat(gStart,gEnd)); // copy local results into global results resI[{gStart..gEnd}] = locResI[here.id][{0..#locNumResults[here.id]}]; resJ[{gStart..gEnd}] = locResJ[here.id][{0..#locNumResults[here.id]}]; @@ -243,7 +243,7 @@ module JoinEqWithDTMsg var resJ_name = st.nextName(); jeLogger.debug(getModuleName(),getRoutineName(),getLineNumber(), - "cmd: %s array1: %s g2seg2: %s g2ukeys: %s g2perm: %s t1name: %s t2name: %s dt: %t pred: %t resLimit: %t resI: %s resJ: %s".format( + "cmd: %s array1: %s g2seg2: %s g2ukeys: %s g2perm: %s t1name: %s t2name: %s dt: %? pred: %? resLimit: %? resI: %s resJ: %s".doFormat( cmd, a1_name, g2Seg_name, g2Ukeys_name, g2Perm_name, t1_name, t2_name, dt, pred, resLimit, resI_name, resJ_name)); diff --git a/src/Logging.chpl b/src/Logging.chpl index 01cbfc2c1d..a222db46f0 100644 --- a/src/Logging.chpl +++ b/src/Logging.chpl @@ -7,6 +7,7 @@ module Logging { import IO.{format, stdout, file}; use ArkoudaFileCompat; + use ArkoudaIOCompat; /* * The LogLevel enum is used to provide a strongly-typed means of @@ -77,11 +78,11 @@ module Logging { /* * getOutputHandler is a factory method for OutputHandler implementations. */ - proc getOutputHandler(channel: LogChannel) : OutputHandler throws { + proc getOutputHandler(channel: LogChannel) : owned OutputHandler throws { if channel == LogChannel.CONSOLE { - return new ConsoleOutputHandler(); + return new owned ConsoleOutputHandler(); } else { - return new FileOutputHandler("%s/arkouda.log".format(here.cwd())); + return new owned FileOutputHandler("%s/arkouda.log".doFormat(here.cwd())); } } @@ -105,7 +106,7 @@ module Logging { var printDate: bool = true; - var outputHandler: OutputHandler = try! getOutputHandler(LogChannel.CONSOLE); + var outputHandler: owned OutputHandler = try! getOutputHandler(LogChannel.CONSOLE); proc init() {} @@ -171,29 +172,29 @@ module Logging { proc generateErrorMsg(moduleName: string, routineName, lineNumber, error) throws { - return "Error in logging message for %s %s %i: %t".format( + return "Error in logging message for %s %s %i: %?".doFormat( moduleName, routineName, lineNumber, error.message()); } proc generateLogMessage(moduleName: string, routineName, lineNumber, msg, level: string) throws { - var lineStr: string = if lineNumber != 0 then "Line %i ".format(lineNumber) else ""; + var lineStr: string = if lineNumber != 0 then "Line %i ".doFormat(lineNumber) else ""; if printDate { - return "%s [%s] %s %s%s [Chapel] %s".format( + return "%s [%s] %s %s%s [Chapel] %s".doFormat( generateDateTimeString(), moduleName,routineName,lineStr, level,msg); } else { - return "[%s] %s %s%s [Chapel] %s".format(moduleName, + return "[%s] %s %s%s [Chapel] %s".doFormat(moduleName, routineName,lineStr,level,msg); } } proc generateDateTimeString() throws { - var dts = dateTime.now():string; + var dts = formatString(dateTime.now()); var vals = dts.split("T"); var cd = vals(0); var rawCms = vals(1).split("."); - return "%s:%s".format(cd,rawCms(0)); + return "%s:%s".doFormat(cd,rawCms(0)); } } } diff --git a/src/MemoryMgmt.chpl b/src/MemoryMgmt.chpl index 5c74b8ebb6..a81289e5e0 100644 --- a/src/MemoryMgmt.chpl +++ b/src/MemoryMgmt.chpl @@ -136,7 +136,7 @@ module MemoryMgmt { var availMemory = getAvailMemory(); mmLogger.debug(getModuleName(),getRoutineName(),getLineNumber(), - "locale: %s reqMemory: %i arkMemAlloc: %i arkMemUsed: %i availMemory: %i".format(here.id, + "locale: %s reqMemory: %i arkMemAlloc: %i arkMemUsed: %i availMemory: %i".doFormat(here.id, reqMemory, arkMemAlloc, arkMemUsed, @@ -149,7 +149,7 @@ module MemoryMgmt { if newArkoudaMemory:int <= availMemory { return true; } else { - var msg = "Arkouda memory request %i on locale %s exceeds available memory %i".format(newArkoudaMemory, + var msg = "Arkouda memory request %i on locale %s exceeds available memory %i".doFormat(newArkoudaMemory, here.id, availMemory); mmLogger.error(getModuleName(),getRoutineName(),getLineNumber(),msg); diff --git a/src/Merge.chpl b/src/Merge.chpl index acb56cdb04..fecc09a24e 100644 --- a/src/Merge.chpl +++ b/src/Merge.chpl @@ -90,7 +90,7 @@ module Merge { var smallS = small[smallPos]; if (numLocales == 1) { mLogger.debug(getModuleName(),getRoutineName(),getLineNumber(), - "Task %t init: bigPos = %t, smallPos = %t, outPos = %t, end = %t, outOffset = %t, bigS = %s, smallS = %s".format( + "Task %? init: bigPos = %?, smallPos = %?, outPos = %?, end = %?, outOffset = %?, bigS = %s, smallS = %s".doFormat( task, bigPos, smallPos, outPos, end, outOffset, bigS, smallS)); } // leapfrog the two arrays until all the output has been filled @@ -100,15 +100,15 @@ module Merge { if (outPos > perm.domain.high) { mLogger.debug(getModuleName(),getRoutineName(),getLineNumber(), - "OOB: outPos = %t not in %t".format(outPos, perm.domain)); + "OOB: outPos = %? not in %?".doFormat(outPos, perm.domain)); } if (bigPos > big.offsets.a.domain.high) { mLogger.debug(getModuleName(),getRoutineName(),getLineNumber(), - "OOB: bigPos = %t not in %t".format(bigPos, big.offsets.a.domain)); + "OOB: bigPos = %? not in %?".doFormat(bigPos, big.offsets.a.domain)); } if (outOffset + bigS.numBytes >= vals.size) { mLogger.debug(getModuleName(),getRoutineName(),getLineNumber(), - "OOB: (outOffset = %t + bigS.numBytes = %t) not in %t".format( + "OOB: (outOffset = %? + bigS.numBytes = %?) not in %?".doFormat( outOffset, bigS.numBytes, vals.domain)); } if bigIsLeft { @@ -130,15 +130,15 @@ module Merge { while (smallPos <= smallEnd) && ((bigPos > bigEnd) || (smallS < bigS)) { if (outPos > perm.domain.high) { mLogger.debug(getModuleName(),getRoutineName(),getLineNumber(), - "OOB: outPos = %t not in %t".format(outPos, perm.domain)); + "OOB: outPos = %? not in %?".doFormat(outPos, perm.domain)); } if (smallPos > small.offsets.a.domain.high) { mLogger.debug(getModuleName(),getRoutineName(),getLineNumber(), - "OOB: smallPos = %t not in %t".format(smallPos, small.offsets.a.domain)); + "OOB: smallPos = %? not in %?".doFormat(smallPos, small.offsets.a.domain)); } if (outOffset + bigS.numBytes >= vals.size) { mLogger.debug(getModuleName(),getRoutineName(),getLineNumber(), - "OOB: (outOffset = %t + smallS.numBytes = %t) not in %t".format( + "OOB: (outOffset = %? + smallS.numBytes = %?) not in %?".doFormat( outOffset, smallS.numBytes, vals.domain)); } } diff --git a/src/Message.chpl b/src/Message.chpl index 2786f0beb4..c3214d8944 100644 --- a/src/Message.chpl +++ b/src/Message.chpl @@ -10,6 +10,7 @@ module Message { use ArkoudaFileCompat; use Map; use ArkoudaListCompat; + use ArkoudaIOCompat; enum MsgType {NORMAL,WARNING,ERROR} enum MsgFormat {STRING,BINARY} @@ -77,7 +78,7 @@ module Message { } proc getJSON() throws { - return "%jt".format(this); + return formatJson(this); } proc setKey(value: string) { @@ -129,7 +130,7 @@ module Message { return this.val:int; } catch { - throw new owned ErrorWithContext("Parameter cannot be cast as int. Attempting to cast %s as type int failed".format(this.val), + throw new owned ErrorWithContext("Parameter cannot be cast as int. Attempting to cast %s as type int failed".doFormat(this.val), getLineNumber(), getRoutineName(), getModuleName(), @@ -146,7 +147,7 @@ module Message { return this.val:uint; } catch { - throw new owned ErrorWithContext("Parameter cannot be cast as uint. Attempting to cast %s as type uint failed".format(this.val), + throw new owned ErrorWithContext("Parameter cannot be cast as uint. Attempting to cast %s as type uint failed".doFormat(this.val), getLineNumber(), getRoutineName(), getModuleName(), @@ -159,7 +160,7 @@ module Message { return this.val:uint(8); } catch { - throw new owned ErrorWithContext("Parameter cannot be cast as uint(8). Attempting to cast %s as type uint(8) failed".format(this.val), + throw new owned ErrorWithContext("Parameter cannot be cast as uint(8). Attempting to cast %s as type uint(8) failed".doFormat(this.val), getLineNumber(), getRoutineName(), getModuleName(), @@ -176,7 +177,7 @@ module Message { return this.val:real; } catch { - throw new owned ErrorWithContext("Parameter cannot be cast as real. Attempting to cast %s as type real failed".format(this.val), + throw new owned ErrorWithContext("Parameter cannot be cast as real. Attempting to cast %s as type real failed".doFormat(this.val), getLineNumber(), getRoutineName(), getModuleName(), @@ -193,7 +194,7 @@ module Message { return this.val.toLower():bool; } catch { - throw new owned ErrorWithContext("Parameter cannot be cast as bool. Attempting to cast %s as type bool failed".format(this.val), + throw new owned ErrorWithContext("Parameter cannot be cast as bool. Attempting to cast %s as type bool failed".doFormat(this.val), getLineNumber(), getRoutineName(), getModuleName(), @@ -206,7 +207,7 @@ module Message { return this.val:bigint; } catch { - throw new owned ErrorWithContext("Parameter cannot be cast as bigint. Attempting to cast %s as type bigint failed".format(this.val), + throw new owned ErrorWithContext("Parameter cannot be cast as bigint. Attempting to cast %s as type bigint failed".doFormat(this.val), getLineNumber(), getRoutineName(), getModuleName(), @@ -230,7 +231,7 @@ module Message { return this.val:t; } catch { - throw new owned ErrorWithContext("Parameter cannot be cast as %t. Attempting to cast %s as type %t failed".format(t, this.val, t), + throw new owned ErrorWithContext("Parameter cannot be cast as %?. Attempting to cast %s as type %? failed".doFormat(t, this.val, t), getLineNumber(), getRoutineName(), getModuleName(), @@ -245,7 +246,7 @@ module Message { */ proc getList(size: int) throws { if this.objType != ObjectType.LIST { - throw new owned ErrorWithContext("Parameter with key, %s, is not a list.".format(this.key), + throw new owned ErrorWithContext("Parameter with key, %s, is not a list.".doFormat(this.key), getLineNumber(), getRoutineName(), getModuleName(), @@ -256,7 +257,7 @@ module Message { proc getJSON(size: int) throws { if this.objType != ObjectType.DICT { - throw new owned ErrorWithContext("Parameter with key, %s, is not a JSON obj.".format(this.key), + throw new owned ErrorWithContext("Parameter with key, %s, is not a JSON obj.".doFormat(this.key), getLineNumber(), getRoutineName(), getModuleName(), @@ -299,7 +300,7 @@ module Message { break; } } - return "%jt".format(json); + return formatJson(json); } /* @@ -313,7 +314,7 @@ module Message { return p; } } - throw new owned ErrorWithContext("Key Not Found; %s".format(key), + throw new owned ErrorWithContext("Key Not Found; %s".doFormat(key), getLineNumber(), getRoutineName(), getModuleName(), @@ -326,7 +327,7 @@ module Message { return p.val; } } - throw new owned ErrorWithContext("Key Not Found; %s".format(key), + throw new owned ErrorWithContext("Key Not Found; %s".doFormat(key), getLineNumber(), getRoutineName(), getModuleName(), @@ -378,11 +379,10 @@ module Message { var p: ParameterObj; var newmem = openMemFile(); newmem.writer().write(payload); - var nreader = newmem.reader(); try { - nreader.readf("%jt", p); + readfCompat(newmem, "%?", p); } catch bfe : BadFormatError { - throw new owned ErrorWithContext("Incorrect JSON format %s".format(payload), + throw new owned ErrorWithContext("Incorrect JSON format %s".doFormat(payload), getLineNumber(), getRoutineName(), getModuleName(), @@ -415,9 +415,9 @@ module Message { newmem.writer().write(request); var nreader = newmem.reader(); try { - nreader.readf("%jt", msg); + readfCompat(newmem, "%?", msg); } catch bfe : BadFormatError { - throw new owned ErrorWithContext("Incorrect JSON format %s".format(request), + throw new owned ErrorWithContext("Incorrect JSON format %s".doFormat(request), getLineNumber(), getRoutineName(), getModuleName(), @@ -430,7 +430,7 @@ module Message { */ proc serialize(msg: string, msgType: MsgType, msgFormat: MsgFormat, user: string) : string throws { - return "%jt".format(new ReplyMsg(msg=msg,msgType=msgType, + return formatJson(new ReplyMsg(msg=msg,msgType=msgType, msgFormat=msgFormat, user=user)); } @@ -438,15 +438,7 @@ module Message { * Converts the JSON array to a pdarray */ proc jsonToPdArray(json: string, size: int) throws { - var f = openMemFile(); defer { ensureClose(f); } - var w = f.writer(); - w.write(json); - w.close(); - var r = f.reader(); - var array: [0..#size] string; - r.readf("%jt", array); - r.close(); - return array; + return jsonToPdArrayCompat(json, size); } } diff --git a/src/MetricsMsg.chpl b/src/MetricsMsg.chpl index 85c7be05c2..4b3f87c05f 100644 --- a/src/MetricsMsg.chpl +++ b/src/MetricsMsg.chpl @@ -14,6 +14,8 @@ module MetricsMsg { use ArkoudaTimeCompat as Time; use ArkoudaListCompat; + use ArkoudaMapCompat; + use ArkoudaIOCompat; enum MetricCategory{ALL,NUM_REQUESTS,RESPONSE_TIME,AVG_RESPONSE_TIME,TOTAL_RESPONSE_TIME, TOTAL_MEMORY_USED,SYSTEM,SERVER,SERVER_INFO}; @@ -190,7 +192,7 @@ module MetricsMsg { * Sets the metrics value */ proc set(metric: string, measurement: real) throws { - this.measurements.addOrSet(metric, measurement); + this.measurements.addOrReplace(metric, measurement); } /* @@ -246,7 +248,7 @@ module MetricsMsg { if !this.measurementTotals.contains(metric) { value = 0.0; - this.measurementTotals.addOrSet(metric, value); + this.measurementTotals.addOrReplace(metric, value); } else { value = this.measurementTotals(metric); } @@ -266,12 +268,12 @@ module MetricsMsg { var numMeasurements = getNumMeasurements(metric); var measurementTotal = getMeasurementTotal(metric); - this.numMeasurements.addOrSet(metric, numMeasurements); + this.numMeasurements.addOrReplace(metric, numMeasurements); this.measurementTotals(metric) += measurement; var value: real = this.measurementTotals(metric)/numMeasurements; - this.measurements.addOrSet(metric, value); + this.measurements.addOrReplace(metric, value); } } @@ -288,7 +290,7 @@ module MetricsMsg { } proc set(metric: string, count: int) { - this.counts.addOrSet(metric,count); + this.counts.addOrReplace(metric,count); } proc increment(metric: string, increment: int=1) { @@ -475,7 +477,7 @@ module MetricsMsg { var total = getMaxLocaleMemory(loc); mLogger.debug(getModuleName(),getRoutineName(),getLineNumber(), - 'memoryUsed: %i physicalMemory: %i'.format(used,total)); + 'memoryUsed: %i physicalMemory: %i'.doFormat(used,total)); metrics.pushBack(new LocaleMetric(name="arkouda_memory_used_per_locale", category=MetricCategory.SYSTEM, @@ -630,33 +632,33 @@ module MetricsMsg { var category = msgArgs.getValueOf("category"):MetricCategory; mLogger.debug(getModuleName(),getRoutineName(),getLineNumber(), - 'category: %s'.format(category)); + 'category: %s'.doFormat(category)); var metrics: string; select category { when MetricCategory.ALL { - metrics = "%jt".format(exportAllMetrics()); + metrics = formatJson(exportAllMetrics()); } when MetricCategory.NUM_REQUESTS { - metrics = "%jt".format(getNumRequestMetrics()); + metrics = formatJson(getNumRequestMetrics()); } when MetricCategory.SERVER { - metrics = "%jt".format(getServerMetrics()); + metrics = formatJson(getServerMetrics()); } when MetricCategory.SYSTEM { - metrics = "%jt".format(getSystemMetrics()); + metrics = formatJson(getSystemMetrics()); } when MetricCategory.SERVER_INFO { - metrics = "%jt".format(getServerInfo()); + metrics = formatJson(getServerInfo()); } when MetricCategory.TOTAL_MEMORY_USED { - metrics = "%jt".format(getTotalMemoryUsedMetrics()); + metrics = formatJson(getTotalMemoryUsedMetrics()); } when MetricCategory.AVG_RESPONSE_TIME { - metrics = "%jt".format(getAvgResponseTimeMetrics()); + metrics = formatJson(getAvgResponseTimeMetrics()); } when MetricCategory.TOTAL_RESPONSE_TIME { - metrics = "%jt".format(getTotalResponseTimeMetrics()); + metrics = formatJson(getTotalResponseTimeMetrics()); } otherwise { throw getErrorWithContext(getLineNumber(),getModuleName(),getRoutineName(), @@ -665,7 +667,7 @@ module MetricsMsg { } mLogger.debug(getModuleName(),getRoutineName(),getLineNumber(), - 'metrics %s'.format(metrics)); + 'metrics %s'.doFormat(metrics)); return new MsgTuple(metrics, MsgType.NORMAL); } diff --git a/src/MsgProcessing.chpl b/src/MsgProcessing.chpl index ae5d0f66c3..ef06b82304 100644 --- a/src/MsgProcessing.chpl +++ b/src/MsgProcessing.chpl @@ -47,13 +47,13 @@ module MsgProcessing // if verbose print action mpLogger.debug(getModuleName(),getRoutineName(),getLineNumber(), - "cmd: %s dtype: %s size: %i new pdarray name: %s".format( + "cmd: %s dtype: %s size: %i new pdarray name: %s".doFormat( cmd,dtype2str(dtype),size,rname)); // create and add entry to symbol table st.addEntry(rname, size, dtype); // if verbose print result mpLogger.debug(getModuleName(),getRoutineName(),getLineNumber(), - "created the pdarray %s".format(st.attrib(rname))); + "created the pdarray %s".doFormat(st.attrib(rname))); repMsg = "created " + st.attrib(rname); mpLogger.debug(getModuleName(),getRoutineName(),getLineNumber(), repMsg); @@ -75,13 +75,13 @@ module MsgProcessing var repMsg: string; // response message const name = msgArgs.getValueOf("name"); mpLogger.debug(getModuleName(),getRoutineName(),getLineNumber(), - "cmd: %s array: %s".format(cmd,st.attrib(name))); + "cmd: %s array: %s".doFormat(cmd,st.attrib(name))); // delete entry from symbol table if st.deleteEntry(name) { - repMsg = "deleted %s".format(name); + repMsg = "deleted %s".doFormat(name); } else { - repMsg = "registered symbol, %s, not deleted".format(name); + repMsg = "registered symbol, %s, not deleted".doFormat(name); } mpLogger.debug(getModuleName(),getRoutineName(),getLineNumber(),repMsg); return new MsgTuple(repMsg, MsgType.NORMAL); @@ -100,7 +100,7 @@ module MsgProcessing */ proc clearMsg(cmd: string, msgArgs: borrowed MessageArgs, st: borrowed SymTab): MsgTuple throws { var repMsg: string; // response message - mpLogger.debug(getModuleName(),getRoutineName(),getLineNumber(), "cmd: %s".format(cmd)); + mpLogger.debug(getModuleName(),getRoutineName(),getLineNumber(), "cmd: %s".doFormat(cmd)); st.clear(); repMsg = "success"; @@ -143,7 +143,7 @@ module MsgProcessing */ proc getconfigMsg(cmd: string, msgArgs: borrowed MessageArgs, st: borrowed SymTab): MsgTuple throws { var repMsg: string; // response message - mpLogger.debug(getModuleName(),getRoutineName(),getLineNumber(),"cmd: %s".format(cmd)); + mpLogger.debug(getModuleName(),getRoutineName(),getLineNumber(),"cmd: %s".doFormat(cmd)); return new MsgTuple(getConfig(), MsgType.NORMAL); } @@ -162,7 +162,7 @@ module MsgProcessing var repMsg: string; // response message var factor = msgArgs.get("factor").getIntValue(); var asPercent = msgArgs.get("as_percent").getBoolValue(); - mpLogger.debug(getModuleName(),getRoutineName(),getLineNumber(),"cmd: %s".format(cmd)); + mpLogger.debug(getModuleName(),getRoutineName(),getLineNumber(),"cmd: %s".doFormat(cmd)); var memUsed = if memTrack then getMemUsed():real * numLocales else st.memUsed():real; if asPercent { repMsg = AutoMath.round((memUsed / (getMemLimit():real * numLocales)) * 100):uint:string; @@ -188,7 +188,7 @@ module MsgProcessing var repMsg: string; // response message var factor = msgArgs.get("factor").getIntValue(); var asPercent = msgArgs.get("as_percent").getBoolValue(); - mpLogger.debug(getModuleName(),getRoutineName(),getLineNumber(),"cmd: %s".format(cmd)); + mpLogger.debug(getModuleName(),getRoutineName(),getLineNumber(),"cmd: %s".doFormat(cmd)); var memUsed = if memTrack then getMemUsed():real * numLocales else st.memUsed():real; var totMem = getMemLimit():real * numLocales; if asPercent { @@ -248,7 +248,7 @@ module MsgProcessing var printThresh = msgArgs.get("printThresh").getIntValue(); mpLogger.debug(getModuleName(),getRoutineName(),getLineNumber(), - "cmd: %s name: %s threshold: %i".format( + "cmd: %s name: %s threshold: %i".doFormat( cmd,name,printThresh)); repMsg = st.datastr(name,printThresh); @@ -299,112 +299,112 @@ module MsgProcessing var gEnt: borrowed GenSymEntry = getGenericTypedArrayEntry(name, st); mpLogger.debug(getModuleName(),getRoutineName(),getLineNumber(), - "cmd: %s value: %s in pdarray %s".format(cmd,name,st.attrib(name))); + "cmd: %s value: %s in pdarray %s".doFormat(cmd,name,st.attrib(name))); select (gEnt.dtype, dtype) { when (DType.Int64, DType.Int64) { var e = toSymEntry(gEnt,int); var val: int = value.getIntValue(); e.a = val; - repMsg = "set %s to %t".format(name, val); + repMsg = "set %s to %?".doFormat(name, val); } when (DType.Int64, DType.Float64) { var e = toSymEntry(gEnt,int); var val: real = value.getRealValue(); mpLogger.debug(getModuleName(),getRoutineName(),getLineNumber(), - "cmd: %s name: %s to val: %t".format(cmd,name,val:int)); + "cmd: %s name: %s to val: %?".doFormat(cmd,name,val:int)); e.a = val:int; - repMsg = "set %s to %t".format(name, val:int); + repMsg = "set %s to %?".doFormat(name, val:int); } when (DType.Int64, DType.Bool) { var e = toSymEntry(gEnt,int); var val: bool = value.getBoolValue(); mpLogger.debug(getModuleName(),getRoutineName(),getLineNumber(), - "cmd: %s name: %s to val: %t".format(cmd,name,val:int)); + "cmd: %s name: %s to val: %?".doFormat(cmd,name,val:int)); e.a = val:int; - repMsg = "set %s to %t".format(name, val:int); + repMsg = "set %s to %?".doFormat(name, val:int); } when (DType.Float64, DType.Int64) { var e = toSymEntry(gEnt,real); var val: int = value.getIntValue(); mpLogger.debug(getModuleName(),getRoutineName(),getLineNumber(), - "cmd: %s name: %s to value: %t".format(cmd,name,val:real)); + "cmd: %s name: %s to value: %?".doFormat(cmd,name,val:real)); e.a = val:real; - repMsg = "set %s to %t".format(name, val:real); + repMsg = "set %s to %?".doFormat(name, val:real); } when (DType.Float64, DType.Float64) { var e = toSymEntry(gEnt,real); var val: real = value.getRealValue(); mpLogger.debug(getModuleName(),getRoutineName(),getLineNumber(), - "cmd: %s name; %s to value: %t".format(cmd,name,val)); + "cmd: %s name; %s to value: %?".doFormat(cmd,name,val)); e.a = val; - repMsg = "set %s to %t".format(name, val); + repMsg = "set %s to %?".doFormat(name, val); } when (DType.Float64, DType.Bool) { var e = toSymEntry(gEnt,real); var val: bool = value.getBoolValue(); mpLogger.debug(getModuleName(),getRoutineName(),getLineNumber(), - "cmd: %s name: %s to value: %t".format(cmd,name,val:real)); + "cmd: %s name: %s to value: %?".doFormat(cmd,name,val:real)); e.a = val:real; - repMsg = "set %s to %t".format(name, val:real); + repMsg = "set %s to %?".doFormat(name, val:real); } when (DType.Bool, DType.Int64) { var e = toSymEntry(gEnt,bool); var val: int = value.getIntValue(); mpLogger.debug(getModuleName(),getRoutineName(),getLineNumber(), - "cmd: %s name: %s to value: %t".format(cmd,name,val:bool)); + "cmd: %s name: %s to value: %?".doFormat(cmd,name,val:bool)); e.a = val:bool; - repMsg = "set %s to %t".format(name, val:bool); + repMsg = "set %s to %?".doFormat(name, val:bool); } when (DType.Bool, DType.Float64) { var e = toSymEntry(gEnt,int); var val: real = value.getRealValue(); mpLogger.debug(getModuleName(),getRoutineName(),getLineNumber(), - "cmd: %s name: %s to value: %t".format(cmd,name,val:bool)); + "cmd: %s name: %s to value: %?".doFormat(cmd,name,val:bool)); e.a = val:bool; - repMsg = "set %s to %t".format(name, val:bool); + repMsg = "set %s to %?".doFormat(name, val:bool); } when (DType.Bool, DType.Bool) { var e = toSymEntry(gEnt,bool); var val: bool = value.getBoolValue(); mpLogger.debug(getModuleName(),getRoutineName(),getLineNumber(), - "cmd: %s name: %s to value: %t".format(cmd,name,val)); + "cmd: %s name: %s to value: %?".doFormat(cmd,name,val)); e.a = val; - repMsg = "set %s to %t".format(name, val); + repMsg = "set %s to %?".doFormat(name, val); } when (DType.UInt64, DType.UInt64) { var e = toSymEntry(gEnt,uint); var val: uint = value.getUIntValue(); e.a = val; - repMsg = "set %s to %t".format(name, val); + repMsg = "set %s to %?".doFormat(name, val); } when (DType.BigInt, DType.BigInt) { var e = toSymEntry(gEnt,bigint); var val: bigint = value.getBigIntValue(); e.a = val; - repMsg = "set %s to %t".format(name, val); + repMsg = "set %s to %?".doFormat(name, val); } when (DType.BigInt, DType.UInt64) { var e = toSymEntry(gEnt,bigint); var val: uint = value.getUIntValue(); e.a = val:bigint; - repMsg = "set %s to %t".format(name, val); + repMsg = "set %s to %?".doFormat(name, val); } when (DType.BigInt, DType.Int64) { var e = toSymEntry(gEnt,bigint); var val: int = value.getIntValue(); e.a = val:bigint; - repMsg = "set %s to %t".format(name, val); + repMsg = "set %s to %?".doFormat(name, val); } when (DType.BigInt, DType.Bool) { var e = toSymEntry(gEnt,bigint); var val: bool = value.getBoolValue(); e.a = val:bigint; - repMsg = "set %s to %t".format(name, val); + repMsg = "set %s to %?".doFormat(name, val); } otherwise { mpLogger.error(getModuleName(),getRoutineName(), - getLineNumber(),"dtype: %s".format(msgArgs.getValueOf("dtype"))); + getLineNumber(),"dtype: %s".doFormat(msgArgs.getValueOf("dtype"))); return new MsgTuple(unrecognizedTypeError(pn,msgArgs.getValueOf("dtype")), MsgType.ERROR); } } diff --git a/src/MultiTypeSymEntry.chpl b/src/MultiTypeSymEntry.chpl index dc6ef4f46b..e82a22b777 100644 --- a/src/MultiTypeSymEntry.chpl +++ b/src/MultiTypeSymEntry.chpl @@ -184,7 +184,7 @@ module MultiTypeSymEntry */ override proc __str__(thresh:int=1, prefix:string="", suffix:string="", baseFormat:string=""): string throws { genLogger.debug(getModuleName(),getRoutineName(),getLineNumber(), "__str__ invoked"); - var s = "DType: %s, itemsize: %t, size: %t".format(this.dtype, this.itemsize, this.size); + var s = "DType: %s, itemsize: %?, size: %?".doFormat(this.dtype, this.itemsize, this.size); return prefix + s + suffix; } } @@ -302,17 +302,17 @@ module MultiTypeSymEntry :returns: s (string) containing the array data */ - override proc __str__(thresh:int=6, prefix:string = "[", suffix:string = "]", baseFormat:string = "%t"): string throws { + override proc __str__(thresh:int=6, prefix:string = "[", suffix:string = "]", baseFormat:string = "%?"): string throws { var s:string = ""; if (this.size == 0) { s = ""; // Unnecessary, but left for clarity } else if (this.size < thresh || this.size <= 6) { - for i in 0..(this.size-2) {s += try! baseFormat.format(this.a[i]) + " ";} - s += try! baseFormat.format(this.a[this.size-1]); + for i in 0..(this.size-2) {s += try! baseFormat.doFormat(this.a[i]) + " ";} + s += try! baseFormat.doFormat(this.a[this.size-1]); } else { var b = baseFormat + " " + baseFormat + " " + baseFormat + " ... " + baseFormat + " " + baseFormat + " " + baseFormat; - s = try! b.format( + s = try! b.doFormat( this.a[0], this.a[1], this.a[2], this.a[this.size-3], this.a[this.size-2], this.a[this.size-1]); } @@ -403,7 +403,7 @@ module MultiTypeSymEntry */ override proc __str__(thresh:int=1, prefix:string="", suffix:string="", baseFormat:string=""): string throws { genLogger.debug(getModuleName(),getRoutineName(),getLineNumber(), "__str__ invoked"); - var s = "DType: %s, itemsize: %t, size: %t".format(this.dtype, this.itemsize, this.size); + var s = "DType: %s, itemsize: %?, size: %?".doFormat(this.dtype, this.itemsize, this.size); return prefix + s + suffix; } } diff --git a/src/MultiTypeSymbolTable.chpl b/src/MultiTypeSymbolTable.chpl index 8023d3f685..6c0f22f6b6 100644 --- a/src/MultiTypeSymbolTable.chpl +++ b/src/MultiTypeSymbolTable.chpl @@ -14,6 +14,8 @@ module MultiTypeSymbolTable use Map; use ArkoudaRegexCompat; use ArkoudaFileCompat; + use ArkoudaMapCompat; + use ArkoudaIOCompat; private config const logLevel = ServerConfig.logLevel; private config const logChannel = ServerConfig.logChannel; @@ -49,7 +51,7 @@ module MultiTypeSymbolTable // check to see if userDefinedName is already defined, with in-place modification, this will be an error if (registry.contains(userDefinedName)) { mtLogger.error(getModuleName(),getRoutineName(),getLineNumber(), - "regName: requested symbol `%s` is already in use".format(userDefinedName)); + "regName: requested symbol `%s` is already in use".doFormat(userDefinedName)); throw getErrorWithContext( msg=incompatibleArgumentsError("regName", name), lineNumber=getLineNumber(), @@ -58,7 +60,7 @@ module MultiTypeSymbolTable errorClass="ArgumentError"); } else { mtLogger.debug(getModuleName(),getRoutineName(),getLineNumber(), - "Registering symbol: %s ".format(userDefinedName)); + "Registering symbol: %s ".doFormat(userDefinedName)); } // RE: Issue#729 we no longer support multiple name registration of the same object @@ -70,7 +72,7 @@ module MultiTypeSymbolTable // point at same shared table entry var entry = tab.getAndRemove(name); - tab.addOrSet(userDefinedName, entry); + tab.addOrReplace(userDefinedName, entry); entry.setName(userDefinedName); } @@ -78,10 +80,10 @@ module MultiTypeSymbolTable checkTable(name, "unregName"); if registry.contains(name) { mtLogger.debug(getModuleName(),getRoutineName(),getLineNumber(), - "Unregistering symbol: %s ".format(name)); + "Unregistering symbol: %s ".doFormat(name)); } else { mtLogger.error(getModuleName(),getRoutineName(),getLineNumber(), - "The symbol %s is not registered".format(name)); + "The symbol %s is not registered".doFormat(name)); } registry -= name; // take name out of registry @@ -112,13 +114,13 @@ module MultiTypeSymbolTable var entry = new shared SymEntry(len, t); if (tab.contains(name)) { mtLogger.debug(getModuleName(),getRoutineName(),getLineNumber(), - "redefined symbol: %s ".format(name)); + "redefined symbol: %s ".doFormat(name)); } else { mtLogger.debug(getModuleName(),getRoutineName(),getLineNumber(), - "adding symbol: %s ".format(name)); + "adding symbol: %s ".doFormat(name)); } - tab.addOrSet(name, entry); + tab.addOrReplace(name, entry); entry.setName(name); // When we retrieve from table, it comes back as AbstractSymEntry so we need to cast it // back to the original type. Since we know it already we can skip isAssignableTo check @@ -148,13 +150,13 @@ module MultiTypeSymbolTable if (tab.contains(name)) { mtLogger.debug(getModuleName(),getRoutineName(),getLineNumber(), - "redefined symbol: %s ".format(name)); + "redefined symbol: %s ".doFormat(name)); } else { mtLogger.debug(getModuleName(),getRoutineName(),getLineNumber(), - "adding symbol: %s ".format(name)); + "adding symbol: %s ".doFormat(name)); } - tab.addOrSet(name, entry); + tab.addOrReplace(name, entry); entry.setName(name); return tab[name]; } @@ -180,7 +182,7 @@ module MultiTypeSymbolTable when DType.Bool { return addEntry(name, len, bool); } when DType.BigInt { return addEntry(name, len, bigint); } otherwise { - var errorMsg = "addEntry not implemented for %t".format(dtype); + var errorMsg = "addEntry not implemented for %?".doFormat(dtype); throw getErrorWithContext( msg=errorMsg, lineNumber=getLineNumber(), @@ -203,12 +205,12 @@ module MultiTypeSymbolTable checkTable(name, "deleteEntry"); if !registry.contains(name) { mtLogger.debug(getModuleName(),getRoutineName(),getLineNumber(), - "Deleting unregistered entry: %s".format(name)); + "Deleting unregistered entry: %s".doFormat(name)); tab.remove(name); return true; } else { mtLogger.debug(getModuleName(),getRoutineName(),getLineNumber(), - "Skipping registered entry: %s".format(name)); + "Skipping registered entry: %s".doFormat(name)); return false; } } @@ -242,7 +244,7 @@ module MultiTypeSymbolTable proc checkTable(name: string, calling_func="check") throws { if (!tab.contains(name)) { mtLogger.error(getModuleName(),getRoutineName(),getLineNumber(), - "undefined symbol: %s".format(name)); + "undefined symbol: %s".doFormat(name)); throw getErrorWithContext( msg=unknownSymbolError(pname=calling_func, sname=name), lineNumber=getLineNumber(), @@ -251,7 +253,7 @@ module MultiTypeSymbolTable errorClass="UnknownSymbolError"); } else { mtLogger.debug(getModuleName(),getRoutineName(),getLineNumber(), - "found symbol: %s".format(name)); + "found symbol: %s".doFormat(name)); } } @@ -260,7 +262,7 @@ module MultiTypeSymbolTable */ proc pretty() throws { for n in tab { - writeln("%10s = ".format(n), tab.getValue(n)); stdout.flush(); + writeln("%10s = ".doFormat(n), tab.getValue(n)); stdout.flush(); } } @@ -281,10 +283,10 @@ module MultiTypeSymbolTable */ proc dump(name:string): string throws { if name == "__AllSymbols__" { - return "%jt".format(this); + return formatJson(this); } checkTable(name, "dump"); - return "%jt %jt".format(name, tab.getReference(name)); + return formatJson(name) + " " + formatJson(tab.getReference(name)); } /* @@ -307,7 +309,7 @@ module MultiTypeSymbolTable when "__RegisteredSymbols__" {entries = getEntries(registry);} otherwise {entries = getEntries(parseJson(names));} } - return "[%s]".format(','.join(entries)); + return "[%s]".doFormat(','.join(entries)); } /* @@ -385,17 +387,16 @@ module MultiTypeSymbolTable proc formatEntry(name:string, abstractEntry:borrowed AbstractSymEntry): string throws { if abstractEntry.isAssignableTo(SymbolEntryType.TypedArraySymEntry) { var item:borrowed GenSymEntry = toGenSymEntry(abstractEntry); - return '{"name":%jt, "dtype":%jt, "size":%jt, "ndim":%jt, "shape":%jt, "itemsize":%jt, "registered":%jt}'.format(name, - dtype2str(item.dtype), item.size, item.ndim, item.shape, item.itemsize, registry.contains(name)); - + return formatJson('{"name":%?, "dtype":%?, "size":%?, "ndim":%?, "shape":%?, "itemsize":%?, "registered":%?}', + name, dtype2str(item.dtype), item.size, item.ndim, item.shape, item.itemsize, registry.contains(name)); } else if abstractEntry.isAssignableTo(SymbolEntryType.SegStringSymEntry) { var item:borrowed SegStringSymEntry = toSegStringSymEntry(abstractEntry); - return '{"name":%jt, "dtype":%jt, "size":%jt, "ndim":%jt, "shape":%jt, "itemsize":%jt, "registered":%jt}'.format(name, - dtype2str(item.dtype), item.size, item.ndim, item.shape, item.itemsize, registry.contains(name)); + return formatJson('{"name":%?, "dtype":%?, "size":%?, "ndim":%?, "shape":%?, "itemsize":%?, "registered":%?}', + name, dtype2str(item.dtype), item.size, item.ndim, item.shape, item.itemsize, registry.contains(name)); } else { - return '{"name":%jt, "dtype":%jt, "size":%jt, "ndim":%jt, "shape":%jt, "itemsize":%jt, "registered":%jt}'.format(name, - dtype2str(DType.UNDEF), 0, 0, (0,), 0, registry.contains(name)); + return formatJson('{"name":%?, "dtype":%?, "size":%?, "ndim":%?, "shape":%?, "itemsize":%?, "registered":%?}', + name, dtype2str(DType.UNDEF), 0, 0, (0,), 0, registry.contains(name)); } } @@ -414,14 +415,14 @@ module MultiTypeSymbolTable var entry = tab[name]; if entry.isAssignableTo(SymbolEntryType.TypedArraySymEntry){ //Anything considered a GenSymEntry var g:GenSymEntry = toGenSymEntry(entry); - return "%s %s %t %t %t %t".format(name, dtype2str(g.dtype), g.size, g.ndim, g.shape, g.itemsize); + return "%s %s %? %? %? %?".doFormat(name, dtype2str(g.dtype), g.size, g.ndim, g.shape, g.itemsize); } else if entry.isAssignableTo(SymbolEntryType.CompositeSymEntry) { //CompositeSymEntry var c: CompositeSymEntry = toCompositeSymEntry(entry); - return "%s %t %t".format(name, c.size, c.ndim); + return "%s %? %?".doFormat(name, c.size, c.ndim); } - throw new Error("attrib - Unsupported Entry Type %s".format(entry.entryType)); + throw new Error("attrib - Unsupported Entry Type %s".doFormat(entry.entryType)); } /* @@ -448,7 +449,7 @@ module MultiTypeSymbolTable // mtLogger.error(getModuleName(),getRoutineName(),getLineNumber(),s); // return s; // } - return u.__str__(thresh=thresh, prefix="[", suffix="]", baseFormat="%t"); + return u.__str__(thresh=thresh, prefix="[", suffix="]", baseFormat="%?"); } /* @@ -476,10 +477,10 @@ module MultiTypeSymbolTable mtLogger.error(getModuleName(),getRoutineName(),getLineNumber(),s); return s; } - var frmt:string = if (u.dtype == DType.Float64) then "%.17r" else "%t"; + var frmt:string = if (u.dtype == DType.Float64) then "%.17r" else "%?"; return u.__str__(thresh=thresh, prefix="array([", suffix="])", baseFormat=frmt); } else { - return "Unhandled type %s".format(entry.entryType); + return "Unhandled type %s".doFormat(entry.entryType); } } @@ -533,7 +534,7 @@ module MultiTypeSymbolTable proc getGenericTypedArrayEntry(name:string, st: borrowed SymTab): borrowed GenSymEntry throws { var abstractEntry = st.lookup(name); if ! abstractEntry.isAssignableTo(SymbolEntryType.TypedArraySymEntry) { - var errorMsg = "Error: SymbolEntryType %s is not assignable to GenSymEntry".format(abstractEntry.entryType); + var errorMsg = "Error: SymbolEntryType %s is not assignable to GenSymEntry".doFormat(abstractEntry.entryType); mtLogger.error(getModuleName(),getRoutineName(),getLineNumber(),errorMsg); throw new Error(errorMsg); } @@ -548,7 +549,7 @@ module MultiTypeSymbolTable proc getSegStringEntry(name:string, st: borrowed SymTab): borrowed SegStringSymEntry throws { var abstractEntry = st.lookup(name); if ! abstractEntry.isAssignableTo(SymbolEntryType.SegStringSymEntry) { - var errorMsg = "Error: SymbolEntryType %s is not assignable to SegStringSymEntry".format(abstractEntry.entryType); + var errorMsg = "Error: SymbolEntryType %s is not assignable to SegStringSymEntry".doFormat(abstractEntry.entryType); mtLogger.error(getModuleName(),getRoutineName(),getLineNumber(),errorMsg); throw new Error(errorMsg); } diff --git a/src/OperatorMsg.chpl b/src/OperatorMsg.chpl index ef74f5d71b..c787efd1ce 100644 --- a/src/OperatorMsg.chpl +++ b/src/OperatorMsg.chpl @@ -50,7 +50,7 @@ module OperatorMsg var right: borrowed GenSymEntry = getGenericTypedArrayEntry(bname, st); omLogger.debug(getModuleName(), getRoutineName(), getLineNumber(), - "cmd: %t op: %t left pdarray: %t right pdarray: %t".format( + "cmd: %? op: %? left pdarray: %? right pdarray: %?".doFormat( cmd,op,st.attrib(aname),st.attrib(bname))); use Set; @@ -253,13 +253,13 @@ module OperatorMsg if boolOps.contains(op) { // call bigint specific func which returns distr bool array var e = st.addEntry(rname, new shared SymEntry(doBigIntBinOpvvBoolReturn(l, r, op))); - var repMsg = "created %s".format(st.attrib(rname)); + var repMsg = "created %s".doFormat(st.attrib(rname)); return new MsgTuple(repMsg, MsgType.NORMAL); } // call bigint specific func which returns dist bigint array var (tmp, max_bits) = doBigIntBinOpvv(l, r, op); var e = st.addEntry(rname, new shared SymEntry(tmp, max_bits)); - var repMsg = "created %s".format(st.attrib(rname)); + var repMsg = "created %s".doFormat(st.attrib(rname)); return new MsgTuple(repMsg, MsgType.NORMAL); } when (DType.BigInt, DType.Int64) { @@ -268,13 +268,13 @@ module OperatorMsg if boolOps.contains(op) { // call bigint specific func which returns distr bool array var e = st.addEntry(rname, new shared SymEntry(doBigIntBinOpvvBoolReturn(l, r, op))); - var repMsg = "created %s".format(st.attrib(rname)); + var repMsg = "created %s".doFormat(st.attrib(rname)); return new MsgTuple(repMsg, MsgType.NORMAL); } // call bigint specific func which returns dist bigint array var (tmp, max_bits) = doBigIntBinOpvv(l, r, op); var e = st.addEntry(rname, new shared SymEntry(tmp, max_bits)); - var repMsg = "created %s".format(st.attrib(rname)); + var repMsg = "created %s".doFormat(st.attrib(rname)); return new MsgTuple(repMsg, MsgType.NORMAL); } when (DType.BigInt, DType.UInt64) { @@ -283,13 +283,13 @@ module OperatorMsg if boolOps.contains(op) { // call bigint specific func which returns distr bool array var e = st.addEntry(rname, new shared SymEntry(doBigIntBinOpvvBoolReturn(l, r, op))); - var repMsg = "created %s".format(st.attrib(rname)); + var repMsg = "created %s".doFormat(st.attrib(rname)); return new MsgTuple(repMsg, MsgType.NORMAL); } // call bigint specific func which returns dist bigint array var (tmp, max_bits) = doBigIntBinOpvv(l, r, op); var e = st.addEntry(rname, new shared SymEntry(tmp, max_bits)); - var repMsg = "created %s".format(st.attrib(rname)); + var repMsg = "created %s".doFormat(st.attrib(rname)); return new MsgTuple(repMsg, MsgType.NORMAL); } when (DType.BigInt, DType.Bool) { @@ -298,13 +298,13 @@ module OperatorMsg if boolOps.contains(op) { // call bigint specific func which returns distr bool array var e = st.addEntry(rname, new shared SymEntry(doBigIntBinOpvvBoolReturn(l, r, op))); - var repMsg = "created %s".format(st.attrib(rname)); + var repMsg = "created %s".doFormat(st.attrib(rname)); return new MsgTuple(repMsg, MsgType.NORMAL); } // call bigint specific func which returns dist bigint array var (tmp, max_bits) = doBigIntBinOpvv(l, r, op); var e = st.addEntry(rname, new shared SymEntry(tmp, max_bits)); - var repMsg = "created %s".format(st.attrib(rname)); + var repMsg = "created %s".doFormat(st.attrib(rname)); return new MsgTuple(repMsg, MsgType.NORMAL); } when (DType.Int64, DType.BigInt) { @@ -313,13 +313,13 @@ module OperatorMsg if boolOps.contains(op) { // call bigint specific func which returns distr bool array var e = st.addEntry(rname, new shared SymEntry(doBigIntBinOpvvBoolReturn(l, r, op))); - var repMsg = "created %s".format(st.attrib(rname)); + var repMsg = "created %s".doFormat(st.attrib(rname)); return new MsgTuple(repMsg, MsgType.NORMAL); } // call bigint specific func which returns dist bigint array var (tmp, max_bits) = doBigIntBinOpvv(l, r, op); var e = st.addEntry(rname, new shared SymEntry(tmp, max_bits)); - var repMsg = "created %s".format(st.attrib(rname)); + var repMsg = "created %s".doFormat(st.attrib(rname)); return new MsgTuple(repMsg, MsgType.NORMAL); } when (DType.UInt64, DType.BigInt) { @@ -328,13 +328,13 @@ module OperatorMsg if boolOps.contains(op) { // call bigint specific func which returns distr bool array var e = st.addEntry(rname, new shared SymEntry(doBigIntBinOpvvBoolReturn(l, r, op))); - var repMsg = "created %s".format(st.attrib(rname)); + var repMsg = "created %s".doFormat(st.attrib(rname)); return new MsgTuple(repMsg, MsgType.NORMAL); } // call bigint specific func which returns dist bigint array var (tmp, max_bits) = doBigIntBinOpvv(l, r, op); var e = st.addEntry(rname, new shared SymEntry(tmp, max_bits)); - var repMsg = "created %s".format(st.attrib(rname)); + var repMsg = "created %s".doFormat(st.attrib(rname)); return new MsgTuple(repMsg, MsgType.NORMAL); } when (DType.Bool, DType.BigInt) { @@ -343,13 +343,13 @@ module OperatorMsg if boolOps.contains(op) { // call bigint specific func which returns distr bool array var e = st.addEntry(rname, new shared SymEntry(doBigIntBinOpvvBoolReturn(l, r, op))); - var repMsg = "created %s".format(st.attrib(rname)); + var repMsg = "created %s".doFormat(st.attrib(rname)); return new MsgTuple(repMsg, MsgType.NORMAL); } // call bigint specific func which returns dist bigint array var (tmp, max_bits) = doBigIntBinOpvv(l, r, op); var e = st.addEntry(rname, new shared SymEntry(tmp, max_bits)); - var repMsg = "created %s".format(st.attrib(rname)); + var repMsg = "created %s".doFormat(st.attrib(rname)); return new MsgTuple(repMsg, MsgType.NORMAL); } } @@ -384,7 +384,7 @@ module OperatorMsg var left: borrowed GenSymEntry = getGenericTypedArrayEntry(aname, st); omLogger.debug(getModuleName(),getRoutineName(),getLineNumber(), - "op: %s dtype: %t pdarray: %t scalar: %t".format( + "op: %s dtype: %? pdarray: %? scalar: %?".doFormat( op,dtype,st.attrib(aname),value.getValue())); use Set; @@ -588,13 +588,13 @@ module OperatorMsg if boolOps.contains(op) { // call bigint specific func which returns distr bool array var e = st.addEntry(rname, new shared SymEntry(doBigIntBinOpvsBoolReturn(l, val, op))); - var repMsg = "created %s".format(st.attrib(rname)); + var repMsg = "created %s".doFormat(st.attrib(rname)); return new MsgTuple(repMsg, MsgType.NORMAL); } // call bigint specific func which returns dist bigint array var (tmp, max_bits) = doBigIntBinOpvs(l, val, op); var e = st.addEntry(rname, new shared SymEntry(tmp, max_bits)); - var repMsg = "created %s".format(st.attrib(rname)); + var repMsg = "created %s".doFormat(st.attrib(rname)); return new MsgTuple(repMsg, MsgType.NORMAL); } when (DType.BigInt, DType.Int64) { @@ -603,13 +603,13 @@ module OperatorMsg if boolOps.contains(op) { // call bigint specific func which returns distr bool array var e = st.addEntry(rname, new shared SymEntry(doBigIntBinOpvsBoolReturn(l, val, op))); - var repMsg = "created %s".format(st.attrib(rname)); + var repMsg = "created %s".doFormat(st.attrib(rname)); return new MsgTuple(repMsg, MsgType.NORMAL); } // call bigint specific func which returns dist bigint array var (tmp, max_bits) = doBigIntBinOpvs(l, val, op); var e = st.addEntry(rname, new shared SymEntry(tmp, max_bits)); - var repMsg = "created %s".format(st.attrib(rname)); + var repMsg = "created %s".doFormat(st.attrib(rname)); return new MsgTuple(repMsg, MsgType.NORMAL); } when (DType.BigInt, DType.UInt64) { @@ -618,13 +618,13 @@ module OperatorMsg if boolOps.contains(op) { // call bigint specific func which returns distr bool array var e = st.addEntry(rname, new shared SymEntry(doBigIntBinOpvsBoolReturn(l, val, op))); - var repMsg = "created %s".format(st.attrib(rname)); + var repMsg = "created %s".doFormat(st.attrib(rname)); return new MsgTuple(repMsg, MsgType.NORMAL); } // call bigint specific func which returns dist bigint array var (tmp, max_bits) = doBigIntBinOpvs(l, val, op); var e = st.addEntry(rname, new shared SymEntry(tmp, max_bits)); - var repMsg = "created %s".format(st.attrib(rname)); + var repMsg = "created %s".doFormat(st.attrib(rname)); return new MsgTuple(repMsg, MsgType.NORMAL); } when (DType.BigInt, DType.Bool) { @@ -633,13 +633,13 @@ module OperatorMsg if boolOps.contains(op) { // call bigint specific func which returns distr bool array var e = st.addEntry(rname, new shared SymEntry(doBigIntBinOpvsBoolReturn(l, val, op))); - var repMsg = "created %s".format(st.attrib(rname)); + var repMsg = "created %s".doFormat(st.attrib(rname)); return new MsgTuple(repMsg, MsgType.NORMAL); } // call bigint specific func which returns dist bigint array var (tmp, max_bits) = doBigIntBinOpvs(l, val, op); var e = st.addEntry(rname, new shared SymEntry(tmp, max_bits)); - var repMsg = "created %s".format(st.attrib(rname)); + var repMsg = "created %s".doFormat(st.attrib(rname)); return new MsgTuple(repMsg, MsgType.NORMAL); } when (DType.Int64, DType.BigInt) { @@ -648,13 +648,13 @@ module OperatorMsg if boolOps.contains(op) { // call bigint specific func which returns distr bool array var e = st.addEntry(rname, new shared SymEntry(doBigIntBinOpvsBoolReturn(l, val, op))); - var repMsg = "created %s".format(st.attrib(rname)); + var repMsg = "created %s".doFormat(st.attrib(rname)); return new MsgTuple(repMsg, MsgType.NORMAL); } // call bigint specific func which returns dist bigint array var (tmp, max_bits) = doBigIntBinOpvs(l, val, op); var e = st.addEntry(rname, new shared SymEntry(tmp, max_bits)); - var repMsg = "created %s".format(st.attrib(rname)); + var repMsg = "created %s".doFormat(st.attrib(rname)); return new MsgTuple(repMsg, MsgType.NORMAL); } when (DType.UInt64, DType.BigInt) { @@ -663,13 +663,13 @@ module OperatorMsg if boolOps.contains(op) { // call bigint specific func which returns distr bool array var e = st.addEntry(rname, new shared SymEntry(doBigIntBinOpvsBoolReturn(l, val, op))); - var repMsg = "created %s".format(st.attrib(rname)); + var repMsg = "created %s".doFormat(st.attrib(rname)); return new MsgTuple(repMsg, MsgType.NORMAL); } // call bigint specific func which returns dist bigint array var (tmp, max_bits) = doBigIntBinOpvs(l, val, op); var e = st.addEntry(rname, new shared SymEntry(tmp, max_bits)); - var repMsg = "created %s".format(st.attrib(rname)); + var repMsg = "created %s".doFormat(st.attrib(rname)); return new MsgTuple(repMsg, MsgType.NORMAL); } when (DType.Bool, DType.BigInt) { @@ -678,13 +678,13 @@ module OperatorMsg if boolOps.contains(op) { // call bigint specific func which returns distr bool array var e = st.addEntry(rname, new shared SymEntry(doBigIntBinOpvsBoolReturn(l, val, op))); - var repMsg = "created %s".format(st.attrib(rname)); + var repMsg = "created %s".doFormat(st.attrib(rname)); return new MsgTuple(repMsg, MsgType.NORMAL); } // call bigint specific func which returns dist bigint array var (tmp, max_bits) = doBigIntBinOpvs(l, val, op); var e = st.addEntry(rname, new shared SymEntry(tmp, max_bits)); - var repMsg = "created %s".format(st.attrib(rname)); + var repMsg = "created %s".doFormat(st.attrib(rname)); return new MsgTuple(repMsg, MsgType.NORMAL); } } @@ -719,7 +719,7 @@ module OperatorMsg var right: borrowed GenSymEntry = getGenericTypedArrayEntry(aname, st); omLogger.debug(getModuleName(),getRoutineName(),getLineNumber(), - "command = %t op = %t scalar dtype = %t scalar = %t pdarray = %t".format( + "command = %? op = %? scalar dtype = %? scalar = %? pdarray = %?".doFormat( cmd,op,dtype2str(dtype),value,st.attrib(aname))); use Set; @@ -923,13 +923,13 @@ module OperatorMsg if boolOps.contains(op) { // call bigint specific func which returns distr bool array var e = st.addEntry(rname, new shared SymEntry(doBigIntBinOpsvBoolReturn(val, r, op))); - var repMsg = "created %s".format(st.attrib(rname)); + var repMsg = "created %s".doFormat(st.attrib(rname)); return new MsgTuple(repMsg, MsgType.NORMAL); } // call bigint specific func which returns dist bigint array var (tmp, max_bits) = doBigIntBinOpsv(val, r, op); var e = st.addEntry(rname, new shared SymEntry(tmp, max_bits)); - var repMsg = "created %s".format(st.attrib(rname)); + var repMsg = "created %s".doFormat(st.attrib(rname)); return new MsgTuple(repMsg, MsgType.NORMAL); } when (DType.BigInt, DType.Int64) { @@ -938,13 +938,13 @@ module OperatorMsg if boolOps.contains(op) { // call bigint specific func which returns distr bool array var e = st.addEntry(rname, new shared SymEntry(doBigIntBinOpsvBoolReturn(val, r, op))); - var repMsg = "created %s".format(st.attrib(rname)); + var repMsg = "created %s".doFormat(st.attrib(rname)); return new MsgTuple(repMsg, MsgType.NORMAL); } // call bigint specific func which returns dist bigint array var (tmp, max_bits) = doBigIntBinOpsv(val, r, op); var e = st.addEntry(rname, new shared SymEntry(tmp, max_bits)); - var repMsg = "created %s".format(st.attrib(rname)); + var repMsg = "created %s".doFormat(st.attrib(rname)); return new MsgTuple(repMsg, MsgType.NORMAL); } when (DType.BigInt, DType.UInt64) { @@ -953,13 +953,13 @@ module OperatorMsg if boolOps.contains(op) { // call bigint specific func which returns distr bool array var e = st.addEntry(rname, new shared SymEntry(doBigIntBinOpsvBoolReturn(val, r, op))); - var repMsg = "created %s".format(st.attrib(rname)); + var repMsg = "created %s".doFormat(st.attrib(rname)); return new MsgTuple(repMsg, MsgType.NORMAL); } // call bigint specific func which returns dist bigint array var (tmp, max_bits) = doBigIntBinOpsv(val, r, op); var e = st.addEntry(rname, new shared SymEntry(tmp, max_bits)); - var repMsg = "created %s".format(st.attrib(rname)); + var repMsg = "created %s".doFormat(st.attrib(rname)); return new MsgTuple(repMsg, MsgType.NORMAL); } when (DType.BigInt, DType.Bool) { @@ -968,13 +968,13 @@ module OperatorMsg if boolOps.contains(op) { // call bigint specific func which returns distr bool array var e = st.addEntry(rname, new shared SymEntry(doBigIntBinOpsvBoolReturn(val, r, op))); - var repMsg = "created %s".format(st.attrib(rname)); + var repMsg = "created %s".doFormat(st.attrib(rname)); return new MsgTuple(repMsg, MsgType.NORMAL); } // call bigint specific func which returns dist bigint array var (tmp, max_bits) = doBigIntBinOpsv(val, r, op); var e = st.addEntry(rname, new shared SymEntry(tmp, max_bits)); - var repMsg = "created %s".format(st.attrib(rname)); + var repMsg = "created %s".doFormat(st.attrib(rname)); return new MsgTuple(repMsg, MsgType.NORMAL); } when (DType.Int64, DType.BigInt) { @@ -983,13 +983,13 @@ module OperatorMsg if boolOps.contains(op) { // call bigint specific func which returns distr bool array var e = st.addEntry(rname, new shared SymEntry(doBigIntBinOpsvBoolReturn(val, r, op))); - var repMsg = "created %s".format(st.attrib(rname)); + var repMsg = "created %s".doFormat(st.attrib(rname)); return new MsgTuple(repMsg, MsgType.NORMAL); } // call bigint specific func which returns dist bigint array var (tmp, max_bits) = doBigIntBinOpsv(val, r, op); var e = st.addEntry(rname, new shared SymEntry(tmp, max_bits)); - var repMsg = "created %s".format(st.attrib(rname)); + var repMsg = "created %s".doFormat(st.attrib(rname)); return new MsgTuple(repMsg, MsgType.NORMAL); } when (DType.UInt64, DType.BigInt) { @@ -998,13 +998,13 @@ module OperatorMsg if boolOps.contains(op) { // call bigint specific func which returns distr bool array var e = st.addEntry(rname, new shared SymEntry(doBigIntBinOpsvBoolReturn(val, r, op))); - var repMsg = "created %s".format(st.attrib(rname)); + var repMsg = "created %s".doFormat(st.attrib(rname)); return new MsgTuple(repMsg, MsgType.NORMAL); } // call bigint specific func which returns dist bigint array var (tmp, max_bits) = doBigIntBinOpsv(val, r, op); var e = st.addEntry(rname, new shared SymEntry(tmp, max_bits)); - var repMsg = "created %s".format(st.attrib(rname)); + var repMsg = "created %s".doFormat(st.attrib(rname)); return new MsgTuple(repMsg, MsgType.NORMAL); } when (DType.Bool, DType.BigInt) { @@ -1013,13 +1013,13 @@ module OperatorMsg if boolOps.contains(op) { // call bigint specific func which returns distr bool array var e = st.addEntry(rname, new shared SymEntry(doBigIntBinOpsvBoolReturn(val, r, op))); - var repMsg = "created %s".format(st.attrib(rname)); + var repMsg = "created %s".doFormat(st.attrib(rname)); return new MsgTuple(repMsg, MsgType.NORMAL); } // call bigint specific func which returns dist bigint array var (tmp, max_bits) = doBigIntBinOpsv(val, r, op); var e = st.addEntry(rname, new shared SymEntry(tmp, max_bits)); - var repMsg = "created %s".format(st.attrib(rname)); + var repMsg = "created %s".doFormat(st.attrib(rname)); return new MsgTuple(repMsg, MsgType.NORMAL); } } @@ -1054,7 +1054,7 @@ module OperatorMsg var right: borrowed GenSymEntry = getGenericTypedArrayEntry(bname, st); omLogger.debug(getModuleName(),getRoutineName(),getLineNumber(), - "cmd: %s op: %s left pdarray: %s right pdarray: %s".format(cmd,op, + "cmd: %s op: %s left pdarray: %s right pdarray: %s".doFormat(cmd,op, st.attrib(aname),st.attrib(bname))); select (left.dtype, right.dtype) { @@ -1637,13 +1637,13 @@ module OperatorMsg var dtype = str2dtype(msgArgs.getValueOf("dtype")); omLogger.debug(getModuleName(),getRoutineName(),getLineNumber(), - "cmd: %s op: %s aname: %s dtype: %s scalar: %s".format( + "cmd: %s op: %s aname: %s dtype: %s scalar: %s".doFormat( cmd,op,aname,dtype2str(dtype),value.getValue())); var left: borrowed GenSymEntry = getGenericTypedArrayEntry(aname, st); omLogger.debug(getModuleName(),getRoutineName(),getLineNumber(), - "op: %t pdarray: %t scalar: %t".format(op,st.attrib(aname),value.getValue())); + "op: %? pdarray: %? scalar: %?".doFormat(op,st.attrib(aname),value.getValue())); select (left.dtype, dtype) { when (DType.Int64, DType.Int64) { var l = toSymEntry(left,int); diff --git a/src/ParquetMsg.chpl b/src/ParquetMsg.chpl index 7f5d587c07..c4964a422d 100644 --- a/src/ParquetMsg.chpl +++ b/src/ParquetMsg.chpl @@ -20,6 +20,7 @@ module ParquetMsg { use ArkoudaCTypesCompat; use ArkoudaListCompat; use ArkoudaStringBytesCompat; + use ArkoudaIOCompat; enum CompressionType { NONE=0, @@ -608,7 +609,7 @@ module ParquetMsg { } } else { throw getErrorWithContext( - msg="The mode %t is invalid".format(mode), + msg="The mode %? is invalid".doFormat(mode), lineNumber=getLineNumber(), routineName=getRoutineName(), moduleName=getModuleName(), @@ -665,7 +666,7 @@ module ParquetMsg { var entryVal = new shared SymEntry((+ reduce byteSizes), uint(8)); readListFilesByName(entryVal.a, sizes, seg_sizes, segments, filenames, byteSizes, dsetname, ty); var stringsEntry = assembleSegStringFromParts(entrySeg, entryVal, st); - rtnmap.add("values", "created %s+created bytes.size %t".format(st.attrib(stringsEntry.name), stringsEntry.nBytes)); + rtnmap.add("values", "created %s+created bytes.size %?".doFormat(st.attrib(stringsEntry.name), stringsEntry.nBytes)); } else { throw getErrorWithContext( @@ -675,7 +676,7 @@ module ParquetMsg { moduleName=getModuleName(), errorClass='IllegalArgumentError'); } - return "%jt".format(rtnmap); + return formatJson(rtnmap); } proc populateTagData(A, filenames: [?fD] string, sizes) throws { @@ -724,7 +725,7 @@ module ParquetMsg { var n: int = 1000; var jsondsets = msgArgs.getValueOf("dsets"); var dsets: string = if jsondsets.size > 2*n then jsondsets[0..#n]+'...'+jsondsets[jsondsets.size-n..#n] else jsondsets; - var errorMsg = "Could not decode json dataset names via tempfile (%i files: %s)".format( + var errorMsg = "Could not decode json dataset names via tempfile (%i files: %s)".doFormat( ndsets, dsets); pqLogger.error(getModuleName(),getRoutineName(),getLineNumber(),errorMsg); return new MsgTuple(errorMsg, MsgType.ERROR); @@ -737,7 +738,7 @@ module ParquetMsg { var n: int = 1000; var jsonfiles = msgArgs.getValueOf("filenames"); var files: string = if jsonfiles.size > 2*n then jsonfiles[0..#n]+'...'+jsonfiles[jsonfiles.size-n..#n] else jsonfiles; - var errorMsg = "Could not decode json filenames via tempfile (%i files: %s)".format(nfiles, files); + var errorMsg = "Could not decode json filenames via tempfile (%i files: %s)".doFormat(nfiles, files); pqLogger.error(getModuleName(),getRoutineName(),getLineNumber(),errorMsg); return new MsgTuple(errorMsg, MsgType.ERROR); } @@ -756,9 +757,9 @@ module ParquetMsg { } var tmp = glob(filelist[0]); pqLogger.debug(getModuleName(),getRoutineName(),getLineNumber(), - "glob expanded %s to %i files".format(filelist[0], tmp.size)); + "glob expanded %s to %i files".doFormat(filelist[0], tmp.size)); if tmp.size == 0 { - var errorMsg = "The wildcarded filename %s either corresponds to files inaccessible to Arkouda or files of an invalid format".format(filelist[0]); + var errorMsg = "The wildcarded filename %s either corresponds to files inaccessible to Arkouda or files of an invalid format".doFormat(filelist[0]); pqLogger.error(getModuleName(),getRoutineName(),getLineNumber(),errorMsg); return new MsgTuple(errorMsg, MsgType.ERROR); } @@ -787,7 +788,7 @@ module ParquetMsg { sizes[i] = getArrSize(fname); } catch e : Error { // This is only type of error thrown by Parquet - fileErrorMsg = "Other error in accessing file %s: %s".format(fname,e.message()); + fileErrorMsg = "Other error in accessing file %s: %s".doFormat(fname,e.message()); pqLogger.error(getModuleName(),getRoutineName(),getLineNumber(),fileErrorMsg); hadError = true; if !allowErrors { return new MsgTuple(fileErrorMsg, MsgType.ERROR); } @@ -852,7 +853,7 @@ module ParquetMsg { readStrFilesByName(entryVal.a, filenames, byteSizes, dsetname, ty); var stringsEntry = assembleSegStringFromParts(entrySeg, entryVal, st); - rnames.pushBack((dsetname, ObjType.STRINGS, "%s+%t".format(stringsEntry.name, stringsEntry.nBytes))); + rnames.pushBack((dsetname, ObjType.STRINGS, "%s+%?".doFormat(stringsEntry.name, stringsEntry.nBytes))); } else if ty == ArrowTypes.double || ty == ArrowTypes.float { var entryVal = new shared SymEntry(len, real); readFilesByName(entryVal.a, filenames, sizes, dsetname, ty); @@ -862,14 +863,14 @@ module ParquetMsg { } else if ty == ArrowTypes.list { var list_ty = getListData(filenames[0], dsetname); if list_ty == ArrowTypes.notimplemented { // check for and skip further nested datasets - pqLogger.info(getModuleName(),getRoutineName(),getLineNumber(),"Invalid list datatype found in %s. Skipping.".format(dsetname)); + pqLogger.info(getModuleName(),getRoutineName(),getLineNumber(),"Invalid list datatype found in %s. Skipping.".doFormat(dsetname)); } else { var create_str: string = parseListDataset(filenames, dsetname, list_ty, len, sizes, st); rnames.pushBack((dsetname, ObjType.SEGARRAY, create_str)); } } else { - var errorMsg = "DType %s not supported for Parquet reading".format(ty); + var errorMsg = "DType %s not supported for Parquet reading".doFormat(ty); pqLogger.error(getModuleName(),getRoutineName(),getLineNumber(),errorMsg); return new MsgTuple(errorMsg, MsgType.ERROR); } @@ -908,7 +909,7 @@ module ParquetMsg { var compression = msgArgs.getValueOf("compression").toUpper(): CompressionType; if (!entry.isAssignableTo(SymbolEntryType.TypedArraySymEntry)) { - var errorMsg = "ObjType (PDARRAY) does not match SymEntry Type: %s".format(entry.entryType); + var errorMsg = "ObjType (PDARRAY) does not match SymEntry Type: %s".doFormat(entry.entryType); throw getErrorWithContext( msg=errorMsg, lineNumber=getLineNumber(), @@ -934,7 +935,7 @@ module ParquetMsg { var e = toSymEntry(toGenSymEntry(entry), real); warnFlag = write1DDistArrayParquet(filename, dsetname, dtypestr, compression:int, mode, e.a); } otherwise { - var errorMsg = "Writing Parquet files not supported for %s type".format(msgArgs.getValueOf("dtype")); + var errorMsg = "Writing Parquet files not supported for %s type".doFormat(msgArgs.getValueOf("dtype")); pqLogger.error(getModuleName(),getRoutineName(),getLineNumber(),errorMsg); throw getErrorWithContext( msg=errorMsg, @@ -956,7 +957,7 @@ module ParquetMsg { var compression = msgArgs.getValueOf("compression").toUpper(): CompressionType; if (!entry.isAssignableTo(SymbolEntryType.SegStringSymEntry)) { - var errorMsg = "ObjType (STRINGS) does not match SymEntry Type: %s".format(entry.entryType); + var errorMsg = "ObjType (STRINGS) does not match SymEntry Type: %s".doFormat(entry.entryType); throw getErrorWithContext( msg=errorMsg, lineNumber=getLineNumber(), @@ -1196,7 +1197,7 @@ module ParquetMsg { var values = toSegStringSymEntry(genVal); warnFlag = writeStrSegArrayParquet(filename, dsetname, segments, values, compression:int); } otherwise { - var errorMsg = "Writing Parquet files not supported for %s type".format(genVal.dtype); + var errorMsg = "Writing Parquet files not supported for %s type".doFormat(genVal.dtype); pqLogger.error(getModuleName(),getRoutineName(),getLineNumber(),errorMsg); throw getErrorWithContext( msg=errorMsg, @@ -1228,25 +1229,25 @@ module ParquetMsg { warnFlag = segarray_toParquetMsg(msgArgs, st); } otherwise { - var errorMsg = "Unable to write object type %s to Parquet file.".format(objType); + var errorMsg = "Unable to write object type %s to Parquet file.".doFormat(objType); pqLogger.error(getModuleName(),getRoutineName(),getLineNumber(),errorMsg); return new MsgTuple(errorMsg, MsgType.ERROR); } } } catch e: FileNotFoundError { - var errorMsg = "Unable to open %s for writing: %s".format(msgArgs.getValueOf("filename"),e.message()); + var errorMsg = "Unable to open %s for writing: %s".doFormat(msgArgs.getValueOf("filename"),e.message()); pqLogger.error(getModuleName(),getRoutineName(),getLineNumber(),errorMsg); return new MsgTuple(errorMsg, MsgType.ERROR); } catch e: MismatchedAppendError { - var errorMsg = "Mismatched append %s".format(e.message()); + var errorMsg = "Mismatched append %s".doFormat(e.message()); pqLogger.error(getModuleName(),getRoutineName(),getLineNumber(),errorMsg); return new MsgTuple(errorMsg, MsgType.ERROR); } catch e: WriteModeError { - var errorMsg = "Write mode error %s".format(e.message()); + var errorMsg = "Write mode error %s".doFormat(e.message()); pqLogger.error(getModuleName(),getRoutineName(),getLineNumber(),errorMsg); return new MsgTuple(errorMsg, MsgType.ERROR); } catch e: Error { - var errorMsg = "problem writing to file %s".format(e.message()); + var errorMsg = "problem writing to file %s".doFormat(e.message()); pqLogger.error(getModuleName(),getRoutineName(),getLineNumber(),errorMsg); return new MsgTuple(errorMsg, MsgType.ERROR); } @@ -1365,7 +1366,7 @@ module ParquetMsg { } otherwise { throw getErrorWithContext( - msg="Unsupported SegArray DType for writing to Parquet, ".format(values.dtype: string), + msg="Unsupported SegArray DType for writing to Parquet, ".doFormat(values.dtype: string), lineNumber=getLineNumber(), routineName=getRoutineName(), moduleName=getModuleName(), @@ -1529,7 +1530,7 @@ module ParquetMsg { } otherwise { throw getErrorWithContext( - msg="Unsupported SegArray DType for writing to Parquet, ".format(valEntry.dtype: string), + msg="Unsupported SegArray DType for writing to Parquet, ".doFormat(valEntry.dtype: string), lineNumber=getLineNumber(), routineName=getRoutineName(), moduleName=getModuleName(), @@ -1559,7 +1560,7 @@ module ParquetMsg { } otherwise { throw getErrorWithContext( - msg="Unsupported SegArray DType for writing to Parquet, ".format(valEntry.dtype: string), + msg="Unsupported SegArray DType for writing to Parquet, ".doFormat(valEntry.dtype: string), lineNumber=getLineNumber(), routineName=getRoutineName(), moduleName=getModuleName(), @@ -1618,7 +1619,7 @@ module ParquetMsg { } otherwise { throw getErrorWithContext( - msg="Unsupported PDArray DType for writing to Parquet, ".format(entry.dtype: string), + msg="Unsupported PDArray DType for writing to Parquet, ".doFormat(entry.dtype: string), lineNumber=getLineNumber(), routineName=getRoutineName(), moduleName=getModuleName(), @@ -1629,7 +1630,7 @@ module ParquetMsg { } otherwise { throw getErrorWithContext( - msg="Writing Parquet files (multi-column) does not support %s columns.".format(ot), + msg="Writing Parquet files (multi-column) does not support %s columns.".doFormat(ot), lineNumber=getLineNumber(), routineName=getRoutineName(), moduleName=getModuleName(), @@ -1698,7 +1699,7 @@ module ParquetMsg { } otherwise { throw getErrorWithContext( - msg="Writing Parquet files (multi-column) does not support columns of type %s".format(entryDtype: string), + msg="Writing Parquet files (multi-column) does not support columns of type %s".doFormat(entryDtype: string), lineNumber=getLineNumber(), routineName=getRoutineName(), moduleName=getModuleName(), @@ -1709,7 +1710,7 @@ module ParquetMsg { } otherwise { throw getErrorWithContext( - msg="Writing Parquet files (multi-column) does not support %s columns.".format(objType), + msg="Writing Parquet files (multi-column) does not support %s columns.".doFormat(objType), lineNumber=getLineNumber(), routineName=getRoutineName(), moduleName=getModuleName(), @@ -1743,15 +1744,15 @@ module ParquetMsg { try { warnFlag = writeMultiColParquet(filename, col_names, ncols, sym_names, col_objType_strs, targetLocales, compression:int, st); } catch e: FileNotFoundError { - var errorMsg = "Unable to open %s for writing: %s".format(filename,e.message()); + var errorMsg = "Unable to open %s for writing: %s".doFormat(filename,e.message()); pqLogger.error(getModuleName(),getRoutineName(),getLineNumber(),errorMsg); return new MsgTuple(errorMsg, MsgType.ERROR); } catch e: WriteModeError { - var errorMsg = "Write mode error %s".format(e.message()); + var errorMsg = "Write mode error %s".doFormat(e.message()); pqLogger.error(getModuleName(),getRoutineName(),getLineNumber(),errorMsg); return new MsgTuple(errorMsg, MsgType.ERROR); } catch e: Error { - var errorMsg = "problem writing to file %s".format(e.message()); + var errorMsg = "problem writing to file %s".doFormat(e.message()); pqLogger.error(getModuleName(),getRoutineName(),getLineNumber(),errorMsg); return new MsgTuple(errorMsg, MsgType.ERROR); } @@ -1787,7 +1788,7 @@ module ParquetMsg { var tmp = glob(filename); if tmp.size <= 0 { - var errorMsg = "Cannot retrieve filename from glob expression %s, check file name or format".format(filename); + var errorMsg = "Cannot retrieve filename from glob expression %s, check file name or format".doFormat(filename); return new MsgTuple(errorMsg, MsgType.ERROR); } @@ -1797,7 +1798,7 @@ module ParquetMsg { // Check to see if the file exists. If not, return an error message if !exists(filename) { - var errorMsg = "File %s does not exist in a location accessible to Arkouda".format(filename); + var errorMsg = "File %s does not exist in a location accessible to Arkouda".doFormat(filename); return new MsgTuple(errorMsg,MsgType.ERROR); } @@ -1817,9 +1818,9 @@ module ParquetMsg { try! repMsg = string.createCopyingBuffer(res, strlen(res)); var items = new list(repMsg.split(",")); // convert to json - repMsg = "%jt".format(items); + repMsg = formatJson(items); } catch e : Error { - var errorMsg = "Failed to process Parquet file %t".format(e.message()); + var errorMsg = "Failed to process Parquet file %?".doFormat(e.message()); return new MsgTuple(errorMsg, MsgType.ERROR); } @@ -1837,7 +1838,7 @@ module ParquetMsg { try { dsetlist = msgArgs.get("dsets").getList(ndsets); } catch { - var errorMsg = "Could not decode json dataset names via tempfile (%i files: %s)".format( + var errorMsg = "Could not decode json dataset names via tempfile (%i files: %s)".doFormat( 1, msgArgs.getValueOf("dsets")); pqLogger.error(getModuleName(),getRoutineName(),getLineNumber(),errorMsg); return new MsgTuple(errorMsg, MsgType.ERROR); @@ -1850,7 +1851,7 @@ module ParquetMsg { var n: int = 1000; var jsonfiles = msgArgs.getValueOf("filenames"); var files: string = if jsonfiles.size > 2*n then jsonfiles[0..#n]+'...'+jsonfiles[jsonfiles.size-n..#n] else jsonfiles; - var errorMsg = "Could not decode json filenames via tempfile (%i files: %s)".format(nfiles, files); + var errorMsg = "Could not decode json filenames via tempfile (%i files: %s)".doFormat(nfiles, files); pqLogger.error(getModuleName(),getRoutineName(),getLineNumber(),errorMsg); return new MsgTuple(errorMsg, MsgType.ERROR); } @@ -1869,9 +1870,9 @@ module ParquetMsg { } var tmp = glob(filelist[0]); pqLogger.debug(getModuleName(),getRoutineName(),getLineNumber(), - "glob expanded %s to %i files".format(filelist[0], tmp.size)); + "glob expanded %s to %i files".doFormat(filelist[0], tmp.size)); if tmp.size == 0 { - var errorMsg = "The wildcarded filename %s either corresponds to files inaccessible to Arkouda or files of an invalid format".format(filelist[0]); + var errorMsg = "The wildcarded filename %s either corresponds to files inaccessible to Arkouda or files of an invalid format".doFormat(filelist[0]); pqLogger.error(getModuleName(),getRoutineName(),getLineNumber(),errorMsg); return new MsgTuple(errorMsg, MsgType.ERROR); } @@ -1900,7 +1901,7 @@ module ParquetMsg { sizes[i] = getArrSize(fname); } catch e : Error { // This is only type of error thrown by Parquet - fileErrorMsg = "Other error in accessing file %s: %s".format(fname,e.message()); + fileErrorMsg = "Other error in accessing file %s: %s".doFormat(fname,e.message()); pqLogger.error(getModuleName(),getRoutineName(),getLineNumber(),fileErrorMsg); hadError = true; return new MsgTuple(fileErrorMsg, MsgType.ERROR); @@ -1925,7 +1926,7 @@ module ParquetMsg { st.addEntry(valName, entryVal); rnames.pushBack((dsetname, ObjType.PDARRAY, valName)); } else { - var errorMsg = "Null indices only supported on Parquet string columns, not {} columns".format(ty); + var errorMsg = "Null indices only supported on Parquet string columns, not %? columns".doFormat(ty); pqLogger.error(getModuleName(),getRoutineName(),getLineNumber(),errorMsg); return new MsgTuple(errorMsg, MsgType.ERROR); } diff --git a/src/RadixSortLSD.chpl b/src/RadixSortLSD.chpl index d1d96ea70c..51f6c61b2c 100644 --- a/src/RadixSortLSD.chpl +++ b/src/RadixSortLSD.chpl @@ -65,7 +65,7 @@ module RadixSortLSD */ private proc radixSortLSDCore(a:[?aD] ?t, nBits, negs, comparator) { try! rsLogger.debug(getModuleName(),getRoutineName(),getLineNumber(), - "type = %s nBits = %t".format(t:string,nBits)); + "type = %s nBits = %?".doFormat(t:string,nBits)); var temp = a; // create a global count array to scan @@ -76,7 +76,7 @@ module RadixSortLSD for rshift in {0..#nBits by bitsPerDigit} { const last = (rshift + bitsPerDigit) >= nBits; try! rsLogger.debug(getModuleName(),getRoutineName(),getLineNumber(), - "rshift = %t".format(rshift)); + "rshift = %?".doFormat(rshift)); // count digits coforall loc in Locales { on loc { diff --git a/src/RandMsg.chpl b/src/RandMsg.chpl index 0a91851c14..d32f56d97a 100644 --- a/src/RandMsg.chpl +++ b/src/RandMsg.chpl @@ -39,7 +39,7 @@ module RandMsg // if verbose print action randLogger.debug(getModuleName(),getRoutineName(),getLineNumber(), - "cmd: %s len: %i dtype: %s rname: %s aMin: %s: aMax: %s".format( + "cmd: %s len: %i dtype: %s rname: %s aMin: %s: aMax: %s".doFormat( cmd,len,dtype2str(dtype),rname,low.getValue(),high.getValue())); select (dtype) { when (DType.Int64) { @@ -49,12 +49,12 @@ module RandMsg var t1 = Time.timeSinceEpoch().totalSeconds(); var e = st.addEntry(rname, len, int); randLogger.debug(getModuleName(),getRoutineName(),getLineNumber(), - "alloc time = %i sec".format(Time.timeSinceEpoch().totalSeconds() - t1)); + "alloc time = %i sec".doFormat(Time.timeSinceEpoch().totalSeconds() - t1)); t1 = Time.timeSinceEpoch().totalSeconds(); fillInt(e.a, aMin, aMax, seed); randLogger.debug(getModuleName(),getRoutineName(),getLineNumber(), - "compute time = %i sec".format(Time.timeSinceEpoch().totalSeconds() - t1)); + "compute time = %i sec".doFormat(Time.timeSinceEpoch().totalSeconds() - t1)); } when (DType.UInt8) { overMemLimit(len); @@ -63,12 +63,12 @@ module RandMsg var t1 = Time.timeSinceEpoch().totalSeconds(); var e = st.addEntry(rname, len, uint(8)); randLogger.debug(getModuleName(),getRoutineName(),getLineNumber(), - "alloc time = %i sec".format(Time.timeSinceEpoch().totalSeconds() - t1)); + "alloc time = %i sec".doFormat(Time.timeSinceEpoch().totalSeconds() - t1)); t1 = Time.timeSinceEpoch().totalSeconds(); fillUInt(e.a, aMin, aMax, seed); randLogger.debug(getModuleName(),getRoutineName(),getLineNumber(), - "compute time = %i".format(Time.timeSinceEpoch().totalSeconds() - t1)); + "compute time = %i".doFormat(Time.timeSinceEpoch().totalSeconds() - t1)); } when (DType.UInt64) { overMemLimit(len); @@ -77,12 +77,12 @@ module RandMsg var t1 = Time.timeSinceEpoch().totalSeconds(); var e = st.addEntry(rname, len, uint); randLogger.debug(getModuleName(),getRoutineName(),getLineNumber(), - "alloc time = %i sec".format(Time.timeSinceEpoch().totalSeconds() - t1)); + "alloc time = %i sec".doFormat(Time.timeSinceEpoch().totalSeconds() - t1)); t1 = Time.timeSinceEpoch().totalSeconds(); fillUInt(e.a, aMin, aMax, seed); randLogger.debug(getModuleName(),getRoutineName(),getLineNumber(), - "compute time = %i".format(Time.timeSinceEpoch().totalSeconds() - t1)); + "compute time = %i".doFormat(Time.timeSinceEpoch().totalSeconds() - t1)); } when (DType.Float64) { overMemLimit(8*len); @@ -91,24 +91,24 @@ module RandMsg var t1 = Time.timeSinceEpoch().totalSeconds(); var e = st.addEntry(rname, len, real); randLogger.debug(getModuleName(),getRoutineName(),getLineNumber(), - "alloc time = %i sec".format(Time.timeSinceEpoch().totalSeconds() - t1)); + "alloc time = %i sec".doFormat(Time.timeSinceEpoch().totalSeconds() - t1)); t1 = Time.timeSinceEpoch().totalSeconds(); fillReal(e.a, aMin, aMax, seed); randLogger.debug(getModuleName(),getRoutineName(),getLineNumber(), - "compute time = %i sec".format(Time.timeSinceEpoch().totalSeconds() - t1)); + "compute time = %i sec".doFormat(Time.timeSinceEpoch().totalSeconds() - t1)); } when (DType.Bool) { overMemLimit(len); var t1 = Time.timeSinceEpoch().totalSeconds(); var e = st.addEntry(rname, len, bool); randLogger.debug(getModuleName(),getRoutineName(),getLineNumber(), - "alloc time = %i sec".format(Time.timeSinceEpoch().totalSeconds() - t1)); + "alloc time = %i sec".doFormat(Time.timeSinceEpoch().totalSeconds() - t1)); t1 = Time.timeSinceEpoch().totalSeconds(); fillBool(e.a, seed); randLogger.debug(getModuleName(),getRoutineName(),getLineNumber(), - "compute time = %i sec".format(Time.timeSinceEpoch().totalSeconds() - t1)); + "compute time = %i sec".doFormat(Time.timeSinceEpoch().totalSeconds() - t1)); } otherwise { var errorMsg = notImplementedError(pn,dtype); diff --git a/src/ReductionMsg.chpl b/src/ReductionMsg.chpl index dc5e38c135..b78d0bd80c 100644 --- a/src/ReductionMsg.chpl +++ b/src/ReductionMsg.chpl @@ -39,7 +39,7 @@ module ReductionMsg const reductionop = msgArgs.getValueOf("op"); const name = msgArgs.getValueOf("array"); rmLogger.debug(getModuleName(),getRoutineName(),getLineNumber(), - "cmd: %s reductionop: %s name: %s".format(cmd,reductionop,name)); + "cmd: %s reductionop: %s name: %s".doFormat(cmd,reductionop,name)); var gEnt: borrowed GenSymEntry = getGenericTypedArrayEntry(name, st); @@ -52,46 +52,46 @@ module ReductionMsg var val:string; var sum = + reduce (e.a != 0); if sum != 0 {val = "True";} else {val = "False";} - repMsg = "bool %s".format(val); + repMsg = "bool %s".doFormat(val); } when "all" { var val:string; var sum = + reduce (e.a != 0); if sum == e.a.domain.size {val = "True";} else {val = "False";} - repMsg = "bool %s".format(val); + repMsg = "bool %s".doFormat(val); } when "sum" { var val = + reduce e.a; - repMsg = "int64 %i".format(val); + repMsg = "int64 %i".doFormat(val); } when "prod" { // Cast to real to avoid int64 overflow var val = * reduce e.a:real; // Return value is always float64 for prod - repMsg = "float64 %.17r".format(val); + repMsg = "float64 %.17r".doFormat(val); } when "min" { var val = min reduce e.a; - repMsg = "int64 %i".format(val); + repMsg = "int64 %i".doFormat(val); } when "max" { var val = max reduce e.a; - repMsg = "int64 %i".format(val); + repMsg = "int64 %i".doFormat(val); } when "argmin" { var (minVal, minLoc) = minloc reduce zip(e.a,e.a.domain); - repMsg = "int64 %i".format(minLoc); + repMsg = "int64 %i".doFormat(minLoc); } when "argmax" { var (maxVal, maxLoc) = maxloc reduce zip(e.a,e.a.domain); - repMsg = "int64 %i".format(maxLoc); + repMsg = "int64 %i".doFormat(maxLoc); } when "is_sorted" { ref ea = e.a; var sorted = isSorted(ea); var val: string; if sorted {val = "True";} else {val = "False";} - repMsg = "bool %s".format(val); + repMsg = "bool %s".doFormat(val); } when "is_locally_sorted" { var locSorted: [LocaleSpace] bool; @@ -105,7 +105,7 @@ module ReductionMsg var val: string; if (& reduce locSorted) {val = "True";} else {val = "False";} - repMsg = "bool %s".format(val); + repMsg = "bool %s".doFormat(val); rmLogger.debug(getModuleName(),getRoutineName(),getLineNumber(),repMsg); return new MsgTuple(repMsg, MsgType.NORMAL); } @@ -122,36 +122,36 @@ module ReductionMsg { when "sum" { var val = + reduce e.a; - repMsg = "uint64 %i".format(val); + repMsg = "uint64 %i".doFormat(val); } when "prod" { // Cast to real to avoid int64 overflow var val = * reduce e.a:real; // Return value is always float64 for prod - repMsg = "float64 %.17r".format(val); + repMsg = "float64 %.17r".doFormat(val); } when "min" { var val = min reduce e.a; - repMsg = "uint64 %i".format(val); + repMsg = "uint64 %i".doFormat(val); } when "max" { var val = max reduce e.a; - repMsg = "uint64 %i".format(val); + repMsg = "uint64 %i".doFormat(val); } when "argmin" { var (minVal, minLoc) = minloc reduce zip(e.a,e.a.domain); - repMsg = "uint64 %i".format(minLoc); + repMsg = "uint64 %i".doFormat(minLoc); } when "argmax" { var (maxVal, maxLoc) = maxloc reduce zip(e.a,e.a.domain); - repMsg = "uint64 %i".format(maxLoc); + repMsg = "uint64 %i".doFormat(maxLoc); } when "is_sorted" { ref ea = e.a; var sorted = isSorted(ea); var val: string; if sorted {val = "True";} else {val = "False";} - repMsg = "bool %s".format(val); + repMsg = "bool %s".doFormat(val); } otherwise { var errorMsg = notImplementedError(pn,reductionop,gEnt.dtype); @@ -168,43 +168,43 @@ module ReductionMsg var val:string; var sum = + reduce (e.a != 0.0); if sum != 0.0 {val = "True";} else {val = "False";} - repMsg = "bool %s".format(val); + repMsg = "bool %s".doFormat(val); } when "all" { var val:string; var sum = + reduce (e.a != 0.0); if sum == e.a.domain.size {val = "True";} else {val = "False";} - repMsg = "bool %s".format(val); + repMsg = "bool %s".doFormat(val); } when "sum" { var val = + reduce e.a; - repMsg = "float64 %.17r".format(val); + repMsg = "float64 %.17r".doFormat(val); } when "prod" { var val = * reduce e.a; - repMsg = "float64 %.17r".format(val); + repMsg = "float64 %.17r".doFormat(val); } when "min" { var val = min reduce e.a; - repMsg = "float64 %.17r".format(val); + repMsg = "float64 %.17r".doFormat(val); } when "max" { var val = max reduce e.a; - repMsg = "float64 %.17r".format(val); + repMsg = "float64 %.17r".doFormat(val); } when "argmin" { var (minVal, minLoc) = minloc reduce zip(e.a,e.a.domain); - repMsg = "int64 %i".format(minLoc); + repMsg = "int64 %i".doFormat(minLoc); } when "argmax" { var (maxVal, maxLoc) = maxloc reduce zip(e.a,e.a.domain); - repMsg = "int64 %i".format(maxLoc); + repMsg = "int64 %i".doFormat(maxLoc); } when "is_sorted" { var sorted = isSorted(e.a); var val:string; if sorted {val = "True";} else {val = "False";} - repMsg = "bool %s".format(val); + repMsg = "bool %s".doFormat(val); } otherwise { var errorMsg = notImplementedError(pn,reductionop,gEnt.dtype); @@ -221,39 +221,39 @@ module ReductionMsg var val:string; var any = | reduce e.a; if any {val = "True";} else {val = "False";} - repMsg = "bool %s".format(val); + repMsg = "bool %s".doFormat(val); } when "all" { var val:string; var all = & reduce e.a; if all {val = "True";} else {val = "False";} - repMsg = "bool %s".format(val); + repMsg = "bool %s".doFormat(val); } when "sum" { var val = + reduce e.a:int; - repMsg = "int64 %i".format(val); + repMsg = "int64 %i".doFormat(val); } when "prod" { var val = * reduce e.a:int; - repMsg = "int64 %i".format(val); + repMsg = "int64 %i".doFormat(val); } when "min" { var val:string; if (& reduce e.a) { val = "True"; } else { val = "False"; } - repMsg = "bool %s".format(val); + repMsg = "bool %s".doFormat(val); } when "max" { var val:string; if (| reduce e.a) { val = "True"; } else { val = "False"; } - repMsg = "bool %s".format(val); + repMsg = "bool %s".doFormat(val); } when "argmax" { var (maxVal, maxLoc) = maxloc reduce zip(e.a,e.a.domain); - repMsg = "int64 %i".format(maxLoc); + repMsg = "int64 %i".doFormat(maxLoc); } when "argmin" { var (minVal, minLoc) = minloc reduce zip(e.a,e.a.domain); - repMsg = "int64 %i".format(minLoc); + repMsg = "int64 %i".doFormat(minLoc); } otherwise { var errorMsg = notImplementedError(pn,reductionop,gEnt.dtype); @@ -280,7 +280,7 @@ module ReductionMsg const size = msgArgs.get("size").getIntValue(); var rname = st.nextName(); rmLogger.debug(getModuleName(),getRoutineName(),getLineNumber(), - "cmd: %s segments_name: %s size: %s".format(cmd,segments_name, size)); + "cmd: %s segments_name: %s size: %s".doFormat(cmd,segments_name, size)); var gSeg: borrowed GenSymEntry = getGenericTypedArrayEntry(segments_name, st); var segments = toSymEntry(gSeg, int); @@ -350,7 +350,7 @@ module ReductionMsg var rname = st.nextName(); rmLogger.debug(getModuleName(),getRoutineName(),getLineNumber(), - "cmd: %s values_name: %s segments_name: %s operator: %s skipNan: %s".format( + "cmd: %s values_name: %s segments_name: %s operator: %s skipNan: %s".doFormat( cmd,values_name,segments_name,op,skipNan)); var gVal: borrowed GenSymEntry = getGenericTypedArrayEntry(values_name, st); var gSeg: borrowed GenSymEntry = getGenericTypedArrayEntry(segments_name, st); @@ -1348,7 +1348,7 @@ module ReductionMsg valsAgg.copy(kvi1, values[idx]); } rmLogger.debug(getModuleName(),getRoutineName(),getLineNumber(), - "sort time = %i".format(Time.timeSinceEpoch().totalSeconds() - t1)); + "sort time = %i".doFormat(Time.timeSinceEpoch().totalSeconds() - t1)); rmLogger.debug(getModuleName(),getRoutineName(),getLineNumber(), "Finding unique (key, value) pairs..."); var truth: [kD] bool; @@ -1375,7 +1375,7 @@ module ReductionMsg } } rmLogger.debug(getModuleName(),getRoutineName(),getLineNumber(), - "time = %i".format(Time.timeSinceEpoch().totalSeconds() - t1)); + "time = %i".doFormat(Time.timeSinceEpoch().totalSeconds() - t1)); rmLogger.debug(getModuleName(),getRoutineName(),getLineNumber(), "Finding unique keys and num unique vals per key."); // find steps in keys @@ -1413,7 +1413,7 @@ module ReductionMsg } } rmLogger.debug(getModuleName(),getRoutineName(),getLineNumber(), - "time = %i".format(Time.timeSinceEpoch().totalSeconds() - t1)); + "time = %i".doFormat(Time.timeSinceEpoch().totalSeconds() - t1)); return res; } diff --git a/src/RegistrationMsg.chpl b/src/RegistrationMsg.chpl index 71675bc114..83d1b2b0f7 100644 --- a/src/RegistrationMsg.chpl +++ b/src/RegistrationMsg.chpl @@ -20,6 +20,8 @@ module RegistrationMsg use Map; + use ArkoudaIOCompat; + private config const logLevel = ServerConfig.logLevel; private config const logChannel = ServerConfig.logChannel; const regLogger = new Logger(logLevel, logChannel); @@ -45,7 +47,7 @@ module RegistrationMsg // if verbose print action regLogger.debug(getModuleName(),getRoutineName(),getLineNumber(), - "cmd: %s name: %s userDefinedName: %s".format(cmd,name,userDefinedName)); + "cmd: %s name: %s userDefinedName: %s".doFormat(cmd,name,userDefinedName)); // register new user_defined_name for name var msgTuple:MsgTuple; @@ -55,7 +57,7 @@ module RegistrationMsg regLogger.debug(getModuleName(),getRoutineName(),getLineNumber(),repMsg); msgTuple = new MsgTuple(repMsg, MsgType.NORMAL); } catch e: ArgumentError { - repMsg = "Error: requested name '%s' was already in use.".format(userDefinedName); + repMsg = "Error: requested name '%s' was already in use.".doFormat(userDefinedName); regLogger.error(getModuleName(),getRoutineName(),getLineNumber(),repMsg); msgTuple = new MsgTuple(repMsg, MsgType.ERROR); } @@ -87,13 +89,13 @@ module RegistrationMsg // if verbose print action regLogger.debug(getModuleName(),getRoutineName(),getLineNumber(), - "%s %s".format(cmd,name)); + "%s %s".doFormat(cmd,name)); // lookup name in symbol table to get attributes var attrib = st.attrib(name); regLogger.debug(getModuleName(),getRoutineName(),getLineNumber(), - "requested attrib: %s".format(attrib)); + "requested attrib: %s".doFormat(attrib)); // response message if (attrib.startsWith("Error:")) { @@ -102,14 +104,14 @@ module RegistrationMsg return new MsgTuple(errorMsg, MsgType.ERROR); } else { if objType == ObjType.UNKNOWN || objType == ObjType.STRINGS || objType == ObjType.PDARRAY { - repMsg = "created %s".format(attrib); + repMsg = "created %s".doFormat(attrib); if (isStringAttrib(attrib)) { var s = getSegString(name, st); - repMsg += "+created bytes.size %t".format(s.nBytes); + repMsg += "+created bytes.size %?".doFormat(s.nBytes); } } else { - var errorMsg = "Error: Unkown object type passed to attachMsg - %s".format(objType); + var errorMsg = "Error: Unkown object type passed to attachMsg - %s".doFormat(objType); regLogger.error(getModuleName(),getRoutineName(),getLineNumber(),errorMsg); return new MsgTuple(errorMsg, MsgType.ERROR); } @@ -135,13 +137,13 @@ module RegistrationMsg proc attachCategoricalMsg(cmd: string, name: string, st: borrowed SymTab): MsgTuple throws { regLogger.debug(getModuleName(),getRoutineName(),getLineNumber(), - "%s: Collecting Categorical components for '%s'".format(cmd, name)); + "%s: Collecting Categorical components for '%s'".doFormat(cmd, name)); var rtnMap: map(string, string); - var cats = st.attrib("%s.categories".format(name)); - var codes = st.attrib("%s.codes".format(name)); - var naCode = st.attrib("%s._akNAcode".format(name)); + var cats = st.attrib("%s.categories".doFormat(name)); + var codes = st.attrib("%s.codes".doFormat(name)); + var naCode = st.attrib("%s._akNAcode".doFormat(name)); if (cats.startsWith("Error:")) { var errorMsg = cats; @@ -161,16 +163,16 @@ module RegistrationMsg // categories should always be string, add bytes for string return message if (isStringAttrib(cats)) { - var s = getSegString("%s.categories".format(name), st); - rtnMap.add("categories", "created %s+created %t".format(st.attrib(s.name), s.nBytes)); + var s = getSegString("%s.categories".doFormat(name), st); + rtnMap.add("categories", "created %s+created %?".doFormat(st.attrib(s.name), s.nBytes)); } rtnMap.add("codes", "created " + codes); rtnMap.add("_akNAcode", "created " + naCode); // Optional components of categorical - if st.contains("%s.permutation".format(name)) { - var perm = st.attrib("%s.permutation".format(name)); + if st.contains("%s.permutation".doFormat(name)) { + var perm = st.attrib("%s.permutation".doFormat(name)); if (perm.startsWith("Error:")) { var errorMsg = perm; regLogger.error(getModuleName(),getRoutineName(),getLineNumber(),errorMsg); @@ -178,8 +180,8 @@ module RegistrationMsg } rtnMap.add("permutation", "created " + perm); } - if st.contains("%s.segments".format(name)) { - var segs = st.attrib("%s.segments".format(name)); + if st.contains("%s.segments".doFormat(name)) { + var segs = st.attrib("%s.segments".doFormat(name)); if (segs.startsWith("Error:")) { var errorMsg = segs; regLogger.error(getModuleName(),getRoutineName(),getLineNumber(),errorMsg); @@ -188,7 +190,7 @@ module RegistrationMsg rtnMap.add("segments", "created " + segs); } - var repMsg: string = "categorical+%s+%jt".format(name, rtnMap); + var repMsg: string = "categorical+%s+".doFormat(name)+formatJson(rtnMap); return new MsgTuple(repMsg, MsgType.NORMAL); } @@ -209,15 +211,15 @@ module RegistrationMsg */ proc attachSeriesMsg(cmd: string, name: string, st: borrowed SymTab): MsgTuple throws { regLogger.debug(getModuleName(),getRoutineName(),getLineNumber(), - "%s: Collecting Series components for '%s'".format(cmd, name)); + "%s: Collecting Series components for '%s'".doFormat(cmd, name)); var repMsg: string; var ind = ""; // if Series matches MultiIndex format - if st.contains("%s_key_0".format(name)) { - var nameList = st.findAll("%s_key_\\d".format(name)); + if st.contains("%s_key_0".doFormat(name)) { + var nameList = st.findAll("%s_key_\\d".doFormat(name)); sort(nameList); for regName in nameList { var entry = st.attrib(regName); @@ -226,27 +228,27 @@ module RegistrationMsg regLogger.error(getModuleName(),getRoutineName(),getLineNumber(),errorMsg); return new MsgTuple(errorMsg, MsgType.ERROR); } - ind += "+created %s".format(entry); + ind += "+created %s".doFormat(entry); } } else { // Series only contains one key for index - ind = st.attrib("%s_key".format(name)); + ind = st.attrib("%s_key".doFormat(name)); if (ind.startsWith("Error:")) { var errorMsg = ind; regLogger.error(getModuleName(),getRoutineName(),getLineNumber(),errorMsg); return new MsgTuple(errorMsg, MsgType.ERROR); } - ind = "+created %s".format(ind); + ind = "+created %s".doFormat(ind); } - var vals = st.attrib("%s_value".format(name)); + var vals = st.attrib("%s_value".doFormat(name)); if (vals.startsWith("Error:")) { var errorMsg = vals; regLogger.error(getModuleName(),getRoutineName(),getLineNumber(),errorMsg); return new MsgTuple(errorMsg, MsgType.ERROR); } - repMsg = "series+created %s%s".format(vals, ind); + repMsg = "series+created %s%s".doFormat(vals, ind); return new MsgTuple(repMsg, MsgType.NORMAL); } @@ -271,20 +273,20 @@ module RegistrationMsg proc attachDataFrameMsg(cmd: string, msgArgs: borrowed MessageArgs, st: borrowed SymTab): MsgTuple throws { const name = msgArgs.getValueOf("name"); - var colName = "df_columns_%s".format(name); - var repMsg = "dataframe+%s".format(name); + var colName = "df_columns_%s".doFormat(name); + var repMsg = "dataframe+%s".doFormat(name); regLogger.debug(getModuleName(),getRoutineName(),getLineNumber(), - "%s: Collecting DataFrame components for '%s'".format(cmd, name)); + "%s: Collecting DataFrame components for '%s'".doFormat(cmd, name)); var jsonParam = new ParameterObj("name", colName, ObjectType.VALUE, "str"); var subArgs1 = new MessageArgs(new list([jsonParam, ])); // Add columns as a json list var cols = stringsToJSONMsg(cmd, subArgs1, st).msg; - repMsg += "+json %s".format(cols); + repMsg += "+json %s".doFormat(cols); // Get index - var indParam = new ParameterObj("name", "df_index_%s_key".format(name), ObjectType.VALUE, ""); + var indParam = new ParameterObj("name", "df_index_%s_key".doFormat(name), ObjectType.VALUE, ""); var subArgs2 = new MessageArgs(new list([indParam, ])); var ind = attachMsg(cmd, subArgs2, st).msg; if ind.startsWith("Error:") { @@ -292,13 +294,13 @@ module RegistrationMsg regLogger.error(getModuleName(),getRoutineName(),getLineNumber(),errorMsg); return new MsgTuple(errorMsg, MsgType.ERROR); } - repMsg += "+%s".format(ind); + repMsg += "+%s".doFormat(ind); // Get column data - var nameList = st.findAll("df_data_(pdarray|str|SegArray|Categorical)_.*_%s".format(name)); + var nameList = st.findAll("df_data_(pdarray|str|SegArray|Categorical)_.*_%s".doFormat(name)); if nameList.size == 1 && nameList[0] == "" { - var errorMsg = "No data values found for DataFrame %s".format(name); + var errorMsg = "No data values found for DataFrame %s".doFormat(name); regLogger.error(getModuleName(),getRoutineName(),getLineNumber(),errorMsg); return new MsgTuple(errorMsg, MsgType.ERROR); } @@ -307,7 +309,7 @@ module RegistrationMsg var u : set(string) = new set(string, nameList); regLogger.debug(getModuleName(),getRoutineName(),getLineNumber(), - "%s: Data components found for dataframe: '%jt'".format(cmd, u)); + "%s: Data components found for dataframe: '".doFormat(cmd)+formatJson(u)+"'"); // Use existing attach functionality to build the response message based on the objType of each data column forall regName in u with (+ reduce repMsg) { @@ -334,7 +336,7 @@ module RegistrationMsg var attParam3 = new ParameterObj("name", regName+"_lengths", ObjectType.VALUE, ""); var subArgs3 = new MessageArgs(new list([attParam3, ])); sa_map.add("lengths", attachMsg(cmd, subArgs3, st).msg); - msg = "segarray+%jt".format(sa_map); + msg = "segarray+"+formatJson(sa_map); } when (ObjType.STRINGS) { var attParam = new ParameterObj("name", regName, ObjectType.VALUE, ""); @@ -347,10 +349,10 @@ module RegistrationMsg otherwise { regLogger.warn(getModuleName(),getRoutineName(),getLineNumber(), "Unsupported column type found in DataFrame: '%s'. \ - Supported types are: pdarray, str, Categorical, and SegArray".format(objtype)); + Supported types are: pdarray, str, Categorical, and SegArray".doFormat(objtype)); throw getErrorWithContext( - msg="Unknown column type (%s) found in DataFrame: %s".format(objtype, name), + msg="Unknown column type (%s) found in DataFrame: %s".doFormat(objtype, name), lineNumber=getLineNumber(), routineName=getRoutineName(), moduleName=getModuleName(), @@ -363,7 +365,7 @@ module RegistrationMsg regLogger.error(getModuleName(),getRoutineName(),getLineNumber(),msg); repMsg = msg; } else { - repMsg += "+%s".format(msg); + repMsg += "+%s".doFormat(msg); } } @@ -386,7 +388,7 @@ module RegistrationMsg proc findType(cmd: string, name: string, st: borrowed SymTab): string throws { // Try to determine the type from the entries in the symbol table regLogger.debug(getModuleName(),getRoutineName(),getLineNumber(), - "Attempting to find type of registered element '%s'".format(name)); + "Attempting to find type of registered element '%s'".doFormat(name)); var objtype: string; @@ -395,18 +397,18 @@ module RegistrationMsg var entry = st.lookup(name); // pdarray or Strings objtype = "simple"; - } else if st.contains("%s.categories".format(name)) && st.contains("%s.codes".format(name)) { + } else if st.contains("%s.categories".doFormat(name)) && st.contains("%s.codes".doFormat(name)) { objtype = "categorical"; - } else if st.contains("%s_value".format(name)) && (st.contains("%s_key".format(name)) || st.contains("%s_key_0".format(name))) { + } else if st.contains("%s_value".doFormat(name)) && (st.contains("%s_key".doFormat(name)) || st.contains("%s_key_0".doFormat(name))) { objtype = "series"; - } else if st.contains("df_columns_%s".format(name)) && (st.contains("df_index_%s_key".format(name))) { + } else if st.contains("df_columns_%s".doFormat(name)) && (st.contains("df_index_%s_key".doFormat(name))) { objtype = "dataframe"; - } else if st.contains("%s_segments".format(name)) && st.contains("%s_values".format(name)) { + } else if st.contains("%s_segments".doFormat(name)) && st.contains("%s_values".doFormat(name)) { objtype = "segarray"; } else { throw getErrorWithContext( - msg="Unable to determine type for given name: %s".format(name), + msg="Unable to determine type for given name: %s".doFormat(name), lineNumber=getLineNumber(), routineName=getRoutineName(), moduleName=getModuleName(), @@ -415,7 +417,7 @@ module RegistrationMsg } regLogger.debug(getModuleName(),getRoutineName(),getLineNumber(), - "Type determined to be: '%s'".format(objtype)); + "Type determined to be: '%s'".doFormat(objtype)); return objtype; } @@ -455,7 +457,7 @@ module RegistrationMsg var aRet = attachMsg(cmd, msgArgs, st); var msg = aRet.msg; var msgType = aRet.msgType; - repMsg = "simple+%s".format(msg); + repMsg = "simple+%s".doFormat(msg); return new MsgTuple(repMsg, msgType); } when ("categorical") { @@ -484,14 +486,14 @@ module RegistrationMsg var subArgs3 = new MessageArgs(new list([attParam3, ])); sa_map.add("lengths", attachMsg(cmd, subArgs3, st).msg); - return new MsgTuple("segarray+%jt".format(sa_map), MsgType.NORMAL); + return new MsgTuple("segarray+"+formatJson(sa_map), MsgType.NORMAL); } otherwise { regLogger.warn(getModuleName(),getRoutineName(),getLineNumber(), - "Unsupported type provided: '%s'. Supported types are: pdarray, strings, categorical, segarray, series, and dataframe".format(dtype)); + "Unsupported type provided: '%s'. Supported types are: pdarray, strings, categorical, segarray, series, and dataframe".doFormat(dtype)); throw getErrorWithContext( - msg="Unknown type (%s) supplied for given name: %s".format(dtype, name), + msg="Unknown type (%s) supplied for given name: %s".doFormat(dtype, name), lineNumber=getLineNumber(), routineName=getRoutineName(), moduleName=getModuleName(), @@ -530,7 +532,7 @@ module RegistrationMsg // if verbose print action regLogger.debug(getModuleName(),getRoutineName(),getLineNumber(), - "%s %s".format(cmd,name)); + "%s %s".doFormat(cmd,name)); // take name out of the registry st.unregName(name); @@ -562,15 +564,15 @@ module RegistrationMsg when ("categorical") { // Create an array with 5 strings, one for each component of categorical, and assign the names var nameList: [0..4] string; - nameList[0] = "%s.categories".format(name); - nameList[1] = "%s.codes".format(name); - nameList[2] = "%s._akNAcode".format(name); + nameList[0] = "%s.categories".doFormat(name); + nameList[1] = "%s.codes".doFormat(name); + nameList[2] = "%s._akNAcode".doFormat(name); - if st.contains("%s.permutation".format(name)) { - nameList[3] = "%s.permutation".format(name); + if st.contains("%s.permutation".doFormat(name)) { + nameList[3] = "%s.permutation".doFormat(name); } - if st.contains("%s.segments".format(name)) { - nameList[4] = "%s.segments".format(name); + if st.contains("%s.segments".doFormat(name)) { + nameList[4] = "%s.segments".doFormat(name); } var base_json = msgArgs.get("name"); @@ -581,7 +583,7 @@ module RegistrationMsg base_json.setVal(n); var subArgs = new MessageArgs(new list([base_json, ])); var resp = unregisterMsg(cmd, subArgs, st); - status += " %s: %s ".format(n, resp.msg); + status += " %s: %s ".doFormat(n, resp.msg); } } } @@ -590,18 +592,18 @@ module RegistrationMsg var nameStr = ""; // MultiIndex - if st.contains("%s_key_0".format(name)) { + if st.contains("%s_key_0".doFormat(name)) { // Get an array of all the multi-index parts - var indexList = st.findAll("%s_key_\\d".format(name)); + var indexList = st.findAll("%s_key_\\d".doFormat(name)); // Convert the array into a + delimited string nameStr = "+".join(indexList); } else { // Single index // Add the name of the single key to the name String - nameStr = "%s_key".format(name); + nameStr = "%s_key".doFormat(name); } // Add the name of the values to the name String - nameStr += "+%s_value".format(name); + nameStr += "+%s_value".doFormat(name); // Convert the string back into an array for looping var nameList = nameStr.split("+"); @@ -610,15 +612,15 @@ module RegistrationMsg base_json.setVal(n); var subArgs = new MessageArgs(new list([base_json, ])); var resp = unregisterMsg(cmd, subArgs, st); - status += " %s: %s ".format(n, resp.msg); + status += " %s: %s ".doFormat(n, resp.msg); } } otherwise { regLogger.warn(getModuleName(),getRoutineName(),getLineNumber(), - "Unsupported type provided: '%s'. Supported types are: pdarray, strings, categorical, segarray and series".format(dtype)); + "Unsupported type provided: '%s'. Supported types are: pdarray, strings, categorical, segarray and series".doFormat(dtype)); throw getErrorWithContext( - msg="Unknown type (%s) supplied for given name: %s".format(dtype, name), + msg="Unknown type (%s) supplied for given name: %s".doFormat(dtype, name), lineNumber=getLineNumber(), routineName=getRoutineName(), moduleName=getModuleName(), diff --git a/src/SegStringSort.chpl b/src/SegStringSort.chpl index b546a1169c..f9e75a25d3 100644 --- a/src/SegStringSort.chpl +++ b/src/SegStringSort.chpl @@ -39,14 +39,14 @@ module SegStringSort { var t = timeSinceEpoch().totalSeconds(); const lengths = ss.getLengths(); ssLogger.debug(getModuleName(),getRoutineName(),getLineNumber(), - "Found lengths in %t seconds".format(timeSinceEpoch().totalSeconds() - t)); + "Found lengths in %? seconds".doFormat(timeSinceEpoch().totalSeconds() - t)); t = timeSinceEpoch().totalSeconds(); // Compute length survival function and choose a pivot length const (pivot, nShort) = getPivot(lengths); ssLogger.debug(getModuleName(),getRoutineName(),getLineNumber(), - "Computed pivot in %t seconds".format(timeSinceEpoch().totalSeconds() - t)); + "Computed pivot in %? seconds".doFormat(timeSinceEpoch().totalSeconds() - t)); ssLogger.debug(getModuleName(),getRoutineName(),getLineNumber(), - "Pivot = %t, nShort = %t".format(pivot, nShort)); + "Pivot = %?, nShort = %?".doFormat(pivot, nShort)); t = timeSinceEpoch().totalSeconds(); const longStart = ss.offsets.a.domain.low + nShort; const isLong = (lengths >= pivot); @@ -65,7 +65,7 @@ module SegStringSort { } } ssLogger.debug(getModuleName(),getRoutineName(),getLineNumber(), - "Partitioned short/long strings in %t seconds".format(timeSinceEpoch().totalSeconds() - t)); + "Partitioned short/long strings in %? seconds".doFormat(timeSinceEpoch().totalSeconds() - t)); on Locales[Locales.domain.high] { var tl = timeSinceEpoch().totalSeconds(); const ref highDom = {longStart..ss.offsets.a.domain.high}; @@ -74,14 +74,14 @@ module SegStringSort { var stringsWithInds = gatherLongStrings(ss, lengths, highInds); ssLogger.debug(getModuleName(),getRoutineName(),getLineNumber(), - "Gathered long strings in %t seconds".format(timeSinceEpoch().totalSeconds() - tl)); + "Gathered long strings in %? seconds".doFormat(timeSinceEpoch().totalSeconds() - tl)); tl = timeSinceEpoch().totalSeconds(); // Sort the strings, but bring the inds along for the ride const myComparator = new StringIntComparator(); sort(stringsWithInds, comparator=myComparator); ssLogger.debug(getModuleName(),getRoutineName(),getLineNumber(), - "Sorted long strings in %t seconds".format(timeSinceEpoch().totalSeconds() - tl)); + "Sorted long strings in %? seconds".doFormat(timeSinceEpoch().totalSeconds() - tl)); tl = timeSinceEpoch().totalSeconds(); forall (h, s) in zip(highDom, stringsWithInds.domain) with (var agg = newDstAggregator(int)) { @@ -89,12 +89,12 @@ module SegStringSort { agg.copy(gatherInds[h], val); } ssLogger.debug(getModuleName(),getRoutineName(),getLineNumber(), - "Permuted long inds in %t seconds".format(timeSinceEpoch().totalSeconds() - tl)); + "Permuted long inds in %? seconds".doFormat(timeSinceEpoch().totalSeconds() - tl)); } t = timeSinceEpoch().totalSeconds(); const ranks = radixSortLSD_raw(ss.offsets.a, lengths, ss.values.a, gatherInds, pivot); ssLogger.debug(getModuleName(),getRoutineName(),getLineNumber(), - "Sorted ranks in %t seconds".format(timeSinceEpoch().totalSeconds() - t)); + "Sorted ranks in %? seconds".doFormat(timeSinceEpoch().totalSeconds() - t)); return ranks; } @@ -231,7 +231,7 @@ module SegStringSort { // loop over digits for rshift in {2..#pivot by 2} { - ssLogger.debug(getModuleName(),getRoutineName(),getLineNumber(),"rshift = %t".format(rshift)); + ssLogger.debug(getModuleName(),getRoutineName(),getLineNumber(),"rshift = %?".doFormat(rshift)); // count digits coforall loc in Locales { on loc { diff --git a/src/SegmentedComputation.chpl b/src/SegmentedComputation.chpl index 71646e31f6..6646cceb68 100644 --- a/src/SegmentedComputation.chpl +++ b/src/SegmentedComputation.chpl @@ -119,7 +119,7 @@ module SegmentedComputation { } } } catch { - throw new owned ErrorWithContext("Error computing %s on string or segment".format(function:string), + throw new owned ErrorWithContext("Error computing %s on string or segment".doFormat(function:string), getLineNumber(), getRoutineName(), getModuleName(), @@ -171,7 +171,7 @@ module SegmentedComputation { } } } catch { - throw new owned ErrorWithContext("Error computing %s on string or segment".format(function:string), + throw new owned ErrorWithContext("Error computing %s on string or segment".doFormat(function:string), getLineNumber(), getRoutineName(), getModuleName(), diff --git a/src/SegmentedMsg.chpl b/src/SegmentedMsg.chpl index 4a8bdac1b5..3d7cf9a130 100644 --- a/src/SegmentedMsg.chpl +++ b/src/SegmentedMsg.chpl @@ -18,6 +18,7 @@ module SegmentedMsg { use Map; use ArkoudaStringBytesCompat; use ArkoudaCTypesCompat; + use ArkoudaIOCompat; private config const logLevel = ServerConfig.logLevel; private config const logChannel = ServerConfig.logChannel; @@ -34,7 +35,7 @@ module SegmentedMsg { const offsetsName = msgArgs.getValueOf("offsets"); const valuesName = msgArgs.getValueOf("values"); smLogger.debug(getModuleName(),getRoutineName(),getLineNumber(), - "cmd: %s offsetsName: %s valuesName: %s".format(cmd, offsetsName, valuesName)); + "cmd: %s offsetsName: %s valuesName: %s".doFormat(cmd, offsetsName, valuesName)); st.checkTable(offsetsName); st.checkTable(valuesName); var offsets = getGenericTypedArrayEntry(offsetsName, st); @@ -47,7 +48,7 @@ module SegmentedMsg { // st.deleteEntry(valuesName); // Now return msg binding our newly created SegString object - var repMsg = "created " + st.attrib(segString.name) + "+created bytes.size %t".format(segString.nBytes); + var repMsg = "created " + st.attrib(segString.name) + "+created bytes.size %?".doFormat(segString.nBytes); smLogger.debug(getModuleName(), getRoutineName(), getLineNumber(), repMsg); return new MsgTuple(repMsg, MsgType.NORMAL); } @@ -60,7 +61,7 @@ module SegmentedMsg { } else if (comp == "values") { return _tondarrayMsg(entry.values); } else { - var msg = "Unrecognized component: %s".format(comp); + var msg = "Unrecognized component: %s".doFormat(comp); smLogger.error(getModuleName(),getRoutineName(),getLineNumber(), msg); return msg.encode(); } @@ -92,7 +93,7 @@ module SegmentedMsg { } else if entry.dtype == DType.BigInt { arrayBytes = distArrToBytes(toSymEntry(entry, bigint).a); } else { - var errorMsg = "Error: Unhandled dtype %s".format(entry.dtype); + var errorMsg = "Error: Unhandled dtype %s".doFormat(entry.dtype); smLogger.error(getModuleName(),getRoutineName(),getLineNumber(),errorMsg); return errorMsg.encode(); // return as bytes } @@ -115,7 +116,7 @@ module SegmentedMsg { overMemLimit(8*len + 16*len + (maxLen + minLen)*len); var (segs, vals) = newRandStringsUniformLength(len, minLen, maxLen, charset, seedStr); var strings = getSegString(segs, vals, st); - repMsg = 'created ' + st.attrib(strings.name) + '+created bytes.size %t'.format(strings.nBytes); + repMsg = 'created ' + st.attrib(strings.name) + '+created bytes.size %?'.doFormat(strings.nBytes); } when "lognormal" { var logMean = msgArgs.get("arg1").getRealValue(); @@ -124,7 +125,7 @@ module SegmentedMsg { overMemLimit(8*len + 16*len + exp(logMean + (logStd**2)/2):int*len); var (segs, vals) = newRandStringsLogNormalLength(len, logMean, logStd, charset, seedStr); var strings = getSegString(segs, vals, st); - repMsg = 'created ' + st.attrib(strings.name) + '+created bytes.size %t'.format(strings.nBytes); + repMsg = 'created ' + st.attrib(strings.name) + '+created bytes.size %?'.doFormat(strings.nBytes); } otherwise { var errorMsg = notImplementedError(pn, dist); @@ -148,7 +149,7 @@ module SegmentedMsg { var rname = st.nextName(); smLogger.debug(getModuleName(),getRoutineName(),getLineNumber(), - "cmd: %s objtype: %t name: %t".format( + "cmd: %s objtype: %? name: %?".doFormat( cmd,objtype,name)); select objtype { @@ -159,7 +160,7 @@ module SegmentedMsg { lengths.a = strings.getLengths() - 1; } otherwise { - var errorMsg = notImplementedError(pn, "%s".format(objtype)); + var errorMsg = notImplementedError(pn, "%s".doFormat(objtype)); smLogger.error(getModuleName(),getRoutineName(),getLineNumber(),errorMsg); return new MsgTuple(errorMsg, MsgType.ERROR); } @@ -178,7 +179,7 @@ module SegmentedMsg { var genSym = toGenSymEntry(st.lookup(name)); if genSym.dtype != DType.Strings{ - var errorMsg = notImplementedError(pn, "%s".format(dtype2str(genSym.dtype))); + var errorMsg = notImplementedError(pn, "%s".doFormat(dtype2str(genSym.dtype))); smLogger.error(getModuleName(),getRoutineName(),getLineNumber(),errorMsg); return new MsgTuple(errorMsg, MsgType.ERROR); } @@ -216,7 +217,7 @@ module SegmentedMsg { st.checkTable(name); var rname = st.nextName(); - smLogger.debug(getModuleName(),getRoutineName(),getLineNumber(),"cmd: %s objtype: %t name: %t".format(cmd,objtype,name)); + smLogger.debug(getModuleName(),getRoutineName(),getLineNumber(),"cmd: %s objtype: %? name: %?".doFormat(cmd,objtype,name)); select objtype { when ObjType.STRINGS { @@ -225,27 +226,27 @@ module SegmentedMsg { when "toLower" { var (off, val) = strings.lower(); var retString = getSegString(off, val, st); - repMsg = "created " + st.attrib(retString.name) + "+created bytes.size %t".format(retString.nBytes); + repMsg = "created " + st.attrib(retString.name) + "+created bytes.size %?".doFormat(retString.nBytes); } when "toUpper" { var (off, val) = strings.upper(); var retString = getSegString(off, val, st); - repMsg = "created " + st.attrib(retString.name) + "+created bytes.size %t".format(retString.nBytes); + repMsg = "created " + st.attrib(retString.name) + "+created bytes.size %?".doFormat(retString.nBytes); } when "toTitle" { var (off, val) = strings.title(); var retString = getSegString(off, val, st); - repMsg = "created " + st.attrib(retString.name) + "+created bytes.size %t".format(retString.nBytes); + repMsg = "created " + st.attrib(retString.name) + "+created bytes.size %?".doFormat(retString.nBytes); } otherwise { - var errorMsg = notImplementedError(pn, "%s".format(subcmd)); + var errorMsg = notImplementedError(pn, "%s".doFormat(subcmd)); smLogger.error(getModuleName(),getRoutineName(),getLineNumber(),errorMsg); return new MsgTuple(errorMsg, MsgType.ERROR); } } } otherwise { - var errorMsg = notImplementedError(pn, "%s".format(objtype)); + var errorMsg = notImplementedError(pn, "%s".doFormat(objtype)); smLogger.error(getModuleName(),getRoutineName(),getLineNumber(),errorMsg); return new MsgTuple(errorMsg, MsgType.ERROR); } @@ -265,7 +266,7 @@ module SegmentedMsg { st.checkTable(name); var rname = st.nextName(); - smLogger.debug(getModuleName(),getRoutineName(),getLineNumber(),"cmd: %s objtype: %t name: %t".format(cmd,objtype,name)); + smLogger.debug(getModuleName(),getRoutineName(),getLineNumber(),"cmd: %s objtype: %? name: %?".doFormat(cmd,objtype,name)); select objtype { when ObjType.STRINGS { @@ -285,14 +286,14 @@ module SegmentedMsg { repMsg = "created "+st.attrib(rname); } otherwise { - var errorMsg = notImplementedError(pn, "%s".format(subcmd)); + var errorMsg = notImplementedError(pn, "%s".doFormat(subcmd)); smLogger.error(getModuleName(),getRoutineName(),getLineNumber(),errorMsg); return new MsgTuple(errorMsg, MsgType.ERROR); } } } otherwise { - var errorMsg = notImplementedError(pn, "%s".format(objtype)); + var errorMsg = notImplementedError(pn, "%s".doFormat(objtype)); smLogger.error(getModuleName(),getRoutineName(),getLineNumber(),errorMsg); return new MsgTuple(errorMsg, MsgType.ERROR); } @@ -314,7 +315,7 @@ module SegmentedMsg { var rname = st.nextName(); smLogger.debug(getModuleName(),getRoutineName(),getLineNumber(), - "cmd: %s objtype: %t valtype: %t".format( + "cmd: %s objtype: %? valtype: %?".doFormat( cmd,objtype,valtype)); select (objtype, valtype) { @@ -325,7 +326,7 @@ module SegmentedMsg { repMsg = "created "+st.attrib(rname); } otherwise { - var errorMsg = "(%s, %s)".format(objtype, valtype); + var errorMsg = "(%s, %s)".doFormat(objtype, valtype); smLogger.error(getModuleName(),getRoutineName(),getLineNumber(),errorMsg); return new MsgTuple(notImplementedError(pn, errorMsg), MsgType.ERROR); } @@ -360,7 +361,7 @@ module SegmentedMsg { checkMatchStrings(name, st); smLogger.debug(getModuleName(), getRoutineName(), getLineNumber(), - "cmd: %s objtype: %t".format(cmd, objtype)); + "cmd: %s objtype: %?".doFormat(cmd, objtype)); if objtype == "Matcher" || objtype == "Match" { const rNumMatchesName = st.nextName(); @@ -388,20 +389,20 @@ module SegmentedMsg { st.addEntry(rfullMatchScanName, new shared SymEntry(fullMatchScan)); var createdMap = new map(keyType=string,valType=string); - createdMap.add("NumMatches", "created %s".format(st.attrib(rNumMatchesName))); - createdMap.add("Starts", "created %s".format(st.attrib(rStartsName))); - createdMap.add("Lens", "created %s".format(st.attrib(rLensName))); - createdMap.add("Indices", "created %s".format(st.attrib(rIndicesName))); - createdMap.add("SearchBool", "created %s".format(st.attrib(rSearchBoolName))); - createdMap.add("SearchInd", "created %s".format(st.attrib(rSearchScanName))); - createdMap.add("MatchBool", "created %s".format(st.attrib(rMatchBoolName))); - createdMap.add("MatchInd", "created %s".format(st.attrib(rMatchScanName))); - createdMap.add("FullMatchBool", "created %s".format(st.attrib(rfullMatchBoolName))); - createdMap.add("FullMatchInd", "created %s".format(st.attrib(rfullMatchScanName))); - repMsg = "%jt".format(createdMap); + createdMap.add("NumMatches", "created %s".doFormat(st.attrib(rNumMatchesName))); + createdMap.add("Starts", "created %s".doFormat(st.attrib(rStartsName))); + createdMap.add("Lens", "created %s".doFormat(st.attrib(rLensName))); + createdMap.add("Indices", "created %s".doFormat(st.attrib(rIndicesName))); + createdMap.add("SearchBool", "created %s".doFormat(st.attrib(rSearchBoolName))); + createdMap.add("SearchInd", "created %s".doFormat(st.attrib(rSearchScanName))); + createdMap.add("MatchBool", "created %s".doFormat(st.attrib(rMatchBoolName))); + createdMap.add("MatchInd", "created %s".doFormat(st.attrib(rMatchScanName))); + createdMap.add("FullMatchBool", "created %s".doFormat(st.attrib(rfullMatchBoolName))); + createdMap.add("FullMatchInd", "created %s".doFormat(st.attrib(rfullMatchScanName))); + repMsg = formatJson(createdMap); } else { - var errorMsg = "%s".format(objtype); + var errorMsg = "%s".doFormat(objtype); smLogger.error(getModuleName(),getRoutineName(),getLineNumber(),errorMsg); return new MsgTuple(notImplementedError(pn, errorMsg), MsgType.ERROR); } @@ -428,7 +429,7 @@ module SegmentedMsg { st.checkTable(indicesName); smLogger.debug(getModuleName(), getRoutineName(), getLineNumber(), - "cmd: %s objtype: %t".format(cmd, objtype)); + "cmd: %s objtype: %?".doFormat(cmd, objtype)); select objtype { when "Matcher" { @@ -441,11 +442,11 @@ module SegmentedMsg { var (off, val, matchOrigins) = strings.findAllMatches(numMatches, starts, lens, indices, returnMatchOrig); var retString = getSegString(off, val, st); - repMsg = "created " + st.attrib(retString.name) + "+created bytes.size %t".format(retString.nBytes); + repMsg = "created " + st.attrib(retString.name) + "+created bytes.size %?".doFormat(retString.nBytes); if returnMatchOrig { const optName: string = if returnMatchOrig then st.nextName() else ""; st.addEntry(optName, new shared SymEntry(matchOrigins)); - repMsg += "+created %s".format(st.attrib(optName)); + repMsg += "+created %s".doFormat(st.attrib(optName)); } } when "Match" { @@ -459,15 +460,15 @@ module SegmentedMsg { var (off, val, matchOrigins) = strings.findAllMatches(numMatches, starts, lens, indices, returnMatchOrig); var retString = getSegString(off, val, st); - repMsg = "created " + st.attrib(retString.name) + "+created bytes.size %t".format(retString.nBytes); + repMsg = "created " + st.attrib(retString.name) + "+created bytes.size %?".doFormat(retString.nBytes); if returnMatchOrig { st.addEntry(optName, new shared SymEntry(matchOrigins)); - repMsg += "+created %s".format(st.attrib(optName)); + repMsg += "+created %s".doFormat(st.attrib(optName)); } } // when "Match" do numMatch SymEntry(bool) AND ?t in FindAll declaration in Strings idk if "for k in matchInd..#numMatches[stringInd]" will still work otherwise { - var errorMsg = "%s".format(objtype); + var errorMsg = "%s".doFormat(objtype); smLogger.error(getModuleName(),getRoutineName(),getLineNumber(),errorMsg); return new MsgTuple(notImplementedError(pn, errorMsg), MsgType.ERROR); } @@ -490,7 +491,7 @@ module SegmentedMsg { st.checkTable(name); smLogger.debug(getModuleName(), getRoutineName(), getLineNumber(), - "cmd: %s objtype: %t".format(cmd, objtype)); + "cmd: %s objtype: %?".doFormat(cmd, objtype)); select objtype { when "Matcher" { @@ -498,14 +499,14 @@ module SegmentedMsg { const strings = getSegString(name, st); var (off, val, numSubs) = strings.sub(pattern, repl, count, returnNumSubs); var retString = getSegString(off, val, st); - repMsg = "created " + st.attrib(retString.name) + "+created bytes.size %t".format(retString.nBytes); + repMsg = "created " + st.attrib(retString.name) + "+created bytes.size %?".doFormat(retString.nBytes); if returnNumSubs { st.addEntry(optName, new shared SymEntry(numSubs)); - repMsg += "+created %s".format(st.attrib(optName)); + repMsg += "+created %s".doFormat(st.attrib(optName)); } } otherwise { - var errorMsg = "%s".format(objtype); + var errorMsg = "%s".doFormat(objtype); smLogger.error(getModuleName(),getRoutineName(),getLineNumber(),errorMsg); return new MsgTuple(notImplementedError(pn, errorMsg), MsgType.ERROR); } @@ -529,11 +530,11 @@ module SegmentedMsg { var strings = getSegString(name, st); var (off, val) = strings.strip(msgArgs.getValueOf("chars")); var retString = getSegString(off, val, st); - repMsg = "created " + st.attrib(retString.name) + "+created bytes.size %t".format(retString.nBytes); + repMsg = "created " + st.attrib(retString.name) + "+created bytes.size %?".doFormat(retString.nBytes); return new MsgTuple(repMsg, MsgType.NORMAL); } otherwise { - var errorMsg = notImplementedError(pn, "%s".format(objtype)); + var errorMsg = notImplementedError(pn, "%s".doFormat(objtype)); smLogger.error(getModuleName(),getRoutineName(),getLineNumber(),errorMsg); return new MsgTuple(errorMsg, MsgType.ERROR); } @@ -565,7 +566,7 @@ module SegmentedMsg { st.checkTable(name); smLogger.debug(getModuleName(),getRoutineName(),getLineNumber(), - "cmd: %s subcmd: %s objtype: %t valtype: %t".format( + "cmd: %s subcmd: %s objtype: %? valtype: %?".doFormat( cmd,subcmd,objtype,valtype)); select (objtype, valtype) { @@ -617,7 +618,7 @@ module SegmentedMsg { } var leftEntry = getSegString(leftName, st); var rightEntry = getSegString(rightName, st); - repMsg = "created %s+created bytes.size %t+created %s+created bytes.size %t".format( + repMsg = "created %s+created bytes.size %?+created %s+created bytes.size %?".doFormat( st.attrib(leftEntry.name), leftEntry.nBytes, st.attrib(rightEntry.name), @@ -625,14 +626,14 @@ module SegmentedMsg { } otherwise { var errorMsg = notImplementedError(pn, - "subcmd: %s, (%s, %s)".format(subcmd, objtype, valtype)); + "subcmd: %s, (%s, %s)".doFormat(subcmd, objtype, valtype)); smLogger.error(getModuleName(),getRoutineName(),getLineNumber(),errorMsg); return new MsgTuple(errorMsg, MsgType.ERROR); } } } otherwise { - var errorMsg = notImplementedError(pn, "(%s, %s)".format(objtype, valtype)); + var errorMsg = notImplementedError(pn, "(%s, %s)".doFormat(objtype, valtype)); smLogger.error(getModuleName(),getRoutineName(),getLineNumber(),errorMsg); return new MsgTuple(errorMsg, MsgType.ERROR); } @@ -674,7 +675,7 @@ module SegmentedMsg { st.addEntry(upperName, new shared SymEntry(upper)); var lowerName = st.nextName(); st.addEntry(lowerName, new shared SymEntry(lower)); - repMsg = "created %s+created %s".format(st.attrib(upperName), st.attrib(lowerName)); + repMsg = "created %s+created %s".doFormat(st.attrib(upperName), st.attrib(lowerName)); } otherwise { var errorMsg = notImplementedError(pn, objtype: string); @@ -707,7 +708,7 @@ module SegmentedMsg { const name = msgArgs.getValueOf("obj"); const dtype = str2dtype(msgArgs.getValueOf("dtype")); smLogger.debug(getModuleName(),getRoutineName(),getLineNumber(), - "subcmd: %s objtype: %s".format(subcmd,objtype)); + "subcmd: %s objtype: %s".doFormat(subcmd,objtype)); try { select subcmd { when "intIndex" { @@ -721,7 +722,7 @@ module SegmentedMsg { return segPdarrayIndex(objtype, name, msgArgs.getValueOf("key"), dtype, st); } otherwise { - var errorMsg = "Error in %s, unknown subcommand %s".format(pn, subcmd); + var errorMsg = "Error in %s, unknown subcommand %s".doFormat(pn, subcmd); smLogger.error(getModuleName(),getRoutineName(),getLineNumber(),errorMsg); return new MsgTuple(errorMsg, MsgType.ERROR); } @@ -731,7 +732,7 @@ module SegmentedMsg { smLogger.error(getModuleName(),getRoutineName(),getLineNumber(),errorMsg); return new MsgTuple(errorMsg, MsgType.ERROR); } catch e: Error { - var errorMsg = "unknown cause %t".format(e); + var errorMsg = "unknown cause %?".doFormat(e); smLogger.error(getModuleName(),getRoutineName(),getLineNumber(),errorMsg); return new MsgTuple(errorMsg, MsgType.ERROR); } @@ -745,7 +746,7 @@ module SegmentedMsg { var pn = Reflection.getRoutineName(); // check to make sure symbols defined - smLogger.debug(getModuleName(),getRoutineName(),getLineNumber(), "strName: %s".format(objName)); + smLogger.debug(getModuleName(),getRoutineName(),getLineNumber(), "strName: %s".doFormat(objName)); st.checkTable(objName); select objtype { @@ -758,7 +759,7 @@ module SegmentedMsg { idx = convertPythonIndexToChapel(idx, strings.size); var s = strings[idx]; - var repMsg = "item %s %jt".format("str", s); + var repMsg = "item str "+formatJson(s); smLogger.debug(getModuleName(),getRoutineName(),getLineNumber(),repMsg); return new MsgTuple(repMsg, MsgType.NORMAL); } @@ -813,7 +814,7 @@ module SegmentedMsg { var (newSegs, newVals) = strings[slice]; // Store the resulting offsets and bytes arrays var newStringsObj = getSegString(newSegs, newVals, st); - repMsg = "created " + st.attrib(newStringsObj.name) + "+created bytes.size %t".format(newStringsObj.nBytes); + repMsg = "created " + st.attrib(newStringsObj.name) + "+created bytes.size %?".doFormat(newStringsObj.nBytes); } otherwise { var errorMsg = notImplementedError(pn, objtype: string); @@ -842,7 +843,7 @@ module SegmentedMsg { st.checkTable(objName); smLogger.debug(getModuleName(),getRoutineName(),getLineNumber(), - "objtype:%s".format(objtype)); + "objtype:%s".doFormat(objtype)); var gIV: borrowed GenSymEntry = getGenericTypedArrayEntry(iname, st); @@ -859,7 +860,7 @@ module SegmentedMsg { var newStringsObj = getSegString(newSegs, newVals, st); newStringsName = newStringsObj.name; nBytes = newStringsObj.nBytes; - repMsg = "created " + st.attrib(newStringsName) + "+created bytes.size %t".format(nBytes); + repMsg = "created " + st.attrib(newStringsName) + "+created bytes.size %?".doFormat(nBytes); } when DType.UInt64 { var iv = toSymEntry(gIV, uint); @@ -867,7 +868,7 @@ module SegmentedMsg { var newStringsObj = getSegString(newSegs, newVals, st); newStringsName = newStringsObj.name; nBytes = newStringsObj.nBytes; - repMsg = "created " + st.attrib(newStringsName) + "+created bytes.size %t".format(nBytes); + repMsg = "created " + st.attrib(newStringsName) + "+created bytes.size %?".doFormat(nBytes); } when DType.Bool { var iv = toSymEntry(gIV, bool); @@ -875,7 +876,7 @@ module SegmentedMsg { var newStringsObj = getSegString(newSegs, newVals, st); newStringsName = newStringsObj.name; nBytes = newStringsObj.nBytes; - repMsg = "created " + st.attrib(newStringsName) + "+created bytes.size %t".format(nBytes); + repMsg = "created " + st.attrib(newStringsName) + "+created bytes.size %?".doFormat(nBytes); } otherwise { var errorMsg = "("+objtype: string+","+dtype2str(gIV.dtype)+")"; @@ -891,7 +892,7 @@ module SegmentedMsg { } } otherwise { - var errorMsg = "unsupported objtype: %t".format(objtype); + var errorMsg = "unsupported objtype: %?".doFormat(objtype); smLogger.error(getModuleName(),getRoutineName(),getLineNumber(),errorMsg); return new MsgTuple(notImplementedError(pn, objtype: string), MsgType.ERROR); } @@ -944,7 +945,7 @@ module SegmentedMsg { var (newOffsets, newVals) = lstrings.stick(rstrings, delim, true); strings = getSegString(newOffsets, newVals, st); } - repMsg = "created %s+created bytes.size %t".format(st.attrib(strings.name), strings.nBytes); + repMsg = "created %s+created bytes.size %?".doFormat(st.attrib(strings.name), strings.nBytes); smLogger.debug(getModuleName(),getRoutineName(),getLineNumber(),repMsg); } otherwise { @@ -1004,7 +1005,7 @@ module SegmentedMsg { } } - repMsg = "created %s".format(st.attrib(rname)); + repMsg = "created %s".doFormat(st.attrib(rname)); smLogger.debug(getModuleName(),getRoutineName(),getLineNumber(), repMsg); return new MsgTuple(repMsg, MsgType.NORMAL); } @@ -1079,7 +1080,7 @@ module SegmentedMsg { rtn[i] = strings[i]; } - var repMsg = "%jt".format(rtn); + var repMsg = formatJson(rtn); return new MsgTuple(repMsg, MsgType.NORMAL); } @@ -1101,7 +1102,7 @@ module SegmentedMsg { msgArgs.getValueOf("kind"): Fixes, msgArgs.get("proper").getBoolValue()); var retString = getSegString(off, byt, st); - repMsg = "created " + st.attrib(retString.name) + "+created bytes.size %t".format(retString.nBytes); + repMsg = "created " + st.attrib(retString.name) + "+created bytes.size %?".doFormat(retString.nBytes); if returnOrigins { var leName = st.nextName(); st.addEntry(leName, new shared SymEntry(longEnough)); @@ -1110,7 +1111,7 @@ module SegmentedMsg { return new MsgTuple(repMsg, MsgType.NORMAL); } otherwise { - var errorMsg = notImplementedError(pn, "%s".format(objtype)); + var errorMsg = notImplementedError(pn, "%s".doFormat(objtype)); smLogger.error(getModuleName(),getRoutineName(),getLineNumber(),errorMsg); return new MsgTuple(errorMsg, MsgType.ERROR); } @@ -1138,7 +1139,7 @@ module SegmentedMsg { var (off, val) = if isStrLiteral then strings.segStrWhere(other, condition, newLens) else strings.segStrWhere(getSegString(other, st), condition, newLens); var retString = getSegString(off, val, st); - repMsg = "created " + st.attrib(retString.name) + "+created bytes.size %t".format(retString.nBytes); + repMsg = "created " + st.attrib(retString.name) + "+created bytes.size %?".doFormat(retString.nBytes); smLogger.debug(getModuleName(),getRoutineName(),getLineNumber(),repMsg); return new MsgTuple(repMsg, MsgType.NORMAL); @@ -1151,7 +1152,7 @@ module SegmentedMsg { var (off, val) = segStrFull(segStrSize, segStrFillValue); var retString = getSegString(off, val, st); - repMsg = "created " + st.attrib(retString.name) + "+created bytes.size %t".format(retString.nBytes); + repMsg = "created " + st.attrib(retString.name) + "+created bytes.size %?".doFormat(retString.nBytes); return new MsgTuple(repMsg, MsgType.NORMAL); } diff --git a/src/SegmentedString.chpl b/src/SegmentedString.chpl index 66772c428a..81ab21c016 100644 --- a/src/SegmentedString.chpl +++ b/src/SegmentedString.chpl @@ -43,7 +43,7 @@ module SegmentedString { proc getSegString(name: string, st: borrowed SymTab): owned SegString throws { var abstractEntry = st.lookup(name); if !abstractEntry.isAssignableTo(SymbolEntryType.SegStringSymEntry) { - var errorMsg = "Error: Unhandled SymbolEntryType %s".format(abstractEntry.entryType); + var errorMsg = "Error: Unhandled SymbolEntryType %s".doFormat(abstractEntry.entryType); ssLogger.error(getModuleName(),getRoutineName(),getLineNumber(),errorMsg); throw new Error(errorMsg); } @@ -252,7 +252,7 @@ module SegmentedString { gatheredOffsets -= gatheredLengths; ssLogger.debug(getModuleName(),getRoutineName(),getLineNumber(), - "aggregation in %i seconds".format(timeSinceEpoch().totalSeconds() - t1)); + "aggregation in %i seconds".doFormat(timeSinceEpoch().totalSeconds() - t1)); ssLogger.debug(getModuleName(),getRoutineName(),getLineNumber(), "Copying values"); if logLevel == LogLevel.DEBUG { t1 = timeSinceEpoch().totalSeconds(); @@ -298,7 +298,7 @@ module SegmentedString { } } ssLogger.debug(getModuleName(),getRoutineName(),getLineNumber(), - "Gathered offsets and vals in %i seconds".format( + "Gathered offsets and vals in %i seconds".doFormat( timeSinceEpoch().totalSeconds() -t1)); return (gatheredOffsets, gatheredVals); } @@ -354,7 +354,7 @@ module SegmentedString { if logLevel == LogLevel.DEBUG { ssLogger.debug(getModuleName(),getRoutineName(),getLineNumber(), - "hashing took %t seconds\nSorting hashes".format(timeSinceEpoch().totalSeconds() - t1)); + "hashing took %? seconds\nSorting hashes".doFormat(timeSinceEpoch().totalSeconds() - t1)); t1 = timeSinceEpoch().totalSeconds(); } @@ -362,7 +362,7 @@ module SegmentedString { var iv = radixSortLSD_ranks(hashes); if logLevel == LogLevel.DEBUG { ssLogger.debug(getModuleName(),getRoutineName(),getLineNumber(), - "sorting took %t seconds".format(timeSinceEpoch().totalSeconds() - t1)); + "sorting took %? seconds".doFormat(timeSinceEpoch().totalSeconds() - t1)); } if logLevel == LogLevel.DEBUG { var sortedHashes = [i in iv] hashes[i]; @@ -371,7 +371,7 @@ module SegmentedString { printAry("diffs = ", diffs); var nonDecreasing = [(d0,d1) in diffs] ((d0 > 0) || ((d0 == 0) && (d1 >= 0))); ssLogger.debug(getModuleName(),getRoutineName(),getLineNumber(), - "Are hashes sorted? %i".format(&& reduce nonDecreasing)); + "Are hashes sorted? %i".doFormat(&& reduce nonDecreasing)); } return iv; } else { @@ -509,7 +509,7 @@ module SegmentedString { const concat2Name = st.nextName(); st.addEntry(concat1Name, new shared SymEntry(numeric1)); st.addEntry(concat2Name, new shared SymEntry(numeric2)); - return "%s+%s".format(concat1Name, concat2Name); + return "%s+%s".doFormat(concat1Name, concat2Name); } } @@ -1383,7 +1383,7 @@ module SegmentedString { return compile(pattern); } catch { - var errorMsg = "re2 could not compile pattern: %s".format(pattern); + var errorMsg = "re2 could not compile pattern: %s".doFormat(pattern); ssLogger.error(getModuleName(),getRoutineName(),getLineNumber(),errorMsg); throw new owned IllegalArgumentError(errorMsg); } @@ -1476,7 +1476,7 @@ module SegmentedString { const (uoTest, uvTest, cTest, revTest) = uniqueGroup(testStr); const (segs, vals) = concat(uoMain, uvMain, uoTest, uvTest); ssLogger.debug(getModuleName(),getRoutineName(),getLineNumber(), - "Unique strings in first array: %t\nUnique strings in second array: %t\nConcat length: %t".format( + "Unique strings in first array: %?\nUnique strings in second array: %?\nConcat length: %?".doFormat( uoMain.size, uoTest.size, segs.size)); var st = new owned SymTab(); const ar = new owned SegString(segs, vals, st); @@ -1515,7 +1515,7 @@ module SegmentedString { } ssLogger.debug(getModuleName(),getRoutineName(),getLineNumber(), - "Flag pop: %t".format(+ reduce flag)); + "Flag pop: %?".doFormat(+ reduce flag)); // Now flag contains true for both elements of duplicate pairs if invert {flag = !flag;} @@ -1526,7 +1526,7 @@ module SegmentedString { } if logLevel == LogLevel.DEBUG { ssLogger.debug(getModuleName(),getRoutineName(),getLineNumber(), - "Ret pop: %t".format(+ reduce ret)); + "Ret pop: %?".doFormat(+ reduce ret)); } // Broadcast back to original (pre-unique) order var truth: [mainStr.offsets.a.domain] bool; diff --git a/src/SequenceMsg.chpl b/src/SequenceMsg.chpl index 3ffef37649..c47a4c04a9 100644 --- a/src/SequenceMsg.chpl +++ b/src/SequenceMsg.chpl @@ -27,13 +27,13 @@ module SequenceMsg { proc arangeMsg(cmd: string, msgArgs: borrowed MessageArgs, st: borrowed SymTab): MsgTuple throws { proc arangeHelper(start: ?t, stop: t, stride: t, len, rname) throws { smLogger.debug(getModuleName(),getRoutineName(),getLineNumber(), - "cmd: %s start: %t stop: %t stride: %t : len: %t rname: %s".format( + "cmd: %s start: %? stop: %? stride: %? : len: %? rname: %s".doFormat( cmd, start, stop, stride, len, rname)); var t1 = Time.timeSinceEpoch().totalSeconds(); var ea = makeDistArray(len, t); smLogger.debug(getModuleName(),getRoutineName(),getLineNumber(), - "alloc time = %i sec".format(Time.timeSinceEpoch().totalSeconds() - t1)); + "alloc time = %i sec".doFormat(Time.timeSinceEpoch().totalSeconds() - t1)); t1 = Time.timeSinceEpoch().totalSeconds(); const ref ead = ea.domain; @@ -42,7 +42,7 @@ module SequenceMsg { } var e = st.addEntry(rname, new shared SymEntry(ea)); smLogger.debug(getModuleName(),getRoutineName(),getLineNumber(), - "compute time = %i sec".format(Time.timeSinceEpoch().totalSeconds() - t1)); + "compute time = %i sec".doFormat(Time.timeSinceEpoch().totalSeconds() - t1)); } var repMsg: string; // response message @@ -105,13 +105,13 @@ module SequenceMsg { // get next symbol name var rname = st.nextName(); smLogger.debug(getModuleName(),getRoutineName(),getLineNumber(), - "cmd: %s start: %r stop: %r len: %i stride: %r rname: %s".format( + "cmd: %s start: %r stop: %r len: %i stride: %r rname: %s".doFormat( cmd, start, stop, len, stride, rname)); var t1 = Time.timeSinceEpoch().totalSeconds(); var e = st.addEntry(rname, len, real); smLogger.debug(getModuleName(),getRoutineName(),getLineNumber(), - "alloc time = %i".format(Time.timeSinceEpoch().totalSeconds() - t1)); + "alloc time = %i".doFormat(Time.timeSinceEpoch().totalSeconds() - t1)); t1 = Time.timeSinceEpoch().totalSeconds(); ref ea = e.a; @@ -122,7 +122,7 @@ module SequenceMsg { ea[0] = start; ea[len-1] = stop; smLogger.debug(getModuleName(),getRoutineName(),getLineNumber(), - "compute time = %i".format(Time.timeSinceEpoch().totalSeconds() - t1)); + "compute time = %i".doFormat(Time.timeSinceEpoch().totalSeconds() - t1)); repMsg = "created " + st.attrib(rname); smLogger.debug(getModuleName(),getRoutineName(),getLineNumber(),repMsg); diff --git a/src/ServerConfig.chpl b/src/ServerConfig.chpl index 273730de7a..873f4cc92c 100644 --- a/src/ServerConfig.chpl +++ b/src/ServerConfig.chpl @@ -6,6 +6,7 @@ module ServerConfig use SymArrayDmap only makeDistDom; public use IO; + public use ArkoudaIOCompat; use ServerErrorStrings; use Reflection; @@ -189,8 +190,8 @@ module ServerConfig const cfg = new owned Config( arkoudaVersion = (ServerConfig.arkoudaVersion:string), chplVersion = chplVersion, - ZMQVersion = try! "%i.%i.%i".format(Zmajor, Zminor, Zmicro), - HDF5Version = try! "%i.%i.%i".format(H5major, H5minor, H5micro), + ZMQVersion = try! "%i.%i.%i".doFormat(Zmajor, Zminor, Zmicro), + HDF5Version = try! "%i.%i.%i".doFormat(H5major, H5minor, H5micro), serverHostname = serverHostname, ServerPort = ServerPort, numLocales = numLocales, @@ -207,7 +208,7 @@ module ServerConfig autoShutdown = autoShutdown, serverInfoNoSplash = serverInfoNoSplash ); - return try! "%jt".format(cfg); + return try! formatJson(cfg); } private var cfgStr = createConfig(); @@ -282,7 +283,7 @@ module ServerConfig proc checkStaticMemoryLimit(total: real) { if total > getMemLimit() { var pct = AutoMath.round((total:real / getMemLimit():real * 100):uint); - var msg = "cmd requiring %i bytes of memory exceeds %i limit with projected pct memory used of %i%%".format( + var msg = "cmd requiring %i bytes of memory exceeds %i limit with projected pct memory used of %i%%".doFormat( total, getMemLimit(), pct); scLogger.error(getModuleName(),getRoutineName(),getLineNumber(), msg); throw getErrorWithContext( @@ -301,7 +302,7 @@ module ServerConfig if (total > memHighWater) { memHighWater = total; scLogger.info(getModuleName(),getRoutineName(),getLineNumber(), - "memory high watermark = %i memory limit = %i projected pct memory used of %i%%".format( + "memory high watermark = %i memory limit = %i projected pct memory used of %i%%".doFormat( memHighWater:uint * numLocales:uint, getMemLimit():uint * numLocales:uint, AutoMath.round((memHighWater:real * numLocales / @@ -323,7 +324,7 @@ module ServerConfig if memMgmtType == MemMgmtType.STATIC { if total > getMemLimit() { var pct = AutoMath.round((total:real / getMemLimit():real * 100):uint); - var msg = "cmd requiring %i bytes of memory exceeds %i limit with projected pct memory used of %i%%".format( + var msg = "cmd requiring %i bytes of memory exceeds %i limit with projected pct memory used of %i%%".doFormat( total, getMemLimit(), pct); scLogger.error(getModuleName(),getRoutineName(),getLineNumber(), msg); throw getErrorWithContext( @@ -335,7 +336,7 @@ module ServerConfig } } else { if !isMemAvailable(additionalAmount) { - var msg = "cmd requiring %i more bytes of memory exceeds available memory on one or more locales".format( + var msg = "cmd requiring %i more bytes of memory exceeds available memory on one or more locales".doFormat( additionalAmount); scLogger.error(getModuleName(),getRoutineName(),getLineNumber(), msg); throw getErrorWithContext( diff --git a/src/ServerDaemon.chpl b/src/ServerDaemon.chpl index f9f8b98a0f..c51f90d93f 100644 --- a/src/ServerDaemon.chpl +++ b/src/ServerDaemon.chpl @@ -29,6 +29,7 @@ module ServerDaemon { use ArkoudaFileCompat; use ArkoudaListCompat; + use ArkoudaIOCompat; enum ServerDaemonType {DEFAULT,INTEGRATION,METRICS} @@ -158,26 +159,26 @@ module ServerDaemon { proc init() { this.socket = this.context.socket(ZMQ.REP); - try! this.socket.bind("tcp://*:%t".format(ServerPort)); + try! this.socket.bind("tcp://*:%?".doFormat(ServerPort)); } proc getConnectUrl(token: string) throws { if token.isEmpty() { - return "tcp://%s:%t".format(serverHostname, + return "tcp://%s:%?".doFormat(serverHostname, ServerPort); } else { - return "tcp://%s:%i?token=%s".format(serverHostname, + return "tcp://%s:%i?token=%s".doFormat(serverHostname, ServerPort, token); } } proc printServerSplashMessage(token: string, arkDirectory: string) throws { - var verMessage = "arkouda server version = %s".format(arkoudaVersion); - var chplVerMessage = "built with chapel version%s".format(chplVersion); - var dirMessage = ".arkouda directory %s".format(arkDirectory); - var memLimMessage = "memory limit = %i".format(getMemLimit()); - var memUsedMessage = "bytes of memory used = %i".format(getMemUsed()); + var verMessage = "arkouda server version = %s".doFormat(arkoudaVersion); + var chplVerMessage = "built with chapel version%s".doFormat(chplVersion); + var dirMessage = ".arkouda directory %s".doFormat(arkDirectory); + var memLimMessage = "memory limit = %i".doFormat(getMemLimit()); + var memUsedMessage = "bytes of memory used = %i".doFormat(getMemUsed()); var serverMessage: string; const buff = ' '; @@ -202,25 +203,25 @@ module ServerDaemon { return buffer; } - serverMessage = "server listening on %s".format(this.connectUrl); + serverMessage = "server listening on %s".doFormat(this.connectUrl); serverMessage = adjustMsg(serverMessage); - serverMessage = "%s %s %s".format(buff,serverMessage,buff); + serverMessage = "%s %s %s".doFormat(buff,serverMessage,buff); var vBuff = generateBuffer(serverMessage,verMessage); verMessage = adjustMsg(verMessage); - verMessage = "*%s %s %s*".format(vBuff,verMessage,vBuff); + verMessage = "*%s %s %s*".doFormat(vBuff,verMessage,vBuff); var cvBuff = generateBuffer(serverMessage,chplVerMessage); chplVerMessage = adjustMsg(chplVerMessage); - chplVerMessage = "*%s %s %s*".format(cvBuff,chplVerMessage,cvBuff); + chplVerMessage = "*%s %s %s*".doFormat(cvBuff,chplVerMessage,cvBuff); var mlBuff = generateBuffer(serverMessage,memLimMessage); memLimMessage = adjustMsg(memLimMessage); - memLimMessage = "*%s %s %s*".format(mlBuff,memLimMessage,mlBuff); + memLimMessage = "*%s %s %s*".doFormat(mlBuff,memLimMessage,mlBuff); var muBuff = generateBuffer(serverMessage,memUsedMessage); memUsedMessage = adjustMsg(memUsedMessage); - memUsedMessage = "*%s %s %s*".format(muBuff,memUsedMessage,muBuff); + memUsedMessage = "*%s %s %s*".doFormat(muBuff,memUsedMessage,muBuff); var blankBuffer: string; var counter = 0; @@ -230,7 +231,7 @@ module ServerDaemon { counter+=1; } - var blankLine = '*%s*'.format(blankBuffer); + var blankLine = '*%s*'.doFormat(blankBuffer); var tag = '*'; counter = 0; @@ -245,7 +246,7 @@ module ServerDaemon { writeln(tag); writeln(tag); writeln(blankLine); - writeln('*%s*'.format(serverMessage)); + writeln('*%s*'.doFormat(serverMessage)); writeln(verMessage); writeln(chplVerMessage); @@ -269,10 +270,10 @@ module ServerDaemon { use IO; if !serverConnectionInfo.isEmpty() { sdLogger.debug(getModuleName(),getRoutineName(),getLineNumber(), - 'writing serverConnectionInfo to %t'.format(serverConnectionInfo)); + 'writing serverConnectionInfo to %?'.doFormat(serverConnectionInfo)); try! { var w = open(serverConnectionInfo, ioMode.cw).writer(); - w.writef("%s %t %s\n",serverHostname,ServerPort,this.connectUrl); + w.writef("%s %i %s\n",serverHostname,ServerPort,this.connectUrl); } } } @@ -288,10 +289,10 @@ module ServerDaemon { } } catch fnfe : FileNotFoundError { sdLogger.error(getModuleName(),getRoutineName(),getLineNumber(), - "The serverConnectionInfo file was not found %s".format(fnfe.message())); + "The serverConnectionInfo file was not found %s".doFormat(fnfe.message())); } catch e : Error { sdLogger.error(getModuleName(),getRoutineName(),getLineNumber(), - "Error in deleting serverConnectionInfo file %s".format(e.message())); + "Error in deleting serverConnectionInfo file %s".doFormat(e.message())); } } @@ -308,7 +309,7 @@ module ServerDaemon { "repMsg: "); } else { sdLogger.info(getModuleName(),getRoutineName(),getLineNumber(), - "repMsg: %s".format(repMsg)); + "repMsg: %s".doFormat(repMsg)); } } this.socket.send(repMsg); @@ -325,7 +326,7 @@ module ServerDaemon { throw new owned ErrorWithMsg("Error: access to arkouda requires a token"); } else if serverToken != token { - throw new owned ErrorWithMsg("Error: token %s does not match server token, check with server owner".format(token)); + throw new owned ErrorWithMsg("Error: token %s does not match server token, check with server owner".doFormat(token)); } } @@ -338,7 +339,7 @@ module ServerDaemon { writeUsedModules(); super.requestShutdown(user); this.repCount += 1; - this.socket.send(serialize(msg="shutdown server (%i req)".format(repCount), + this.socket.send(serialize(msg="shutdown server (%i req)".doFormat(repCount), msgType=MsgType.NORMAL,msgFormat=MsgFormat.STRING, user=user)); } @@ -379,7 +380,7 @@ module ServerDaemon { } proc initArkoudaDirectory() throws { - var arkDirectory = '%s%s%s'.format(here.cwd(), pathSep,'.arkouda'); + var arkDirectory = '%s%s%s'.doFormat(here.cwd(), pathSep,'.arkouda'); initDirectory(arkDirectory); return arkDirectory; } @@ -425,7 +426,7 @@ module ServerDaemon { sdLogger.debug(getModuleName(), getRoutineName(), getLineNumber(), - "Set Response Time for %s: %t".format(cmd,elapsedTime)); + "Set Response Time for %s: %?".doFormat(cmd,elapsedTime)); // Add response time to the avg response time for the cmd avgResponseTimeMetrics.add(cmd,elapsedTime:real); @@ -439,17 +440,17 @@ module ServerDaemon { sdLogger.debug(getModuleName(), getRoutineName(), getLineNumber(), - "Added Avg Response Time for cmd %s: %t".format(cmd,elapsedTime)); + "Added Avg Response Time for cmd %s: %?".doFormat(cmd,elapsedTime)); sdLogger.debug(getModuleName(), getRoutineName(), getLineNumber(), - "Total Response Time for cmd %s: %t".format(cmd,totalResponseTimeMetrics.get(cmd))); + "Total Response Time for cmd %s: %?".doFormat(cmd,totalResponseTimeMetrics.get(cmd))); sdLogger.debug(getModuleName(), getRoutineName(), getLineNumber(), - "Total Memory Used for cmd %s: %t GB".format(cmd,totalMemoryUsedMetrics.get(cmd))); + "Total Memory Used for cmd %s: %? GB".doFormat(cmd,totalMemoryUsedMetrics.get(cmd))); var apo = getArrayParameterObj(args); @@ -474,7 +475,7 @@ module ServerDaemon { // Log to the console or arkouda.log file sdLogger.debug(getModuleName(),getRoutineName(),getLineNumber(), - "%jt".format(metric)); + formatJson(metric)); } } @@ -484,11 +485,11 @@ module ServerDaemon { this.arkDirectory = this.initArkoudaDirectory(); if authenticate { - this.serverToken = getArkoudaToken('%s%s%s'.format(this.arkDirectory, pathSep, 'tokens.txt')); + this.serverToken = getArkoudaToken('%s%s%s'.doFormat(this.arkDirectory, pathSep, 'tokens.txt')); } sdLogger.debug(getModuleName(), getRoutineName(), getLineNumber(), - "initialized the .arkouda directory %s".format(this.arkDirectory)); + "initialized the .arkouda directory %s".doFormat(this.arkDirectory)); this.connectUrl = this.getConnectUrl(this.serverToken); this.createServerConnectionInfo(); @@ -532,7 +533,7 @@ module ServerDaemon { request = rawRequest.decode(); } catch e: DecodeError { sdLogger.error(getModuleName(),getRoutineName(),getLineNumber(), - "illegal byte sequence in command: %t".format( + "illegal byte sequence in command: %?".doFormat( rawRequest.decode(decodePolicy.replace))); sendRepMsg(serialize(msg=unknownError(e.message()),msgType=MsgType.ERROR, msgFormat=MsgFormat.STRING, user="Unknown")); @@ -551,7 +552,7 @@ module ServerDaemon { } catch e { sdLogger.error(getModuleName(),getRoutineName(),getLineNumber(), - "Argument List size is not an integer. %s cannot be cast".format(msg.size)); + "Argument List size is not an integer. %s cannot be cast".doFormat(msg.size)); sendRepMsg(serialize(msg=unknownError(e.message()),msgType=MsgType.ERROR, msgFormat=MsgFormat.STRING, user="Unknown")); } @@ -567,7 +568,7 @@ module ServerDaemon { sdLogger.info(getModuleName(), getRoutineName(), getLineNumber(), - "MessageArgs: %t".format(msgArgs)); + "MessageArgs: %?".doFormat(msgArgs)); /* * If authentication is enabled with the --authenticate flag, authenticate @@ -582,10 +583,10 @@ module ServerDaemon { try { if (cmd != "array") { sdLogger.info(getModuleName(), getRoutineName(), getLineNumber(), - ">>> %t %t".format(cmd, args)); + ">>> %? %?".doFormat(cmd, args)); } else { sdLogger.info(getModuleName(), getRoutineName(), getLineNumber(), - ">>> %s [binary data]".format(cmd)); + ">>> %s [binary data]".doFormat(cmd)); } } catch { // No action on error @@ -596,7 +597,7 @@ module ServerDaemon { requestShutdown(user=user); if (trace) { sdLogger.info(getModuleName(),getRoutineName(),getLineNumber(), - "<<< shutdown initiated by %s took %.17r sec".format(user, + "<<< shutdown initiated by %s took %.17r sec".doFormat(user, timeSinceEpoch().totalSeconds() - s0)); } } @@ -622,10 +623,10 @@ module ServerDaemon { when "array" { repTuple = arrayMsg(cmd, msgArgs, payload, st); } when "connect" { if authenticate { - repTuple = new MsgTuple("connected to arkouda server tcp://*:%i as user %s with token %s".format( + repTuple = new MsgTuple("connected to arkouda server tcp://*:%i as user %s with token %s".doFormat( ServerPort,user,token), MsgType.NORMAL); } else { - repTuple = new MsgTuple("connected to arkouda server tcp://*:%i".format(ServerPort), MsgType.NORMAL); + repTuple = new MsgTuple("connected to arkouda server tcp://*:%i".doFormat(ServerPort), MsgType.NORMAL); } } when "disconnect" { @@ -634,7 +635,7 @@ module ServerDaemon { break; } - repTuple = new MsgTuple("disconnected from arkouda server tcp://*:%i".format(ServerPort), MsgType.NORMAL); + repTuple = new MsgTuple("disconnected from arkouda server tcp://*:%i".doFormat(ServerPort), MsgType.NORMAL); } when "noop" { repTuple = new MsgTuple("noop", MsgType.NORMAL); @@ -653,7 +654,7 @@ module ServerDaemon { var binaryRepMsg = commandMapBinary[cmd](cmd, msgArgs, st); sendRepMsg(binaryRepMsg); } else { - repTuple = new MsgTuple("Unrecognized command: %s".format(cmd), MsgType.ERROR); + repTuple = new MsgTuple("Unrecognized command: %s".doFormat(cmd), MsgType.ERROR); sdLogger.error(getModuleName(),getRoutineName(),getLineNumber(),repTuple.msg); } } @@ -675,14 +676,14 @@ module ServerDaemon { */ if trace { sdLogger.info(getModuleName(),getRoutineName(),getLineNumber(), - "<<< %s took %.17r sec".format(cmd, elapsedTime)); + "<<< %s took %.17r sec".doFormat(cmd, elapsedTime)); } if (trace && memTrack) { var memUsed = getMemUsed():uint * numLocales:uint; var memLimit = (getMemLimit():real * numLocales:uint):int; var pctMemUsed = ((memUsed:real/memLimit)*100):int; sdLogger.info(getModuleName(),getRoutineName(),getLineNumber(), - "bytes of memory %t used after %s command is %t%% pct of max memory %t".format(memUsed, + "bytes of memory %? used after %s command is %?%% pct of max memory %?".doFormat(memUsed, cmd, pctMemUsed, memLimit)); @@ -696,7 +697,7 @@ module ServerDaemon { user=user)); if trace { sdLogger.error(getModuleName(),getRoutineName(),getLineNumber(), - "<<< %s resulted in error %s in %.17r sec".format(cmd, e.msg, timeSinceEpoch().totalSeconds() - s0)); + "<<< %s resulted in error %s in %.17r sec".doFormat(cmd, e.msg, timeSinceEpoch().totalSeconds() - s0)); } } catch (e: Error) { // Generate a ReplyMsg of type ERROR and serialize to a JSON-formatted string @@ -710,7 +711,7 @@ module ServerDaemon { msgFormat=MsgFormat.STRING, user=user)); if trace { sdLogger.error(getModuleName(), getRoutineName(), getLineNumber(), - "<<< %s resulted in error: %s in %.17r sec".format(cmd, e.message(), + "<<< %s resulted in error: %s in %.17r sec".doFormat(cmd, e.message(), timeSinceEpoch().totalSeconds() - s0)); } } @@ -721,7 +722,7 @@ module ServerDaemon { deleteServerConnectionInfo(); sdLogger.info(getModuleName(), getRoutineName(), getLineNumber(), - "requests = %i responseCount = %i elapsed sec = %i".format(reqCount, + "requests = %i responseCount = %i elapsed sec = %i".doFormat(reqCount, repCount, elapsed)); this.shutdown(); @@ -741,18 +742,18 @@ module ServerDaemon { this.socket = this.context.socket(ZMQ.REP); this.port = try! getEnv('METRICS_SERVER_PORT','5556'):int; - try! this.socket.bind("tcp://*:%t".format(this.port)); + try! this.socket.bind("tcp://*:%?".doFormat(this.port)); try! sdLogger.debug(getModuleName(), getRoutineName(), getLineNumber(), - "initialized and listening in port %i".format( + "initialized and listening in port %i".doFormat( this.port)); } override proc run() throws { while !this.shutdownDaemon { sdLogger.debug(getModuleName(), getRoutineName(), getLineNumber(), - "awaiting message on port %i".format(this.port)); + "awaiting message on port %i".doFormat(this.port)); var req = this.socket.recv(bytes).decode(); var msg: RequestMsg = extractRequest(req); @@ -778,9 +779,9 @@ module ServerDaemon { when "connect" { if authenticate { repTuple = new MsgTuple("connected to arkouda metrics server tcp://*:%i as user " + - "%s with token %s".format(this.port,user,token), MsgType.NORMAL); + "%s with token %s".doFormat(this.port,user,token), MsgType.NORMAL); } else { - repTuple = new MsgTuple("connected to arkouda metrics server tcp://*:%i".format(this.port), + repTuple = new MsgTuple("connected to arkouda metrics server tcp://*:%i".doFormat(this.port), MsgType.NORMAL); } } @@ -844,7 +845,7 @@ module ServerDaemon { } otherwise { throw getErrorWithContext( - msg="Unsupported ServerDaemonType: %t".format(daemonType), + msg="Unsupported ServerDaemonType: %?".doFormat(daemonType), lineNumber=getLineNumber(), routineName=getRoutineName(), moduleName=getModuleName(), diff --git a/src/ServerErrorStrings.chpl b/src/ServerErrorStrings.chpl index 699a578dad..e1ab2a6145 100644 --- a/src/ServerErrorStrings.chpl +++ b/src/ServerErrorStrings.chpl @@ -3,6 +3,7 @@ module ServerErrorStrings { use NumPyDType; use IO; + use ArkoudaIOCompat; class ErrorWithMsg: Error { var msg: string; @@ -10,32 +11,32 @@ module ServerErrorStrings /* binary operator is not implemented for DTypes */ proc notImplementedError(pname: string, ldtype: DType, op: string, rdtype: DType):string { - return try! "Error: %s: %s %s %s not implemented".format(pname, + return try! "Error: %s: %s %s %s not implemented".doFormat(pname, dtype2str(ldtype), op, dtype2str(rdtype)); } proc notImplementedError(pname: string, ldtype: string, op: string, rdtype: string):string { - return try! "Error: %s: %s %s %s not implemented".format(pname, + return try! "Error: %s: %s %s %s not implemented".doFormat(pname, ldtype, op, rdtype); } /* efunc is not implemented for DType */ proc notImplementedError(pname: string, efunc: string, ldtype: DType):string { - return try! "Error: %s: %s %s not implemented".format(pname, + return try! "Error: %s: %s %s not implemented".doFormat(pname, efunc, dtype2str(ldtype)); } /* efunc is not implemented for DTypes */ proc notImplementedError(pname: string, efunc: string, dt1: DType, dt2: DType): string { - return try! "Error: %s: %s %s %s not implemented".format(pname, + return try! "Error: %s: %s %s %s not implemented".doFormat(pname, efunc, dtype2str(dt1), dtype2str(dt2)); } proc notImplementedError(pname: string, efunc: string, dt1: DType, dt2: DType, dt3: DType): string { - return try! "Error: %s: %s %s %s %s not implemented".format(pname, + return try! "Error: %s: %s %s %s %s not implemented".doFormat(pname, efunc, dtype2str(dt1), dtype2str(dt2), @@ -43,34 +44,34 @@ module ServerErrorStrings } /* algorthm is not implemented for DType */ proc notImplementedError(pname: string, dtype: DType):string { - return try! "Error: %s: %s not implemented".format(pname, + return try! "Error: %s: %s not implemented".doFormat(pname, dtype2str(dtype)); } /* proc is not implemented for this kind of argument */ proc notImplementedError(pname: string, arg: string):string { - return try! "Error: %s: %s not implemented".format(pname,arg); + return try! "Error: %s: %s not implemented".doFormat(pname,arg); } /* unrecognized DType */ proc unrecognizedTypeError(pname: string, stype: string):string { - return try! "Error: %s: unrecognized type: %s".format(pname, stype); + return try! "Error: %s: unrecognized type: %s".doFormat(pname, stype); } /* name not found in the symbol table */ proc unknownSymbolError(pname: string, sname: string):string { if pname != "" then - return try! "Error: %s: unknown symbol: %s".format(pname, sname); + return try! "Error: %s: unknown symbol: %s".doFormat(pname, sname); else - return try! "Error: unknown symbol: %s".format(sname); + return try! "Error: unknown symbol: %s".doFormat(sname); } proc unknownError(pname: string): string { - return try! "Error: %s: unexpected error".format(pname); + return try! "Error: %s: unexpected error".doFormat(pname); } /* incompatible arguments */ proc incompatibleArgumentsError(pname: string, reason: string) { - return try! "Error: %s: Incompatible arguments: %s".format(pname, reason); + return try! "Error: %s: Incompatible arguments: %s".doFormat(pname, reason); } diff --git a/src/ServerErrors.chpl b/src/ServerErrors.chpl index e3520e7219..282780626b 100644 --- a/src/ServerErrors.chpl +++ b/src/ServerErrors.chpl @@ -1,6 +1,7 @@ module ServerErrors { private use IO; // for string.format + use ArkoudaIOCompat; class OutOfBoundsError: Error {} @@ -23,7 +24,7 @@ module ServerErrors { */ proc init(msg : string, lineNumber: int, routineName: string, moduleName: string, errorClass: string='ErrorWithContext') { - try! super.init("%s Line %t In %s.%s: %s".format(errorClass,lineNumber, + try! super.init("%s Line %? In %s.%s: %s".doFormat(errorClass,lineNumber, moduleName, routineName, msg)); @@ -44,7 +45,7 @@ module ServerErrors { * understandable to front-end developers as well as users. */ proc publish() : string { - return try! "Error: %s".format(publishMsg); + return try! "Error: %s".doFormat(publishMsg); } } @@ -179,7 +180,7 @@ module ServerErrors { */ proc generateErrorContext(msg: string, lineNumber: int, moduleName: string, routineName: string, errorClass: string="ErrorWithContext") : string { - return try! "%s %t %s:%s %s".format(errorClass,lineNumber,moduleName,routineName,msg); + return try! "%s %? %s:%s %s".doFormat(errorClass,lineNumber,moduleName,routineName,msg); } /* diff --git a/src/SipHash.chpl b/src/SipHash.chpl index f2fcedef36..8b7ed72365 100644 --- a/src/SipHash.chpl +++ b/src/SipHash.chpl @@ -164,13 +164,13 @@ module SipHash { if DEBUG { try! { shLogger.debug(getModuleName(),getRoutineName(),getLineNumber(), - "%i v0 %016xu".format(numBytes, v0)); + "%i v0 %016xu".doFormat(numBytes, v0)); shLogger.debug(getModuleName(),getRoutineName(),getLineNumber(), - "%i v1 %016xu".format(numBytes, v1)); + "%i v1 %016xu".doFormat(numBytes, v1)); shLogger.debug(getModuleName(),getRoutineName(),getLineNumber(), - "%i v2 %016xu".format(numBytes, v2)); + "%i v2 %016xu".doFormat(numBytes, v2)); shLogger.debug(getModuleName(),getRoutineName(),getLineNumber(), - "%i v3 %016xu".format(numBytes, v3)); + "%i v3 %016xu".doFormat(numBytes, v3)); } } } @@ -196,7 +196,7 @@ module SipHash { if DEBUG { try! shLogger.debug(getModuleName(), getRoutineName(), getLineNumber(), - "m = %016xu".format(m)); + "m = %016xu".doFormat(m)); } v3 ^= m; @@ -254,7 +254,7 @@ module SipHash { const res0 = byte_reverse(b); if DEBUG { try! shLogger.debug(getModuleName(), getRoutineName(), getLineNumber(), - "b = %016xu".format(b)); + "b = %016xu".doFormat(b)); } if (outlen == 8) { @@ -271,7 +271,7 @@ module SipHash { b = v0 ^ v1 ^ v2 ^ v3; if DEBUG { try! shLogger.debug(getModuleName(), getRoutineName(), getLineNumber(), - "b = %016xu".format(b)); + "b = %016xu".doFormat(b)); } return (res0, byte_reverse(b)); } diff --git a/src/SortMsg.chpl b/src/SortMsg.chpl index b85a323174..960d80f1fe 100644 --- a/src/SortMsg.chpl +++ b/src/SortMsg.chpl @@ -39,7 +39,7 @@ module SortMsg algorithm = algoName: SortingAlgorithm; } catch { throw getErrorWithContext( - msg="Unrecognized sorting algorithm: %s".format(algoName), + msg="Unrecognized sorting algorithm: %s".doFormat(algoName), lineNumber=getLineNumber(), routineName=getRoutineName(), moduleName=getModuleName(), @@ -56,7 +56,7 @@ module SortMsg overMemLimit(radixSortLSD_keys_memEst(gEnt.size, gEnt.itemsize)); sortLogger.debug(getModuleName(),getRoutineName(),getLineNumber(), - "cmd: %s name: %s sortedName: %s dtype: %t".format( + "cmd: %s name: %s sortedName: %s dtype: %?".doFormat( cmd, name, sortedName, gEnt.dtype)); proc doSort(a: [?D] ?t) throws { @@ -71,7 +71,7 @@ module SortMsg } otherwise { throw getErrorWithContext( - msg="Unrecognized sorting algorithm: %s".format(algorithm:string), + msg="Unrecognized sorting algorithm: %s".doFormat(algorithm:string), lineNumber=getLineNumber(), routineName=getRoutineName(), moduleName=getModuleName(), diff --git a/src/StatsMsg.chpl b/src/StatsMsg.chpl index 12a8705a21..1946b2d906 100644 --- a/src/StatsMsg.chpl +++ b/src/StatsMsg.chpl @@ -11,6 +11,7 @@ module StatsMsg { use Stats; use Map; + use ArkoudaIOCompat; private config const logLevel = ServerConfig.logLevel; private config const logChannel = ServerConfig.logChannel; @@ -24,16 +25,16 @@ module StatsMsg { select (x.dtype) { when (DType.Int64) { - repMsg = "float64 %.17r".format(mean(toSymEntry(x,int).a)); + repMsg = "float64 %.17r".doFormat(mean(toSymEntry(x,int).a)); } when (DType.Float64) { - repMsg = "float64 %.17r".format(mean(toSymEntry(x,real).a)); + repMsg = "float64 %.17r".doFormat(mean(toSymEntry(x,real).a)); } when (DType.Bool) { - repMsg = "float64 %.17r".format(mean(toSymEntry(x,bool).a)); + repMsg = "float64 %.17r".doFormat(mean(toSymEntry(x,bool).a)); } when (DType.UInt64) { - repMsg = "float64 %.17r".format(mean(toSymEntry(x,uint).a)); + repMsg = "float64 %.17r".doFormat(mean(toSymEntry(x,uint).a)); } otherwise { var errorMsg = unrecognizedTypeError(pn, dtype2str(x.dtype)); @@ -54,16 +55,16 @@ module StatsMsg { select (x.dtype) { when (DType.Int64) { - repMsg = "float64 %.17r".format(variance(toSymEntry(x,int).a, ddof)); + repMsg = "float64 %.17r".doFormat(variance(toSymEntry(x,int).a, ddof)); } when (DType.Float64) { - repMsg = "float64 %.17r".format(variance(toSymEntry(x,real).a, ddof)); + repMsg = "float64 %.17r".doFormat(variance(toSymEntry(x,real).a, ddof)); } when (DType.Bool) { - repMsg = "float64 %.17r".format(variance(toSymEntry(x,bool).a, ddof)); + repMsg = "float64 %.17r".doFormat(variance(toSymEntry(x,bool).a, ddof)); } when (DType.UInt64) { - repMsg = "float64 %.17r".format(variance(toSymEntry(x,uint).a, ddof)); + repMsg = "float64 %.17r".doFormat(variance(toSymEntry(x,uint).a, ddof)); } otherwise { var errorMsg = unrecognizedTypeError(pn, dtype2str(x.dtype)); @@ -84,16 +85,16 @@ module StatsMsg { select (x.dtype) { when (DType.Int64) { - repMsg = "float64 %.17r".format(std(toSymEntry(x,int).a, ddof)); + repMsg = "float64 %.17r".doFormat(std(toSymEntry(x,int).a, ddof)); } when (DType.Float64) { - repMsg = "float64 %.17r".format(std(toSymEntry(x,real).a, ddof)); + repMsg = "float64 %.17r".doFormat(std(toSymEntry(x,real).a, ddof)); } when (DType.Bool) { - repMsg = "float64 %.17r".format(std(toSymEntry(x,bool).a, ddof)); + repMsg = "float64 %.17r".doFormat(std(toSymEntry(x,bool).a, ddof)); } when (DType.UInt64) { - repMsg = "float64 %.17r".format(std(toSymEntry(x,uint).a, ddof)); + repMsg = "float64 %.17r".doFormat(std(toSymEntry(x,uint).a, ddof)); } otherwise { var errorMsg = unrecognizedTypeError(pn, dtype2str(x.dtype)); @@ -116,85 +117,85 @@ module StatsMsg { when (DType.Int64, DType.Int64) { var eX = toSymEntry(x,int); var eY = toSymEntry(y,int); - repMsg = "float64 %.17r".format(cov(eX.a, eY.a)); + repMsg = "float64 %.17r".doFormat(cov(eX.a, eY.a)); } when (DType.Int64, DType.Float64) { var eX = toSymEntry(x,int); var eY = toSymEntry(y,real); - repMsg = "float64 %.17r".format(cov(eX.a, eY.a)); + repMsg = "float64 %.17r".doFormat(cov(eX.a, eY.a)); } when (DType.Int64, DType.Bool) { var eX = toSymEntry(x,int); var eY = toSymEntry(y,bool); - repMsg = "float64 %.17r".format(cov(eX.a, eY.a)); + repMsg = "float64 %.17r".doFormat(cov(eX.a, eY.a)); } when (DType.Int64, DType.UInt64) { var eX = toSymEntry(x,int); var eY = toSymEntry(y,uint); - repMsg = "float64 %.17r".format(cov(eX.a, eY.a)); + repMsg = "float64 %.17r".doFormat(cov(eX.a, eY.a)); } when (DType.Float64, DType.Float64) { var eX = toSymEntry(x,real); var eY = toSymEntry(y,real); - repMsg = "float64 %.17r".format(cov(eX.a, eY.a)); + repMsg = "float64 %.17r".doFormat(cov(eX.a, eY.a)); } when (DType.Float64, DType.Int64) { var eX = toSymEntry(x,real); var eY = toSymEntry(y,int); - repMsg = "float64 %.17r".format(cov(eX.a, eY.a)); + repMsg = "float64 %.17r".doFormat(cov(eX.a, eY.a)); } when (DType.Float64, DType.Bool) { var eX = toSymEntry(x,real); var eY = toSymEntry(y,bool); - repMsg = "float64 %.17r".format(cov(eX.a, eY.a)); + repMsg = "float64 %.17r".doFormat(cov(eX.a, eY.a)); } when (DType.Float64, DType.UInt64) { var eX = toSymEntry(x,real); var eY = toSymEntry(y,uint); - repMsg = "float64 %.17r".format(cov(eX.a, eY.a)); + repMsg = "float64 %.17r".doFormat(cov(eX.a, eY.a)); } when (DType.Bool, DType.Bool) { var eX = toSymEntry(x,bool); var eY = toSymEntry(y,bool); - repMsg = "float64 %.17r".format(cov(eX.a, eY.a)); + repMsg = "float64 %.17r".doFormat(cov(eX.a, eY.a)); } when (DType.Bool, DType.Float64) { var eX = toSymEntry(x,bool); var eY = toSymEntry(y,real); - repMsg = "float64 %.17r".format(cov(eX.a, eY.a)); + repMsg = "float64 %.17r".doFormat(cov(eX.a, eY.a)); } when (DType.Bool, DType.Int64) { var eX = toSymEntry(x,bool); var eY = toSymEntry(y,int); - repMsg = "float64 %.17r".format(cov(eX.a, eY.a)); + repMsg = "float64 %.17r".doFormat(cov(eX.a, eY.a)); } when (DType.Bool, DType.UInt64) { var eX = toSymEntry(x,bool); var eY = toSymEntry(y,uint); - repMsg = "float64 %.17r".format(cov(eX.a, eY.a)); + repMsg = "float64 %.17r".doFormat(cov(eX.a, eY.a)); } when (DType.UInt64, DType.UInt64) { var eX = toSymEntry(x,uint); var eY = toSymEntry(y,uint); - repMsg = "float64 %.17r".format(cov(eX.a, eY.a)); + repMsg = "float64 %.17r".doFormat(cov(eX.a, eY.a)); } when (DType.UInt64, DType.Int64) { var eX = toSymEntry(x,uint); var eY = toSymEntry(y,int); - repMsg = "float64 %.17r".format(cov(eX.a, eY.a)); + repMsg = "float64 %.17r".doFormat(cov(eX.a, eY.a)); } when (DType.UInt64, DType.Float64) { var eX = toSymEntry(x,uint); var eY = toSymEntry(y,real); - repMsg = "float64 %.17r".format(cov(eX.a, eY.a)); + repMsg = "float64 %.17r".doFormat(cov(eX.a, eY.a)); } when (DType.UInt64, DType.Bool) { var eX = toSymEntry(x,uint); var eY = toSymEntry(y,bool); - repMsg = "float64 %.17r".format(cov(eX.a, eY.a)); + repMsg = "float64 %.17r".doFormat(cov(eX.a, eY.a)); } otherwise { - var errorMsg = unrecognizedTypeError(pn, "(%s,%s)".format(dtype2str(x.dtype),dtype2str(y.dtype))); + var errorMsg = unrecognizedTypeError(pn, "(%s,%s)".doFormat(dtype2str(x.dtype),dtype2str(y.dtype))); sLogger.error(getModuleName(),getRoutineName(),getLineNumber(),errorMsg); return new MsgTuple(errorMsg, MsgType.ERROR); } @@ -209,7 +210,7 @@ module StatsMsg { var x: borrowed GenSymEntry = getGenericTypedArrayEntry(msgArgs.getValueOf("x"), st); var y: borrowed GenSymEntry = getGenericTypedArrayEntry(msgArgs.getValueOf("y"), st); - var repMsg: string = "float64 %.17r".format(corrHelper(x, y)); + var repMsg: string = "float64 %.17r".doFormat(corrHelper(x, y)); sLogger.debug(getModuleName(),getRoutineName(),getLineNumber(),repMsg); return new MsgTuple(repMsg, MsgType.NORMAL); } @@ -266,7 +267,7 @@ module StatsMsg { return corr(toSymEntry(x,uint).a, toSymEntry(y,bool).a); } otherwise { - var errorMsg = unrecognizedTypeError(pn, "(%s,%s)".format(dtype2str(x.dtype),dtype2str(y.dtype))); + var errorMsg = unrecognizedTypeError(pn, "(%s,%s)".doFormat(dtype2str(x.dtype),dtype2str(y.dtype))); sLogger.error(getModuleName(),getRoutineName(),getLineNumber(),errorMsg); throw new owned IllegalArgumentError(errorMsg); } @@ -290,9 +291,9 @@ module StatsMsg { } var retname = st.nextName(); st.addEntry(retname, new shared SymEntry(corrPdarray)); - corrDict.add(col, "created %s".format(st.attrib(retname))); + corrDict.add(col, "created %s".doFormat(st.attrib(retname))); } - var repMsg: string = "%jt".format(corrDict); + var repMsg: string = formatJson(corrDict); sLogger.debug(getModuleName(),getRoutineName(),getLineNumber(),repMsg); return new MsgTuple(repMsg, MsgType.NORMAL); diff --git a/src/StatusMsg.chpl b/src/StatusMsg.chpl index 46e7ea382a..23cc357741 100644 --- a/src/StatusMsg.chpl +++ b/src/StatusMsg.chpl @@ -6,16 +6,17 @@ module StatusMsg { use MemoryMgmt; use MultiTypeSymbolTable; use MultiTypeSymEntry; + use ArkoudaIOCompat; private config const logLevel = ServerConfig.logLevel; private config const logChannel = ServerConfig.logChannel; const sLogger = new Logger(logLevel, logChannel); proc getMemoryStatusMsg(cmd: string, msgArgs: borrowed MessageArgs, st: borrowed SymTab): MsgTuple throws { - var statuses = "%jt".format(getLocaleMemoryStatuses()); + var statuses = formatJson(getLocaleMemoryStatuses()); sLogger.debug(getModuleName(),getRoutineName(),getLineNumber(), - 'memory statuses %jt'.format(statuses)); + 'memory statuses '+formatJson(statuses)); return new MsgTuple(statuses, MsgType.NORMAL); } } \ No newline at end of file diff --git a/src/TimeClassMsg.chpl b/src/TimeClassMsg.chpl index ac29566e0c..7cb44c1fbb 100644 --- a/src/TimeClassMsg.chpl +++ b/src/TimeClassMsg.chpl @@ -12,6 +12,8 @@ module TimeClassMsg { use ArkoudaTimeCompat as Time; use Map; + use ArkoudaMapCompat; + use ArkoudaIOCompat; private config const logLevel = ServerConfig.logLevel; private config const logChannel = ServerConfig.logChannel; @@ -65,30 +67,30 @@ module TimeClassMsg { var retname = st.nextName(); st.addEntry(retname, new shared SymEntry(day)); - attributesDict.addOrSet("day", "created %s".format(st.attrib(retname))); + attributesDict.addOrReplace("day", "created %s".doFormat(st.attrib(retname))); retname = st.nextName(); st.addEntry(retname, new shared SymEntry(month)); - attributesDict.add("month", "created %s".format(st.attrib(retname))); + attributesDict.add("month", "created %s".doFormat(st.attrib(retname))); retname = st.nextName(); st.addEntry(retname, new shared SymEntry(year)); - attributesDict.add("year", "created %s".format(st.attrib(retname))); + attributesDict.add("year", "created %s".doFormat(st.attrib(retname))); retname = st.nextName(); st.addEntry(retname, new shared SymEntry(is_leap_year)); - attributesDict.add("isLeapYear", "created %s".format(st.attrib(retname))); + attributesDict.add("isLeapYear", "created %s".doFormat(st.attrib(retname))); retname = st.nextName(); st.addEntry(retname, new shared SymEntry(dayOfYear)); - attributesDict.add("dayOfYear", "created %s".format(st.attrib(retname))); + attributesDict.add("dayOfYear", "created %s".doFormat(st.attrib(retname))); retname = st.nextName(); st.addEntry(retname, new shared SymEntry(isoYear)); - attributesDict.add("isoYear", "created %s".format(st.attrib(retname))); + attributesDict.add("isoYear", "created %s".doFormat(st.attrib(retname))); retname = st.nextName(); st.addEntry(retname, new shared SymEntry(weekOfYear)); - attributesDict.add("weekOfYear", "created %s".format(st.attrib(retname))); + attributesDict.add("weekOfYear", "created %s".doFormat(st.attrib(retname))); retname = st.nextName(); st.addEntry(retname, new shared SymEntry(dayOfWeek)); - attributesDict.add("dayOfWeek", "created %s".format(st.attrib(retname))); + attributesDict.add("dayOfWeek", "created %s".doFormat(st.attrib(retname))); - var repMsg: string = "%jt".format(attributesDict); + var repMsg: string = formatJson(attributesDict); tLogger.debug(getModuleName(),getRoutineName(),getLineNumber(),repMsg); return new MsgTuple(repMsg, MsgType.NORMAL); @@ -96,7 +98,7 @@ module TimeClassMsg { proc timeDeltaAttributesMsg(cmd: string, msgArgs: borrowed MessageArgs, st: borrowed SymTab): MsgTuple throws { var values: borrowed GenSymEntry = getGenericTypedArrayEntry(msgArgs.getValueOf("values"), st); - var repMsg: string = "%jt".format(simpleAttributesHelper(toSymEntry(values, int).a, st)); + var repMsg: string = formatJson(simpleAttributesHelper(toSymEntry(values, int).a, st)); tLogger.debug(getModuleName(),getRoutineName(),getLineNumber(),repMsg); return new MsgTuple(repMsg, MsgType.NORMAL); @@ -117,7 +119,7 @@ module TimeClassMsg { // "day" is not modded, because it's the last unit [(ei,vi) in zip(e.a,values)] ei = floorDivisionHelper(vi, denominator):int; } - attributesDict.add(u, "created %s".format(st.attrib(retname))); + attributesDict.add(u, "created %s".doFormat(st.attrib(retname))); denominator *= f; //denominator is product of previous factors } return attributesDict; diff --git a/src/Unique.chpl b/src/Unique.chpl index bd33fc5f45..22e2defd3d 100644 --- a/src/Unique.chpl +++ b/src/Unique.chpl @@ -115,7 +115,7 @@ module Unique var iv: [truth.domain] int = (+ scan truth); // compute how many segments var pop = iv[iv.size-1]; - try! uLogger.debug(getModuleName(),getRoutineName(),getLineNumber(),"pop = %t".format(pop)); + try! uLogger.debug(getModuleName(),getRoutineName(),getLineNumber(),"pop = %?".doFormat(pop)); var segs = makeDistArray(pop, int); var ukeys = makeDistArray(pop, eltType); @@ -248,7 +248,7 @@ module Unique var iv: [aD] int = (+ scan truth); // compute how many segments var pop = iv[iv.size-1]; - uLogger.debug(getModuleName(),getRoutineName(),getLineNumber(),"pop = %t".format(pop)); + uLogger.debug(getModuleName(),getRoutineName(),getLineNumber(),"pop = %?".doFormat(pop)); var segs = makeDistArray(pop, int); var counts = makeDistArray(pop, int); diff --git a/src/UniqueMsg.chpl b/src/UniqueMsg.chpl index ac5df48e32..f596d06617 100644 --- a/src/UniqueMsg.chpl +++ b/src/UniqueMsg.chpl @@ -122,7 +122,7 @@ module UniqueMsg var g = getSegString(myNames, st); var (uSegs, uVals) = g[gatherInds]; var newStringsObj = getSegString(uSegs, uVals, st); - repMsg += "created " + st.attrib(newStringsObj.name) + "+created bytes.size %t".format(newStringsObj.nBytes); + repMsg += "created " + st.attrib(newStringsObj.name) + "+created bytes.size %?".doFormat(newStringsObj.nBytes); } } } diff --git a/src/compat/e-130/ArkoudaIOCompat.chpl b/src/compat/e-130/ArkoudaIOCompat.chpl new file mode 100644 index 0000000000..d0c5697dbc --- /dev/null +++ b/src/compat/e-130/ArkoudaIOCompat.chpl @@ -0,0 +1,50 @@ +module ArkoudaIOCompat { + use IO; + + proc formatString(input) throws { + return input:string; + } + + proc formatJson(input): string throws { + return "%jt".format(input); + } + + proc formatJson(input:string, vals...?): string throws { + var toUse = input.replace("%?", "%jt"); + return toUse.format((...vals)); + } + + proc string.doFormat(vals...?): string throws { + var toUse = this.replace('%?', '%t'); + return toUse.format((...vals)); + } + + proc jsonToTupleCompat(json: string, type t) throws { + var f = openMemFile(); + var w = f.writer(); + w.write(json); + w.close(); + var r = f.reader(); + var tup: t; + r.readf("%jt", tup); + r.close(); + return tup; + } + + proc jsonToPdArrayCompat(json: string, size: int) throws { + var f = openMemFile(); + var w = f.writer(); + w.write(json); + w.close(); + var r = f.reader(); + var array: [0..#size] string; + r.readf("%jt", array); + r.close(); + return array; + } + + proc readfCompat(f: file, str: string, ref obj) throws { + var nreader = f.reader(); + nreader.readf("%jt", obj); + } +} diff --git a/src/compat/e-130/ArkoudaMapCompat.chpl b/src/compat/e-130/ArkoudaMapCompat.chpl new file mode 100644 index 0000000000..72afd822ce --- /dev/null +++ b/src/compat/e-130/ArkoudaMapCompat.chpl @@ -0,0 +1,7 @@ +module ArkoudaMapCompat { + public use Map; + + proc map.addOrReplace(in k: keyType, in v: valType) { + this.addOrSet(k, v); + } +} diff --git a/src/compat/eq-131/ArkoudaIOCompat.chpl b/src/compat/eq-131/ArkoudaIOCompat.chpl new file mode 100644 index 0000000000..d0c5697dbc --- /dev/null +++ b/src/compat/eq-131/ArkoudaIOCompat.chpl @@ -0,0 +1,50 @@ +module ArkoudaIOCompat { + use IO; + + proc formatString(input) throws { + return input:string; + } + + proc formatJson(input): string throws { + return "%jt".format(input); + } + + proc formatJson(input:string, vals...?): string throws { + var toUse = input.replace("%?", "%jt"); + return toUse.format((...vals)); + } + + proc string.doFormat(vals...?): string throws { + var toUse = this.replace('%?', '%t'); + return toUse.format((...vals)); + } + + proc jsonToTupleCompat(json: string, type t) throws { + var f = openMemFile(); + var w = f.writer(); + w.write(json); + w.close(); + var r = f.reader(); + var tup: t; + r.readf("%jt", tup); + r.close(); + return tup; + } + + proc jsonToPdArrayCompat(json: string, size: int) throws { + var f = openMemFile(); + var w = f.writer(); + w.write(json); + w.close(); + var r = f.reader(); + var array: [0..#size] string; + r.readf("%jt", array); + r.close(); + return array; + } + + proc readfCompat(f: file, str: string, ref obj) throws { + var nreader = f.reader(); + nreader.readf("%jt", obj); + } +} diff --git a/src/compat/eq-131/ArkoudaMapCompat.chpl b/src/compat/eq-131/ArkoudaMapCompat.chpl index 3835b040c4..72afd822ce 100644 --- a/src/compat/eq-131/ArkoudaMapCompat.chpl +++ b/src/compat/eq-131/ArkoudaMapCompat.chpl @@ -1,3 +1,7 @@ module ArkoudaMapCompat { public use Map; + + proc map.addOrReplace(in k: keyType, in v: valType) { + this.addOrSet(k, v); + } } diff --git a/src/compat/gt-131/ArkoudaIOCompat.chpl b/src/compat/gt-131/ArkoudaIOCompat.chpl new file mode 100644 index 0000000000..784a0a6dd2 --- /dev/null +++ b/src/compat/gt-131/ArkoudaIOCompat.chpl @@ -0,0 +1,52 @@ +module ArkoudaIOCompat { + use IO, JSON; + + proc formatString(input) throws { + return "%?".format(input); + } + + proc formatJson(input): string throws { + var f = openMemFile(); + f.writer(serializer = new JsonSerializer()).write(input); + return f.reader().readAll(string); + } + + proc formatJson(input:string, vals...?): string throws { + var f = openMemFile(); + f.writer(serializer = new JsonSerializer()).writef(input, (...vals)); + return f.reader().readAll(string); + } + + proc string.doFormat(vals...?): string throws { + return this.format((...vals)); + } + + proc jsonToTupleCompat(json: string, type t) throws { + var f = openMemFile(); + var w = f.writer(); + w.write(json); + w.close(); + var r = f.reader(deserializer=new JsonDeserializer()); + var tup: t; + r.readf("%?", tup); + r.close(); + return tup; + } + + proc jsonToPdArrayCompat(json: string, size: int) throws { + var f = openMemFile(); + var w = f.writer(); + w.write(json); + w.close(); + var r = f.reader(deserializer=new JsonDeserializer()); + var array: [0..#size] string; + r.readf("%?", array); + r.close(); + return array; + } + + proc readfCompat(f: file, str: string, ref obj) throws { + var nreader = f.reader(deserializer=new JsonDeserializer()); + nreader.readf("%?", obj); + } +} diff --git a/tests/operator_tests.py b/tests/operator_tests.py index 36a0446c79..c136f422c0 100755 --- a/tests/operator_tests.py +++ b/tests/operator_tests.py @@ -732,11 +732,12 @@ def test_str_repr(self): # Test __str__() self.assertEqual("[1 2 3]", ak.array([1, 2, 3]).__str__()) self.assertEqual("[1 2 3 ... 17 18 19]", ak.arange(1, 20).__str__()) - self.assertEqual("[1.100000e+00 2.300000e+00 5.000000e+00]", ak.array([1.1, 2.3, 5]).__str__()) - self.assertEqual( - "[0.000000e+00 5.263158e-01 1.052632e+00 ... 8.947368e+00 9.473684e+00 1.000000e+01]", - ak.linspace(0, 10, 20).__str__(), - ) + # Printing floating point values changed precision in Chapel 1.32 + answers = ["[1.100000e+00 2.300000e+00 5.000000e+00]", "[1.1 2.3 5.0]"] + self.assertTrue(ak.array([1.1, 2.3, 5]).__str__() in answers) + answers = ["[0.000000e+00 5.263158e-01 1.052632e+00 ... 8.947368e+00 9.473684e+00 1.000000e+01]", + "[0.0 0.526316 1.05263 ... 8.94737 9.47368 10.0]"] + self.assertTrue(ak.linspace(0, 10, 20).__str__() in answers) self.assertEqual("[False False False]", ak.isnan(ak.array([1.1, 2.3, 5])).__str__()) self.assertEqual( "[False False False ... False False False]", ak.isnan(ak.linspace(0, 10, 20)).__str__() @@ -745,14 +746,12 @@ def test_str_repr(self): # Test __repr__() self.assertEqual("array([1 2 3])", ak.array([1, 2, 3]).__repr__()) self.assertEqual("array([1 2 3 ... 17 18 19])", ak.arange(1, 20).__repr__()) - self.assertEqual( - "array([1.1000000000000001 2.2999999999999998 5])", ak.array([1.1, 2.3, 5]).__repr__() - ) - self.assertEqual( - "array([0 0.52631578947368418 1.0526315789473684 ... " - "8.9473684210526319 9.473684210526315 10])", - ak.linspace(0, 10, 20).__repr__(), - ) + answers = ["array([1.1000000000000001 2.2999999999999998 5])", "array([1.1 2.3 5])"] + self.assertTrue(ak.array([1.1, 2.3, 5]).__repr__() in answers) + + answers = ["array([0 0.52631578947368418 1.0526315789473684 ... 8.9473684210526319 9.473684210526315 10])", + "array([0 0.5 1.1 ... 8.9 9.5 10])"] + self.assertTrue(ak.linspace(0, 10, 20).__repr__() in answers) self.assertEqual("array([False False False])", ak.isnan(ak.array([1.1, 2.3, 5])).__repr__()) self.assertEqual( "array([False False False ... False False False])",