-
Notifications
You must be signed in to change notification settings - Fork 16
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
1 parent
2641d2e
commit ad246c6
Showing
19 changed files
with
789 additions
and
200 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
23 changes: 23 additions & 0 deletions
23
src/main/java/io/stargate/sgv2/jsonapi/api/model/command/impl/ListTablesCommand.java
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,23 @@ | ||
package io.stargate.sgv2.jsonapi.api.model.command.impl; | ||
|
||
import com.fasterxml.jackson.annotation.JsonTypeName; | ||
import io.stargate.sgv2.jsonapi.api.model.command.TableOnlyCommand; | ||
import org.eclipse.microprofile.openapi.annotations.enums.SchemaType; | ||
import org.eclipse.microprofile.openapi.annotations.media.Schema; | ||
|
||
@Schema(description = "Command that lists all available tables in a namespace.") | ||
@JsonTypeName("listTables") | ||
public record ListTablesCommand(Options options) implements TableOnlyCommand { | ||
public record Options( | ||
@Schema( | ||
description = "include table properties.", | ||
type = SchemaType.BOOLEAN, | ||
implementation = Boolean.class) | ||
boolean explain) {} | ||
|
||
/** {@inheritDoc} */ | ||
@Override | ||
public CommandName commandName() { | ||
return CommandName.LIST_TABLES; | ||
} | ||
} |
42 changes: 42 additions & 0 deletions
42
...ava/io/stargate/sgv2/jsonapi/api/model/command/serializer/ColumnDefinitionSerializer.java
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,42 @@ | ||
package io.stargate.sgv2.jsonapi.api.model.command.serializer; | ||
|
||
import com.fasterxml.jackson.core.JsonGenerator; | ||
import com.fasterxml.jackson.databind.JsonSerializer; | ||
import com.fasterxml.jackson.databind.SerializerProvider; | ||
import io.stargate.sgv2.jsonapi.api.model.command.table.definition.datatype.ColumnType; | ||
import io.stargate.sgv2.jsonapi.api.model.command.table.definition.datatype.ComplexTypes; | ||
import java.io.IOException; | ||
|
||
/** | ||
* Custom serializer to encode the column type to the JSON payload This is required because | ||
* composite and custom column types may need additional properties to be serialized | ||
*/ | ||
public class ColumnDefinitionSerializer extends JsonSerializer<ColumnType> { | ||
|
||
@Override | ||
public void serialize( | ||
ColumnType columnType, JsonGenerator jsonGenerator, SerializerProvider serializerProvider) | ||
throws IOException { | ||
jsonGenerator.writeStartObject(); | ||
jsonGenerator.writeStringField("type", columnType.getApiName()); | ||
if (columnType instanceof ComplexTypes.MapType mt) { | ||
jsonGenerator.writeStringField("keyType", mt.keyTypeName()); | ||
jsonGenerator.writeStringField("valueType", mt.valueTypeName()); | ||
} else if (columnType instanceof ComplexTypes.ListType lt) { | ||
jsonGenerator.writeStringField("valueType", lt.valueTypeName()); | ||
} else if (columnType instanceof ComplexTypes.SetType st) { | ||
jsonGenerator.writeStringField("valueType", st.valueTypeName()); | ||
} else if (columnType instanceof ComplexTypes.VectorType vt) { | ||
jsonGenerator.writeNumberField("dimension", vt.getDimension()); | ||
if (vt.getVectorConfig() != null) | ||
jsonGenerator.writeObjectField("service", vt.getVectorConfig()); | ||
} else if (columnType instanceof ComplexTypes.UnsupportedType ut) { | ||
jsonGenerator.writeObjectField( | ||
"apiSupport", new ApiSupport(false, false, false, ut.cqlFormat())); | ||
} | ||
jsonGenerator.writeEndObject(); | ||
} | ||
|
||
public record ApiSupport( | ||
boolean createTable, boolean insert, boolean read, String cqlDefinition) {} | ||
} |
42 changes: 42 additions & 0 deletions
42
...in/java/io/stargate/sgv2/jsonapi/api/model/command/serializer/OrderingKeysSerializer.java
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,42 @@ | ||
package io.stargate.sgv2.jsonapi.api.model.command.serializer; | ||
|
||
import com.fasterxml.jackson.core.JsonGenerator; | ||
import com.fasterxml.jackson.databind.JsonSerializer; | ||
import com.fasterxml.jackson.databind.SerializerProvider; | ||
import io.stargate.sgv2.jsonapi.api.model.command.table.definition.PrimaryKey; | ||
import java.io.IOException; | ||
|
||
/** | ||
* Custom serializer to encode the column type to the JSON payload This is required because | ||
* composite and custom column types may need additional properties to be serialized | ||
*/ | ||
public class OrderingKeysSerializer extends JsonSerializer<PrimaryKey.OrderingKey[]> { | ||
|
||
@Override | ||
public void serialize( | ||
PrimaryKey.OrderingKey[] orderingKeys, | ||
JsonGenerator jsonGenerator, | ||
SerializerProvider serializerProvider) | ||
throws IOException { | ||
jsonGenerator.writeStartObject(); | ||
if (orderingKeys != null) { | ||
for (PrimaryKey.OrderingKey orderingKey : orderingKeys) { | ||
jsonGenerator.writeNumberField( | ||
orderingKey.column(), orderingKey.order() == PrimaryKey.OrderingKey.Order.ASC ? 1 : -1); | ||
} | ||
} | ||
jsonGenerator.writeEndObject(); | ||
} | ||
|
||
/** | ||
* This is used when a unsupported type column is present in a table. How to use this class will | ||
* evolve as different unsupported types are analyzed. | ||
* | ||
* @param createTable | ||
* @param insert | ||
* @param read | ||
* @param cqlDefinition | ||
*/ | ||
private record ApiSupport( | ||
boolean createTable, boolean insert, boolean read, String cqlDefinition) {} | ||
} |
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
Oops, something went wrong.