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 Nov 7, 2024
1 parent 019af39 commit 4886bac
Show file tree
Hide file tree
Showing 59 changed files with 2,475 additions and 1,204 deletions.
6 changes: 6 additions & 0 deletions seatunnel-api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -41,5 +41,11 @@
<version>${project.version}</version>
<classifier>optional</classifier>
</dependency>
<dependency>
<groupId>org.apache.seatunnel</groupId>
<artifactId>seatunnel-arrow</artifactId>
<version>${project.version}</version>
<classifier>optional</classifier>
</dependency>
</dependencies>
</project>
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.api.arrow.converter;

import org.apache.arrow.vector.BigIntVector;
import 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.api.arrow.converter;

import org.apache.arrow.vector.BitVector;
import 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.api.arrow.converter;

import org.apache.arrow.vector.FieldVector;
import 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.api.arrow.converter;

import org.apache.arrow.vector.DateDayVector;
import 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.api.arrow.converter;

import org.apache.arrow.vector.DateMilliVector;
import 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.api.arrow.converter;

import org.apache.arrow.vector.Decimal256Vector;
import 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.api.arrow.converter;

import org.apache.arrow.vector.DecimalVector;
import 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.api.arrow.converter;

import org.apache.arrow.vector.complex.DenseUnionVector;
import 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.api.arrow.converter;

import org.apache.arrow.vector.DurationVector;
import 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.api.arrow.converter;

import org.apache.arrow.vector.ExtensionTypeVector;
import 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;
}
}
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.api.arrow.converter;

import org.apache.arrow.vector.FixedSizeBinaryVector;
import org.apache.arrow.vector.types.Types;

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

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

0 comments on commit 4886bac

Please sign in to comment.