This is an automated email from the ASF dual-hosted git repository. amashenkov pushed a commit to branch ignite-22270 in repository https://gitbox.apache.org/repos/asf/ignite-3.git
commit ef50405e8d8e4dbe435d55c81a79092cb7c17890 Author: amashenkov <[email protected]> AuthorDate: Tue Jun 18 18:37:31 2024 +0300 Get rid of TupleMarshallerException --- .../apache/ignite/lang/MarshallerException.java | 4 ++ .../requests/table/ClientHandlerTupleTests.java | 5 +-- .../ItRaftCommandLeftInLogUntilRestartTest.java | 3 +- .../runner/app/PlatformTestNodeRunner.java | 15 ++----- .../internal/table/ItThinClientColocationTest.java | 4 +- .../ignite/internal/rebalance/ItRebalanceTest.java | 3 +- .../ignite/internal/table/ItColocationTest.java | 7 +--- .../schema/marshaller/TupleMarshaller.java | 13 +++--- .../marshaller/TupleMarshallerException.java | 36 ---------------- .../schema/marshaller/TupleMarshallerImpl.java | 13 +++--- .../internal/table/KeyValueBinaryViewImpl.java | 12 ++---- .../internal/table/RecordBinaryViewImpl.java | 20 ++++----- .../apache/ignite/internal/table/TableImpl.java | 13 ++---- .../table/partition/HashPartitionManagerImpl.java | 13 ++---- .../TupleMarshallerFixlenOnlyBenchmark.java | 3 +- .../TupleMarshallerVarlenOnlyBenchmark.java | 3 +- .../table/ColocationHashCalculationTest.java | 5 +-- .../internal/table/MutableRowTupleAdapterTest.java | 48 ++++++++-------------- .../table/type/NumericTypesSerializerTest.java | 28 ++++++------- 19 files changed, 81 insertions(+), 167 deletions(-) diff --git a/modules/api/src/main/java/org/apache/ignite/lang/MarshallerException.java b/modules/api/src/main/java/org/apache/ignite/lang/MarshallerException.java index 98f1d7d41b..25dcccf5eb 100644 --- a/modules/api/src/main/java/org/apache/ignite/lang/MarshallerException.java +++ b/modules/api/src/main/java/org/apache/ignite/lang/MarshallerException.java @@ -35,6 +35,10 @@ public class MarshallerException extends IgniteException { super(Common.INTERNAL_ERR, cause); } + public MarshallerException(String msg, @Nullable Throwable cause) { + super(Common.INTERNAL_ERR, msg, cause); + } + /** * Creates an exception with the given trace ID, error code, detailed message, and cause. * diff --git a/modules/client-handler/src/test/java/org/apache/ignite/client/handler/requests/table/ClientHandlerTupleTests.java b/modules/client-handler/src/test/java/org/apache/ignite/client/handler/requests/table/ClientHandlerTupleTests.java index a2e653afe7..2a01508f60 100644 --- a/modules/client-handler/src/test/java/org/apache/ignite/client/handler/requests/table/ClientHandlerTupleTests.java +++ b/modules/client-handler/src/test/java/org/apache/ignite/client/handler/requests/table/ClientHandlerTupleTests.java @@ -43,7 +43,6 @@ import java.util.UUID; import org.apache.ignite.internal.binarytuple.BinaryTupleReader; import org.apache.ignite.internal.schema.Column; import org.apache.ignite.internal.schema.SchemaDescriptor; -import org.apache.ignite.internal.schema.marshaller.TupleMarshallerException; import org.apache.ignite.internal.schema.marshaller.TupleMarshallerImpl; import org.apache.ignite.internal.testframework.IgniteTestUtils; import org.apache.ignite.internal.type.NativeTypes; @@ -88,7 +87,7 @@ public class ClientHandlerTupleTests { ); @Test - public void testTupleEquality() throws TupleMarshallerException { + public void testTupleEquality() { Tuple tuple = createTuple(); BinaryTupleReader binaryTuple = new TupleMarshallerImpl(fullSchema).marshal(tuple).binaryTuple(); @@ -98,7 +97,7 @@ public class ClientHandlerTupleTests { } @Test - public void testTupleEqualityKeyOnly() throws TupleMarshallerException { + public void testTupleEqualityKeyOnly() { Tuple tuple = createKeyTuple(); BinaryTupleReader binaryTuple = new TupleMarshallerImpl(fullSchema).marshalKey(tuple).binaryTuple(); diff --git a/modules/runner/src/integrationTest/java/org/apache/ignite/internal/runner/app/ItRaftCommandLeftInLogUntilRestartTest.java b/modules/runner/src/integrationTest/java/org/apache/ignite/internal/runner/app/ItRaftCommandLeftInLogUntilRestartTest.java index 5e54b3dea0..51b1135e20 100644 --- a/modules/runner/src/integrationTest/java/org/apache/ignite/internal/runner/app/ItRaftCommandLeftInLogUntilRestartTest.java +++ b/modules/runner/src/integrationTest/java/org/apache/ignite/internal/runner/app/ItRaftCommandLeftInLogUntilRestartTest.java @@ -42,7 +42,6 @@ import org.apache.ignite.internal.raft.service.RaftGroupService; import org.apache.ignite.internal.schema.BinaryRow; import org.apache.ignite.internal.schema.BinaryRowEx; import org.apache.ignite.internal.schema.SchemaRegistry; -import org.apache.ignite.internal.schema.marshaller.TupleMarshallerException; import org.apache.ignite.internal.schema.marshaller.TupleMarshallerImpl; import org.apache.ignite.internal.schema.row.Row; import org.apache.ignite.internal.table.TableViewInternal; @@ -218,7 +217,7 @@ public class ItRaftCommandLeftInLogUntilRestartTest extends ClusterPerClassInteg clearData(ignite.tables().table(DEFAULT_TABLE_NAME)); } - private static Row marshalKey(TableViewInternal table, Tuple tuple) throws TupleMarshallerException { + private static Row marshalKey(TableViewInternal table, Tuple tuple) { SchemaRegistry schemaReg = table.schemaView(); var marshaller = new TupleMarshallerImpl(schemaReg.lastKnownSchema()); diff --git a/modules/runner/src/integrationTest/java/org/apache/ignite/internal/runner/app/PlatformTestNodeRunner.java b/modules/runner/src/integrationTest/java/org/apache/ignite/internal/runner/app/PlatformTestNodeRunner.java index d66ba86956..7d3f9213b1 100644 --- a/modules/runner/src/integrationTest/java/org/apache/ignite/internal/runner/app/PlatformTestNodeRunner.java +++ b/modules/runner/src/integrationTest/java/org/apache/ignite/internal/runner/app/PlatformTestNodeRunner.java @@ -70,7 +70,6 @@ import org.apache.ignite.internal.client.proto.ColumnTypeConverter; import org.apache.ignite.internal.schema.Column; import org.apache.ignite.internal.schema.SchemaDescriptor; import org.apache.ignite.internal.schema.marshaller.TupleMarshaller; -import org.apache.ignite.internal.schema.marshaller.TupleMarshallerException; import org.apache.ignite.internal.schema.marshaller.TupleMarshallerImpl; import org.apache.ignite.internal.schema.row.Row; import org.apache.ignite.internal.security.authentication.basic.BasicAuthenticationProviderChange; @@ -709,13 +708,9 @@ public class PlatformTestNodeRunner { var marsh = new TupleMarshallerImpl(schema); - try { - Row row = marsh.marshal(tuple); + Row row = marsh.marshal(tuple); - return row.colocationHash(); - } catch (TupleMarshallerException e) { - throw new RuntimeException(e); - } + return row.colocationHash(); } } @@ -735,11 +730,7 @@ public class PlatformTestNodeRunner { RecordBinaryViewImpl view = Wrappers.unwrap(table.recordView(), RecordBinaryViewImpl.class); TupleMarshaller marsh = view.marshaller(1); - try { - return marsh.marshal(key).colocationHash(); - } catch (TupleMarshallerException e) { - throw new RuntimeException(e); - } + return marsh.marshal(key).colocationHash(); } } diff --git a/modules/runner/src/integrationTest/java/org/apache/ignite/internal/table/ItThinClientColocationTest.java b/modules/runner/src/integrationTest/java/org/apache/ignite/internal/table/ItThinClientColocationTest.java index e6c2125b3c..267e04667b 100644 --- a/modules/runner/src/integrationTest/java/org/apache/ignite/internal/table/ItThinClientColocationTest.java +++ b/modules/runner/src/integrationTest/java/org/apache/ignite/internal/table/ItThinClientColocationTest.java @@ -37,7 +37,6 @@ import org.apache.ignite.internal.marshaller.ReflectionMarshallersProvider; import org.apache.ignite.internal.schema.Column; import org.apache.ignite.internal.schema.SchemaDescriptor; import org.apache.ignite.internal.schema.marshaller.TupleMarshaller; -import org.apache.ignite.internal.schema.marshaller.TupleMarshallerException; import org.apache.ignite.internal.schema.marshaller.TupleMarshallerImpl; import org.apache.ignite.internal.schema.row.Row; import org.apache.ignite.internal.testframework.IgniteTestUtils; @@ -59,8 +58,7 @@ public class ItThinClientColocationTest extends ClusterPerClassIntegrationTest { @ParameterizedTest @MethodSource("nativeTypes") - public void testClientAndServerColocationHashesAreSame(NativeType type) - throws TupleMarshallerException { + public void testClientAndServerColocationHashesAreSame(NativeType type) { var columnName = "COL1"; TupleMarshaller serverMarshaller = tupleMarshaller(type, columnName); diff --git a/modules/table/src/integrationTest/java/org/apache/ignite/internal/rebalance/ItRebalanceTest.java b/modules/table/src/integrationTest/java/org/apache/ignite/internal/rebalance/ItRebalanceTest.java index 9d41c32b1b..dddbb66995 100644 --- a/modules/table/src/integrationTest/java/org/apache/ignite/internal/rebalance/ItRebalanceTest.java +++ b/modules/table/src/integrationTest/java/org/apache/ignite/internal/rebalance/ItRebalanceTest.java @@ -50,7 +50,6 @@ import org.apache.ignite.internal.metastorage.MetaStorageManager; import org.apache.ignite.internal.replicator.exception.ReplicationException; import org.apache.ignite.internal.schema.BinaryRowEx; import org.apache.ignite.internal.schema.SchemaRegistry; -import org.apache.ignite.internal.schema.marshaller.TupleMarshallerException; import org.apache.ignite.internal.schema.marshaller.TupleMarshallerImpl; import org.apache.ignite.internal.schema.row.Row; import org.apache.ignite.internal.table.TableViewInternal; @@ -209,7 +208,7 @@ public class ItRebalanceTest extends IgniteIntegrationTest { waitForTablesCounterInMetastore(0, zoneId, 2); } - private static Row marshalTuple(TableViewInternal table, Tuple tuple) throws TupleMarshallerException { + private static Row marshalTuple(TableViewInternal table, Tuple tuple) { SchemaRegistry schemaReg = table.schemaView(); var marshaller = new TupleMarshallerImpl(schemaReg.lastKnownSchema()); diff --git a/modules/table/src/integrationTest/java/org/apache/ignite/internal/table/ItColocationTest.java b/modules/table/src/integrationTest/java/org/apache/ignite/internal/table/ItColocationTest.java index c06ff4e866..50f9ffa202 100644 --- a/modules/table/src/integrationTest/java/org/apache/ignite/internal/table/ItColocationTest.java +++ b/modules/table/src/integrationTest/java/org/apache/ignite/internal/table/ItColocationTest.java @@ -83,7 +83,6 @@ import org.apache.ignite.internal.schema.Column; import org.apache.ignite.internal.schema.NullBinaryRow; import org.apache.ignite.internal.schema.SchemaDescriptor; import org.apache.ignite.internal.schema.SchemaRegistry; -import org.apache.ignite.internal.schema.marshaller.TupleMarshallerException; import org.apache.ignite.internal.schema.marshaller.TupleMarshallerImpl; import org.apache.ignite.internal.schema.row.Row; import org.apache.ignite.internal.storage.engine.MvTableStorage; @@ -391,8 +390,7 @@ public class ItColocationTest extends BaseIgniteAbstractTest { */ @ParameterizedTest(name = "types=" + ARGUMENTS_PLACEHOLDER) @MethodSource("twoColumnsParameters") - public void colocationTwoColumnsInsert(NativeTypeSpec t0, NativeTypeSpec t1) - throws TupleMarshallerException { + public void colocationTwoColumnsInsert(NativeTypeSpec t0, NativeTypeSpec t1) { init(t0, t1); for (int i = 0; i < KEYS; ++i) { @@ -415,8 +413,7 @@ public class ItColocationTest extends BaseIgniteAbstractTest { */ @ParameterizedTest(name = "types=" + ARGUMENTS_PLACEHOLDER) @MethodSource("twoColumnsParameters") - public void colocationTwoColumnsInsertAll(NativeTypeSpec t0, NativeTypeSpec t1) - throws TupleMarshallerException { + public void colocationTwoColumnsInsertAll(NativeTypeSpec t0, NativeTypeSpec t1) { int keysCount = t0 == NativeTypeSpec.BOOLEAN && t0 == t1 ? 2 : KEYS; init(t0, t1); diff --git a/modules/table/src/main/java/org/apache/ignite/internal/schema/marshaller/TupleMarshaller.java b/modules/table/src/main/java/org/apache/ignite/internal/schema/marshaller/TupleMarshaller.java index 8fc279c3f4..30ebcb5341 100644 --- a/modules/table/src/main/java/org/apache/ignite/internal/schema/marshaller/TupleMarshaller.java +++ b/modules/table/src/main/java/org/apache/ignite/internal/schema/marshaller/TupleMarshaller.java @@ -18,6 +18,7 @@ package org.apache.ignite.internal.schema.marshaller; import org.apache.ignite.internal.schema.row.Row; +import org.apache.ignite.lang.MarshallerException; import org.apache.ignite.table.Tuple; import org.jetbrains.annotations.Nullable; @@ -35,9 +36,9 @@ public interface TupleMarshaller { * * @param tuple Record tuple. * @return Table row with columns set from given tuples. - * @throws TupleMarshallerException If failed to marshal tuple. + * @throws MarshallerException If failed to marshal tuple. */ - Row marshal(Tuple tuple) throws TupleMarshallerException; + Row marshal(Tuple tuple) throws MarshallerException; /** * Marshals KV pair. @@ -45,16 +46,16 @@ public interface TupleMarshaller { * @param keyTuple Key tuple. * @param valTuple Value tuple. * @return Table row with columns set from given tuples. - * @throws TupleMarshallerException If failed to marshal tuple. + * @throws MarshallerException If failed to marshal tuple. */ - Row marshal(Tuple keyTuple, @Nullable Tuple valTuple) throws TupleMarshallerException; + Row marshal(Tuple keyTuple, @Nullable Tuple valTuple) throws MarshallerException; /** * Marshal tuple key part only. * * @param tuple Record tuple with key columns only. * @return Table row with columns set from given tuples. - * @throws TupleMarshallerException If failed to marshal tuple. + * @throws MarshallerException If failed to marshal tuple. */ - Row marshalKey(Tuple tuple) throws TupleMarshallerException; + Row marshalKey(Tuple tuple) throws MarshallerException; } diff --git a/modules/table/src/main/java/org/apache/ignite/internal/schema/marshaller/TupleMarshallerException.java b/modules/table/src/main/java/org/apache/ignite/internal/schema/marshaller/TupleMarshallerException.java deleted file mode 100644 index acf2e7d92f..0000000000 --- a/modules/table/src/main/java/org/apache/ignite/internal/schema/marshaller/TupleMarshallerException.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * 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.ignite.internal.schema.marshaller; - -import org.apache.ignite.internal.lang.IgniteInternalCheckedException; - -/** - * Throws when failed to marshal a tuple. - */ -public class TupleMarshallerException extends IgniteInternalCheckedException { - /** - * Creates a new grid exception with the given throwable as a cause and - * source of error message. - * - * @param s Msg. - * @param cause Non-null throwable cause. - */ - public TupleMarshallerException(String s, Throwable cause) { - super(cause); - } -} diff --git a/modules/table/src/main/java/org/apache/ignite/internal/schema/marshaller/TupleMarshallerImpl.java b/modules/table/src/main/java/org/apache/ignite/internal/schema/marshaller/TupleMarshallerImpl.java index 422cf4373c..a84ffa2ba1 100644 --- a/modules/table/src/main/java/org/apache/ignite/internal/schema/marshaller/TupleMarshallerImpl.java +++ b/modules/table/src/main/java/org/apache/ignite/internal/schema/marshaller/TupleMarshallerImpl.java @@ -39,6 +39,7 @@ import org.apache.ignite.internal.schema.row.RowAssembler; import org.apache.ignite.internal.type.DecimalNativeType; import org.apache.ignite.internal.type.NativeType; import org.apache.ignite.internal.type.NativeTypeSpec; +import org.apache.ignite.lang.MarshallerException; import org.apache.ignite.lang.util.IgniteNameUtils; import org.apache.ignite.table.Tuple; import org.jetbrains.annotations.Nullable; @@ -68,7 +69,7 @@ public class TupleMarshallerImpl implements TupleMarshaller { /** {@inheritDoc} */ @Override - public Row marshal(Tuple tuple) throws TupleMarshallerException { + public Row marshal(Tuple tuple) throws MarshallerException { try { if (tuple instanceof SchemaAware && tuple instanceof BinaryTupleContainer) { SchemaDescriptor tupleSchema = ((SchemaAware) tuple).schema(); @@ -101,13 +102,13 @@ public class TupleMarshallerImpl implements TupleMarshaller { return buildRow(false, valuesWithStatistics); } catch (Exception ex) { - throw new TupleMarshallerException("Failed to marshal tuple.", ex); + throw new MarshallerException("Failed to marshal tuple.", ex); } } /** {@inheritDoc} */ @Override - public Row marshal(Tuple keyTuple, @Nullable Tuple valTuple) throws TupleMarshallerException { + public Row marshal(Tuple keyTuple, @Nullable Tuple valTuple) throws MarshallerException { try { ValuesWithStatistics valuesWithStatistics = new ValuesWithStatistics(); @@ -132,13 +133,13 @@ public class TupleMarshallerImpl implements TupleMarshaller { return buildRow(keyOnly, valuesWithStatistics); } catch (Exception ex) { - throw new TupleMarshallerException("Failed to marshal tuple.", ex); + throw new MarshallerException("Failed to marshal tuple.", ex); } } /** {@inheritDoc} */ @Override - public Row marshalKey(Tuple keyTuple) throws TupleMarshallerException { + public Row marshalKey(Tuple keyTuple) throws MarshallerException { try { ValuesWithStatistics valuesWithStatistics = new ValuesWithStatistics(); @@ -150,7 +151,7 @@ public class TupleMarshallerImpl implements TupleMarshaller { return buildRow(true, valuesWithStatistics); } catch (Exception ex) { - throw new TupleMarshallerException("Failed to marshal tuple.", ex); + throw new MarshallerException("Failed to marshal tuple.", ex); } } diff --git a/modules/table/src/main/java/org/apache/ignite/internal/table/KeyValueBinaryViewImpl.java b/modules/table/src/main/java/org/apache/ignite/internal/table/KeyValueBinaryViewImpl.java index aed7f93d7d..7f559e895e 100644 --- a/modules/table/src/main/java/org/apache/ignite/internal/table/KeyValueBinaryViewImpl.java +++ b/modules/table/src/main/java/org/apache/ignite/internal/table/KeyValueBinaryViewImpl.java @@ -38,7 +38,6 @@ import org.apache.ignite.internal.schema.BinaryRow; import org.apache.ignite.internal.schema.BinaryRowEx; import org.apache.ignite.internal.schema.SchemaDescriptor; import org.apache.ignite.internal.schema.SchemaRegistry; -import org.apache.ignite.internal.schema.marshaller.TupleMarshallerException; import org.apache.ignite.internal.schema.row.Row; import org.apache.ignite.internal.streamer.StreamerBatchSender; import org.apache.ignite.internal.table.criteria.SqlRowProjection; @@ -46,7 +45,6 @@ import org.apache.ignite.internal.table.distributed.schema.SchemaVersions; import org.apache.ignite.internal.thread.PublicApiThreading; import org.apache.ignite.internal.tx.InternalTransaction; import org.apache.ignite.internal.util.IgniteUtils; -import org.apache.ignite.lang.IgniteException; import org.apache.ignite.lang.MarshallerException; import org.apache.ignite.lang.NullableValue; import org.apache.ignite.sql.IgniteSql; @@ -470,14 +468,10 @@ public class KeyValueBinaryViewImpl extends AbstractTableView<Entry<Tuple, Tuple * @param val Value. * @param schemaVersion Schema version to use when marshalling * @return Row. - * @throws IgniteException If failed to marshal key and/or value. + * @throws MarshallerException If failed to marshal key and/or value. */ - private Row marshal(Tuple key, @Nullable Tuple val, int schemaVersion) throws IgniteException { - try { - return marshallerCache.marshaller(schemaVersion).marshal(key, val); - } catch (TupleMarshallerException ex) { - throw new MarshallerException(ex); - } + private Row marshal(Tuple key, @Nullable Tuple val, int schemaVersion) { + return marshallerCache.marshaller(schemaVersion).marshal(key, val); } /** diff --git a/modules/table/src/main/java/org/apache/ignite/internal/table/RecordBinaryViewImpl.java b/modules/table/src/main/java/org/apache/ignite/internal/table/RecordBinaryViewImpl.java index 2c4e841bf3..be5921e163 100644 --- a/modules/table/src/main/java/org/apache/ignite/internal/table/RecordBinaryViewImpl.java +++ b/modules/table/src/main/java/org/apache/ignite/internal/table/RecordBinaryViewImpl.java @@ -36,13 +36,11 @@ import org.apache.ignite.internal.schema.BinaryRow; import org.apache.ignite.internal.schema.BinaryRowEx; import org.apache.ignite.internal.schema.SchemaRegistry; import org.apache.ignite.internal.schema.marshaller.TupleMarshaller; -import org.apache.ignite.internal.schema.marshaller.TupleMarshallerException; import org.apache.ignite.internal.schema.row.Row; import org.apache.ignite.internal.streamer.StreamerBatchSender; import org.apache.ignite.internal.table.distributed.schema.SchemaVersions; import org.apache.ignite.internal.thread.PublicApiThreading; import org.apache.ignite.internal.tx.InternalTransaction; -import org.apache.ignite.lang.IgniteException; import org.apache.ignite.lang.MarshallerException; import org.apache.ignite.sql.IgniteSql; import org.apache.ignite.table.DataStreamerItem; @@ -379,9 +377,9 @@ public class RecordBinaryViewImpl extends AbstractTableView<Tuple> implements Re * @param schemaVersion Schema version in which to marshal. * @param keyOnly Marshal key part only if {@code true}, otherwise marshal both, key and value parts. * @return Row. - * @throws IgniteException If failed to marshal tuple. + * @throws MarshallerException If failed to marshal tuple. */ - private Row marshal(Tuple tuple, int schemaVersion, boolean keyOnly) throws IgniteException { + private Row marshal(Tuple tuple, int schemaVersion, boolean keyOnly) { TupleMarshaller marshaller = marshaller(schemaVersion); return marshal(tuple, marshaller, keyOnly); @@ -394,17 +392,13 @@ public class RecordBinaryViewImpl extends AbstractTableView<Tuple> implements Re * @param marshaller Marshaller. * @param keyOnly Marshal key part only if {@code true}, otherwise marshal both, key and value parts. * @return Row. - * @throws IgniteException If failed to marshal tuple. + * @throws MarshallerException If failed to marshal tuple. */ private static Row marshal(Tuple tuple, TupleMarshaller marshaller, boolean keyOnly) { - try { - if (keyOnly) { - return marshaller.marshalKey(tuple); - } else { - return marshaller.marshal(tuple); - } - } catch (TupleMarshallerException ex) { - throw new MarshallerException(ex); + if (keyOnly) { + return marshaller.marshalKey(tuple); + } else { + return marshaller.marshal(tuple); } } diff --git a/modules/table/src/main/java/org/apache/ignite/internal/table/TableImpl.java b/modules/table/src/main/java/org/apache/ignite/internal/table/TableImpl.java index d8e966fcbe..2805110a6d 100644 --- a/modules/table/src/main/java/org/apache/ignite/internal/table/TableImpl.java +++ b/modules/table/src/main/java/org/apache/ignite/internal/table/TableImpl.java @@ -30,7 +30,6 @@ import org.apache.ignite.internal.marshaller.ReflectionMarshallersProvider; import org.apache.ignite.internal.schema.BinaryRowEx; import org.apache.ignite.internal.schema.ColumnsExtractor; import org.apache.ignite.internal.schema.SchemaRegistry; -import org.apache.ignite.internal.schema.marshaller.TupleMarshallerException; import org.apache.ignite.internal.schema.marshaller.TupleMarshallerImpl; import org.apache.ignite.internal.schema.marshaller.reflection.KvMarshallerImpl; import org.apache.ignite.internal.schema.row.Row; @@ -194,15 +193,11 @@ public class TableImpl implements TableViewInternal { public int partition(Tuple key) { Objects.requireNonNull(key); - try { - // Taking latest schema version for marshaller here because it's only used to calculate colocation hash, and colocation - // columns never change (so they are the same for all schema versions of the table), - Row keyRow = new TupleMarshallerImpl(schemaReg.lastKnownSchema()).marshalKey(key); + // Taking latest schema version for marshaller here because it's only used to calculate colocation hash, and colocation + // columns never change (so they are the same for all schema versions of the table), + Row keyRow = new TupleMarshallerImpl(schemaReg.lastKnownSchema()).marshalKey(key); - return tbl.partition(keyRow); - } catch (TupleMarshallerException e) { - throw new org.apache.ignite.lang.MarshallerException(e); - } + return tbl.partition(keyRow); } @Override diff --git a/modules/table/src/main/java/org/apache/ignite/internal/table/partition/HashPartitionManagerImpl.java b/modules/table/src/main/java/org/apache/ignite/internal/table/partition/HashPartitionManagerImpl.java index a185be1e33..1c8d68914c 100644 --- a/modules/table/src/main/java/org/apache/ignite/internal/table/partition/HashPartitionManagerImpl.java +++ b/modules/table/src/main/java/org/apache/ignite/internal/table/partition/HashPartitionManagerImpl.java @@ -29,7 +29,6 @@ import org.apache.ignite.internal.marshaller.MarshallersProvider; import org.apache.ignite.internal.replicator.TablePartitionId; import org.apache.ignite.internal.schema.BinaryRowEx; import org.apache.ignite.internal.schema.SchemaRegistry; -import org.apache.ignite.internal.schema.marshaller.TupleMarshallerException; import org.apache.ignite.internal.schema.marshaller.TupleMarshallerImpl; import org.apache.ignite.internal.schema.marshaller.reflection.KvMarshallerImpl; import org.apache.ignite.internal.schema.row.Row; @@ -116,14 +115,10 @@ public class HashPartitionManagerImpl implements PartitionManager { public CompletableFuture<Partition> partitionAsync(Tuple key) { Objects.requireNonNull(key); - try { - // Taking latest schema version for marshaller here because it's only used to calculate colocation hash, and colocation - // columns never change (so they are the same for all schema versions of the table), - Row keyRow = new TupleMarshallerImpl(schemaReg.lastKnownSchema()).marshalKey(key); + // Taking latest schema version for marshaller here because it's only used to calculate colocation hash, and colocation + // columns never change (so they are the same for all schema versions of the table), + Row keyRow = new TupleMarshallerImpl(schemaReg.lastKnownSchema()).marshalKey(key); - return completedFuture(new HashPartition(table.partition(keyRow))); - } catch (TupleMarshallerException e) { - throw new org.apache.ignite.lang.MarshallerException(e); - } + return completedFuture(new HashPartition(table.partition(keyRow))); } } diff --git a/modules/table/src/test/java/org/apache/ignite/internal/benchmarks/TupleMarshallerFixlenOnlyBenchmark.java b/modules/table/src/test/java/org/apache/ignite/internal/benchmarks/TupleMarshallerFixlenOnlyBenchmark.java index 1997c07550..c5c430139b 100644 --- a/modules/table/src/test/java/org/apache/ignite/internal/benchmarks/TupleMarshallerFixlenOnlyBenchmark.java +++ b/modules/table/src/test/java/org/apache/ignite/internal/benchmarks/TupleMarshallerFixlenOnlyBenchmark.java @@ -24,7 +24,6 @@ import java.util.stream.IntStream; import org.apache.ignite.internal.schema.Column; import org.apache.ignite.internal.schema.SchemaDescriptor; import org.apache.ignite.internal.schema.marshaller.TupleMarshaller; -import org.apache.ignite.internal.schema.marshaller.TupleMarshallerException; import org.apache.ignite.internal.schema.marshaller.TupleMarshallerImpl; import org.apache.ignite.internal.schema.row.Row; import org.apache.ignite.internal.type.NativeTypes; @@ -119,7 +118,7 @@ public class TupleMarshallerFixlenOnlyBenchmark { * @param bh Black hole. */ @Benchmark - public void measureTupleBuildAndMarshallerCost(Blackhole bh) throws TupleMarshallerException { + public void measureTupleBuildAndMarshallerCost(Blackhole bh) { List<Column> cols = schema.valueColumns(); final Tuple valBld = Tuple.create(cols.size()); diff --git a/modules/table/src/test/java/org/apache/ignite/internal/benchmarks/TupleMarshallerVarlenOnlyBenchmark.java b/modules/table/src/test/java/org/apache/ignite/internal/benchmarks/TupleMarshallerVarlenOnlyBenchmark.java index baff84fc6f..1e3a48ebaf 100644 --- a/modules/table/src/test/java/org/apache/ignite/internal/benchmarks/TupleMarshallerVarlenOnlyBenchmark.java +++ b/modules/table/src/test/java/org/apache/ignite/internal/benchmarks/TupleMarshallerVarlenOnlyBenchmark.java @@ -30,7 +30,6 @@ import org.apache.ignite.internal.schema.Column; import org.apache.ignite.internal.schema.DefaultValueProvider; import org.apache.ignite.internal.schema.SchemaDescriptor; import org.apache.ignite.internal.schema.marshaller.TupleMarshaller; -import org.apache.ignite.internal.schema.marshaller.TupleMarshallerException; import org.apache.ignite.internal.schema.marshaller.TupleMarshallerImpl; import org.apache.ignite.internal.schema.row.Row; import org.apache.ignite.table.Tuple; @@ -139,7 +138,7 @@ public class TupleMarshallerVarlenOnlyBenchmark { * @param bh Black hole. */ @Benchmark - public void measureTupleBuildAndMarshallerCost(Blackhole bh) throws TupleMarshallerException { + public void measureTupleBuildAndMarshallerCost(Blackhole bh) { List<Column> cols = schema.valueColumns(); final Tuple valBld = Tuple.create(cols.size()); diff --git a/modules/table/src/test/java/org/apache/ignite/internal/table/ColocationHashCalculationTest.java b/modules/table/src/test/java/org/apache/ignite/internal/table/ColocationHashCalculationTest.java index 11def44a37..a9c814e989 100644 --- a/modules/table/src/test/java/org/apache/ignite/internal/table/ColocationHashCalculationTest.java +++ b/modules/table/src/test/java/org/apache/ignite/internal/table/ColocationHashCalculationTest.java @@ -32,7 +32,6 @@ import org.apache.ignite.internal.schema.Column; import org.apache.ignite.internal.schema.SchemaDescriptor; import org.apache.ignite.internal.schema.SchemaTestUtils; import org.apache.ignite.internal.schema.marshaller.TupleMarshaller; -import org.apache.ignite.internal.schema.marshaller.TupleMarshallerException; import org.apache.ignite.internal.schema.marshaller.TupleMarshallerImpl; import org.apache.ignite.internal.schema.row.Row; import org.apache.ignite.internal.schema.row.RowAssembler; @@ -97,7 +96,7 @@ public class ColocationHashCalculationTest { } @Test - public void allTypes() throws TupleMarshallerException { + public void allTypes() { Column[] keyCols = IntStream.range(0, SchemaTestUtils.ALL_TYPES.size()) .mapToObj(i -> { NativeType t = SchemaTestUtils.ALL_TYPES.get(i); @@ -180,7 +179,7 @@ public class ColocationHashCalculationTest { } } - private static Row generateRandomRow(Random rnd, SchemaDescriptor schema) throws TupleMarshallerException { + private static Row generateRandomRow(Random rnd, SchemaDescriptor schema) { TupleMarshaller marshaller = new TupleMarshallerImpl(schema); Tuple t = Tuple.create(); diff --git a/modules/table/src/test/java/org/apache/ignite/internal/table/MutableRowTupleAdapterTest.java b/modules/table/src/test/java/org/apache/ignite/internal/table/MutableRowTupleAdapterTest.java index 8549247f09..b190e1d9ca 100644 --- a/modules/table/src/test/java/org/apache/ignite/internal/table/MutableRowTupleAdapterTest.java +++ b/modules/table/src/test/java/org/apache/ignite/internal/table/MutableRowTupleAdapterTest.java @@ -37,7 +37,6 @@ import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.junit.jupiter.api.Assertions.assertNull; import static org.junit.jupiter.api.Assertions.assertThrows; import static org.junit.jupiter.api.Assertions.assertTrue; -import static org.junit.jupiter.api.Assertions.fail; import java.math.BigDecimal; import java.time.Instant; @@ -54,7 +53,6 @@ import org.apache.ignite.internal.schema.SchemaAware; import org.apache.ignite.internal.schema.SchemaDescriptor; import org.apache.ignite.internal.schema.SchemaMismatchException; import org.apache.ignite.internal.schema.marshaller.TupleMarshaller; -import org.apache.ignite.internal.schema.marshaller.TupleMarshallerException; import org.apache.ignite.internal.schema.marshaller.TupleMarshallerImpl; import org.apache.ignite.internal.schema.row.Row; import org.apache.ignite.internal.type.NativeType; @@ -112,7 +110,7 @@ public class MutableRowTupleAdapterTest extends AbstractMutableTupleTest { ); @Test - public void testKeyValueChunks() throws TupleMarshallerException { + public void testKeyValueChunks() { SchemaDescriptor schema = new SchemaDescriptor( 42, List.of( @@ -159,7 +157,7 @@ public class MutableRowTupleAdapterTest extends AbstractMutableTupleTest { } @Test - public void testRowTupleMutability() throws TupleMarshallerException { + public void testRowTupleMutability() { TupleMarshaller marshaller = new TupleMarshallerImpl(schema); Row row = marshaller.marshal(Tuple.create().set("id", 1L).set("simpleName", "Shirt")); @@ -186,7 +184,7 @@ public class MutableRowTupleAdapterTest extends AbstractMutableTupleTest { } @Test - public void testKeyValueTupleMutability() throws TupleMarshallerException { + public void testKeyValueTupleMutability() { TupleMarshaller marshaller = new TupleMarshallerImpl(schema); Row row = marshaller.marshal(Tuple.create().set("id", 1L).set("simpleName", "Shirt")); @@ -215,7 +213,7 @@ public class MutableRowTupleAdapterTest extends AbstractMutableTupleTest { } @Test - public void testRowTupleSchemaAwareness() throws TupleMarshallerException { + public void testRowTupleSchemaAwareness() { TupleMarshaller marshaller = new TupleMarshallerImpl(schema); Row row = marshaller.marshal(Tuple.create().set("id", 1L).set("simpleName", "Shirt")); @@ -238,7 +236,7 @@ public class MutableRowTupleAdapterTest extends AbstractMutableTupleTest { } @Test - public void testKeyValueTupleSchemaAwareness() throws TupleMarshallerException { + public void testKeyValueTupleSchemaAwareness() { TupleMarshaller marshaller = new TupleMarshallerImpl(schema); Row row = marshaller.marshal(Tuple.create().set("id", 1L).set("simpleName", "Shirt")); @@ -488,46 +486,34 @@ public class MutableRowTupleAdapterTest extends AbstractMutableTupleTest { @Override protected Tuple createTuple(Function<Tuple, Tuple> transformer) { - try { - Tuple tuple = Tuple.create().set("ID", 1L); + Tuple tuple = Tuple.create().set("ID", 1L); - tuple = transformer.apply(tuple); + tuple = transformer.apply(tuple); - TupleMarshaller marshaller = new TupleMarshallerImpl(schema); + TupleMarshaller marshaller = new TupleMarshallerImpl(schema); - return TableRow.tuple(marshaller.marshal(tuple)); - } catch (TupleMarshallerException e) { - return fail(e); - } + return TableRow.tuple(marshaller.marshal(tuple)); } @Override protected Tuple getTuple() { - try { - Tuple tuple = Tuple.create(); + Tuple tuple = Tuple.create(); - tuple = addColumnsForDefaultSchema(tuple); + tuple = addColumnsForDefaultSchema(tuple); - TupleMarshaller marshaller = new TupleMarshallerImpl(schema); + TupleMarshaller marshaller = new TupleMarshallerImpl(schema); - return TableRow.tuple(marshaller.marshal(tuple)); - } catch (TupleMarshallerException e) { - return fail(e); - } + return TableRow.tuple(marshaller.marshal(tuple)); } @Override protected Tuple getTupleWithColumnOfAllTypes() { - try { - Tuple tuple = Tuple.create().set("keyUuidCol", UUID_VALUE); + Tuple tuple = Tuple.create().set("keyUuidCol", UUID_VALUE); - tuple = addColumnOfAllTypes(tuple); + tuple = addColumnOfAllTypes(tuple); - TupleMarshaller marshaller = new TupleMarshallerImpl(fullSchema); + TupleMarshaller marshaller = new TupleMarshallerImpl(fullSchema); - return TableRow.tuple(marshaller.marshal(tuple)); - } catch (TupleMarshallerException e) { - return fail(e); - } + return TableRow.tuple(marshaller.marshal(tuple)); } } diff --git a/modules/table/src/test/java/org/apache/ignite/internal/table/type/NumericTypesSerializerTest.java b/modules/table/src/test/java/org/apache/ignite/internal/table/type/NumericTypesSerializerTest.java index e8071c906c..4bdfd4672a 100644 --- a/modules/table/src/test/java/org/apache/ignite/internal/table/type/NumericTypesSerializerTest.java +++ b/modules/table/src/test/java/org/apache/ignite/internal/table/type/NumericTypesSerializerTest.java @@ -31,11 +31,11 @@ import org.apache.ignite.internal.catalog.commands.CatalogUtils; import org.apache.ignite.internal.schema.Column; import org.apache.ignite.internal.schema.SchemaDescriptor; import org.apache.ignite.internal.schema.marshaller.TupleMarshaller; -import org.apache.ignite.internal.schema.marshaller.TupleMarshallerException; import org.apache.ignite.internal.schema.marshaller.TupleMarshallerImpl; import org.apache.ignite.internal.schema.row.Row; import org.apache.ignite.internal.type.NativeTypes; import org.apache.ignite.internal.util.Pair; +import org.apache.ignite.lang.MarshallerException; import org.apache.ignite.table.Tuple; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -110,7 +110,7 @@ public class NumericTypesSerializerTest { */ @ParameterizedTest @MethodSource("numbers") - public void testNumber(Pair<BigInteger, BigInteger> pair) throws TupleMarshallerException { + public void testNumber(Pair<BigInteger, BigInteger> pair) { schema = new SchemaDescriptor( 42, new Column[]{new Column("KEY", NativeTypes.INT64, false)}, @@ -143,19 +143,19 @@ public class NumericTypesSerializerTest { assertThrowsWithCause( () -> marshaller.marshal(badTup.set("number1", BigInteger.valueOf(999991L))), - TupleMarshallerException.class, + MarshallerException.class, "Column's type mismatch"); assertThrowsWithCause( () -> marshaller.marshal(badTup.set("number1", new BigInteger("111111"))), - TupleMarshallerException.class, + MarshallerException.class, "Column's type mismatch"); assertThrowsWithCause( () -> marshaller.marshal(badTup.set("number1", BigInteger.valueOf(-999991L))), - TupleMarshallerException.class, + MarshallerException.class, "Column's type mismatch"); assertThrowsWithCause( () -> marshaller.marshal(badTup.set("number1", new BigInteger("-111111"))), - TupleMarshallerException.class, + MarshallerException.class, "Column's type mismatch"); } @@ -175,28 +175,28 @@ public class NumericTypesSerializerTest { assertThrowsWithCause( () -> marshaller.marshal(badTup.set("decimalCol", new BigDecimal("123456789.0123"))), - TupleMarshallerException.class, + MarshallerException.class, "Failed to set decimal value for column" ); assertThrowsWithCause( () -> marshaller.marshal(badTup.set("decimalCol", new BigDecimal("-1234567890123"))), - TupleMarshallerException.class, + MarshallerException.class, "Failed to set decimal value for column" ); assertThrowsWithCause( () -> marshaller.marshal(badTup.set("decimalCol", new BigDecimal("1234567"))), - TupleMarshallerException.class, + MarshallerException.class, "Failed to set decimal value for column" ); assertThrowsWithCause( () -> marshaller.marshal(badTup.set("decimalCol", new BigDecimal("12345678.9"))), - TupleMarshallerException.class, + MarshallerException.class, "Failed to set decimal value for column" ); } @Test - public void testStringDecimalSpecialCase() throws TupleMarshallerException { + public void testStringDecimalSpecialCase() { schema = new SchemaDescriptor( 42, new Column[]{new Column("KEY", NativeTypes.INT64, false)}, @@ -220,7 +220,7 @@ public class NumericTypesSerializerTest { */ @ParameterizedTest @MethodSource("stringDecimalRepresentation") - public void testUpscaleForDecimal(String decimalStr) throws TupleMarshallerException { + public void testUpscaleForDecimal(String decimalStr) { schema = new SchemaDescriptor( 42, new Column[]{new Column("KEY", NativeTypes.INT64, false)}, @@ -241,7 +241,7 @@ public class NumericTypesSerializerTest { } @Test - public void testDecimalMaxScale() throws TupleMarshallerException { + public void testDecimalMaxScale() { int maxScale = CatalogUtils.MAX_DECIMAL_SCALE; schema = new SchemaDescriptor( @@ -295,7 +295,7 @@ public class NumericTypesSerializerTest { */ @ParameterizedTest @MethodSource("sameDecimals") - public void testSameBinaryRepresentation(Pair<BigInteger, BigInteger> pair) throws Exception { + public void testSameBinaryRepresentation(Pair<BigInteger, BigInteger> pair) { schema = new SchemaDescriptor( 42, new Column[]{new Column("KEY", NativeTypes.INT64, false)},
