/** * Convert {@link BTable} to JSON. * * @param table {@link BTable} to be converted to {@link BStreamingJSON} * @return JSON representation of the provided table */ public static BRefType<?> toJSON(BTable table) { TableJSONDataSource jsonDataSource = new TableJSONDataSource(table); if (table.isInMemoryTable()) { return jsonDataSource.build(); } return new BStreamingJSON(jsonDataSource); }
public BTable(String query, BTable fromTable, BTable joinTable, BStructureType constraintType, BValueArray params) { this.tableProvider = TableProvider.getInstance(); if (!fromTable.isInMemoryTable()) { throw new BallerinaException(BallerinaErrorReasons.TABLE_OPERATION_ERROR, "Table query over a cursor table not supported"); } if (joinTable != null) { if (!joinTable.isInMemoryTable()) { throw new BallerinaException(BallerinaErrorReasons.TABLE_OPERATION_ERROR, "Table query over a cursor table not supported"); } this.tableName = tableProvider.createTable(fromTable.tableName, joinTable.tableName, query, constraintType, params); } else { this.tableName = tableProvider.createTable(fromTable.tableName, query, constraintType, params); } this.constraintType = constraintType; this.type = new BTableType(constraintType); }