11import './App.css' ;
22import { RelationalPlanViewer } from "@lingodb/common/RelationalPlanViewer"
3- import { useRef , useState } from "react" ;
3+ import { useEffect , useRef , useState } from "react" ;
44import {
55 Button ,
66 Tabs ,
@@ -10,8 +10,7 @@ import {
1010 Dropdown ,
1111 Form ,
1212 FormGroup ,
13- FormCheck ,
14- Alert , Spinner
13+ FormCheck , Spinner , Accordion
1514} from 'react-bootstrap' ;
1615import { FontAwesomeIcon } from '@fortawesome/react-fontawesome' ;
1716import { faPlay } from '@fortawesome/free-solid-svg-icons' ;
@@ -39,9 +38,9 @@ export const RelationalPlanViewerWithLoading = ({input, loading, error, onOperat
3938 </ div > )
4039 } else if ( error ) {
4140 return (
42- < div style = { { height : '50vh' , overflow : 'auto' , textAlign : "center "} } >
41+ < div style = { { height : '50vh' , overflow : 'auto' , maxWidth : "100vw "} } >
4342 An Error occurred:
44- < pre >
43+ < pre >
4544 { error }
4645 </ pre >
4746 </ div >
@@ -61,7 +60,7 @@ export const SubOpPlanViewerWithLoading = ({input, loading, error, selectedOps,
6160 </ div > )
6261 } else if ( error ) {
6362 return (
64- < div style = { { height : '50vh' , overflow : 'auto' , textAlign : "center "} } >
63+ < div style = { { height : '50vh' , overflow : 'auto' , maxWidth : "100vw "} } >
6564 An Error occurred:
6665 < pre >
6766 { error }
@@ -144,6 +143,10 @@ function App() {
144143 const [ showResults , setShowResults ] = useState ( false )
145144 const [ realCardinalities , setRealCardinalities ] = useState ( false )
146145
146+
147+ const [ selectedOp , setSelectedOp ] = useState ( null )
148+ const [ selectedLayer , setSelectedLayer ] = useState ( null )
149+
147150 const [ selectedRelAlgOps , setSelectedRelAlgOps ] = useState ( [ ] )
148151 const [ selectedSubOpOps , setSelectedSubOpOps ] = useState ( [ ] )
149152 const [ selectedImpOps1 , setSelectedImpOps1 ] = useState ( [ ] )
@@ -271,42 +274,55 @@ function App() {
271274 }
272275 } ;
273276
274- const handleRelAlgOpSelection = ( op ) => {
275- setSelectedRelAlgOps ( [ op ] )
276- const subOpBaseRef = getBaseReference ( layers [ 3 ] . passInfo . file )
277- const imp1BaseRef = getBaseReference ( layers [ 4 ] . passInfo . file )
278- const imp2BaseRef = getBaseReference ( layers [ 5 ] . passInfo . file )
279- const relatedSubOps = goDown ( op , subOpBaseRef , layerInfo )
280- const relatedImpOps1 = goDown ( op , imp1BaseRef , layerInfo )
281- const relatedImpOps2 = goDown ( op , imp2BaseRef , layerInfo )
282- setSelectedSubOpOps ( relatedSubOps )
283- setSelectedImpOps1 ( relatedImpOps1 )
284- setSelectedImpOps2 ( relatedImpOps2 )
285- console . log ( "selecting SubOps:" , relatedSubOps )
277+
278+ useEffect ( ( ) => {
279+ if ( selectedOp && selectedLayer ) {
280+ const displayedLayers = [ { idx : 1 , fn : setSelectedRelAlgOps } , {
281+ idx : 3 ,
282+ fn : setSelectedSubOpOps
283+ } , { idx : 4 , fn : setSelectedImpOps1 } , { idx : 5 , fn : setSelectedImpOps2 } ]
284+ displayedLayers . forEach ( ( l ) => {
285+ if ( l . idx && selectedLayer !== l . idx ) {
286+ const baseRef = getBaseReference ( layers [ l . idx ] . passInfo . file )
287+ const relatedOps = selectedLayer < l . idx ? goDown ( selectedOp , baseRef , layerInfo ) : goUp ( selectedOp , baseRef , layerInfo )
288+ l . fn ( relatedOps )
289+ } else if ( l . idx ) {
290+ l . fn ( [ selectedOp ] )
291+ }
292+ } )
293+ }
294+ } , [ layers , layerInfo , selectedOp , selectedLayer ] )
295+
296+ const handleSubOpSelection = ( op ) => {
297+ setSelectedOp ( op )
298+ setSelectedLayer ( 3 )
299+ }
300+ const handleImp1Selection = ( op ) => {
301+ setSelectedOp ( op )
302+ setSelectedLayer ( 4 )
303+ }
304+ const handleImp2Selection = ( op ) => {
305+ setSelectedOp ( op )
306+ setSelectedLayer ( 5 )
286307 }
287- const handleSubOpOpSelection = ( op ) => {
288- setSelectedSubOpOps ( [ op ] )
289- const relalgBaseRef = getBaseReference ( layers [ 1 ] . passInfo . file )
290- const imp1BaseRef = getBaseReference ( layers [ 4 ] . passInfo . file )
291- const imp2BaseRef = getBaseReference ( layers [ 5 ] . passInfo . file )
292- const relatedRelalgOps = goUp ( op , relalgBaseRef , layerInfo )
293- const relatedImpOps1 = goDown ( op , imp1BaseRef , layerInfo )
294- const relatedImpOps2 = goDown ( op , imp2BaseRef , layerInfo )
295- setSelectedRelAlgOps ( relatedRelalgOps )
296- setSelectedImpOps1 ( relatedImpOps1 )
297- setSelectedImpOps2 ( relatedImpOps2 )
308+ const handleRelAlgOpSelection = ( op ) => {
309+ setSelectedOp ( op )
310+ setSelectedLayer ( 1 )
298311 }
299312 return (
300313 < div className = "App" >
301- < h2 > SQL WebInterface</ h2 >
302- < Alert variant = "warning" >
303- < b > Note!</ b > This webinterface is for demo purposes only, and especially not suited for benchmarking.
304- It runs with 4 threads on a small virtual machine (4 GiB RAM, 4 virtual cores), and LingoDB executes queries
305- with additional verifications. Furthermore, every request is processed by executing one of LingoDB's command line tools which first
306- loads the data set into memory, increasing the observable latency significantly.
307- </ Alert >
314+ < Accordion >
315+ < Accordion . Item eventKey = "0" >
316+ < Accordion . Header > < b > This webinterface is for demo purposes only, and especially not suited for benchmarking.</ b > </ Accordion . Header >
317+ < Accordion . Body >
318+ It runs with 4 threads on a small virtual machine (4 GiB RAM, 4 virtual cores), and LingoDB executes queries
319+ with additional verifications. Furthermore, every request is processed by executing one of LingoDB's command line tools which first
320+ loads the data set into memory, increasing the observable latency significantly.
321+ </ Accordion . Body >
322+ </ Accordion . Item >
323+ </ Accordion >
308324 < Editor
309- height = "40vh"
325+ height = { window . innerHeight * 0.5 - 54 - 38 - 50 }
310326 defaultLanguage = "sql"
311327 value = { query }
312328 onMount = { handleEditorDidMount }
@@ -365,7 +381,7 @@ function App() {
365381 < div style = { { height : '50vh' , backgroundColor : "gray" } } >
366382 < SubOpPlanViewerWithLoading input = { subOpPlan } loading = { queryPlanLoading }
367383 error = { queryPlanError } selectedOps = { selectedSubOpOps }
368- onOperatorSelect = { handleSubOpOpSelection } />
384+ onOperatorSelect = { handleSubOpSelection } />
369385 </ div >
370386 </ div >
371387 < div eventKey = "mlir" title = "MLIR"
@@ -387,7 +403,7 @@ function App() {
387403 } } >
388404 < div style = { { height : '50vh' } } >
389405 { layers && < MLIRViewer height = { window . innerHeight * 0.5 } width = { window . innerWidth }
390- selectedOps = { selectedSubOpOps } layer = { layers [ 3 ] } onOpClick = { ( d ) => handleSubOpOpSelection ( d . id ) } /> }
406+ selectedOps = { selectedSubOpOps } layer = { layers [ 3 ] } onOpClick = { ( d ) => handleSubOpSelection ( d . id ) } /> }
391407 </ div >
392408 </ div >
393409 < div title = "MLIR"
@@ -398,7 +414,7 @@ function App() {
398414 } } >
399415 < div style = { { height : '50vh' } } >
400416 { layers && < MLIRViewer height = { window . innerHeight * 0.5 } width = { window . innerWidth }
401- selectedOps = { selectedImpOps1 } layer = { layers [ 4 ] } onOpClick = { ( d ) => { } } /> }
417+ selectedOps = { selectedImpOps1 } layer = { layers [ 4 ] } onOpClick = { ( d ) => { handleImp1Selection ( d . id ) } } /> }
402418 </ div >
403419 </ div >
404420 < div title = "MLIR"
@@ -409,7 +425,7 @@ function App() {
409425 } } >
410426 < div style = { { height : '50vh' } } >
411427 { layers && < MLIRViewer height = { window . innerHeight * 0.5 } width = { window . innerWidth }
412- selectedOps = { selectedImpOps2 } layer = { layers [ 5 ] } onOpClick = { ( d ) => { } } /> }
428+ selectedOps = { selectedImpOps2 } layer = { layers [ 5 ] } onOpClick = { ( d ) => { handleImp2Selection ( d . id ) } } /> }
413429 </ div >
414430 </ div >
415431 </ div >
0 commit comments