mirror of
https://github.com/nosqlbench/nosqlbench.git
synced 2024-11-21 16:27:51 -06:00
partial work on cql workload gen
This commit is contained in:
parent
c73ca6ddea
commit
e50f0478b5
@ -79,43 +79,50 @@
|
||||
<build>
|
||||
<plugins>
|
||||
|
||||
<plugin>
|
||||
<groupId>com.googlecode.maven-download-plugin</groupId>
|
||||
<artifactId>download-maven-plugin</artifactId>
|
||||
<version>1.4.0</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>get-cql-lexer</id>
|
||||
<phase>generate-sources</phase>
|
||||
<goals>
|
||||
<goal>wget</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<url>
|
||||
https://raw.githubusercontent.com/antlr/grammars-v4/master/cql3/CqlLexer.g4
|
||||
</url>
|
||||
<outputFileName>CqlLexer.g4</outputFileName>
|
||||
<outputDirectory>src/main/grammars/cql3/
|
||||
</outputDirectory>
|
||||
</configuration>
|
||||
</execution>
|
||||
<execution>
|
||||
<id>get-cql-parser</id>
|
||||
<phase>generate-sources</phase>
|
||||
<goals>
|
||||
<goal>wget</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<url>
|
||||
https://raw.githubusercontent.com/antlr/grammars-v4/master/cql3/CqlParser.g4
|
||||
</url>
|
||||
<outputFileName>CqlParser.g4</outputFileName>
|
||||
<outputDirectory>src/main/grammars/cql3/
|
||||
</outputDirectory>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<!--
|
||||
If this plugin is re-enabled, the local CQL grammar will
|
||||
be overwritten. The grammar has some syntax issues, so
|
||||
fixes will be made to it before it is submitted back.
|
||||
|
||||
(lack of composite key syntax, nested type syntax, etc)
|
||||
-->
|
||||
<!-- <plugin>-->
|
||||
<!-- <groupId>com.googlecode.maven-download-plugin</groupId>-->
|
||||
<!-- <artifactId>download-maven-plugin</artifactId>-->
|
||||
<!-- <version>1.4.0</version>-->
|
||||
<!-- <executions>-->
|
||||
<!-- <execution>-->
|
||||
<!-- <id>get-cql-lexer</id>-->
|
||||
<!-- <phase>generate-sources</phase>-->
|
||||
<!-- <goals>-->
|
||||
<!-- <goal>wget</goal>-->
|
||||
<!-- </goals>-->
|
||||
<!-- <configuration>-->
|
||||
<!-- <url>-->
|
||||
<!-- https://raw.githubusercontent.com/antlr/grammars-v4/master/cql3/CqlLexer.g4-->
|
||||
<!-- </url>-->
|
||||
<!-- <outputFileName>CqlLexer.g4</outputFileName>-->
|
||||
<!-- <outputDirectory>src/main/grammars/cql3/-->
|
||||
<!-- </outputDirectory>-->
|
||||
<!-- </configuration>-->
|
||||
<!-- </execution>-->
|
||||
<!-- <execution>-->
|
||||
<!-- <id>get-cql-parser</id>-->
|
||||
<!-- <phase>generate-sources</phase>-->
|
||||
<!-- <goals>-->
|
||||
<!-- <goal>wget</goal>-->
|
||||
<!-- </goals>-->
|
||||
<!-- <configuration>-->
|
||||
<!-- <url>-->
|
||||
<!-- https://raw.githubusercontent.com/antlr/grammars-v4/master/cql3/CqlParser.g4-->
|
||||
<!-- </url>-->
|
||||
<!-- <outputFileName>CqlParser.g4</outputFileName>-->
|
||||
<!-- <outputDirectory>src/main/grammars/cql3/-->
|
||||
<!-- </outputDirectory>-->
|
||||
<!-- </configuration>-->
|
||||
<!-- </execution>-->
|
||||
<!-- </executions>-->
|
||||
<!-- </plugin>-->
|
||||
|
||||
<plugin>
|
||||
<groupId>org.antlr</groupId>
|
||||
|
194
driver-cql-shaded/src/main/grammars/cql3/CqlLexer.tokens
Normal file
194
driver-cql-shaded/src/main/grammars/cql3/CqlLexer.tokens
Normal file
@ -0,0 +1,194 @@
|
||||
LR_BRACKET=1
|
||||
RR_BRACKET=2
|
||||
LC_BRACKET=3
|
||||
RC_BRACKET=4
|
||||
LS_BRACKET=5
|
||||
RS_BRACKET=6
|
||||
COMMA=7
|
||||
SEMI=8
|
||||
COLON=9
|
||||
SPACE=10
|
||||
SPEC_MYSQL_COMMENT=11
|
||||
COMMENT_INPUT=12
|
||||
LINE_COMMENT=13
|
||||
DOT=14
|
||||
STAR=15
|
||||
DIVIDE=16
|
||||
MODULE=17
|
||||
PLUS=18
|
||||
MINUSMINUS=19
|
||||
MINUS=20
|
||||
DQUOTE=21
|
||||
SQUOTE=22
|
||||
K_ADD=23
|
||||
K_AGGREGATE=24
|
||||
K_ALL=25
|
||||
K_ALLOW=26
|
||||
K_ALTER=27
|
||||
K_AND=28
|
||||
K_ANY=29
|
||||
K_APPLY=30
|
||||
K_AS=31
|
||||
K_ASC=32
|
||||
K_AUTHORIZE=33
|
||||
K_BATCH=34
|
||||
K_BEGIN=35
|
||||
K_BY=36
|
||||
K_CALLED=37
|
||||
K_CLUSTERING=38
|
||||
K_COLUMNFAMILY=39
|
||||
K_COMPACT=40
|
||||
K_CONSISTENCY=41
|
||||
K_CONTAINS=42
|
||||
K_CREATE=43
|
||||
K_CUSTOM=44
|
||||
K_DELETE=45
|
||||
K_DESC=46
|
||||
K_DESCRIBE=47
|
||||
K_DISTINCT=48
|
||||
K_DROP=49
|
||||
K_DURABLE_WRITES=50
|
||||
K_EACH_QUORUM=51
|
||||
K_ENTRIES=52
|
||||
K_EXECUTE=53
|
||||
K_EXISTS=54
|
||||
K_FALSE=55
|
||||
K_FILTERING=56
|
||||
K_FINALFUNC=57
|
||||
K_FROM=58
|
||||
K_FULL=59
|
||||
K_FUNCTION=60
|
||||
K_FUNCTIONS=61
|
||||
K_GRANT=62
|
||||
K_IF=63
|
||||
K_IN=64
|
||||
K_INDEX=65
|
||||
K_INFINITY=66
|
||||
K_INITCOND=67
|
||||
K_INPUT=68
|
||||
K_INSERT=69
|
||||
K_INTO=70
|
||||
K_IS=71
|
||||
K_JSON=72
|
||||
K_KEY=73
|
||||
K_KEYS=74
|
||||
K_KEYSPACE=75
|
||||
K_KEYSPACES=76
|
||||
K_LANGUAGE=77
|
||||
K_LEVEL=78
|
||||
K_LIMIT=79
|
||||
K_LOCAL_ONE=80
|
||||
K_LOCAL_QUORUM=81
|
||||
K_LOGGED=82
|
||||
K_LOGIN=83
|
||||
K_MATERIALIZED=84
|
||||
K_MODIFY=85
|
||||
K_NAN=86
|
||||
K_NORECURSIVE=87
|
||||
K_NOSUPERUSER=88
|
||||
K_NOT=89
|
||||
K_NULL=90
|
||||
K_OF=91
|
||||
K_ON=92
|
||||
K_ONE=93
|
||||
K_OPTIONS=94
|
||||
K_OR=95
|
||||
K_ORDER=96
|
||||
K_PARTITION=97
|
||||
K_PASSWORD=98
|
||||
K_PER=99
|
||||
K_PERMISSION=100
|
||||
K_PERMISSIONS=101
|
||||
K_PRIMARY=102
|
||||
K_QUORUM=103
|
||||
K_RENAME=104
|
||||
K_REPLACE=105
|
||||
K_REPLICATION=106
|
||||
K_RETURNS=107
|
||||
K_REVOKE=108
|
||||
K_ROLE=109
|
||||
K_ROLES=110
|
||||
K_SCHEMA=111
|
||||
K_SELECT=112
|
||||
K_SET=113
|
||||
K_SFUNC=114
|
||||
K_STATIC=115
|
||||
K_STORAGE=116
|
||||
K_STYPE=117
|
||||
K_SUPERUSER=118
|
||||
K_TABLE=119
|
||||
K_THREE=120
|
||||
K_TIMESTAMP=121
|
||||
K_TO=122
|
||||
K_TOKEN=123
|
||||
K_TRIGGER=124
|
||||
K_TRUE=125
|
||||
K_TRUNCATE=126
|
||||
K_TTL=127
|
||||
K_TWO=128
|
||||
K_TYPE=129
|
||||
K_UNLOGGED=130
|
||||
K_UPDATE=131
|
||||
K_USE=132
|
||||
K_USER=133
|
||||
K_USING=134
|
||||
K_UUID=135
|
||||
K_VALUES=136
|
||||
K_VIEW=137
|
||||
K_WHERE=138
|
||||
K_WITH=139
|
||||
K_WRITETIME=140
|
||||
K_ASCII=141
|
||||
K_BIGINT=142
|
||||
K_BLOB=143
|
||||
K_BOOLEAN=144
|
||||
K_COUNTER=145
|
||||
K_DATE=146
|
||||
K_DECIMAL=147
|
||||
K_DOUBLE=148
|
||||
K_FLOAT=149
|
||||
K_FROZEN=150
|
||||
K_INET=151
|
||||
K_INT=152
|
||||
K_LIST=153
|
||||
K_MAP=154
|
||||
K_SMALLINT=155
|
||||
K_TEXT=156
|
||||
K_TIMEUUID=157
|
||||
K_TIME=158
|
||||
K_TINYINT=159
|
||||
K_TUPLE=160
|
||||
K_VARCHAR=161
|
||||
K_VARINT=162
|
||||
CODE_BLOCK=163
|
||||
STRING_LITERAL=164
|
||||
DECIMAL_LITERAL=165
|
||||
FLOAT_LITERAL=166
|
||||
HEXADECIMAL_LITERAL=167
|
||||
REAL_LITERAL=168
|
||||
OBJECT_NAME=169
|
||||
UUID=170
|
||||
OPERATOR_EQ=171
|
||||
OPERATOR_LT=172
|
||||
OPERATOR_GT=173
|
||||
OPERATOR_LTE=174
|
||||
OPERATOR_GTE=175
|
||||
K_USERS=176
|
||||
'('=1
|
||||
')'=2
|
||||
'{'=3
|
||||
'}'=4
|
||||
'['=5
|
||||
']'=6
|
||||
','=7
|
||||
';'=8
|
||||
':'=9
|
||||
'.'=14
|
||||
'*'=15
|
||||
'/'=16
|
||||
'%'=17
|
||||
'+'=18
|
||||
'--'=19
|
||||
'-'=20
|
||||
'"'=21
|
||||
'\''=22
|
@ -1,4 +1,4 @@
|
||||
package io.nosqlbench.activitytype.cql.endpoints;
|
||||
package io.nosqlbench.endpoints.cql;
|
||||
|
||||
import io.nosqlbench.generators.cql.lang.CqlWorkloadGen;
|
||||
import io.nosqlbench.docsys.api.WebServiceObject;
|
@ -2,28 +2,86 @@ package io.nosqlbench.generators.cql.lang;
|
||||
|
||||
import io.nosqlbench.generators.cql.generated.CqlParser;
|
||||
import io.nosqlbench.generators.cql.generated.CqlParserBaseListener;
|
||||
import org.antlr.v4.runtime.Token;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class CQLAstBuilder extends CqlParserBaseListener {
|
||||
|
||||
CqlWorkloadBuffer buf = new CqlWorkloadBuffer();
|
||||
|
||||
@Override
|
||||
public void exitCreateTable(CqlParser.CreateTableContext ctx) {
|
||||
List<CqlParser.ColumnDefinitionContext> columnDefinitionContexts =
|
||||
ctx.columnDefinitionList().columnDefinition();
|
||||
for (CqlParser.ColumnDefinitionContext coldef : columnDefinitionContexts) {
|
||||
CqlParser.ColumnContext column = coldef.column();
|
||||
Token symbol = column.OBJECT_NAME().getSymbol();
|
||||
CqlParser.DataTypeContext datatype = coldef.dataType();
|
||||
CqlParser.DataTypeNameContext dtn = datatype.dataTypeName();
|
||||
CqlParser.DataTypeDefinitionContext dtd = datatype.dataTypeDefinition();
|
||||
if (dtd != null) {
|
||||
List<CqlParser.DataTypeNameContext> dataTypeNameContexts = dtd.dataTypeName();
|
||||
for (CqlParser.DataTypeNameContext dtnc : dataTypeNameContexts) {
|
||||
System.out.println("here");
|
||||
}
|
||||
}
|
||||
}
|
||||
buf.newTable(ctx.keyspace().getText(), ctx.table().getText());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void exitColumnDefinition(CqlParser.ColumnDefinitionContext ctx) {
|
||||
List<String> typedef = new ArrayList<>();
|
||||
|
||||
CqlParser.DataTypeContext dt = ctx.dataType();
|
||||
|
||||
typedef.add(dt.dataTypeName().getText());
|
||||
CqlParser.DataTypeDefinitionContext dtd = dt.dataTypeDefinition();
|
||||
if (dtd != null) {
|
||||
typedef.add("<");
|
||||
dtd.dataTypeName().forEach(dtn -> {
|
||||
typedef.add(dtn.getText());
|
||||
typedef.add(",");
|
||||
});
|
||||
}
|
||||
typedef.remove(typedef.size() - 1);
|
||||
|
||||
buf.newColumn(
|
||||
ctx.column().OBJECT_NAME().getText(),
|
||||
typedef.toArray(new String[0])
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void exitPrimaryKeyDefinition(CqlParser.PrimaryKeyDefinitionContext ctx) {
|
||||
super.exitPrimaryKeyDefinition(ctx);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void exitPrimaryKeyColumn(CqlParser.PrimaryKeyColumnContext ctx) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void exitPartitionKey(CqlParser.PartitionKeyContext ctx) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void exitClusteringKey(CqlParser.ClusteringKeyContext ctx) {
|
||||
}
|
||||
|
||||
// This is the form of a primary key that is tacked onto the end of a column def
|
||||
@Override
|
||||
public void enterPrimaryKeyColumn(CqlParser.PrimaryKeyColumnContext ctx) {
|
||||
}
|
||||
|
||||
// This is the form of a primary key that is added to the column def list as an element
|
||||
@Override
|
||||
public void enterPrimaryKeyElement(CqlParser.PrimaryKeyElementContext ctx) {
|
||||
}
|
||||
|
||||
// @Override
|
||||
// public void exitCreateTable(CqlParser.CreateTableContext ctx) {
|
||||
// List<CqlParser.ColumnDefinitionContext> columnDefinitionContexts =
|
||||
// ctx.columnDefinitionList().columnDefinition();
|
||||
// for (CqlParser.ColumnDefinitionContext coldef : columnDefinitionContexts) {
|
||||
// CqlParser.ColumnContext column = coldef.column();
|
||||
// Token symbol = column.OBJECT_NAME().getSymbol();
|
||||
// CqlParser.DataTypeContext datatype = coldef.dataType();
|
||||
// CqlParser.DataTypeNameContext dtn = datatype.dataTypeName();
|
||||
// CqlParser.DataTypeDefinitionContext dtd = datatype.dataTypeDefinition();
|
||||
// if (dtd != null) {
|
||||
// List<CqlParser.DataTypeNameContext> dataTypeNameContexts = dtd.dataTypeName();
|
||||
// for (CqlParser.DataTypeNameContext dtnc : dataTypeNameContexts) {
|
||||
// System.out.println("here");
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,23 @@
|
||||
package io.nosqlbench.generators.cql.lang;
|
||||
|
||||
public class CqlWorkloadBuffer {
|
||||
public void newTable(String keyspace, String table) {
|
||||
}
|
||||
|
||||
/**
|
||||
* type is the parsed tokens of the type definition,
|
||||
* with each type token and each bracket taking a position.
|
||||
* For example, both <pre>{@code
|
||||
* "timeuuid"
|
||||
* }</pre> and <pre>{@code
|
||||
* "set","<","text",">"
|
||||
* }</pre> are valid. This is just an opaque transfer type to
|
||||
* allow simple decoupling of the upstream parser and the workload
|
||||
* generator.
|
||||
*
|
||||
* @param colname The name of the column
|
||||
* @param type A token stream representing the type of the column
|
||||
*/
|
||||
public void newColumn(String colname, String... type) {
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user