Skip to content

Add anymaputils#740

Open
bsofjan wants to merge 1 commit into
DataIntellectTech:masterfrom
bsofjan:anymaputils
Open

Add anymaputils#740
bsofjan wants to merge 1 commit into
DataIntellectTech:masterfrom
bsofjan:anymaputils

Conversation

@bsofjan

@bsofjan bsofjan commented May 20, 2026

Copy link
Copy Markdown

Add anymaputils

@CJA18 CJA18 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)

Comment thread code/common/anymaputils.q

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lots of camelCase here, please remove

Comment thread code/common/anymaputils.q
@@ -0,0 +1,5 @@
.anymap.writeToAnyMap:{[data;filePath] (hsym filePath) 1: data; :(::)}
.anymap.deriveAnymapFiles:{[filePath] strPath: string[filePath]; `$(strPath;strPath,"#";strPath,"##")}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
.anymap.deriveAnymapFiles:{[filePath] strPath: string[filePath]; `$(strPath;strPath,"#";strPath,"##")}
.anymap.deriveAnymapFiles:{[filePath] `$string[filePath],/:("";"#";"##")}

think something like this should work the same

Comment thread code/common/anymaputils.q
@@ -0,0 +1,5 @@
.anymap.writeToAnyMap:{[data;filePath] (hsym filePath) 1: data; :(::)}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread code/common/anymaputils.q
.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

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants