Skip to content

Commit eda43fb

Browse files
going to load data
1 parent 6720dca commit eda43fb

File tree

2 files changed

+13
-11
lines changed

2 files changed

+13
-11
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@ target/
44
bin/
55
dependency-reduced-pom.xml
66
out/
7+
testdataset/

src/main/java/com/datastax/cdm/CassandraDatasetManager.java

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package com.datastax.cdm;
22

3-
import com.datastax.driver.core.Cluster;
4-
import com.datastax.driver.core.Session;
3+
import com.datastax.driver.core.*;
54
import com.fasterxml.jackson.core.type.TypeReference;
65
import com.fasterxml.jackson.databind.ObjectMapper;
76
import com.fasterxml.jackson.dataformat.yaml.YAMLFactory;
@@ -20,6 +19,7 @@
2019
import java.io.*;
2120
import java.net.MalformedURLException;
2221
import java.net.URL;
22+
import java.util.List;
2323
import java.util.Map;
2424

2525
/**
@@ -229,28 +229,29 @@ void install(String name) throws IOException, InterruptedException, GitAPIExcept
229229
session.execute("DROP KEYSPACE IF EXISTS " + config.keyspace);
230230
session.execute(createKeyspace.toString());
231231

232-
// Runtime.getRuntime().exec(new String[]{"bash", "-c", createKeyspace}).waitFor();
233-
234-
235232
System.out.println("Schema: " + schema);
236233
String loadSchema = "cqlsh -k " + config.keyspace + " -f " + schema;
237234
Runtime.getRuntime().exec(new String[]{"bash", "-c", loadSchema}).waitFor();
238235

239236
System.out.println("Loading data");
240237

238+
Cluster cluster2 = Cluster.builder()
239+
.addContactPoint("127.0.0.1")
240+
.build();
241+
241242
for(String table: config.tables) {
242243
String dataFile = dataPath + table + ".csv";
243244

244245
Reader in = new FileReader(dataFile);
245246
Iterable<CSVRecord> records = CSVFormat.RFC4180.parse(in);
247+
KeyspaceMetadata keyspaceMetadata = cluster2.getMetadata()
248+
.getKeyspace(config.keyspace);
249+
TableMetadata tableMetadata = keyspaceMetadata.getTable(table);
250+
// PreparedStatement p = session.prepare();
246251
for(CSVRecord record: records) {
247-
252+
// generate a CQL statement
253+
System.out.println("Blah");
248254
}
249-
250-
// String command = "COPY " + table + " FROM " + "'" + dataFile + "'";
251-
// String loadData= "cqlsh -k " + config.keyspace + " -e \"" + command + "\"";
252-
// System.out.println(loadData);
253-
// Runtime.getRuntime().exec(new String[]{"bash", "-c", loadData}).waitFor();
254255
}
255256

256257

0 commit comments

Comments
 (0)