diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml
index 8209b71e..e4eb20fd 100644
--- a/.github/workflows/ci.yaml
+++ b/.github/workflows/ci.yaml
@@ -8,13 +8,9 @@ on:
branches: [ main ]
jobs:
- test-python:
+ test:
runs-on: ubuntu-latest
- defaults:
- run:
- working-directory: python
-
strategy:
matrix:
python-version: ['3.10']
@@ -54,28 +50,3 @@ jobs:
run: |
source venv/bin/activate
pdm run pytest
-
- test-java:
- runs-on: ubuntu-latest
-
- defaults:
- run:
- working-directory: java
-
- strategy:
- matrix:
- java-version: ['11']
-
- steps:
- - uses: actions/checkout@v2
-
- - name: Install dependencies
- uses: actions/setup-java@v1
- with:
- java-version: ${{ matrix.java-version }}
-
- - name: Build
- run: mvn -B clean package
-
- - name: Run tests
- run: mvn test
diff --git a/.gitignore b/.gitignore
index 722d5e71..66fd4bc6 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1 +1,135 @@
+# Byte-compiled / optimized / DLL files
+__pycache__/
+*.py[cod]
+*$py.class
+
+# C extensions
+*.so
+
+# Distribution / packaging
+.Python
+build/
+develop-eggs/
+dist/
+downloads/
+eggs/
+.eggs/
+lib/
+lib64/
+parts/
+sdist/
+var/
+wheels/
+pip-wheel-metadata/
+share/python-wheels/
+*.egg-info/
+.installed.cfg
+*.egg
+MANIFEST
+
+# PyInstaller
+# Usually these files are written by a python script from a template
+# before PyInstaller builds the exe, so as to inject date/other infos into it.
+*.manifest
+*.spec
+
+# Installer logs
+pip-log.txt
+pip-delete-this-directory.txt
+
+# Unit test / coverage reports
+htmlcov/
+.tox/
+.nox/
+.coverage
+.coverage.*
+.cache
+nosetests.xml
+coverage.xml
+*.cover
+*.py,cover
+.hypothesis/
+.pytest_cache/
+
+# Translations
+*.mo
+*.pot
+
+# Django stuff:
+*.log
+local_settings.py
+db.sqlite3
+db.sqlite3-journal
+
+# Flask stuff:
+instance/
+.webassets-cache
+
+# Scrapy stuff:
+.scrapy
+
+# Sphinx documentation
+docs/_build/
+
+# PyBuilder
+target/
+
+# Jupyter Notebook
+.ipynb_checkpoints
+
+# IPython
+profile_default/
+ipython_config.py
+
+# pyenv
+.python-version
+
+# pipenv
+# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
+# However, in case of collaboration, if having platform-specific dependencies or dependencies
+# having no cross-platform support, pipenv may install dependencies that don't work, or not
+# install all needed dependencies.
+#Pipfile.lock
+
+# PEP 582; used by e.g. github.com/David-OConnor/pyflow
+__pypackages__/
+
+# Celery stuff
+celerybeat-schedule
+celerybeat.pid
+
+# SageMath parsed files
+*.sage.py
+
+# Environments
+.env
+.venv
+env/
+venv/
+ENV/
+env.bak/
+venv.bak/
+
+# Spyder project settings
+.spyderproject
+.spyproject
+
+# Rope project settings
+.ropeproject
+
+# mkdocs documentation
+/site
+
+# mypy
+.mypy_cache/
+.dmypy.json
+dmypy.json
+
+# Pyre type checker
+.pyre/
+
+# PDM
+.pdm-python
+
+# VSCode
.vscode
diff --git a/python/DEVELOPER.md b/DEVELOPER.md
similarity index 100%
rename from python/DEVELOPER.md
rename to DEVELOPER.md
diff --git a/python/RELEASE.md b/RELEASE.md
similarity index 100%
rename from python/RELEASE.md
rename to RELEASE.md
diff --git a/java/.gitignore b/java/.gitignore
deleted file mode 100644
index 3e403e30..00000000
--- a/java/.gitignore
+++ /dev/null
@@ -1,35 +0,0 @@
-target/
-!.mvn/wrapper/maven-wrapper.jar
-!**/src/main/**/target/
-!**/src/test/**/target/
-
-### IntelliJ IDEA ###
-.idea
-*.iws
-*.iml
-*.ipr
-
-### Eclipse ###
-.apt_generated
-.classpath
-.factorypath
-.project
-.settings
-.springBeans
-.sts4-cache
-
-### NetBeans ###
-/nbproject/private/
-/nbbuild/
-/dist/
-/nbdist/
-/.nb-gradle/
-build/
-!**/src/main/**/build/
-!**/src/test/**/build/
-
-### VS Code ###
-.vscode/
-
-### Mac OS ###
-.DS_Store
diff --git a/java/pom.xml b/java/pom.xml
deleted file mode 100644
index dae9d94e..00000000
--- a/java/pom.xml
+++ /dev/null
@@ -1,37 +0,0 @@
-
-
- 4.0.0
- build.recap
- recap
- 1.0-SNAPSHOT
- pom
-
- recap-core
- recap-kafka
-
-
- 11
- 11
-
-
-
-
- org.apache.kafka
- connect-api
- 3.4.0
-
-
- build.recap
- recap-core
- 1.0-SNAPSHOT
-
-
- junit
- junit
- 4.13.2
-
-
-
-
\ No newline at end of file
diff --git a/java/recap-core/pom.xml b/java/recap-core/pom.xml
deleted file mode 100644
index 572dcd15..00000000
--- a/java/recap-core/pom.xml
+++ /dev/null
@@ -1,36 +0,0 @@
-
-
- 4.0.0
-
- build.recap
- recap
- 1.0-SNAPSHOT
-
-
-
- junit
- junit
- test
-
-
- javax.json.bind
- javax.json.bind-api
- 1.0
-
-
- org.eclipse
- yasson
- 1.0.3
- test
-
-
- org.glassfish
- javax.json
- 1.1.4
- test
-
-
- recap-core
-
\ No newline at end of file
diff --git a/java/recap-core/src/main/java/build/recap/Client.java b/java/recap-core/src/main/java/build/recap/Client.java
deleted file mode 100644
index 9210130b..00000000
--- a/java/recap-core/src/main/java/build/recap/Client.java
+++ /dev/null
@@ -1,39 +0,0 @@
-package build.recap;
-
-import java.net.URI;
-import java.net.http.HttpClient;
-import java.net.http.HttpRequest;
-import java.net.http.HttpResponse;
-import java.net.http.HttpResponse.BodyHandlers;
-import javax.json.bind.Jsonb;
-import javax.json.bind.JsonbBuilder;
-
-public class Client {
- private HttpClient httpClient;
-
- public Client() {
- this(HttpClient.newHttpClient());
- }
-
- public Client(HttpClient httpClient) {
- this.httpClient = httpClient;
- }
-
- public HttpResponse post(String url, Type type) throws Exception {
- URI uri = URI.create(url);
- HttpRequest request = HttpRequest.newBuilder()
- .uri(uri)
- .version(HttpClient.Version.HTTP_1_1)
- .header("Content-Type", "application/json")
- .PUT(HttpRequest.BodyPublishers.ofString(toJson(type)))
- .build();
-
- return httpClient.send(request, BodyHandlers.ofString());
- }
-
- private String toJson(Type type) throws Exception {
- try (Jsonb jsonb = JsonbBuilder.create()) {
- return jsonb.toJson(type.toTypeDescription());
- }
- }
-}
diff --git a/java/recap-core/src/main/java/build/recap/Data.java b/java/recap-core/src/main/java/build/recap/Data.java
deleted file mode 100644
index bc7a6c34..00000000
--- a/java/recap-core/src/main/java/build/recap/Data.java
+++ /dev/null
@@ -1,42 +0,0 @@
-package build.recap;
-
-import java.util.Objects;
-
-public class Data {
- private final Type type;
- private final Object object;
-
- public Data(Type type, Object object) {
- this.type = type;
- this.object = object;
- }
-
- public Type getType() {
- return type;
- }
-
- public Object getObject() {
- return object;
- }
-
- @Override
- public String toString() {
- return "Data{" +
- "type=" + type +
- ", object=" + object +
- '}';
- }
-
- @Override
- public boolean equals(Object o) {
- if (this == o) return true;
- if (o == null || getClass() != o.getClass()) return false;
- Data data = (Data) o;
- return Objects.equals(type, data.type) && Objects.equals(object, data.object);
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(type, object);
- }
-}
diff --git a/java/recap-core/src/main/java/build/recap/Type.java b/java/recap-core/src/main/java/build/recap/Type.java
deleted file mode 100644
index b1e7c6a4..00000000
--- a/java/recap-core/src/main/java/build/recap/Type.java
+++ /dev/null
@@ -1,613 +0,0 @@
-package build.recap;
-
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Objects;
-import java.util.stream.Collectors;
-
-public class Type {
- // TODO: Add alias support
- protected String logicalType;
- protected String docString;
- protected Map extraAttributes;
-
- public Type() {
- this(null, null, null);
- }
-
- public Type(String logicalType, String docString, Map extraAttributes) {
- this.logicalType = logicalType;
- this.docString = docString;
- this.extraAttributes = extraAttributes != null ? new HashMap<>(extraAttributes) : new HashMap<>();
- }
-
- public String getLogicalType() {
- return logicalType;
- }
-
- public String getDocString() {
- return docString;
- }
-
- public Map getExtraAttributes() {
- return extraAttributes;
- }
-
- public Map toTypeDescription() {
- Map typeDescription = new HashMap<>();
- if (logicalType != null) {
- typeDescription.put("logical", logicalType);
- }
- if (docString != null) {
- typeDescription.put("doc", docString);
- }
- typeDescription.putAll(extraAttributes);
- return typeDescription;
- }
-
- @Override
- public String toString() {
- return "Type{" +
- "logicalType='" + logicalType + '\'' +
- ", docString='" + docString + '\'' +
- ", extraAttributes=" + extraAttributes +
- '}';
- }
-
- @Override
- public boolean equals(Object o) {
- if (this == o) return true;
- if (o == null || getClass() != o.getClass()) return false;
- Type type = (Type) o;
- return Objects.equals(logicalType, type.logicalType) && Objects.equals(docString, type.docString) && Objects.equals(extraAttributes, type.extraAttributes);
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(logicalType, docString, extraAttributes);
- }
-
- public static class Bool extends Type {
- public Bool() {
- this(null, null, null);
- }
-
- public Bool(String logicalType, String docString, Map extraAttributes) {
- super(logicalType, docString, extraAttributes);
- }
-
- public Map toTypeDescription() {
- Map typeDescription = super.toTypeDescription();
- typeDescription.put("type", "bool");
- return typeDescription;
- }
- }
-
- public static class Null extends Type {
- public Null() {
- this(null, null, null);
- }
-
- public Null(String logicalType, String docString, Map extraAttributes) {
- super(logicalType, docString, extraAttributes);
- }
-
- public Map toTypeDescription() {
- Map typeDescription = super.toTypeDescription();
- typeDescription.put("type", "null");
- return typeDescription;
- }
- }
-
- public static class Int extends Type {
- private final int bits;
- private final boolean signed;
-
- public Int(int bits, boolean signed) {
- this(bits, signed, null, null, null);
- }
-
- public Int(int bits, boolean signed, String logicalType, String docString, Map extraAttributes) {
- super(logicalType, docString, extraAttributes);
- this.bits = bits;
- this.signed = signed;
- }
-
- public int getBits() {
- return bits;
- }
-
- public boolean isSigned() {
- return signed;
- }
-
- public Map toTypeDescription() {
- Map typeDescription = super.toTypeDescription();
- typeDescription.putAll(Map.of(
- "type", "int",
- "bits", bits,
- "signed", signed
- ));
- return typeDescription;
- }
-
- @Override
- public String toString() {
- return "Int{" +
- "bits=" + bits +
- ", signed=" + signed +
- ", logicalType='" + logicalType + '\'' +
- ", docString='" + docString + '\'' +
- ", extraAttributes=" + extraAttributes +
- '}';
- }
-
- @Override
- public boolean equals(Object o) {
- if (this == o) return true;
- if (o == null || getClass() != o.getClass()) return false;
- if (!super.equals(o)) return false;
- Int anInt = (Int) o;
- return bits == anInt.bits && signed == anInt.signed;
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(super.hashCode(), bits, signed);
- }
- }
-
- public static class Float extends Type {
- private final int bits;
-
- public Float(int bits) {
- this(bits, null, null, null);
- }
-
- public Float(int bits, String logicalType, String docString, Map extraAttributes) {
- super(logicalType, docString, extraAttributes);
- this.bits = bits;
- }
-
- public int getBits() {
- return bits;
- }
-
- public Map toTypeDescription() {
- Map typeDescription = super.toTypeDescription();
- typeDescription.putAll(Map.of(
- "type", "float",
- "bits", bits
- ));
- return typeDescription;
- }
-
- @Override
- public String toString() {
- return "Float{" +
- "bits=" + bits +
- '}';
- }
-
- @Override
- public boolean equals(Object o) {
- if (this == o) return true;
- if (o == null || getClass() != o.getClass()) return false;
- if (!super.equals(o)) return false;
- Float aFloat = (Float) o;
- return bits == aFloat.bits;
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(super.hashCode(), bits);
- }
- }
-
- public static class String_ extends Type {
- private final long bytes;
- private final boolean variable;
-
- public String_(long bytes, boolean variable) {
- this(bytes, variable, null, null, null);
- }
-
- public String_(long bytes, boolean variable, String logicalType, String docString, Map extraAttributes) {
- super(logicalType, docString, extraAttributes);
- this.bytes = bytes;
- this.variable = variable;
- }
-
- public long getBytes() {
- return bytes;
- }
-
- public boolean isVariable() {
- return variable;
- }
-
- public Map toTypeDescription() {
- Map typeDescription = super.toTypeDescription();
- typeDescription.putAll(Map.of(
- "type", "string",
- "bytes", bytes,
- "variable", variable
- ));
- return typeDescription;
- }
-
- @Override
- public String toString() {
- return "String_{" +
- "bytes=" + bytes +
- ", variable=" + variable +
- ", logicalType='" + logicalType + '\'' +
- ", docString='" + docString + '\'' +
- ", extraAttributes=" + extraAttributes +
- '}';
- }
-
- @Override
- public boolean equals(Object o) {
- if (this == o) return true;
- if (o == null || getClass() != o.getClass()) return false;
- if (!super.equals(o)) return false;
- String_ string = (String_) o;
- return bytes == string.bytes && variable == string.variable;
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(super.hashCode(), bytes, variable);
- }
- }
-
- public static class Bytes extends Type {
- private final long bytes;
- private final boolean variable;
-
- public Bytes(long bytes, boolean variable) {
- this(bytes, variable, null, null, null);
- }
-
- public Bytes(long bytes, boolean variable, String logicalType, String docString, Map extraAttributes) {
- super(logicalType, docString, extraAttributes);
- this.bytes = bytes;
- this.variable = variable;
- }
-
- public long getBytes() {
- return bytes;
- }
-
- public boolean isVariable() {
- return variable;
- }
-
- public Map toTypeDescription() {
- Map typeDescription = super.toTypeDescription();
- typeDescription.putAll(Map.of(
- "type", "bytes",
- "bytes", bytes,
- "variable", variable
- ));
- return typeDescription;
- }
-
- @Override
- public String toString() {
- return "Bytes{" +
- "bytes=" + bytes +
- ", variable=" + variable +
- ", logicalType='" + logicalType + '\'' +
- ", docString='" + docString + '\'' +
- ", extraAttributes=" + extraAttributes +
- '}';
- }
-
- @Override
- public boolean equals(Object o) {
- if (this == o) return true;
- if (o == null || getClass() != o.getClass()) return false;
- if (!super.equals(o)) return false;
- Bytes bytes1 = (Bytes) o;
- return bytes == bytes1.bytes && variable == bytes1.variable;
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(super.hashCode(), bytes, variable);
- }
- }
-
- public static class List_ extends Type {
- private final Type valueType;
- private final Integer length;
- private final boolean variable;
-
- public List_(Type valueType) {
- this(valueType, null, true);
- }
-
- public List_(Type valueType, boolean variable) {
- this(valueType, null, variable);
- }
-
- public List_(Type valueType, Integer length, boolean variable) {
- this(valueType, length, variable, null, null, null);
- }
-
- public List_(Type valueType, Integer length, boolean variable, String logicalType, String docString, Map extraAttributes) {
- super(logicalType, docString, extraAttributes);
- this.valueType = valueType;
- this.length = length;
- this.variable = variable;
- }
-
- public Type getValueType() {
- return valueType;
- }
-
- public Integer getLength() {
- return length;
- }
-
- public boolean isVariable() {
- return variable;
- }
-
- public Map toTypeDescription() {
- Map typeDescription = super.toTypeDescription();
- typeDescription.putAll(Map.of(
- "type", "list",
- "variable", variable,
- "values", valueType.toTypeDescription()
- ));
- if (length != null) {
- typeDescription.put("length", length);
- }
- return typeDescription;
- }
-
- @Override
- public String toString() {
- return "List_{" +
- "valueType=" + valueType +
- ", length=" + length +
- ", variable=" + variable +
- ", logicalType='" + logicalType + '\'' +
- ", docString='" + docString + '\'' +
- ", extraAttributes=" + extraAttributes +
- '}';
- }
-
- @Override
- public boolean equals(Object o) {
- if (this == o) return true;
- if (o == null || getClass() != o.getClass()) return false;
- if (!super.equals(o)) return false;
- List_ list = (List_) o;
- return length == list.length && variable == list.variable && Objects.equals(valueType, list.valueType);
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(super.hashCode(), valueType, length, variable);
- }
- }
-
- public static class Map_ extends Type {
- private final Type keyType;
- private final Type valueType;
-
- public Map_(Type keyType, Type valueType) {
- this(keyType, valueType, null, null, null);
- }
-
- public Map_(Type keyType, Type valueType, String logicalType, String docString, Map extraAttributes) {
- super(logicalType, docString, extraAttributes);
- this.keyType = keyType;
- this.valueType = valueType;
- }
-
- public Type getKeyType() {
- return keyType;
- }
-
- public Type getValueType() {
- return valueType;
- }
-
- public Map toTypeDescription() {
- Map typeDescription = super.toTypeDescription();
- typeDescription.putAll(Map.of(
- "type", "map",
- "keys", keyType.toTypeDescription(),
- "values", valueType.toTypeDescription()
- ));
- return typeDescription;
- }
-
- @Override
- public String toString() {
- return "Map_{" +
- "keyType=" + keyType +
- ", valueType=" + valueType +
- ", logicalType='" + logicalType + '\'' +
- ", docString='" + docString + '\'' +
- ", extraAttributes=" + extraAttributes +
- '}';
- }
-
- @Override
- public boolean equals(Object o) {
- if (this == o) return true;
- if (o == null || getClass() != o.getClass()) return false;
- if (!super.equals(o)) return false;
- Map_ map = (Map_) o;
- return Objects.equals(keyType, map.keyType) && Objects.equals(valueType, map.valueType);
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(super.hashCode(), keyType, valueType);
- }
- }
-
- public static class Struct extends Type {
- List extends Type> fieldTypes;
-
- public Struct(List extends Type> fieldTypes) {
- this(fieldTypes, null, null, null);
- }
-
- public Struct(List extends Type> fieldTypes, String logicalType, String docString, Map extraAttributes) {
- super(logicalType, docString, extraAttributes);
- this.fieldTypes = fieldTypes;
- }
-
- public List extends Type> getFieldTypes() {
- return fieldTypes;
- }
-
- public Map toTypeDescription() {
- Map typeDescription = super.toTypeDescription();
- typeDescription.putAll(Map.of(
- "type", "struct",
- "fields", fieldTypes
- .stream()
- .map(Type::toTypeDescription)
- .collect(Collectors.toList())
- ));
- return typeDescription;
- }
-
- @Override
- public String toString() {
- return "Struct{" +
- "fieldTypes=" + fieldTypes +
- ", logicalType='" + logicalType + '\'' +
- ", docString='" + docString + '\'' +
- ", extraAttributes=" + extraAttributes +
- '}';
- }
-
- @Override
- public boolean equals(Object o) {
- if (this == o) return true;
- if (o == null || getClass() != o.getClass()) return false;
- if (!super.equals(o)) return false;
- Struct struct = (Struct) o;
- return Objects.equals(fieldTypes, struct.fieldTypes);
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(super.hashCode(), fieldTypes);
- }
- }
-
- public static class Enum extends Type {
- private final List symbols;
-
- public Enum(List symbols) {
- this(symbols, null, null, null);
- }
-
- public Enum(List symbols, String logicalType, String docString, Map extraAttributes) {
- super(logicalType, docString, extraAttributes);
- this.symbols = symbols;
- }
-
- public List getSymbols() {
- return symbols;
- }
-
- public Map toTypeDescription() {
- Map typeDescription = super.toTypeDescription();
- typeDescription.putAll(Map.of(
- "type", "enum",
- "symbols", symbols
- ));
- return typeDescription;
- }
-
- @Override
- public String toString() {
- return "Enum{" +
- "symbols=" + symbols +
- ", logicalType='" + logicalType + '\'' +
- ", docString='" + docString + '\'' +
- ", extraAttributes=" + extraAttributes +
- '}';
- }
-
- @Override
- public boolean equals(Object o) {
- if (this == o) return true;
- if (o == null || getClass() != o.getClass()) return false;
- if (!super.equals(o)) return false;
- Enum anEnum = (Enum) o;
- return Objects.equals(symbols, anEnum.symbols);
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(super.hashCode(), symbols);
- }
- }
-
- public static class Union extends Type {
- private final List extends Type> types;
-
- public Union(List extends Type> types) {
- this(types, null, null, null);
- }
-
- public Union(List extends Type> types, String logicalType, String docString, Map extraAttributes) {
- super(logicalType, docString, extraAttributes);
- this.types = types;
- }
-
- public List extends Type> getTypes() {
- return types;
- }
-
- public Map toTypeDescription() {
- Map typeDescription = super.toTypeDescription();
- typeDescription.putAll(Map.of(
- "type", "union",
- "types", types
- .stream()
- .map(Type::toTypeDescription)
- .collect(Collectors.toList())
- ));
- return typeDescription;
- }
-
- @Override
- public String toString() {
- return "Union{" +
- "types=" + types +
- ", logicalType='" + logicalType + '\'' +
- ", docString='" + docString + '\'' +
- ", extraAttributes=" + extraAttributes +
- '}';
- }
-
- @Override
- public boolean equals(Object o) {
- if (this == o) return true;
- if (o == null || getClass() != o.getClass()) return false;
- if (!super.equals(o)) return false;
- Union union = (Union) o;
- return Objects.equals(types, union.types);
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(super.hashCode(), types);
- }
- }
-}
\ No newline at end of file
diff --git a/java/recap-core/src/test/java/build/recap/ClientTest.java b/java/recap-core/src/test/java/build/recap/ClientTest.java
deleted file mode 100644
index 7c4649d3..00000000
--- a/java/recap-core/src/test/java/build/recap/ClientTest.java
+++ /dev/null
@@ -1,65 +0,0 @@
-package build.recap;
-
-import junit.framework.*;
-
-import java.io.IOException;
-import java.io.OutputStream;
-import java.net.InetSocketAddress;
-import java.net.http.HttpResponse;
-
-import com.sun.net.httpserver.HttpExchange;
-import com.sun.net.httpserver.HttpHandler;
-import com.sun.net.httpserver.HttpServer;
-
-public class ClientTest extends TestCase {
-
- private HttpServer server;
- private String serverUrl;
- private TestHttpHandler handler;
-
- protected void setUp() throws IOException {
- handler = new TestHttpHandler();
- server = HttpServer.create(new InetSocketAddress(0), 0);
- server.createContext("/test", handler);
- server.start();
- serverUrl = "http://localhost:" + server.getAddress().getPort() + "/test";
- }
-
- protected void tearDown() {
- server.stop(0);
- }
-
- public void testPost() throws Exception {
- Client client = new Client();
- Type type = new Type.Bool();
- HttpResponse response = client.post(serverUrl, type);
-
- assertNotNull(response);
- assertEquals(200, response.statusCode());
- assertEquals("application/json", handler.getReceivedContentType());
- assertEquals("{\"type\":\"bool\"}", handler.getReceivedBody());
- }
-
- private static class TestHttpHandler implements HttpHandler {
- private String receivedContentType;
- private String receivedBody;
-
- @Override
- public void handle(HttpExchange exchange) throws IOException {
- receivedContentType = exchange.getRequestHeaders().getFirst("Content-Type");
- receivedBody = new String(exchange.getRequestBody().readAllBytes());
- exchange.sendResponseHeaders(200, 0);
- try (OutputStream responseBody = exchange.getResponseBody()) {
- responseBody.write(new byte[0]);
- }
- }
-
- public String getReceivedContentType() {
- return receivedContentType;
- }
-
- public String getReceivedBody() {
- return receivedBody;
- }
- }
-}
diff --git a/java/recap-core/src/test/java/build/recap/TypeTest.java b/java/recap-core/src/test/java/build/recap/TypeTest.java
deleted file mode 100644
index 37a92e43..00000000
--- a/java/recap-core/src/test/java/build/recap/TypeTest.java
+++ /dev/null
@@ -1,84 +0,0 @@
-package build.recap;
-
-import junit.framework.*;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-
-public class TypeTest extends TestCase {
- public void testTypeDescriptions() {
- Type.Bool bool = new Type.Bool(null, null, Map.of("name", "bool"));
- Type.Null null_ = new Type.Null(null, null, Map.of("name", "null"));
- List fields = new ArrayList<>();
- fields.add(bool);
- fields.add(null_);
- fields.add(new Type.Int(32, true, "build.recap.Time", "A logical type test", Map.of("name", "int32")));
- fields.add(new Type.Float(64, null, null, Map.of("name", "double", "default", 32f)));
- fields.add(new Type.String_(Integer.MAX_VALUE, true, null, null, Map.of("name", "string32")));
- fields.add(new Type.Bytes(Integer.MAX_VALUE, false, null, null, Map.of("name", "bytes32")));
- fields.add(new Type.List_(bool, Integer.MAX_VALUE, true, null, null, Map.of("name", "list32")));
- fields.add(new Type.Map_(bool, bool, null, null, Map.of("name", "map")));
- fields.add(new Type.Enum(List.of("red", "green", "blue"), null, null, Map.of("name", "enum")));
- fields.add(new Type.Union(List.of(null_, bool), null, null, Map.of("name", "union")));
- Type.Struct struct = new Type.Struct(fields);
- Map description = struct.toTypeDescription();
- assertEquals("struct", description.get("type"));
- assertTrue("Struct fields attribute should be a list", description.get("fields") instanceof List>);
- List extends Map> fieldDescriptions = (List extends Map>) description.get("fields");
- assertEquals(fields.size(), fieldDescriptions.size());
- Map boolDescription = Map.of("name", "bool", "type", "bool");
- Map nullDescription = Map.of("name", "null", "type", "null");
- assertEquals(boolDescription, fieldDescriptions.get(0));
- assertEquals(nullDescription, fieldDescriptions.get(1));
- assertEquals(Map.of(
- "name", "int32",
- "type", "int",
- "bits", 32,
- "signed", true,
- "logical", "build.recap.Time",
- "doc", "A logical type test"
- ), fieldDescriptions.get(2));
- assertEquals(Map.of(
- "name", "double",
- "type", "float",
- "bits", 64,
- "default", 32f
- ), fieldDescriptions.get(3));
- assertEquals(Map.of(
- "name", "string32",
- "type", "string",
- "bytes", (long) Integer.MAX_VALUE,
- "variable", true
- ), fieldDescriptions.get(4));
- assertEquals(Map.of(
- "name", "bytes32",
- "type", "bytes",
- "bytes", (long) Integer.MAX_VALUE,
- "variable", false
- ), fieldDescriptions.get(5));
- assertEquals(Map.of(
- "name", "list32",
- "type", "list",
- "length", Integer.MAX_VALUE,
- "variable", true,
- "values", boolDescription
- ), fieldDescriptions.get(6));
- assertEquals(Map.of(
- "name", "map",
- "type", "map",
- "keys", boolDescription,
- "values", boolDescription
- ), fieldDescriptions.get(7));
- assertEquals(Map.of(
- "name", "enum",
- "type", "enum",
- "symbols", List.of("red", "green", "blue")
- ), fieldDescriptions.get(8));
- assertEquals(Map.of(
- "name", "union",
- "type", "union",
- "types", List.of(nullDescription, boolDescription)
- ), fieldDescriptions.get(9));
- }
-}
diff --git a/java/recap-kafka/pom.xml b/java/recap-kafka/pom.xml
deleted file mode 100644
index fea7f76f..00000000
--- a/java/recap-kafka/pom.xml
+++ /dev/null
@@ -1,29 +0,0 @@
-
-
- 4.0.0
-
- build.recap
- recap
- 1.0-SNAPSHOT
-
- recap-kafka
-
-
- org.apache.kafka
- connect-api
- compile
-
-
- build.recap
- recap-core
- compile
-
-
- junit
- junit
- test
-
-
-
\ No newline at end of file
diff --git a/java/recap-kafka/src/main/java/build/recap/kafka/Converter.java b/java/recap-kafka/src/main/java/build/recap/kafka/Converter.java
deleted file mode 100644
index ab0ade2f..00000000
--- a/java/recap-kafka/src/main/java/build/recap/kafka/Converter.java
+++ /dev/null
@@ -1,516 +0,0 @@
-package build.recap.kafka;
-
-import build.recap.Data;
-import build.recap.Type;
-import build.recap.kafka.logical.DateConverter;
-import build.recap.kafka.logical.DecimalConverter;
-import build.recap.kafka.logical.LogicalConverter;
-import build.recap.kafka.logical.TimeConverter;
-import build.recap.kafka.logical.TimestampConverter;
-import org.apache.kafka.connect.data.*;
-
-import java.util.*;
-import java.util.stream.Collectors;
-
-public class Converter {
- private final List logicalConverters;
-
- public Converter() {
- this(List.of(
- new DecimalConverter(),
- new DateConverter(),
- new TimeConverter(),
- new TimestampConverter()
- ));
- }
-
- public Converter(List logicalConverters) {
- this.logicalConverters = Collections.unmodifiableList(logicalConverters);
- }
-
- public Data convert(SchemaAndValue connectSchemaAndValue) {
- Data convertedData = null;
- SchemaAndValue connectSchemaAndValueLogical = convertLogical(connectSchemaAndValue);
- Schema connectSchema = connectSchemaAndValue.schema();
-
- switch (connectSchema.type()) {
- case STRING:
- convertedData = convertString(connectSchemaAndValueLogical);
- break;
- case INT8:
- case INT16:
- case INT32:
- case INT64:
- convertedData = convertInt(connectSchemaAndValueLogical);
- break;
- case FLOAT32:
- case FLOAT64:
- convertedData = convertFloat(connectSchemaAndValueLogical);
- break;
- case BOOLEAN:
- convertedData = convertBool(connectSchemaAndValueLogical);
- break;
- case BYTES:
- convertedData = convertBytes(connectSchemaAndValueLogical);
- break;
- case STRUCT:
- convertedData = convertStruct((Struct) connectSchemaAndValueLogical.value());
- break;
- case ARRAY:
- convertedData = convertList(connectSchemaAndValueLogical);
- break;
- case MAP:
- convertedData = convertMap(connectSchemaAndValueLogical);
- break;
- }
-
- if (convertedData != null) {
- if (connectSchema.isOptional()) {
- Type optionalType = new Type.Union(Arrays.asList(new Type.Null(), convertedData.getType()));
- // KC does not differentiate between null default and unset default.
- // Always set default even if it's null, since we don't know if it's explicitly so or not.
- optionalType.getExtraAttributes().put("default", connectSchema.defaultValue());
- convertedData = new Data(optionalType, convertedData.getObject());
- }
- return convertedData;
- }
-
- throw new RuntimeException("Unable to convert Kafka Connect data " + connectSchemaAndValue);
- }
-
- public SchemaAndValue convert(Data data) {
- Data dataLogical = convertLogical(data);
-
- if (dataLogical.getType() instanceof Type.String_) {
- return convertString(dataLogical);
- } else if (dataLogical.getType() instanceof Type.Int) {
- return convertInt(dataLogical);
- } else if (dataLogical.getType() instanceof Type.Float) {
- return convertFloat(dataLogical);
- } else if (dataLogical.getType() instanceof Type.Bytes) {
- return convertBytes(dataLogical);
- } else if (dataLogical.getType() instanceof Type.Bool) {
- return convertBool(dataLogical);
- } else if (dataLogical.getType() instanceof Type.Struct) {
- return convertStruct(dataLogical);
- } else if (dataLogical.getType() instanceof Type.List_) {
- return convertList(dataLogical);
- } else if (dataLogical.getType() instanceof Type.Map_) {
- return convertMap(dataLogical);
- } else if (dataLogical.getType() instanceof Type.Enum) {
- return convertEnum(dataLogical);
- } else if (dataLogical.getType() instanceof Type.Union) {
- return convertUnion(dataLogical);
- }
- throw new UnsupportedOperationException("Unable to convert Recap data " + data);
- }
-
- protected Data convertString(SchemaAndValue connectSchemaAndValue) {
- Schema connectSchema = connectSchemaAndValue.schema();
- Object connectValue = connectSchemaAndValue.value();
- Type.String_ recapStringType = new Type.String_(
- Integer.MAX_VALUE,
- true,
- connectSchema.name(),
- connectSchema.doc(),
- (Map) connectSchema.parameters()
- );
- return new Data(recapStringType, connectValue);
- }
-
- protected SchemaAndValue convertString(Data data) {
- Type.String_ recapStringType = (Type.String_) data.getType();
- Schema connectSchema = setStandardAttributes(SchemaBuilder.string(), recapStringType).build();
- if (recapStringType.getBytes() <= Integer.MAX_VALUE) {
- return new SchemaAndValue(
- connectSchema,
- data.getObject()
- );
- }
- throw new RuntimeException("Unable to convert Recap string " + data);
- }
-
- protected Data convertInt(SchemaAndValue connectSchemaAndValue) {
- Schema connectSchema = connectSchemaAndValue.schema();
- Object connectValue = connectSchemaAndValue.value();
- Integer bits = null;
- switch (connectSchema.type()) {
- case INT8:
- bits = 8;
- break;
- case INT16:
- bits = 16;
- break;
- case INT32:
- bits = 32;
- break;
- case INT64:
- bits = 64;
- break;
- }
- if (bits != null) {
- Type.Int recapIntType = new Type.Int(
- bits,
- true,
- connectSchema.name(),
- connectSchema.doc(),
- (Map) connectSchema.parameters()
- );
- return new Data(recapIntType, connectValue);
- }
- throw new RuntimeException("Unable to convert Kafka Connect integer " + connectSchemaAndValue);
- }
-
- protected SchemaAndValue convertInt(Data data) {
- Type.Int recapIntType = (Type.Int) data.getType();
- if (recapIntType.getBits() <= 8) {
- if (recapIntType.isSigned()) {
- return new SchemaAndValue(
- setStandardAttributes(SchemaBuilder.int8(), recapIntType).build(),
- data.getObject());
- } else {
- return new SchemaAndValue(
- setStandardAttributes(SchemaBuilder.int16(), recapIntType).build(),
- data.getObject());
- }
- } else if (recapIntType.getBits() <= 16) {
- if (recapIntType.isSigned()) {
- return new SchemaAndValue(
- setStandardAttributes(SchemaBuilder.int16(), recapIntType).build(),
- data.getObject());
- } else {
- return new SchemaAndValue(
- setStandardAttributes(SchemaBuilder.int32(), recapIntType).build(),
- data.getObject());
- }
- } else if (recapIntType.getBits() <= 32) {
- if (recapIntType.isSigned()) {
- return new SchemaAndValue(
- setStandardAttributes(SchemaBuilder.int32(), recapIntType).build(),
- data.getObject());
- } else {
- return new SchemaAndValue(
- setStandardAttributes(SchemaBuilder.int64(), recapIntType).build(),
- data.getObject());
- }
- } else if (recapIntType.getBits() <= 64) {
- if (recapIntType.isSigned()) {
- return new SchemaAndValue(
- setStandardAttributes(SchemaBuilder.int64(), recapIntType).build(),
- data.getObject());
- } else {
- return new SchemaAndValue(
- setStandardAttributes(Decimal.builder(0), recapIntType).build(),
- data.getObject());
- }
- }
- throw new RuntimeException("Unable to convert Recap integer " + data);
- }
-
- protected Data convertFloat(SchemaAndValue connectSchemaAndValue) {
- Schema connectSchema = connectSchemaAndValue.schema();
- Object connectValue = connectSchemaAndValue.value();
- Integer bits = null;
- switch (connectSchema.type()) {
- case FLOAT32:
- bits = 32;
- break;
- case FLOAT64:
- bits = 64;
- break;
- }
- if (bits != null) {
- Type.Float recapFloatType = new Type.Float(
- bits,
- connectSchema.name(),
- connectSchema.doc(),
- (Map) connectSchema.parameters()
- );
- return new Data(recapFloatType, connectValue);
- }
- throw new RuntimeException("Unable to convert Kafka Connect float " + connectSchemaAndValue);
- }
-
- protected SchemaAndValue convertFloat(Data data) {
- Type.Float recapFloatType = (Type.Float) data.getType();
- if (recapFloatType.getBits() <= 32) {
- return new SchemaAndValue(
- setStandardAttributes(SchemaBuilder.float32(), recapFloatType).build(),
- data.getObject());
- } else if (recapFloatType.getBits() <= 64) {
- return new SchemaAndValue(
- setStandardAttributes(SchemaBuilder.float64(), recapFloatType).build(),
- data.getObject());
- }
- throw new RuntimeException("Unable to convert Recap float " + data);
- }
-
- protected Data convertBytes(SchemaAndValue connectSchemaAndValue) {
- Schema connectSchema = connectSchemaAndValue.schema();
- Object connectValue = connectSchemaAndValue.value();
- Type.Bytes recapBytesType = new Type.Bytes(
- Integer.MAX_VALUE,
- true,
- connectSchema.name(),
- connectSchema.doc(),
- (Map) connectSchema.parameters()
- );
- return new Data(recapBytesType, connectValue);
- }
-
- protected SchemaAndValue convertBytes(Data data) {
- Type.Bytes recapBytesType = (Type.Bytes) data.getType();
- if (recapBytesType.getBytes() <= Integer.MAX_VALUE) {
- return new SchemaAndValue(
- setStandardAttributes(SchemaBuilder.bytes(), recapBytesType).build(),
- data.getObject());
- }
- throw new RuntimeException("Unable to convert Recap bytes " + data);
- }
-
- protected Data convertBool(SchemaAndValue connectSchemaAndValue) {
- Schema connectSchema = connectSchemaAndValue.schema();
- Object connectValue = connectSchemaAndValue.value();
- Type.Bool recapBoolType = new Type.Bool(
- connectSchema.name(),
- connectSchema.doc(),
- (Map) connectSchema.parameters()
- );
- return new Data(recapBoolType, connectValue);
- }
-
- protected SchemaAndValue convertBool(Data data) {
- return new SchemaAndValue(
- setStandardAttributes(SchemaBuilder.bool(), data.getType()).build(),
- data.getObject());
- }
-
- protected Data convertStruct(Struct connectStruct) {
- // TODO: Need to handle null structs here.
- Schema connectSchema = connectStruct.schema();
- Type[] recapFieldTypes = new Type[connectSchema.fields().size()];
- Map