Add anymaputils#740
Conversation
CJA18
left a comment
There was a problem hiding this comment.
This PR looks good to me - only consideration would be to switch the namespace names to .util.anymap.XXX to indicate that it is a util function (we use this naming convention on my client), but this is only if it makes sense in the context of the wider codebase (I haven't checked I will leave that to you @bsofjan)
There was a problem hiding this comment.
lots of camelCase here, please remove
| @@ -0,0 +1,5 @@ | |||
| .anymap.writeToAnyMap:{[data;filePath] (hsym filePath) 1: data; :(::)} | |||
| .anymap.deriveAnymapFiles:{[filePath] strPath: string[filePath]; `$(strPath;strPath,"#";strPath,"##")} | |||
There was a problem hiding this comment.
| .anymap.deriveAnymapFiles:{[filePath] strPath: string[filePath]; `$(strPath;strPath,"#";strPath,"##")} | |
| .anymap.deriveAnymapFiles:{[filePath] `$string[filePath],/:("";"#";"##")} |
think something like this should work the same
| @@ -0,0 +1,5 @@ | |||
| .anymap.writeToAnyMap:{[data;filePath] (hsym filePath) 1: data; :(::)} | |||
There was a problem hiding this comment.
most data writing functions in q have filepath as first param & data as second (e.g. set, upsert etc.). Seems unintuitive to have this the other way round.
| .anymap.deriveAnymapFiles:{[filePath] strPath: string[filePath]; `$(strPath;strPath,"#";strPath,"##")} | ||
| .anymap.util.copyAnyMap:{[fromFilePath; destFilePath] fromFilePaths:.anymap.deriveAnymapFiles[fromFilePath]; system (("cp "," " sv string fromFilePaths), " ", string destFilePath)} | ||
| .anymap.util.removeAnyMap:{[filePath] filePaths:.anymap.deriveAnymapFiles[filePath]; system ("rm "," " sv string filePaths)} | ||
| .anymap.util.moveAnyMap:{[fromFilePath; destFilePath] fromFilePaths:.anymap.deriveAnymapFiles[fromFilePath]; system (("mv "," " sv string fromFilePaths), " ", string destFilePath)} No newline at end of file |
There was a problem hiding this comment.
these copy/remove/move functions rely on system commands and will only work on Linux. Should use the functions in .os namespace of torq so that they work cross-platform.
Add anymaputils