Skip to content

Commit

Permalink
add mysql spatial data types
Browse files Browse the repository at this point in the history
  • Loading branch information
mxsm committed Dec 6, 2023
1 parent 06d2939 commit 37afa79
Show file tree
Hide file tree
Showing 10 changed files with 356 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,17 @@
import org.apache.eventmesh.connector.jdbc.type.mysql.BytesType;
import org.apache.eventmesh.connector.jdbc.type.mysql.DecimalType;
import org.apache.eventmesh.connector.jdbc.type.mysql.EnumType;
import org.apache.eventmesh.connector.jdbc.type.mysql.Geometry;
import org.apache.eventmesh.connector.jdbc.type.mysql.GeometryCollection;
import org.apache.eventmesh.connector.jdbc.type.mysql.IntType;
import org.apache.eventmesh.connector.jdbc.type.mysql.JsonType;
import org.apache.eventmesh.connector.jdbc.type.mysql.LineString;
import org.apache.eventmesh.connector.jdbc.type.mysql.MediumintType;
import org.apache.eventmesh.connector.jdbc.type.mysql.MultiLineString;
import org.apache.eventmesh.connector.jdbc.type.mysql.MultiPointType;
import org.apache.eventmesh.connector.jdbc.type.mysql.MultiPolygon;
import org.apache.eventmesh.connector.jdbc.type.mysql.PointType;
import org.apache.eventmesh.connector.jdbc.type.mysql.Polygon;
import org.apache.eventmesh.connector.jdbc.type.mysql.SetType;
import org.apache.eventmesh.connector.jdbc.type.mysql.TinyIntType;
import org.apache.eventmesh.connector.jdbc.type.mysql.YearType;
Expand Down Expand Up @@ -115,6 +123,16 @@ public void init() {
//override YearEventMeshDateType
registerType(YearType.INSTANCE);
registerType(BytesType.INSTANCE);

//spatia data types
registerType(PointType.INSTANCE);
registerType(MultiPointType.INSTANCE);
registerType(Geometry.INSTANCE);
registerType(GeometryCollection.INSTANCE);
registerType(LineString.INSTANCE);
registerType(MultiLineString.INSTANCE);
registerType(Polygon.INSTANCE);
registerType(MultiPolygon.INSTANCE);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.apache.eventmesh.connector.jdbc.type.mysql;


import java.util.Arrays;
import java.util.List;
import org.apache.eventmesh.connector.jdbc.table.catalog.Column;

public class Geometry extends SpatialDataType {

public static final Geometry INSTANCE = new Geometry();

public Geometry() {
super("GEOMETRY");
}

@Override
public List<String> ofRegistrationKeys() {
return Arrays.asList(getName(), "geometry");
}

@Override
public String getTypeName(Column<?> column) {
return "geometry";
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.apache.eventmesh.connector.jdbc.type.mysql;


import java.util.Arrays;
import java.util.List;
import org.apache.eventmesh.connector.jdbc.table.catalog.Column;

public class GeometryCollection extends SpatialDataType {

public static final GeometryCollection INSTANCE = new GeometryCollection();

public GeometryCollection() {
super("GEOMETRYCOLLECTION");
}

@Override
public List<String> ofRegistrationKeys() {
return Arrays.asList(getName(), "geometrycollection");
}

@Override
public String getTypeName(Column<?> column) {
return "geometrycollection";
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.apache.eventmesh.connector.jdbc.type.mysql;


import java.util.Arrays;
import java.util.List;
import org.apache.eventmesh.connector.jdbc.table.catalog.Column;

public class LineString extends SpatialDataType {

public static final LineString INSTANCE = new LineString();

public LineString() {
super("LINESTRING");
}

@Override
public List<String> ofRegistrationKeys() {
return Arrays.asList(getName(), "linestring");
}

@Override
public String getTypeName(Column<?> column) {
return "linestring";
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.apache.eventmesh.connector.jdbc.type.mysql;


import java.util.Arrays;
import java.util.List;
import org.apache.eventmesh.connector.jdbc.table.catalog.Column;

public class MultiLineString extends SpatialDataType {

public static final MultiLineString INSTANCE = new MultiLineString();

public MultiLineString() {
super("MULTILINESTRING");
}

@Override
public List<String> ofRegistrationKeys() {
return Arrays.asList(getName(), "multilinestring");
}

@Override
public String getTypeName(Column<?> column) {
return "multilinestring";
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.apache.eventmesh.connector.jdbc.type.mysql;


import java.util.Arrays;
import java.util.List;
import org.apache.eventmesh.connector.jdbc.table.catalog.Column;

public class MultiPointType extends SpatialDataType {

public static final MultiPointType INSTANCE = new MultiPointType();

public MultiPointType() {
super("MULTIPOINT");
}

@Override
public List<String> ofRegistrationKeys() {
return Arrays.asList(getName(), "multipoint");
}

@Override
public String getTypeName(Column<?> column) {
return "multipoint";
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.apache.eventmesh.connector.jdbc.type.mysql;


import java.util.Arrays;
import java.util.List;
import org.apache.eventmesh.connector.jdbc.table.catalog.Column;

public class MultiPolygon extends SpatialDataType {

public static final MultiPolygon INSTANCE = new MultiPolygon();

public MultiPolygon() {
super("MULTIPOLYGON");
}

@Override
public List<String> ofRegistrationKeys() {
return Arrays.asList(getName(), "multipolygon");
}

@Override
public String getTypeName(Column<?> column) {
return "multipolygon";
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.apache.eventmesh.connector.jdbc.type.mysql;


import java.util.Arrays;
import java.util.List;
import org.apache.eventmesh.connector.jdbc.table.catalog.Column;

public class PointType extends SpatialDataType {

public static final PointType INSTANCE = new PointType();

public PointType() {
super("POINT");
}

@Override
public List<String> ofRegistrationKeys() {
return Arrays.asList(getName(), "point");
}

@Override
public String getTypeName(Column<?> column) {
return "point";
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.apache.eventmesh.connector.jdbc.type.mysql;


import java.util.Arrays;
import java.util.List;
import org.apache.eventmesh.connector.jdbc.table.catalog.Column;

public class Polygon extends SpatialDataType {

public static final Polygon INSTANCE = new Polygon();

public Polygon() {
super("POLYGON");
}

@Override
public List<String> ofRegistrationKeys() {
return Arrays.asList(getName(), "polygon");
}

@Override
public String getTypeName(Column<?> column) {
return "polygon";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
*/
public abstract class SpatialDataType extends AbstractType<byte[]> {

public SpatialDataType(Class<byte[]> typeClass, SQLType sqlType, String name) {
super(typeClass, sqlType, name);
public SpatialDataType(String name) {
super(byte[].class, SQLType.BINARY, name);
}
}

0 comments on commit 37afa79

Please sign in to comment.