An Interest In:
Web News this Week
- April 27, 2024
- April 26, 2024
- April 25, 2024
- April 24, 2024
- April 23, 2024
- April 22, 2024
- April 21, 2024
A Quick Universe Snippet
This is about the multivalue database, Universe and a node library that I wrote to talk to it. I have an article about installing Universe if anyone wants to try using a more esoteric and weird database than the usual SQL ones :)
A quick snippet to select a file and read in every record. I'm using this to generate a file of ids and their descriptions. Doing this in BASIC would be quite easy as well, it would actually be identical for the most part but I can't catch the output as easily as just running the script with stout pointed to a file.
const mv = require("pick-mv");const Universe = require("pick-universe");const uv = new Universe("localhost", "username", "password", "/path/to/account");uv.StartSession();const INV = uv.Open("INVENTORY-FILE");uv.Select(INV);while (true) { let id = uv.ReadNext(); if (id === null) break; let record = mv.MVMatrix(uv.Read(id, INV)); console.log(id, record[[1]]);}uv.EndAllSessions();
The core code in BASIC, line wise, they end up very similar but performance wise, huge difference. I had to run the javascript version for 2 minutes versus the BASIC version that ran in a few seconds.
OPEN "INVENTORY-FILE" TO INV ELSE STOPSELECT INVLOOP READNEXT ID ELSE ID = ''WHILE ID # '' DO READ RECORD FROM INV, ID ELSE RECORD = ''REPEAT
It would be worth generating a vim snippet to automatically get hints for the functions. I also need to profile if it's worth doing this readnext in javascript or if its better to do it in C and then do the MVMatrix in javascript land.
Original Link: https://dev.to/krowemoh/a-quick-universe-snippet-5g2n
Dev To
An online community for sharing and discovering great ideas, having debates, and making friendsMore About this Source Visit Dev To