Getting summary information without walking the tree

Following up on earlier discussions, I am now trying to get a list of buffers with the following

define variable molBufferList as class java.util.Set no-undo.
define variable mobIterator as class java.util.Iterator no-undo.
define variable mobTableBuffer as class TableBuffer no-undo.

molBufferList = ipobParseUnit:getRootScope():getBufferSet().
mobIterator = molBufferList:iterator().

do while mobIterator:hasNext():
mobTableBuffer = cast( mobIterator:next(), TableBuffer ).

But, this is giving me:

Error: Invalid cast from java.util.HashMap+Entry to org.prorefactor.treeparser.TableBuffer
So, I seem to get the java.util.Set correctly, but presumably its contents are not supersets of TableBuffer. So, what are they?


Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
tamhas's picture

One thing that is eluding me

One thing that is eluding me at this point (in addition to the unanswered questions above) is how to tell the difference between the entries for a define buffer statement and a define temp-table or define work-table/workfile statement.

Yes, the symbol:FullName() and the table:getName() will match for the TT and WT, but there is nothing illegal about defining a buffer that matches the table name, so that is not diagnostic. Plus, I need to know that it is a TT or WT vs a DB table.


tamhas's picture

Well, I have something

Well, I have something working, but it isn't pretty. When there is a define node, I am walking down into that to get the object type so that I can treat Temp-tables and Work-tables separately from buffers.

The same process is getting me whether it is global or not.

Works, but it seems like there should be a cleaner way.


tamhas's picture

mobTableBuffer:getTable():get

mobTableBuffer:getTable():getDatabase()

returns

org.prorefactor.core.schema.Database@d93ee2

What's that?


tamhas's picture

Making further progress:

Making further progress:

define variable molBufferList as class java.util.ArrayList no-undo.
define variable mobIterator as class java.util.Iterator no-undo.
define variable mobSymbol as class Symbol no-undo.
define variable mobTableBuffer as class TableBuffer no-undo.
define variable mobTable as class org.prorefactor.core.schema.Table no-undo.

molBufferList = ipobParseUnit:getRootScope():getAllSymbolsDeep( ).
mobIterator = molBufferList:iterator().

do while mobIterator:hasNext():
mobSymbol = cast( mobIterator:next(), Symbol ).

if NodeTypes:getTypeName(mobSymbol:getProgressType()) <> "BUFFER" then next.

mobTableBuffer = cast( mobSymbol, TableBuffer ).
mobTable = mobTableBuffer:getTable().

mobSymbol:fullName() is getting me the qualified name including the database or not qualified if a temp-table.
mobTable:getName() gets me the name, not qualified, of the actual table.

One thing that is confusing, though, is that

define shared buffer bf_File for _File.

gives me two entries

DICTDB._File|no|no|_File|
DICTDB.bf_File|yes|no|_File|

where the logicals are
mobSymbol:isImported()
mobSymbol:isExported()

So, the second one makes sense because it is shared and it has the buffer name in fullName and the real name in the Table:getName, but then what is the first line?

Am I going to have to follow these to the getDefineNode or getIndirectDefineIdNode in order to tell what it is?


tamhas's picture

I tried an example where I

I tried an example where I had a buffer parameter to a function. It appears that, for a simple buffer definition like above, that the buffer name is in fullName() and the real name of the table in Table:getName() and the same is true of an implicit buffer definition in the form of a buffer parameter to a function. In both cases, there is a second entry with the qualified table name in fullName() and neither a DefineNode nor an IndirectDefineNode. My guess is that this means the second one is a placeholder for a connection to the database table and the first one is the actual buffer definition.

Reasonable?


tamhas's picture

This view is reinforced by

This view is reinforced by providing a second buffer parameter with a different buffer name, but pointing to the same table. One gets symbols for each buffer name, but only one symbol for the table.


tamhas's picture

So, tried a different

So, tried a different approach:

define variable molBufferList as class java.util.ArrayList no-undo.
define variable mobIterator as class java.util.Iterator no-undo.
define variable mobSymbol as class Symbol no-undo.
define variable minWhich as integer no-undo.

if (ipobParseUnit eq ?) then return.

molBufferList = ipobParseUnit:getRootScope():getAllSymbolsDeep( ).
mobIterator = molBufferList:iterator().

do while mobIterator:hasNext():
mobSymbol = cast( mobIterator:next(), Symbol ).

if NodeTypes:getTypeName(mobSymbol:getProgressType()) <> "BUFFER" then next.

This works, but I can find no expression to use as an argument to getAllSymbolsDeep() that will return only buffers.

I am also not currently seeing how to get the table name that goes with the buffer name.