CLDM has a custom query syntax. Based on the commands and their execution, all the data is stored in a bson file (inside users local machines).
CLDM is a case sensitive query language which uses a python based runner or compiler. So, the commands should be entered in the same case as mentioned in the documentation.
Every CLDM file should start with either creation of Database by >> CREATE DATABASE my_file.bson or loading a prexisting database >> LOAD DATABASE my_file.bson otherwise any other command will not be executed showing an error of database not being loaded. CLDM doesn't come with any kind of keyword restrictions. So, the user can use keywords alsp as a loop name, segment name or data value but it isn't recommended because that can cause ambiguous data storage and retrieval issues.
To use CLDM, you need to have the cldm_runner executable in your working directory. The cldm_runner executable is a command line tool that executes the CLDM commands. You can put the CLDM commands in a text file with '.cldm extension' (e.g., example.cldm) and then run the cldm_runner executable with the input file as an argument.
Inside the CLDM file, every executable line or the query should begin with '>>' and then the command should be written. For commenting a line, use '<<' which will exclude or ignore the line furing execution.
Click here to download CLDM runner exe file
Put this into your working directory and execute any cldm file through the terminal as:
./cldm_runner example.cldm
Creates and loads a bson file where loops, segments and their rspective entries are stored.
Syntax:
>> CREATE DATABASE <filename>.bson
Example:
>> CREATE DATABASE my_new_database.bson
Output:
Database 'my_new_database.bson' created and loaded for use.
Loads a bson file where loops, segments and their rspective entries are stored.
Syntax:
>> LOAD DATABASE <filename>.bson
Example:
>> LOAD DATABASE my_new_database.bson
Output:
Loaded database: my_new_database.bson
Creates a loop in the database. There can be multiple loops within one database (bson file). No two loops can have the same name within the same database.
Syntax:
>> FORGE LOOP <LOOP NAME>
Example:
>> FORGE LOOP CustomerOrders
Output:
Loop CustomerOrders created.
Segments a loop into a segment. A loop can have multiple segments and the segment can be used to store data in a structured format. No two segments can have the same name within the same loop.
Syntax:
>> SEGMENT LOOP <LOOP NAME> INTO <SEGMENT NAME>
Example:
>> SEGMENT LOOP CustomerOrders INTO Customers
Output:
Segment Customers added to Loop CustomerOrders.
Inserts a data value into the segment of the specified loop. Data crafted into a segment is typically handled as a string. This ensures consistent data manipulation, storage, and retrieval across the database. Using strings as a universal format simplifies the parsing and formatting of the data when executing CLDM commands, as well as reduces type conflicts between different data inputs.
Syntax:
>> CRAFT "<DATA>" INTO <SEGMENT NAME> IN <LOOP NAME>
Example:
>> CRAFT "Alice" INTO Customers IN CustomerOrders
Output:
Value Alice added to Segment Customers in Loop CustomerOrders.
Changes the master segment of the specified loop to the given segment. A master segment have all values unique within it. If a current master segment is crafted with a data value which is not unique, then within the same loop any other segment with unique values will be assigned as master segment. If none of the segment is unique, then a default master segment is created with unique values in the same loop. User can't enter value into this DefaultMasterSegment. Also if some other segment is selected as a master segment, then also DefaultMasterSegment persists until it is removed by the user. In case user tries to assign a segment with non-unique values as master segment then an error is shown.
Syntax:
>> CHANGE MASTER SEGMENT OF <LOOP NAME> TO <SEGMENT NAME>
Example 1:
>> CHANGE MASTER SEGMENT OF CustomerOrders TO Customers
Output:
Master Segment changed to Customers for Loop CustomerOrders.
Example 2: (We assume that "Orders" is a segment with non-unique values)
>> CHANGE MASTER SEGMENT OF CustomerOrders TO Orders
Output:
Error: Segment Orders contains non-unique values and cannot be used as the Master Segment.
Links the specified segment of the specified loop to the given segment of the other loop. If the loop or the segment doesn't exist, then error will be shown. (Note: Currently link segment doesn't perform any specific task, the command will be updated soon).
Syntax:
>> LINK SEGMENT <SEGMENT NAME> IN <LOOP NAME> TO <SEGMENT NAME> IN <LOOP NAME>
Example:
>> LINK SEGMENT Names IN DataLoop TO Customers IN CustomerOrders
Output:
Segment 'Names' in Loop 'DataLoop' linked to Segment 'Customers' in Loop 'CustomerOrders'.
Provide details about the specified loop which includes the segments, data values and master segment.
Syntax:
>> VIZUALIZE LOOP <LOOP NAME>
Example:
>> VISUALIZE LOOP DataLoop
Output:
Loop: DataLoop Segments: Names, Names2 Segment Entries: Segment: Names - Alice - Bob - Charlie ---------------------------------------- Segment: Names2 (MS) - Charlie ----------------------------------------
Removes everything from the current loaded database (bson file) including every loop, segment and data entry along with the file.
Syntax:
>> DESTROY DATABASE
Example:
>> DESTROY DATABASE
Output:
Database 'my_new_database.bson' destroyed successfully.
Retrieves data of a segment from the specified loop. Multiple segments can be specified to extract data across several segments.
Syntax:
>> EXTRACT ENTRIES OF <SEGMENT NAME> WITHIN <LOOP NAME>
Example 1:
>> EXTRACT ENTRIES OF Customers WITHIN CustomerOrders
Output:
Basic Retrieval Results for Loop 'CustomerOrders': Segment Customers: Alice, Bob, Charlie
Example 2:
>>EXTRACT ENTRIES OF Customers, Orders WITHIN CustomerOrders
Output:
Basic Retrieval Results for Loop 'CustomerOrders': Segment Customers: Alice, Bob, Charlie Segment Orders: Order001, Order002, Order003
Retrieves data of a segment from the specified loop based on a specific condition. Multiple segments can be specified to extract data across several segments. The command constitues Loop Name which is then filtered by a data value inside a specific segment.
Syntax:
EXTRACT ENTRIES OF <SEGMENT NAME> WITHIN <LOOP NAME> FILTER BY <SEGMENT NAME> MATCHES <"DATA">
Example 1:
>> EXTRACT ENTRIES OF Orders WITHIN CustomerOrders FILTER BY Customers MATCHES "Alice"
Output:
Conditional Retrieval Results for Loop 'CustomerOrders': Segment Orders: Order001
Example 2:
>> EXTRACT ENTRIES OF Orders, OrderAmounts WITHIN CustomerOrders FILTER BY Customers MATCHES "Alice"
Output:
Conditional Retrieval Results for Loop 'CustomerOrders': Segment Orders: Order001 Segment OrderAmounts: 250
Retrieves data of a segment from the specified loop based on a specific pattern. The charcater specified will matche the data string value from the first character only.
Syntax:
>> EXTRACT ENTRIES OF <SEGMENT NAME> WITHIN <LOOP NAME> FILTER BY <SEGEMENT NAME> RESEMBLES "^<CHARACTER>.*"
Example:
>> EXTRACT ENTRIES OF Customers WITHIN CustomerOrders FILTER BY Customers RESEMBLES "^C.*"
Output:
Pattern-Based Retrieval Results for Loop 'CustomerOrders': Segment Customers: Charlie
Retrieves data of a segment from the specified loop based on the filtered segment by a specific order. The data values are sorted in ascending or descending order.
Syntax:
>> EXTRACT ENTRIES OF <SEGMENT NAME> WITHIN <LOOP NAME> SORTED AS <SEGMENT NAME> <ASCENDING / DESCENDING>
Example:
>> EXTRACT ENTRIES OF Orders, OrderAmounts WITHIN CustomerOrders SORTED AS OrderAmounts ASCENDING
Output: (The 'Orders' Segment returns the values based on 'OrderAmounts' segment which was sorted in ascending order)
Ordered Retrieval Results for Loop 'CustomerOrders': Segment Orders: Order003, Order001, Order002 Segment OrderAmounts: 150, 250, 400
Retrieves data of a segment from the specified loop based on the filtered segment by limiting the number of entries to be retrieved. The number of entries can be specified as per the requirement.
Syntax:
>> EXTRACT ENTRIES OF <SEGMENT NAME> WITHIN <LOOP NAME> LIMIT TO <NUMBER> ENTRIES
Example:
>> EXTRACT ENTRIES OF Orders WITHIN CustomerOrders LIMIT TO 2 ENTRIES
Output:
Limiting Retrieval Results for Loop 'CustomerOrders': Segment Orders: Order001, Order002
Retrieves data of a segment from the specified loop based on the filtered segment and a combined condition. The combined condition can be specified using logical operator 'AND'.
Syntax:
>> EXTRACT ENTRIES OF <SEGMENT NAME> WITHIN <SEGMENT NAME> FILTER BY <SEGMENT NAME> MATCHES <"DATA"> AND <SEGMENT NAME> MATCHES <"DATA">
Example:
>> EXTRACT ENTRIES OF Orders, OrderAmounts WITHIN CustomerOrders FILTER BY Customers MATCHES "Alice" AND OrderAmounts MATCHES "250"
Output: (It retrieved 'Orders' and 'OrderAmounts' from the specified loop, filtering it by the segment 'Customers' where the entry matches with data value "Alice" and the segment OrderAmounts where data value matches "250")
Combined Conditions Retrieval Results for Loop 'CustomerOrders': Segment Orders: Order001 Segment OrderAmounts: 250
Retrieves unique data values of a segment from the specified loop.
Syntax:
>> EXTRACT DISTINCT ENTRIES OF <SEGMENT NAME> WITHIN <LOOP NAME>
Example:
>> EXTRACT DISTINCT ENTRIES OF Customers WITHIN CustomerOrders
Output:
Unique Entry Retrieval Results for Loop 'CustomerOrders': Segment Customers: Alice, Charlie, Bob
Counts the total number of entries in the specified segment within the specified loop. Non-unique values are also counted.
Syntax:
>> TALLY ENTRIES IN <SEGMENT NAME> WITHIN <LOOP NAME>
Example:
>> TALLY ENTRIES IN Orders WITHIN CustomerOrders
Output:
Total entries in segment 'Orders' within loop 'CustomerOrders': 9
Aggregates data values of a segment within the specified loop based on the specified aggregation function. The aggregation function can be 'SUM' (it returns the sum of all the number values by typecasting them from strings to float), 'GATHER MAXIMUM' (it returns the maximum numerical value available within the segment), 'GATHER MINIMUM' (it returns the minimum numerical value available in the segment), or 'COLLECT' (it returns a collection of all the numerical values). In case if a segment consists of both values which can or can not be converted to float, then all the convertable values are returned.
Syntax:
>> COMBINE <SUM/GATHER MAXIMUM/GATHER MINIMUM/COLLECT> VALUES OF <SEGMENT NAME> WITHIN <LOOP NAME> ?(optional)FILTER BY <SEGMENT NAME> MATCHES <"DATA">
Example 1:
>> COMBINE SUM VALUES OF OrderAmounts WITHIN CustomerOrders
Output:
SUM of OrderAmounts within 'CustomerOrders': 800.0
Example 2:
>> COMBINE GATHER MAXIMUM VALUES OF OrderAmounts WITHIN CustomerOrders
Output:
GATHER MAXIMUM of OrderAmounts within 'CustomerOrders': 400.0
Example 3:
>> COMBINE GATHER MINIMUM VALUES OF OrderAmounts WITHIN CustomerOrders
Output:
GATHER MINIMUM of OrderAmounts within 'CustomerOrders': 150.0
Example 4:
>> COMBINE COLLECT VALUES OF OrderAmounts WITHIN CustomerOrders
Output:
COLLECT of OrderAmounts within 'CustomerOrders': [250.0, 400.0, 150.0]
Example 5:
>> COMBINE SUM VALUES OF OrderAmounts WITHIN CustomerOrders FILTER BY Customers MATCHES "Alice"
Output:
SUM of OrderAmounts within 'CustomerOrders': 250.0
Deletes the specified loop and all the data associated within.
Syntax:
>> DISMANTLE LOOP <LOOP NAME>
Example:
>> DISMANTLE LOOP TestLoop
Output:
Loop 'TestLoop' dismantled.
Removes the specified segment from the specified loop.
Syntax:
>> REMOVE SEGMENT <SEGMENT NAME> FROM LOOP <LOOP NAME>
Example:
>> REMOVE SEGMENT RemovableSegment FROM LOOP AnotherLoop
Output:
Segment 'RemovableSegment' removed from loop 'AnotherLoop'.
Removes the specified data value from the specified segment in the specified loop.
Syntax:
>> REMOVE "<DATA>" FROM SEGMENT <SEGMENT NAME> IN LOOP <LOOP NAME>
Example:
>> REMOVE "Alice" FROM SEGMENT Names IN LOOP DataLoop
Output:
Data 'Alice' removed from segment 'Names' in loop 'DataLoop'.