我是cassandra的新手.在这里,我有两个表EVENTS和TOWER.我需要加入那些查询.但我无法做到这一点.
EVENTS表结构:
eid int PRIMARY KEY,
a_end_tow_id text,
a_home_circle text,
a_home_operator text,
a_imei text,
a_imsi text,
Run Code Online (Sandbox Code Playgroud)
TOWER表结构:
tid int PRIMARY KEY,
tower_address_1 text,
tower_address_2 text,
tower_azimuth text,
tower_cgi text,
tower_circle text,
tower_id_no text,
tower_lat_d text,
tower_long_d text,
tower_name text,
Run Code Online (Sandbox Code Playgroud)
现在,我想加入这些表就EID和TID这样我就可以获取两个表的数据.
我需要RDDs在一个/多个列上加入两个普通的列.逻辑上,此操作等效于两个表的数据库连接操作.我想知道这是否只有通过Spark SQL或其他方式可行.
作为一个具体示例,请考虑r1使用主键的RDD ITEM_ID:
(ITEM_ID, ITEM_NAME, ITEM_UNIT, COMPANY_ID)
Run Code Online (Sandbox Code Playgroud)
和r2主键的RDD COMPANY_ID:
(COMPANY_ID, COMPANY_NAME, COMPANY_CITY)
Run Code Online (Sandbox Code Playgroud)
我想加入r1和r2.
如何才能做到这一点?
我知道有几个线程,NoHostAvailableException但他们根本不提供我的问题的解决方案.
我无法使用Datastax Java Cassandra Driver连接到Cassandra.我收到错误:
com.datastax.driver.core.exceptions.NoHostAvailableException:尝试查询的所有主机都失败了(试过:[/54.221.241.107])
我确信配置是正确的.我在cassandra.yaml中设置了配置:
start_native_transport: true
# port for the CQL native transport to listen for clients on
native_transport_port: 9042
Run Code Online (Sandbox Code Playgroud)
我的Cassandra安装是AWS上EC2实例的标准安装.我已将AWS配置为允许端口9042.
Cassandra在Windows Server 2008 R2上运行,我还在9042上将防火墙配置为入站和出站连接.
我的代码如下所示:
cluster = Cluster.builder()
.withPort(9042)
.addContactPoint("54.221.241.107").build();
Run Code Online (Sandbox Code Playgroud)
我不知道该怎么办,因为我总是得到这个错误.有什么建议?
Play with Scala中的这些Json序列化器让我疯狂.
我已阅读了数十篇帖子以及教程和文档.尝试了四种不同的实现读/写/格式覆盖的方法,但都无济于事.
所以我退出了自定义类型,并决定简单:
def suggest = Action(parse.json) {
request =>
request.body.validate[(String, String)].map {
case (suggestion, categories) => Ok("You suggested " + suggestion + " for categories " + categories)
}.recoverTotal {
e => BadRequest(JsError.toFlatJson(e))
}
}
Run Code Online (Sandbox Code Playgroud)
如上所述,错误会再次出现.
我是否真的需要为这样的基本体提供自定义的读/写/格式实现?
样本输入主体可以是:
{"suggestion":"add generics", "categories":"request;language;updates"}
Run Code Online (Sandbox Code Playgroud)
我错过了什么简单的事情?
如果我使用es6/7(babel - stage 1)而不是TypeScript,那么如何注入服务,特别是Http?
这是我的组件JS:
import {Component, Inject, View, CORE_DIRECTIVES, ViewEncapsulation} from 'angular2/angular2';
import {Http} from 'angular2/http';
@Component({
selector: 'login'
})
@View({
templateUrl: './components/login/login.html',
styleUrls: ['components/login/login.css'],
directives: [CORE_DIRECTIVES],
encapsulation: ViewEncapsulation.Emulated
})
export class Login {
constructor(@Inject(Http) http) {
console.log('http', http);
}
authenticate(username, password) {
// this.http.get('/login');
}
}
Run Code Online (Sandbox Code Playgroud)
我试过了:
export class Login {
constructor(@Inject(Http) http) {
console.log('http', http);
}
}
/********************/
@Inject(Http)
export class Login {
constructor(http) {
console.log('http', http);
}
}
/********************/
export class Login {
constructor(Http: http) { …Run Code Online (Sandbox Code Playgroud) 这是通过Spark Streaming运行简单SQL查询的代码.
import org.apache.spark.streaming.{Seconds, StreamingContext}
import org.apache.spark.streaming.StreamingContext._
import org.apache.spark.sql.SQLContext
import org.apache.spark.streaming.Duration
object StreamingSQL {
case class Persons(name: String, age: Int)
def main(args: Array[String]) {
val sparkConf = new SparkConf().setMaster("local").setAppName("HdfsWordCount")
val sc = new SparkContext(sparkConf)
// Create the context
val ssc = new StreamingContext(sc, Seconds(2))
val lines = ssc.textFileStream("C:/Users/pravesh.jain/Desktop/people/")
lines.foreachRDD(rdd=>rdd.foreach(println))
val sqc = new SQLContext(sc);
import sqc.createSchemaRDD
// Create the FileInputDStream on the directory and use the
// stream to count words in new files created
lines.foreachRDD(rdd=>{
rdd.map(_.split(",")).map(p => Persons(p(0), p(1).trim.toInt)).registerAsTable("data") …Run Code Online (Sandbox Code Playgroud) 我在我的Windows 7机器上安装了"erlang"和"rabbitmq".但是当我尝试运行此代码时,我得到一个例外.
package com.rabbitmq;
import com.rabbitmq.client.Channel;
import com.rabbitmq.client.Connection;
import com.rabbitmq.client.ConnectionFactory;
public class SendMessage {
private final static String QUEUE_NAME = "hello";
public static void main(String[] argv) throws Exception {
ConnectionFactory factory = new ConnectionFactory();
factory.setHost("localhost");
Connection connection = factory.newConnection();
Channel channel = connection.createChannel();
channel.queueDeclare(QUEUE_NAME, false, false, false, null);
String message = "Hello World!";
channel.basicPublish("", QUEUE_NAME, null, message.getBytes("UTF-8"));
System.out.println(" [x] Sent '" + message + "'");
channel.close();
connection.close();
}
}
Run Code Online (Sandbox Code Playgroud)
我得到了这个例外.
线程"main"中的异常com.rabbitmq.client.AuthenticationFailureException:ACCESS_REFUSED - 使用身份验证机制PLAIN拒绝登录.有关详细信息,请参阅代理日志文件
这是日志:
2016年4月11日:: 12:45:06 ===添加vhost'localhost'
= INFO REPORT …
我有一个项目列表,每个项目都有一个链接,可以单击进行编辑。当他们单击该编辑链接时,我正在使用刺激使编辑“模态”表单可见。将要编辑的内容的 id 以 id= 的形式出现在列表的相应链接标记上
因此,编辑链接如下所示:
<td>
<a data-action="click->content#edit"
data-target="content.editBtn"
id="<%= url_for(content) %>")>
Edit
</a>
</td>
Run Code Online (Sandbox Code Playgroud)
这个想法是刺激控制器中的 content#edit 操作检查并找到它的 id 并使用它来编辑右侧行。
然而,我认为我遇到的问题是,结果该列表的所有行都有一个具有相同名称的数据目标,并且错误的目标(第一个?)绑定到目标。
但是,如果我想通过附加 id 来使每个数据目标不同,现在我在controller.js 中有一个很长的目标列表,所以这是没有意义的。
正确的处理方法是什么?
我有3个收藏:
现在我需要获取用户详细信息的用户详细信息
我的代码是:
return this.dbCollectionService.userOrganizationCollection.snapshotChanges()
.pipe(map(res => {
return res.map(data => {
var userData = data.payload.doc.data()
let userDetails : any;
if (userData.userDetails) {
this.angularFirestore.doc(userData.userDetails).valueChanges().subscribe(res => {
userDetails = res;
console.log(userDetails);
});
return { id, ...userDetails }
}).filter( f => f.organizationId != undefined && f.organizationId == orgId)
}));
Run Code Online (Sandbox Code Playgroud)
这能够正确地控制结果,但不能返回数据.
可以从数据引用获取数据花费时间并且返回语句执行得更早.
我想在Angular应用程序上使用虚拟滚动。我列表中的项目是远程页面搜索的结果。每当我向下滚动视口时,我想加载更多结果(调用下一页)。
这是我的模板:
<div class="container">
<cdk-virtual-scroll-viewport itemSize="100">
<li *cdkVirtualFor="let item of searchResult">{{item}}</li>
</cdk-virtual-scroll-viewport>
</div>
Run Code Online (Sandbox Code Playgroud)
这是我根据需要进行的尝试:
export class SearchComponent {
@ViewChild(CdkVirtualScrollViewport) virtualScroll: CdkVirtualScrollViewport;
searchPageNumber: number;
searchResults: Array<any>;
constructor(private scrollDispatcher: ScrollDispatcher, private searchService: SearchService) {
this.searchPageNumber = 0;
this.searchResults = [];
}
ngOnInit(): void {
this.nextSearchPage(this.searchPageNumber);
}
ngAfterViewInit(): void {
//this.scrollDispatcher.register(this.scrollable);
//this.scrollDispatcher.scrolled(1000)
// .subscribe((viewport: CdkVirtualScrollViewport) => {
// console.log('scroll triggered', viewport);
// });
this.virtualScroll.renderedRangeStream.subscribe(range => {
console.log('range', range);
console.log('range2', this.virtualScroll.getRenderedRange());
if (this.virtualScroll.getRenderedRange().end % 10 === 0) {
this.nextSearchPage(++this.searchPageNumber);
}
});
}
nextSearchPage(pageNumber: number): …Run Code Online (Sandbox Code Playgroud) scrollbar infinite-scroll angular virtualscroll angular-cdk-virtual-scroll
angular ×3
apache-spark ×2
cassandra ×2
javascript ×2
scala ×2
angularfire2 ×1
babeljs ×1
cql ×1
join ×1
rabbitmq ×1
rdd ×1
scrollbar ×1
stimulusjs ×1