package com.mongodb.spark;
import java.io.Serializable;
public final class Character implements Serializable {
private String name;
private Integer age;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Integer getAge() {
return age;
}
public void setAge(final Integer age) {
this.age = age;
}
}
package com.mongodb.spark;
import org.apache.spark.api.java.JavaSparkContext;
import org.apache.spark.sql.Dataset;
import org.apache.spark.sql.Row;
import org.apache.spark.sql.SparkSession;
public final class DatasetSQLDemo {
public static void main(final String[] args) throws InterruptedException {
SparkSession spark = SparkSession.builder().master("local").appName("Aggregation")
.config("spark.mongodb.input.uri", "mongodb://172.28.34.xxx:27117/wangzs.sparktest")
.config("spark.mongodb.output.uri", "mongodb://172.28.34.xxx:27117/wangzs.sparkmongo").getOrCreate();
// Create a JavaSparkContext using the SparkSession's SparkContext object
JavaSparkContext jsc = new JavaSparkContext(spark.sparkContext());
// Load data with explicit schema
Dataset explicitDS = MongoSpark.load(jsc).toDS(Character.class);
explicitDS.printSchema();
explicitDS.show();
// Create the temp view and execute the query
explicitDS.createOrReplaceTempView("characters");
Dataset centenarians = spark.sql("SELECT name, age FROM characters WHERE age >= 100");
centenarians.show();
// Write the data to the "hundredClub" collection
MongoSpark.write(centenarians).option("collection", "hundredClub").mode("overwrite").save();
jsc.close();
}
}
java的多态性是指main方法在调用属性的时候类可以对这一属性做出反应的情况
//package 1;
class A{
public void test(){
System.out.println("A");
}
}
class D extends A{
public void test(){
S
参考了网上的思路,写了个Java版的:
public class Fibonacci {
final static int[] A={1,1,1,0};
public static void main(String[] args) {
int n=7;
for(int i=0;i<=n;i++){
int f=fibonac
1、查看系统客户端,数据库,连接层的编码
查看方法: http://daizj.iteye.com/blog/2174993
进入mysql,通过如下命令查看数据库编码方式: mysql> show variables like 'character_set_%'; +--------------------------+------
public class MyQueue {
private long[] arr;
private int front;
private int end;
// 有效数据的大小
private int elements;
public MyQueue() {
arr = new long[10];
elements = 0;
front
A binary search tree (BST) is a binary tree where each node has a Comparable key (and an associated value) and satisfies the restriction that the key in any node is larger than the keys in all