top of page
DSC00698.JPG

Working With gDS Tables

The test platforms referenced in this website all use a Python-specific “global data store” called “gDS”.

 

See the README below for documentation on gDS V2:

 

        https://talborough.github.io/tcsDocs/README_gDS/ 

 

gDS is unconvential. It's being presented because it works very well in test platforms. You can review its primary characteristics below. You can also use an alternative to gDS if you so choose.

 

See Case Study 1 for a tutorial on gDS.

Creating "ordinary", "non-global" tables

Tables in gDS can be built from collections of Python “lists.” Each Python list is a column of data in the table. For example:

 

    gPerson_Name = []

    gPerson_DOB = []

    gPerson_SSN = []

    gPerson_RowStatus = []

 

Python practitioners can see the above code contains no “special” Python syntax. The variables are not special in any way — it's just a plain-vanilla declaration of 4 ordinary lists.

Creating tables in shared memory

In order to make lists / tables in shared memory, one does the following:

 

    from multiprocessing import Manager

    gDSMgr = Manager()

 

    gPerson_Name = gDSMgr.list()

    gPerson_DOB = gDSMgr.list()

    gPerson_SSN = gDSMgr.list()

    gPerson_RowStatus = gDSMgr.list()

 

The code above creates four list variables in shared memory. The variables do not need to be cited in a Python “global” statement to be used anywhere in the running program or its spawned threads and processes.

Working with data in shared memory tables

To add one “row” of data to the above table/set of lists, use the Python “append” method just like a regular list:

 

    gPerson_Name.append("Tom")

    gPerson_DOB.append("1/1/1970")

    gPerson_SSN.append("100-20-0300")

    gPerson_RowStatus.append(None)

 

The above table is considered to contain one row of data, and that data is said to reside at “offset zero.” To print one column of that one new row of data:

 

    print (gPerson_SSN[0])

 

To print out all the data in the table above, one would write in Python:

 

    for personRef in range(len(gPerson_RowStatus)):

        print (gPerson_Name[personRef],

            gPerson_DOB[personRef],

            gPerson_SSN[personRef])

bottom of page