-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Extract inner PositionsAppender impls to top level classes
- Loading branch information
1 parent
b71b5f0
commit 83cdee3
Showing
10 changed files
with
366 additions
and
219 deletions.
There are no files selected for viewing
44 changes: 44 additions & 0 deletions
44
core/trino-main/src/main/java/io/trino/operator/output/BytePositionsAppender.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,44 @@ | ||
/* | ||
* Licensed 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 io.trino.operator.output; | ||
|
||
import io.trino.spi.block.Block; | ||
import io.trino.spi.block.BlockBuilder; | ||
import it.unimi.dsi.fastutil.ints.IntArrayList; | ||
|
||
public class BytePositionsAppender | ||
implements PositionsAppender | ||
{ | ||
@Override | ||
public void appendTo(IntArrayList positions, Block block, BlockBuilder blockBuilder) | ||
{ | ||
int[] positionArray = positions.elements(); | ||
if (block.mayHaveNull()) { | ||
for (int i = 0; i < positions.size(); i++) { | ||
int position = positionArray[i]; | ||
if (block.isNull(position)) { | ||
blockBuilder.appendNull(); | ||
} | ||
else { | ||
blockBuilder.writeByte(block.getByte(position, 0)).closeEntry(); | ||
} | ||
} | ||
} | ||
else { | ||
for (int i = 0; i < positions.size(); i++) { | ||
blockBuilder.writeByte(block.getByte(positionArray[i], 0)).closeEntry(); | ||
} | ||
} | ||
} | ||
} |
51 changes: 51 additions & 0 deletions
51
core/trino-main/src/main/java/io/trino/operator/output/Int128PositionsAppender.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,51 @@ | ||
/* | ||
* Licensed 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 io.trino.operator.output; | ||
|
||
import io.trino.spi.block.Block; | ||
import io.trino.spi.block.BlockBuilder; | ||
import it.unimi.dsi.fastutil.ints.IntArrayList; | ||
|
||
import static io.airlift.slice.SizeOf.SIZE_OF_LONG; | ||
|
||
public class Int128PositionsAppender | ||
implements PositionsAppender | ||
{ | ||
@Override | ||
public void appendTo(IntArrayList positions, Block block, BlockBuilder blockBuilder) | ||
{ | ||
int[] positionArray = positions.elements(); | ||
if (block.mayHaveNull()) { | ||
for (int i = 0; i < positions.size(); i++) { | ||
int position = positionArray[i]; | ||
if (block.isNull(position)) { | ||
blockBuilder.appendNull(); | ||
} | ||
else { | ||
blockBuilder.writeLong(block.getLong(position, 0)); | ||
blockBuilder.writeLong(block.getLong(position, SIZE_OF_LONG)); | ||
blockBuilder.closeEntry(); | ||
} | ||
} | ||
} | ||
else { | ||
for (int i = 0; i < positions.size(); i++) { | ||
int position = positionArray[i]; | ||
blockBuilder.writeLong(block.getLong(position, 0)); | ||
blockBuilder.writeLong(block.getLong(position, SIZE_OF_LONG)); | ||
blockBuilder.closeEntry(); | ||
} | ||
} | ||
} | ||
} |
51 changes: 51 additions & 0 deletions
51
core/trino-main/src/main/java/io/trino/operator/output/Int96PositionsAppender.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,51 @@ | ||
/* | ||
* Licensed 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 io.trino.operator.output; | ||
|
||
import io.trino.spi.block.Block; | ||
import io.trino.spi.block.BlockBuilder; | ||
import it.unimi.dsi.fastutil.ints.IntArrayList; | ||
|
||
import static io.airlift.slice.SizeOf.SIZE_OF_LONG; | ||
|
||
public class Int96PositionsAppender | ||
implements PositionsAppender | ||
{ | ||
@Override | ||
public void appendTo(IntArrayList positions, Block block, BlockBuilder blockBuilder) | ||
{ | ||
int[] positionArray = positions.elements(); | ||
if (block.mayHaveNull()) { | ||
for (int i = 0; i < positions.size(); i++) { | ||
int position = positionArray[i]; | ||
if (block.isNull(position)) { | ||
blockBuilder.appendNull(); | ||
} | ||
else { | ||
blockBuilder.writeLong(block.getLong(position, 0)); | ||
blockBuilder.writeInt(block.getInt(position, SIZE_OF_LONG)); | ||
blockBuilder.closeEntry(); | ||
} | ||
} | ||
} | ||
else { | ||
for (int i = 0; i < positions.size(); i++) { | ||
int position = positionArray[i]; | ||
blockBuilder.writeLong(block.getLong(position, 0)); | ||
blockBuilder.writeInt(block.getInt(position, SIZE_OF_LONG)); | ||
blockBuilder.closeEntry(); | ||
} | ||
} | ||
} | ||
} |
44 changes: 44 additions & 0 deletions
44
core/trino-main/src/main/java/io/trino/operator/output/IntPositionsAppender.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,44 @@ | ||
/* | ||
* Licensed 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 io.trino.operator.output; | ||
|
||
import io.trino.spi.block.Block; | ||
import io.trino.spi.block.BlockBuilder; | ||
import it.unimi.dsi.fastutil.ints.IntArrayList; | ||
|
||
public class IntPositionsAppender | ||
implements PositionsAppender | ||
{ | ||
@Override | ||
public void appendTo(IntArrayList positions, Block block, BlockBuilder blockBuilder) | ||
{ | ||
int[] positionArray = positions.elements(); | ||
if (block.mayHaveNull()) { | ||
for (int i = 0; i < positions.size(); i++) { | ||
int position = positionArray[i]; | ||
if (block.isNull(position)) { | ||
blockBuilder.appendNull(); | ||
} | ||
else { | ||
blockBuilder.writeInt(block.getInt(position, 0)).closeEntry(); | ||
} | ||
} | ||
} | ||
else { | ||
for (int i = 0; i < positions.size(); i++) { | ||
blockBuilder.writeInt(block.getInt(positionArray[i], 0)).closeEntry(); | ||
} | ||
} | ||
} | ||
} |
44 changes: 44 additions & 0 deletions
44
core/trino-main/src/main/java/io/trino/operator/output/LongPositionsAppender.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,44 @@ | ||
/* | ||
* Licensed 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 io.trino.operator.output; | ||
|
||
import io.trino.spi.block.Block; | ||
import io.trino.spi.block.BlockBuilder; | ||
import it.unimi.dsi.fastutil.ints.IntArrayList; | ||
|
||
public class LongPositionsAppender | ||
implements PositionsAppender | ||
{ | ||
@Override | ||
public void appendTo(IntArrayList positions, Block block, BlockBuilder blockBuilder) | ||
{ | ||
int[] positionArray = positions.elements(); | ||
if (block.mayHaveNull()) { | ||
for (int i = 0; i < positions.size(); i++) { | ||
int position = positionArray[i]; | ||
if (block.isNull(position)) { | ||
blockBuilder.appendNull(); | ||
} | ||
else { | ||
blockBuilder.writeLong(block.getLong(position, 0)).closeEntry(); | ||
} | ||
} | ||
} | ||
else { | ||
for (int i = 0; i < positions.size(); i++) { | ||
blockBuilder.writeLong(block.getLong(positionArray[i], 0)).closeEntry(); | ||
} | ||
} | ||
} | ||
} |
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.