This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
JdbcDialect dialect = new JdbcDialect() { | |
@Override | |
public boolean canHandle(String url) { | |
return url.startsWith("jdbc:oracle") | |
|| url.contains("oracle"); | |
} | |
@Override | |
public Option<JdbcType> getJDBCType(DataType dt) { | |
if(DataTypes.StringType.sameType(dt)) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* :: DeveloperApi :: | |
* Default Oracle dialect, mapping a nonspecific numeric type to a general decimal type. | |
*/ | |
@DeveloperApi | |
case object OracleDialect extends JdbcDialect { | |
override def canHandle(url: String): Boolean = | |
url.startsWith("jdbc:oracle") | |
override def getCatalystType( | |
sqlType: Int, typeName: String, size: Int, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
—NEVER EVER EVER DO | |
BEGIN BATCH; | |
INSERT INTO tester.users (userID, firstName, lastName) VALUES (1, 'Jim', 'James') | |
INSERT INTO tester.users (userID, firstName, lastName) VALUES (2, 'Ernie', 'Orosco') | |
INSERT INTO tester.users (userID, firstName, lastName) VALUES (3, 'Jose', 'Garza') | |
INSERT INTO tester.users (userID, firstName, lastName) VALUES (4, 'Sammy', 'Mason') | |
INSERT INTO tester.users (userID, firstName, lastName) VALUES (5, 'Larry', 'Bird') | |
INSERT INTO tester.users (userID, firstName, lastName) VALUES (6, 'Jim', 'Smith') | |
APPLY BATCH; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
BEGIN BATCH; | |
UPDATE users SET name='Jim' where id =1; | |
UPDATE users_by_ssn set name='Jim' where ssn='888–99–9999'; | |
APPLY BATCH; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
—NEVER EVER EVER DO | |
BEGIN UNLOGGED BATCH; | |
INSERT INTO tester.users (userID, firstName, lastName) VALUES (1, 'Jim', 'James') | |
INSERT INTO tester.users (userID, firstName, lastName) VALUES (2, 'Ernie', 'Orosco') | |
INSERT INTO tester.users (userID, firstName, lastName) VALUES (3, 'Jose', 'Garza') | |
INSERT INTO tester.users (userID, firstName, lastName) VALUES (4, 'Sammy', 'Mason') | |
INSERT INTO tester.users (userID, firstName, lastName) VALUES (5, 'Larry', 'Bird') | |
INSERT INTO tester.users (userID, firstName, lastName) VALUES (6, 'Jim', 'Smith') | |
APPLY BATCH; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
BEGIN UNLOGGED BATCH; | |
INSERT INTO weather_readings (date, timestamp, temp) values (20140822,'2014-08-22T11:00:00.00+0000', 98.2); | |
INSERT INTO weather_readings (date, timestamp, temp) values (20140822,'2014-08-22T11:00:15.00+0000', 99.2); | |
APPLY BATCH; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* I HAVE NOT BEEN FULLY TESTED DO NOT USE ME IN PRODUCTION CODE THERE ARE NO WARRANTIES | |
*/ | |
public class BulkLoader { | |
private final int threads; | |
private final String[] contactHosts; | |
public BulkLoader(int threads, String...contactHosts){ | |
this.threads = threads; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* I HAVE NOT BEEN FULLY TESTED DO NOT USE ME IN PRODUCTION CODE THERE ARE NO WARRANTIES | |
* This is with using the approach in the previous blog post | |
*/ | |
public class BulkLoader { | |
private final int threads; | |
private final String[] contactHosts; | |
public BulkLoader(int threads, String...contactHosts){ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import org.apache.spark.{SparkConf, SparkContext} | |
import org.apache.spark._ | |
import org.apache.spark.storage._ | |
import org.apache.spark.streaming._ | |
object MapWithState { | |
val batchCountKey = "batchCount" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class KeepAlive{ | |
public static void main(String[] args){ | |
Cluster cluster = Cluster.builder().addContactPoint("foo") | |
.withSocketOptions(new SocketOptions().setKeepAlive(true)) | |
.build(); | |
} | |
} |