forked from scray/scray
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
67 changed files
with
2,333 additions
and
980 deletions.
There are no files selected for viewing
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
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
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
21 changes: 21 additions & 0 deletions
21
scray-cassandra/src/main/scala/scray/cassandra/example/BatchOutputTable.scala
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package scray.cassandra.example | ||
|
||
import scray.cassandra.sync.CassandraImplementation._ | ||
import scray.querying.sync.Column | ||
import scray.querying.sync.Column | ||
import scray.querying.sync.Columns | ||
import scray.querying.sync.Table | ||
import scray.querying.sync.RowWithValue | ||
import scray.querying.sync.ColumnWithValue | ||
import scray.querying.sync.RowWithValue | ||
|
||
object BatchOutputTable { | ||
val count = new Column[Int]("count") | ||
|
||
val columns = new Columns(new Column[String]("key") :: count :: Nil, "(key)", None) | ||
val table = new Table("\"BDQ_BATCH\"", "\"BatchCountExample\"", columns) | ||
|
||
val row = new RowWithValue(new ColumnWithValue[String]("key", "key") :: new ColumnWithValue("count", 1) :: Nil, "(key)", None) | ||
|
||
def setCounter(count: Int) = {new RowWithValue(new ColumnWithValue[String]("key", "key") :: new ColumnWithValue("count", count) :: Nil, "(key)", None)} | ||
} |
52 changes: 52 additions & 0 deletions
52
scray-cassandra/src/main/scala/scray/cassandra/example/BatchVersioningMain.scala
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
package scray.cassandra.example | ||
|
||
import scray.cassandra.sync.CassandraJobInfo | ||
import scray.cassandra.sync.OnlineBatchSyncCassandra | ||
import scray.querying.sync.ColumnWithValue | ||
import com.datastax.driver.core.Cluster | ||
import scray.cassandra.sync.CassandraDbSession | ||
import com.datastax.driver.core.querybuilder.QueryBuilder | ||
|
||
/** | ||
* Write 100 batch versions in 5 slots. | ||
* Use old data for new calculation. | ||
* newDate = oldDate + 1 | ||
*/ | ||
object BatchVersioningMain { | ||
|
||
def main(args: Array[String]) { | ||
|
||
if(args.length != 1) { | ||
println("Hostname for cassandra cluster as parameter requiered") | ||
System.exit(0); | ||
} | ||
|
||
val table = new OnlineBatchSyncCassandra(args(0)) | ||
val jobInfo = new CassandraJobInfo("ScrayExample", 5) | ||
|
||
// Prepare database | ||
table.initJob(jobInfo, BatchOutputTable.table.columns) | ||
|
||
for (x <- 1 until 100) { | ||
|
||
table.startNextBatchJob(jobInfo) | ||
|
||
// Get old data | ||
val lastBatchData = table.getBatchJobData(jobInfo, BatchOutputTable.row) | ||
|
||
// Create new data (Increment counter) | ||
val newCount: Int = lastBatchData.map {_.head.getColumn(BatchOutputTable.count).map { _.value }}.flatten.getOrElse(0) + 1 | ||
Thread.sleep(5000) | ||
|
||
// Write new data | ||
table.insertInBatchTable(jobInfo, BatchOutputTable.setCounter(newCount)) | ||
|
||
// Complete job | ||
table.completeBatchJob(jobInfo) | ||
|
||
println(s"\n Writen batch data ${newCount} \n") | ||
|
||
} | ||
|
||
} | ||
} |
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
Oops, something went wrong.