diff --git a/adapter-cqld4/pom.xml b/adapter-cqld4/pom.xml
index ce3ed9d84..636182623 100644
--- a/adapter-cqld4/pom.xml
+++ b/adapter-cqld4/pom.xml
@@ -91,4 +91,31 @@
+
+
+
+ org.antlr
+ antlr4-maven-plugin
+ 4.10.1
+
+ src/main/java/io/nosqlbench/converters/cql/cql/grammars
+
+ -package
+ io.nosqlbench.converters.cql.generated
+
+ src/main/java/io/nosqlbench/converters/cql/generated
+
+
+
+ antlr
+
+ antlr4
+
+ generate-sources
+
+
+
+
+
+
diff --git a/virtdata-lang/src/main/java/io/nosqlbench/virtdata/lang/cqlast/CqlAstBuilder.java b/adapter-cqld4/src/main/java/io/nosqlbench/converters/cql/cql/cqlast/CqlAstBuilder.java
similarity index 60%
rename from virtdata-lang/src/main/java/io/nosqlbench/virtdata/lang/cqlast/CqlAstBuilder.java
rename to adapter-cqld4/src/main/java/io/nosqlbench/converters/cql/cql/cqlast/CqlAstBuilder.java
index 46f2163cb..416a5d216 100644
--- a/virtdata-lang/src/main/java/io/nosqlbench/virtdata/lang/cqlast/CqlAstBuilder.java
+++ b/adapter-cqld4/src/main/java/io/nosqlbench/converters/cql/cql/cqlast/CqlAstBuilder.java
@@ -14,23 +14,38 @@
* limitations under the License.
*/
-package io.nosqlbench.virtdata.lang.cqlast;
+package io.nosqlbench.converters.cql.cql.cqlast;
-import io.nosqlbench.virtdata.lang.generated.CqlParser;
-import io.nosqlbench.virtdata.lang.generated.CqlParserBaseListener;
+import io.nosqlbench.converters.cql.generated.CqlParser;
+import io.nosqlbench.converters.cql.generated.CqlParserBaseListener;
+
+import java.util.ArrayList;
+import java.util.List;
public class CqlAstBuilder extends CqlParserBaseListener {
- CqlKeyspace keyspace = new CqlKeyspace();
+ List keyspaces = new ArrayList<>():
+ CqlKeyspace lastKeyspace = null;
+
+ @Override
+ public void enterKeyspace(CqlParser.KeyspaceContext ctx) {
+ lastKeyspace = new CqlKeyspace();
+ this.keyspaces.add(lastKeyspace);
+ }
+
+ @Override
+ public void exitKeyspace(CqlParser.KeyspaceContext ctx) {
+ lastKeyspace.setKeyspaceName(ctx.OBJECT_NAME().getSymbol().getText());
+ }
@Override
public void enterCreateTable(CqlParser.CreateTableContext ctx) {
- keyspace.addTable();
+ lastKeyspace.addTable();
}
@Override
public void exitCreateTable(CqlParser.CreateTableContext ctx) {
- keyspace.setTableName(ctx.table().OBJECT_NAME().getSymbol().getText());
+ lastKeyspace.setTableName(ctx.table().OBJECT_NAME().getSymbol().getText());
}
@Override
@@ -41,7 +56,7 @@ public class CqlAstBuilder extends CqlParserBaseListener {
@Override
public void exitColumnDefinition(CqlParser.ColumnDefinitionContext ctx) {
System.out.println("here");
- keyspace.addTableColumn(
+ lastKeyspace.addTableColumn(
ctx.dataType().dataTypeName().getText(),
ctx.column().OBJECT_NAME().getSymbol().getText()
);
@@ -50,7 +65,8 @@ public class CqlAstBuilder extends CqlParserBaseListener {
@Override
public String toString() {
return "CqlAstBuilder{" +
- "keyspace=" + keyspace +
+ "keyspaces=" + keyspaces +
+ ", lastKeyspace=" + lastKeyspace +
'}';
}
}
diff --git a/virtdata-lang/src/main/java/io/nosqlbench/virtdata/lang/cqlast/CqlField.java b/adapter-cqld4/src/main/java/io/nosqlbench/converters/cql/cql/cqlast/CqlField.java
similarity index 95%
rename from virtdata-lang/src/main/java/io/nosqlbench/virtdata/lang/cqlast/CqlField.java
rename to adapter-cqld4/src/main/java/io/nosqlbench/converters/cql/cql/cqlast/CqlField.java
index 27a89b942..8385ed3fa 100644
--- a/virtdata-lang/src/main/java/io/nosqlbench/virtdata/lang/cqlast/CqlField.java
+++ b/adapter-cqld4/src/main/java/io/nosqlbench/converters/cql/cql/cqlast/CqlField.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package io.nosqlbench.virtdata.lang.cqlast;
+package io.nosqlbench.converters.cql.cql.cqlast;
public class CqlField {
String name;
diff --git a/virtdata-lang/src/main/java/io/nosqlbench/virtdata/lang/cqlast/CqlKeyspace.java b/adapter-cqld4/src/main/java/io/nosqlbench/converters/cql/cql/cqlast/CqlKeyspace.java
similarity index 74%
rename from virtdata-lang/src/main/java/io/nosqlbench/virtdata/lang/cqlast/CqlKeyspace.java
rename to adapter-cqld4/src/main/java/io/nosqlbench/converters/cql/cql/cqlast/CqlKeyspace.java
index d5e46bccd..8ca919909 100644
--- a/virtdata-lang/src/main/java/io/nosqlbench/virtdata/lang/cqlast/CqlKeyspace.java
+++ b/adapter-cqld4/src/main/java/io/nosqlbench/converters/cql/cql/cqlast/CqlKeyspace.java
@@ -14,15 +14,24 @@
* limitations under the License.
*/
-package io.nosqlbench.virtdata.lang.cqlast;
+package io.nosqlbench.converters.cql.cql.cqlast;
import java.util.ArrayList;
import java.util.List;
+import java.util.stream.Collectors;
public class CqlKeyspace {
+ String keyspaceName= "";
List tables = new ArrayList<>();
CqlTable lastAddedTable = null;
+ public CqlKeyspace() {
+ }
+
+ public void setKeyspaceName(String name) {
+ this.keyspaceName=name;
+ }
+
public void addTable() {
lastAddedTable = new CqlTable();
tables.add(lastAddedTable);
@@ -42,9 +51,10 @@ public class CqlKeyspace {
@Override
public String toString() {
- return "CqlKeyspace{" +
- "tables=" + tables +
- ", lastAddedTable=" + lastAddedTable +
- '}';
+ return "keyspace:" + keyspaceName+"\n"+
+ " tables:\n"+
+ (tables.stream().map(Object::toString)
+ .map(s -> " "+s)
+ .collect(Collectors.joining("\n")));
}
}
diff --git a/virtdata-lang/src/main/java/io/nosqlbench/virtdata/lang/cqlast/CqlTable.java b/adapter-cqld4/src/main/java/io/nosqlbench/converters/cql/cql/cqlast/CqlTable.java
similarity index 96%
rename from virtdata-lang/src/main/java/io/nosqlbench/virtdata/lang/cqlast/CqlTable.java
rename to adapter-cqld4/src/main/java/io/nosqlbench/converters/cql/cql/cqlast/CqlTable.java
index 6642bcb0d..91aabe8c3 100644
--- a/virtdata-lang/src/main/java/io/nosqlbench/virtdata/lang/cqlast/CqlTable.java
+++ b/adapter-cqld4/src/main/java/io/nosqlbench/converters/cql/cql/cqlast/CqlTable.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package io.nosqlbench.virtdata.lang.cqlast;
+package io.nosqlbench.converters.cql.cql.cqlast;
import java.util.ArrayList;
import java.util.List;
diff --git a/virtdata-lang/src/main/java/io/nosqlbench/virtdata/lang/grammars/CqlLexer.g4 b/adapter-cqld4/src/main/java/io/nosqlbench/converters/cql/cql/grammars/CqlLexer.g4
similarity index 100%
rename from virtdata-lang/src/main/java/io/nosqlbench/virtdata/lang/grammars/CqlLexer.g4
rename to adapter-cqld4/src/main/java/io/nosqlbench/converters/cql/cql/grammars/CqlLexer.g4
diff --git a/virtdata-lang/src/main/java/io/nosqlbench/virtdata/lang/grammars/CqlParser.g4 b/adapter-cqld4/src/main/java/io/nosqlbench/converters/cql/cql/grammars/CqlParser.g4
similarity index 100%
rename from virtdata-lang/src/main/java/io/nosqlbench/virtdata/lang/grammars/CqlParser.g4
rename to adapter-cqld4/src/main/java/io/nosqlbench/converters/cql/cql/grammars/CqlParser.g4
diff --git a/virtdata-lang/src/main/java/io/nosqlbench/virtdata/lang/parser/CqlParserHarness.java b/adapter-cqld4/src/main/java/io/nosqlbench/converters/cql/cql/parser/CqlParserHarness.java
similarity index 91%
rename from virtdata-lang/src/main/java/io/nosqlbench/virtdata/lang/parser/CqlParserHarness.java
rename to adapter-cqld4/src/main/java/io/nosqlbench/converters/cql/cql/parser/CqlParserHarness.java
index b9582856a..30861c059 100644
--- a/virtdata-lang/src/main/java/io/nosqlbench/virtdata/lang/parser/CqlParserHarness.java
+++ b/adapter-cqld4/src/main/java/io/nosqlbench/converters/cql/cql/parser/CqlParserHarness.java
@@ -14,11 +14,11 @@
* limitations under the License.
*/
-package io.nosqlbench.virtdata.lang.parser;
+package io.nosqlbench.converters.cql.cql.parser;
-import io.nosqlbench.virtdata.lang.cqlast.CqlAstBuilder;
-import io.nosqlbench.virtdata.lang.generated.CqlLexer;
-import io.nosqlbench.virtdata.lang.generated.CqlParser;
+import io.nosqlbench.converters.cql.cql.cqlast.CqlAstBuilder;
+import io.nosqlbench.converters.cql.generated.CqlLexer;
+import io.nosqlbench.converters.cql.generated.CqlParser;
import org.antlr.v4.runtime.CharStreams;
import org.antlr.v4.runtime.CodePointCharStream;
import org.antlr.v4.runtime.CommonTokenStream;
diff --git a/virtdata-lang/src/test/java/io/nosqlbench/virtdata/lang/parser/CqlParserHarnessTest.java b/adapter-cqld4/src/test/java/io/nosqlbench/converters/cql/cql/parser/CqlParserHarnessTest.java
similarity index 96%
rename from virtdata-lang/src/test/java/io/nosqlbench/virtdata/lang/parser/CqlParserHarnessTest.java
rename to adapter-cqld4/src/test/java/io/nosqlbench/converters/cql/cql/parser/CqlParserHarnessTest.java
index 6254d358d..d00c22a71 100644
--- a/virtdata-lang/src/test/java/io/nosqlbench/virtdata/lang/parser/CqlParserHarnessTest.java
+++ b/adapter-cqld4/src/test/java/io/nosqlbench/converters/cql/cql/parser/CqlParserHarnessTest.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package io.nosqlbench.virtdata.lang.parser;
+package io.nosqlbench.converters.cql.cql.parser;
import org.junit.jupiter.api.Test;