尝试循环使用RDD并使用每条记录上的数据创建图表。 代码是这样的:
bigjoin的结构为//App.js
import React from 'react';
import ReactDOM from 'react-dom';
import logo from './site_logo.png';
import {logo_styles,search_box_style,submit_button_style,shopping_cart_button_style,background_top_style,Login_button_style} from './style'
class FrontPage extends React.Component
{
constructor(props)
{
super(props);
this.state={search_field:''}
this.username_input=this.username_input.bind(this)
}
username_input(e)
{
this.setState({search_field:e.target.value})
}
render()
{
return(
<div style={background_top_style}>
<input type="text" onChange={this.username_input} style={search_box_style}/>
<button style={submit_button_style}><i class="fa fa-amazon"></i> </button>
<button style={Login_button_style}>Log In</button>
<button style={shopping_cart_button_style}><i class="fa fa-shopping-cart"></i></button>
<h1>{this.state.search_field}</h1>
</div>
);
}
}
export default FrontPage
//Login.js
import React from 'react'
import ReactDOM from 'react-dom'
class Login extends React.Component
{
constructor(props)
{
super(props);
this.state={username:'',password:''}
}
Login_data_username(e)
{
this.setState({username:e.target.value})
}
Login_data_password(password)
{
this.setState({password:password.target.value})
}
render()
{
return(
<div>
<h1>Login Page</h1>
</div>
)
}
}
export default Login
//index.js
`import React from 'react';
import ReactDOM from 'react-dom';
import './index.css';
import FrontPage from './App';
import registerServiceWorker from './registerServiceWorker';
import Login from './Login'
import {BrowserRouter,Link,Route} from 'react-router-dom'
class Display extends React.Component
{
render()
{
return(
<BrowserRouter>
<div>
<Route path = 'main/' component={FrontPage} />
<Route path = 'login/' component={Login} />
</div>
</BrowserRouter>
)
}
}
ReactDOM.render(<Display/>,document.getElementById('root'))
registerServiceWorker();`
RDD[(String, List[(Long, Long)])]
我的问题是Graph.fromEdgeTuples需要bigjoin.foreach( a => {
val imsi = a._1
val pairs = a._2
val lsrgraph = Graph.fromEdgeTuples(pairs, defaultValue = "missing")
// do something else with graph
})
代替......无法弄清楚如何让RDD[(graphx.VertexId, graphx.VertexId)]
成为执行该行的List[(Long, Long)]
。任何帮助将不胜感激。
答案 0 :(得分:0)
找到了另一种选择
val bigjoin3 = bigjoin.map(x => Edge(x._2(0),x._2(1),x._1) )
val mygraph = Graph.fromEdges(bigjoin3, defaultValue = "ignore")
图表将原始索引的所有节点和边缘作为属性。