Skip to content

Commit

Permalink
Mais refactorings
Browse files Browse the repository at this point in the history
  • Loading branch information
edwardoliveira committed Sep 1, 2016
1 parent 72625a6 commit 28bf901
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 3 deletions.
18 changes: 18 additions & 0 deletions src/main/java/br/unb/cassandra/etl/CassandraBulkLoader.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,22 @@

public class CassandraBulkLoader {

public static final String SCHEMA = "CREATE TABLE %s.%s (ID TIMEUUID,\n" +
" UF TEXT,\n" +
" CODIGO_MUNICIPIO TEXT,\n" +
" NOME_MUNICIPIO TEXT,\n" +
" NOME_BENEFICIARIO TEXT,\n" +
" VALOR_PAGO FLOAT,\n" +
" MES_ANO TEXT,\n" +
" PRIMARY KEY (ID, VALOR_PAGO))";

public static final String INSERT = "INSERT INTO %s.%s (ID, UF, CODIGO_MUNICIPIO, NOME_MUNICIPIO, NOME_BENEFICIARIO, VALOR_PAGO, MES_ANO) " +
" VALUES (?, ?, ?, ?, ?, ?, ?)";


public static void main(String[] args) {

}


}
6 changes: 3 additions & 3 deletions src/main/java/br/unb/cassandra/etl/CassandraClientLoader.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ public class CassandraClientLoader {
public static final String KEYSPACE = "bolsafamilia";
public static final String TABLE = "bf";

private String insertCmd = "INSERT INTO %s.%s (ID, UF, CODIGO_MUNICIPIO, NOME_MUNICIPIO, NOME_BENEFICIARIO, VALOR_PAGO, MES_ANO) " +
" VALUES (?, ?, ?, ?, ?, ?, ?)";
public static final String INSERT = "INSERT INTO %s.%s (ID, UF, CODIGO_MUNICIPIO, NOME_MUNICIPIO, NOME_BENEFICIARIO, VALOR_PAGO, MES_ANO) " +
" VALUES (?, ?, ?, ?, ?, ?, ?)";

public boolean connect() {
cluster = Cluster.builder().addContactPoint(host).build();
Expand All @@ -29,7 +29,7 @@ public void close() {
// TODO: use BATCH insert to speedup?
public void insert(Registro registro) {

PreparedStatement pstmt = session.prepare(String.format(insertCmd, KEYSPACE, TABLE));
PreparedStatement pstmt = session.prepare(String.format(INSERT, KEYSPACE, TABLE));

BoundStatement bstmt = pstmt.bind(UUIDs.timeBased(),
registro.getUf(),
Expand Down
8 changes: 8 additions & 0 deletions src/main/resources/NOTES.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
wc -l ~/Downloads/201606_BolsaFamiliaFolhaPagamento.csv
13849867 /home/eribeiro/Downloads/201606_BolsaFamiliaFolhaPagamento.csv


* Adicionar indices de baixa cardinalidade para UF
* Colocar VALOR_PAGO como CLUSTERING KEY da chave primária
* Usar SASI indexes para NOME_BENEFICIARIO? NOME_MUNICIPIO? CODIGO_MUNICIPIO?

0 comments on commit 28bf901

Please sign in to comment.