Skip to content

Commit

Permalink
[Feature][core] support arrow transfers data to SeatunnelRow in arrow…
Browse files Browse the repository at this point in the history
… format
  • Loading branch information
hawk9821 committed Dec 2, 2024
1 parent 9cf4192 commit 96ab87e
Show file tree
Hide file tree
Showing 61 changed files with 2,615 additions and 1,204 deletions.
12 changes: 12 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@
<enableSourceJarCreation>true</enableSourceJarCreation>

<hadoop-aws.version>3.1.4</hadoop-aws.version>
<arrow.version>15.0.1</arrow.version>

</properties>

Expand Down Expand Up @@ -489,6 +490,17 @@
<scope>provided</scope>
</dependency>

<dependency>
<groupId>org.apache.arrow</groupId>
<artifactId>arrow-vector</artifactId>
<version>${arrow.version}</version>
</dependency>
<dependency>
<groupId>org.apache.arrow</groupId>
<artifactId>arrow-memory-netty</artifactId>
<version>${arrow.version}</version>
</dependency>

</dependencies>
</dependencyManagement>

Expand Down
7 changes: 7 additions & 0 deletions seatunnel-common/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,13 @@
<classifier>optional</classifier>
</dependency>

<dependency>
<groupId>org.apache.seatunnel</groupId>
<artifactId>seatunnel-arrow</artifactId>
<version>${project.version}</version>
<classifier>optional</classifier>
</dependency>

<dependency>
<groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*
* 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.seatunnel.connectors.seatunnel.common.source.arrow.converter;

import org.apache.seatunnel.shade.org.apache.arrow.vector.BigIntVector;
import org.apache.seatunnel.shade.org.apache.arrow.vector.types.Types;

public class BigIntConverter implements Converter<BigIntVector> {
@Override
public Object convert(int rowIndex, BigIntVector fieldVector) {
return fieldVector.isNull(rowIndex) ? null : fieldVector.getObject(rowIndex);
}

@Override
public boolean support(Types.MinorType type) {
return Types.MinorType.BIGINT == type;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*
* 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.seatunnel.connectors.seatunnel.common.source.arrow.converter;

import org.apache.seatunnel.shade.org.apache.arrow.vector.BitVector;
import org.apache.seatunnel.shade.org.apache.arrow.vector.types.Types;

public class BitConverter implements Converter<BitVector> {
@Override
public Object convert(int rowIndex, BitVector fieldVector) {
return fieldVector.isNull(rowIndex) ? null : fieldVector.getObject(rowIndex);
}

@Override
public boolean support(Types.MinorType type) {
return Types.MinorType.BIT == type;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/*
* 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.seatunnel.connectors.seatunnel.common.source.arrow.converter;

import org.apache.seatunnel.shade.org.apache.arrow.vector.FieldVector;
import org.apache.seatunnel.shade.org.apache.arrow.vector.types.Types;

import java.util.List;
import java.util.function.Function;

public interface Converter<T extends FieldVector> {

Object convert(int rowIndex, T fieldVector);

default Object convert(int rowIndex, T fieldVector, List<Function> genericsConvert) {
throw new UnsupportedOperationException("Unsupported generics convert");
}

boolean support(Types.MinorType type);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*
* 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.seatunnel.connectors.seatunnel.common.source.arrow.converter;

import org.apache.seatunnel.shade.org.apache.arrow.vector.DateDayVector;
import org.apache.seatunnel.shade.org.apache.arrow.vector.types.Types;

public class DateDayConverter implements Converter<DateDayVector> {
@Override
public Object convert(int rowIndex, DateDayVector fieldVector) {
return fieldVector.isNull(rowIndex) ? null : fieldVector.getObject(rowIndex);
}

@Override
public boolean support(Types.MinorType type) {
return Types.MinorType.DATEDAY == type;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*
* 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.seatunnel.connectors.seatunnel.common.source.arrow.converter;

import org.apache.seatunnel.shade.org.apache.arrow.vector.DateMilliVector;
import org.apache.seatunnel.shade.org.apache.arrow.vector.types.Types;

public class DateMilliConverter implements Converter<DateMilliVector> {
@Override
public Object convert(int rowIndex, DateMilliVector fieldVector) {
return fieldVector.isNull(rowIndex) ? null : fieldVector.getObject(rowIndex);
}

@Override
public boolean support(Types.MinorType type) {
return Types.MinorType.DATEMILLI == type;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*
* 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.seatunnel.connectors.seatunnel.common.source.arrow.converter;

import org.apache.seatunnel.shade.org.apache.arrow.vector.Decimal256Vector;
import org.apache.seatunnel.shade.org.apache.arrow.vector.types.Types;

public class Decimal256Converter implements Converter<Decimal256Vector> {
@Override
public Object convert(int rowIndex, Decimal256Vector fieldVector) {
return fieldVector.isNull(rowIndex) ? null : fieldVector.getObject(rowIndex);
}

@Override
public boolean support(Types.MinorType type) {
return Types.MinorType.DECIMAL256 == type;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*
* 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.seatunnel.connectors.seatunnel.common.source.arrow.converter;

import org.apache.seatunnel.shade.org.apache.arrow.vector.DecimalVector;
import org.apache.seatunnel.shade.org.apache.arrow.vector.types.Types;

public class DecimalConverter implements Converter<DecimalVector> {
@Override
public Object convert(int rowIndex, DecimalVector fieldVector) {
return fieldVector.isNull(rowIndex) ? null : fieldVector.getObject(rowIndex);
}

@Override
public boolean support(Types.MinorType type) {
return Types.MinorType.DECIMAL == type;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*
* 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.seatunnel.connectors.seatunnel.common.source.arrow.converter;

import org.apache.seatunnel.shade.org.apache.arrow.vector.complex.DenseUnionVector;
import org.apache.seatunnel.shade.org.apache.arrow.vector.types.Types;

public class DenseUnionConverter implements Converter<DenseUnionVector> {
@Override
public Object convert(int rowIndex, DenseUnionVector fieldVector) {
return fieldVector.isNull(rowIndex) ? null : fieldVector.getObject(rowIndex);
}

@Override
public boolean support(Types.MinorType type) {
return Types.MinorType.DENSEUNION == type;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*
* 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.seatunnel.connectors.seatunnel.common.source.arrow.converter;

import org.apache.seatunnel.shade.org.apache.arrow.vector.DurationVector;
import org.apache.seatunnel.shade.org.apache.arrow.vector.types.Types;

public class DurationConverter implements Converter<DurationVector> {
@Override
public Object convert(int rowIndex, DurationVector fieldVector) {
return fieldVector.isNull(rowIndex) ? null : fieldVector.getObject(rowIndex);
}

@Override
public boolean support(Types.MinorType type) {
return Types.MinorType.DURATION == type;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*
* 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.seatunnel.connectors.seatunnel.common.source.arrow.converter;

import org.apache.seatunnel.shade.org.apache.arrow.vector.ExtensionTypeVector;
import org.apache.seatunnel.shade.org.apache.arrow.vector.types.Types;

public class ExtensionTypeConverter implements Converter<ExtensionTypeVector> {
@Override
public Object convert(int rowIndex, ExtensionTypeVector fieldVector) {
return fieldVector.isNull(rowIndex) ? null : fieldVector.getObject(rowIndex);
}

@Override
public boolean support(Types.MinorType type) {
return Types.MinorType.EXTENSIONTYPE == type;
}
}
Loading

0 comments on commit 96ab87e

Please sign in to comment.