SEMOSS uses internal data structures to represent and manipulate data within the Java backend, primarily through the ITableDataFrame interface and the SelectQueryStruct class for defining queries.
The prerna.algorithm.api.ITableDataFrame interface is the primary abstraction for in-memory tabular and graph-like data structures. Concrete implementations handle data storage and querying for different backends.
-
prerna.ds.shared.AbstractTableDataFrame: A base class providing common functionalities:- Metadata (
OwlTemporalEngineMeta metaData): Describes the frame's structure (headers, types, relationships). - Filtering (
GenRowFilters grf): Manages filters applied to the frame. - Querying: Defines a
query(SelectQueryStruct qs)method for querying the frame's data. - Caching: Caches metrics like column uniqueness.
- Persistence: Methods for saving/loading frame metadata and state.
- Metadata (
-
Key Implementations (found in
src/prerna/ds/):TinkerFrame.java: For graph data, using Apache TinkerPop'sTinkerGraph. Executes Gremlin queries translated fromSelectQueryStruct.H2Frame.java: For tabular data backed by an in-memory H2 database. Executes SQL queries translated fromSelectQueryStruct.NativeFrame.java: A pure Java in-memory table, suitable for smaller datasets.PandasFrame.java: Wraps a Pandas DataFrame in a Python environment, delegating operations.RDataTable.java: Wraps an Rdata.tableordata.frame.SparkDataFrame.java: Represents a Spark DataFrame for distributed data.
The prerna.query.querystruct.SelectQueryStruct (QS) is a Java object that represents a query in an abstract, database-agnostic manner. It allows SEMOSS to define data retrieval and manipulation operations (select, filter, join, group by, order by) programmatically before they are translated into the native language of a target data store (which could be an external IEngine or an in-memory ITableDataFrame).
- Purpose: To provide a common structure for defining queries that can be executed against various backends.
- Key Components: Selectors, filters, joins, groupings, orderings, limit/offset.
- Interaction:
- Reactors often build or modify
SelectQueryStructobjects based on Pixel commands. - These QS objects are then passed to an
IEngineor anITableDataFrame. - Engine-specific interpreters (e.g.,
SqlInterpreter,GremlinInterpreter) translate the QS into executable queries (SQL, Gremlin, etc.).
- Reactors often build or modify
(For a detailed guide on constructing and using SelectQueryStruct with Java examples, particularly for SQL databases, see docs/engines/database_engines.md#in-depth-the-selectquerystruct-sql-focused)).
- Loading Data: Data is typically fetched from an external
IEngineusing aSelectQueryStruct. The engine executes this (e.g., as SQL). - Frame Population: The results are then loaded into an appropriate
ITableDataFrameimplementation (e.g.,H2Frame). - In-Memory Operations: Subsequent Pixel operations might query or modify this in-memory frame directly using its
query(SelectQueryStruct qs)method or otherITableDataFrameAPIs.
This layered approach allows SEMOSS to abstract data sources and provide a consistent way to work with data, whether it's remote or held in local memory structures.