This is an automated email from the ASF dual-hosted git repository. ibessonov pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/ignite-3.git
The following commit(s) were added to refs/heads/main by this push: new 7bcd7cac1 IGNITE-16848 InternalTuple interface extracted from Row. (#775) 7bcd7cac1 is described below commit 7bcd7cac1b1f407815ad62b46c0f8207a3f01a94 Author: ibessonov <bessonov...@gmail.com> AuthorDate: Tue May 17 17:36:42 2022 +0300 IGNITE-16848 InternalTuple interface extracted from Row. (#775) --- .../testobjects/TestObjectWithAllTypes.java | 2 +- .../ignite/internal/schema/NativeTypeSpec.java | 36 ++-- .../ignite/internal/schema/row/InternalTuple.java | 223 ++++++++++++++++++++ .../org/apache/ignite/internal/schema/row/Row.java | 225 ++++++--------------- 4 files changed, 306 insertions(+), 180 deletions(-) diff --git a/modules/marshaller-common/src/test/java/org/apache/ignite/internal/marshaller/testobjects/TestObjectWithAllTypes.java b/modules/marshaller-common/src/test/java/org/apache/ignite/internal/marshaller/testobjects/TestObjectWithAllTypes.java index 1757c8823..22938a795 100644 --- a/modules/marshaller-common/src/test/java/org/apache/ignite/internal/marshaller/testobjects/TestObjectWithAllTypes.java +++ b/modules/marshaller-common/src/test/java/org/apache/ignite/internal/marshaller/testobjects/TestObjectWithAllTypes.java @@ -58,7 +58,7 @@ public class TestObjectWithAllTypes { obj.uuidCol = new UUID(rnd.nextLong(), rnd.nextLong()); obj.bitmaskCol = IgniteTestUtils.randomBitSet(rnd, 42); - obj.dateCol = LocalDate.ofYearDay(1990 + rnd.nextInt(50), rnd.nextInt(360)); + obj.dateCol = LocalDate.ofYearDay(1990 + rnd.nextInt(50), 1 + rnd.nextInt(360)); obj.timeCol = LocalTime.of(rnd.nextInt(24), rnd.nextInt(60)); obj.dateTimeCol = LocalDateTime.of(obj.dateCol, obj.timeCol); obj.timestampCol = Instant.now().plusSeconds(rnd.nextInt(1000)); diff --git a/modules/schema/src/main/java/org/apache/ignite/internal/schema/NativeTypeSpec.java b/modules/schema/src/main/java/org/apache/ignite/internal/schema/NativeTypeSpec.java index 4c5f7e000..66180043b 100644 --- a/modules/schema/src/main/java/org/apache/ignite/internal/schema/NativeTypeSpec.java +++ b/modules/schema/src/main/java/org/apache/ignite/internal/schema/NativeTypeSpec.java @@ -24,7 +24,7 @@ import java.time.LocalDate; import java.time.LocalDateTime; import java.time.LocalTime; import java.util.BitSet; -import org.apache.ignite.internal.schema.row.Row; +import org.apache.ignite.internal.schema.row.InternalTuple; import org.apache.ignite.internal.tostring.S; /** @@ -42,7 +42,7 @@ public enum NativeTypeSpec { INT8("int8", true) { /** {@inheritDoc} */ @Override - public Object objectValue(Row tup, int colIdx) { + public Object objectValue(InternalTuple tup, int colIdx) { return tup.byteValueBoxed(colIdx); } }, @@ -53,7 +53,7 @@ public enum NativeTypeSpec { INT16("int16", true) { /** {@inheritDoc} */ @Override - public Object objectValue(Row tup, int colIdx) { + public Object objectValue(InternalTuple tup, int colIdx) { return tup.shortValueBoxed(colIdx); } }, @@ -64,7 +64,7 @@ public enum NativeTypeSpec { INT32("int32", true) { /** {@inheritDoc} */ @Override - public Object objectValue(Row tup, int colIdx) { + public Object objectValue(InternalTuple tup, int colIdx) { return tup.intValueBoxed(colIdx); } }, @@ -75,7 +75,7 @@ public enum NativeTypeSpec { INT64("int64", true) { /** {@inheritDoc} */ @Override - public Object objectValue(Row tup, int colIdx) { + public Object objectValue(InternalTuple tup, int colIdx) { return tup.longValueBoxed(colIdx); } }, @@ -86,7 +86,7 @@ public enum NativeTypeSpec { FLOAT("float", true) { /** {@inheritDoc} */ @Override - public Object objectValue(Row tup, int colIdx) { + public Object objectValue(InternalTuple tup, int colIdx) { return tup.floatValueBoxed(colIdx); } }, @@ -97,7 +97,7 @@ public enum NativeTypeSpec { DOUBLE("double", true) { /** {@inheritDoc} */ @Override - public Object objectValue(Row tup, int colIdx) { + public Object objectValue(InternalTuple tup, int colIdx) { return tup.doubleValueBoxed(colIdx); } }, @@ -108,7 +108,7 @@ public enum NativeTypeSpec { DECIMAL("decimal", false) { /** {@inheritDoc} */ @Override - public Object objectValue(Row tup, int colIdx) { + public Object objectValue(InternalTuple tup, int colIdx) { return tup.decimalValue(colIdx); } }, @@ -119,7 +119,7 @@ public enum NativeTypeSpec { UUID("uuid", true) { /** {@inheritDoc} */ @Override - public Object objectValue(Row tup, int colIdx) { + public Object objectValue(InternalTuple tup, int colIdx) { return tup.uuidValue(colIdx); } }, @@ -130,7 +130,7 @@ public enum NativeTypeSpec { STRING("string") { /** {@inheritDoc} */ @Override - public Object objectValue(Row tup, int colIdx) { + public Object objectValue(InternalTuple tup, int colIdx) { return tup.stringValue(colIdx); } }, @@ -141,7 +141,7 @@ public enum NativeTypeSpec { BYTES("blob") { /** {@inheritDoc} */ @Override - public Object objectValue(Row tup, int colIdx) { + public Object objectValue(InternalTuple tup, int colIdx) { return tup.bytesValue(colIdx); } }, @@ -152,7 +152,7 @@ public enum NativeTypeSpec { BITMASK("bitmask", true) { /** {@inheritDoc} */ @Override - public Object objectValue(Row tup, int colIdx) { + public Object objectValue(InternalTuple tup, int colIdx) { return tup.bitmaskValue(colIdx); } }, @@ -163,7 +163,7 @@ public enum NativeTypeSpec { NUMBER("number", false) { /** {@inheritDoc} */ @Override - public Object objectValue(Row tup, int colIdx) { + public Object objectValue(InternalTuple tup, int colIdx) { return tup.numberValue(colIdx); } }, @@ -174,7 +174,7 @@ public enum NativeTypeSpec { DATE("date", true) { /** {@inheritDoc} */ @Override - public Object objectValue(Row tup, int colIdx) { + public Object objectValue(InternalTuple tup, int colIdx) { return tup.dateValue(colIdx); } }, @@ -185,7 +185,7 @@ public enum NativeTypeSpec { TIME("time", true) { /** {@inheritDoc} */ @Override - public Object objectValue(Row tup, int colIdx) { + public Object objectValue(InternalTuple tup, int colIdx) { return tup.timeValue(colIdx); } }, @@ -196,7 +196,7 @@ public enum NativeTypeSpec { DATETIME("datetime", true) { /** {@inheritDoc} */ @Override - public Object objectValue(Row tup, int colIdx) { + public Object objectValue(InternalTuple tup, int colIdx) { return tup.dateTimeValue(colIdx); } }, @@ -207,7 +207,7 @@ public enum NativeTypeSpec { TIMESTAMP("timestamp", true) { /** {@inheritDoc} */ @Override - public Object objectValue(Row tup, int colIdx) { + public Object objectValue(InternalTuple tup, int colIdx) { return tup.timestampValue(colIdx); } }; @@ -254,7 +254,7 @@ public enum NativeTypeSpec { * @return An Object representation of the value. * @throws InvalidTypeException If this native type differs from the actual type of {@code colIdx}. */ - public abstract Object objectValue(Row row, int colIdx) throws InvalidTypeException; + public abstract Object objectValue(InternalTuple row, int colIdx) throws InvalidTypeException; /** * Maps class to native type. diff --git a/modules/schema/src/main/java/org/apache/ignite/internal/schema/row/InternalTuple.java b/modules/schema/src/main/java/org/apache/ignite/internal/schema/row/InternalTuple.java new file mode 100644 index 000000000..67386acf5 --- /dev/null +++ b/modules/schema/src/main/java/org/apache/ignite/internal/schema/row/InternalTuple.java @@ -0,0 +1,223 @@ +/* + * 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.row; + +import java.math.BigDecimal; +import java.math.BigInteger; +import java.time.Instant; +import java.time.LocalDate; +import java.time.LocalDateTime; +import java.time.LocalTime; +import java.util.BitSet; +import java.util.UUID; +import org.apache.ignite.internal.schema.InvalidTypeException; + +/** + * General interface to describe tuples outside of their data layout and column schemas. + * Accessor methods may or may not throw {@link InvalidTypeException} depending on the implementation. + */ +public interface InternalTuple { + /** + * Returns a number of values in the tuple. + */ + int count(); + + /** + * Checks whether the given column contains a null value. + * + * @param col Column index. + * @return {@code true} if this column contains a null value, {@code false} otherwise. + */ + boolean hasNullValue(int col); + + /** + * Reads value for specified column. + * + * @param col Column index. + * @return Column value. + */ + byte byteValue(int col); + + /** + * Reads value for specified column. + * + * @param col Column index. + * @return Column value. + */ + Byte byteValueBoxed(int col); + + /** + * Reads value for specified column. + * + * @param col Column index. + * @return Column value. + */ + short shortValue(int col); + + /** + * Reads value for specified column. + * + * @param col Column index. + * @return Column value. + */ + Short shortValueBoxed(int col); + + /** + * Reads value for specified column. + * + * @param col Column index. + * @return Column value. + */ + int intValue(int col); + + /** + * Reads value for specified column. + * + * @param col Column index. + * @return Column value. + */ + Integer intValueBoxed(int col); + + /** + * Reads value for specified column. + * + * @param col Column index. + * @return Column value. + */ + long longValue(int col); + + /** + * Reads value for specified column. + * + * @param col Column index. + * @return Column value. + */ + Long longValueBoxed(int col); + + /** + * Reads value for specified column. + * + * @param col Column index. + * @return Column value. + */ + float floatValue(int col); + + /** + * Reads value for specified column. + * + * @param col Column index. + * @return Column value. + */ + Float floatValueBoxed(int col); + + /** + * Reads value for specified column. + * + * @param col Column index. + * @return Column value. + */ + double doubleValue(int col); + + /** + * Reads value for specified column. + * + * @param col Column index. + * @return Column value. + */ + Double doubleValueBoxed(int col); + + /** + * Reads value from specified column. + * + * @param col Column index. + * @return Column value. + */ + BigDecimal decimalValue(int col); + + /** + * Reads value from specified column. + * + * @param col Column index. + * @return Column value. + */ + BigInteger numberValue(int col); + + /** + * Reads value for specified column. + * + * @param col Column index. + * @return Column value. + */ + String stringValue(int col); + + /** + * Reads value for specified column. + * + * @param col Column index. + * @return Column value. + */ + byte[] bytesValue(int col); + + /** + * Reads value for specified column. + * + * @param col Column index. + * @return Column value. + */ + UUID uuidValue(int col); + + /** + * Reads value for specified column. + * + * @param col Column index. + * @return Column value. + */ + BitSet bitmaskValue(int col); + + /** + * Reads value for specified column. + * + * @param col Column index. + * @return Column value. + */ + LocalDate dateValue(int col); + + /** + * Reads value for specified column. + * + * @param col Column index. + * @return Column value. + */ + LocalTime timeValue(int col); + + /** + * Reads value for specified column. + * + * @param col Column index. + * @return Column value. + */ + LocalDateTime dateTimeValue(int col); + + /** + * Reads value for specified column. + * + * @param col Column index. + * @return Column value. + */ + Instant timestampValue(int col); +} diff --git a/modules/schema/src/main/java/org/apache/ignite/internal/schema/row/Row.java b/modules/schema/src/main/java/org/apache/ignite/internal/schema/row/Row.java index ad6b54838..02baa69dc 100644 --- a/modules/schema/src/main/java/org/apache/ignite/internal/schema/row/Row.java +++ b/modules/schema/src/main/java/org/apache/ignite/internal/schema/row/Row.java @@ -42,6 +42,7 @@ import org.apache.ignite.internal.schema.TemporalNativeType; import org.apache.ignite.internal.util.ColocationUtils; import org.apache.ignite.internal.util.HashCalculator; import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; /** * Schema-aware row. @@ -55,7 +56,7 @@ import org.jetbrains.annotations.NotNull; * * @see TemporalTypesHelper */ -public class Row implements BinaryRowEx, SchemaAware { +public class Row implements BinaryRowEx, SchemaAware, InternalTuple { /** * Null map offset. * TODO Documentation https://issues.apache.org/jira/browse/IGNITE-15859 @@ -99,14 +100,18 @@ public class Row implements BinaryRowEx, SchemaAware { return schema; } - /** - * Get has value flag: {@code True} if row has non-null value, {@code false} otherwise. - */ + /** {@inheritDoc} */ @Override public boolean hasValue() { return row.hasValue(); } + /** {@inheritDoc} */ + @Override + public int count() { + return schema.length(); + } + /** * Reads value for specified column. * @@ -117,13 +122,8 @@ public class Row implements BinaryRowEx, SchemaAware { return schema.column(col).type().spec().objectValue(this, col); } - /** - * Reads value for specified column. - * - * @param col Column index. - * @return Column value. - * @throws InvalidTypeException If actual column type does not match the requested column type. - */ + /** {@inheritDoc} */ + @Override public byte byteValue(int col) throws InvalidTypeException { boolean isKeyCol = schema.isKeyColumn(col); @@ -132,13 +132,8 @@ public class Row implements BinaryRowEx, SchemaAware { return off < 0 ? 0 : chunk(isKeyCol).get(offset(off)); } - /** - * Reads value for specified column. - * - * @param col Column index. - * @return Column value. - * @throws InvalidTypeException If actual column type does not match the requested column type. - */ + /** {@inheritDoc} */ + @Override public Byte byteValueBoxed(int col) throws InvalidTypeException { boolean isKeyCol = schema.isKeyColumn(col); @@ -147,13 +142,8 @@ public class Row implements BinaryRowEx, SchemaAware { return off < 0 ? null : chunk(isKeyCol).get(offset(off)); } - /** - * Reads value for specified column. - * - * @param col Column index. - * @return Column value. - * @throws InvalidTypeException If actual column type does not match the requested column type. - */ + /** {@inheritDoc} */ + @Override public short shortValue(int col) throws InvalidTypeException { boolean isKeyCol = schema.isKeyColumn(col); @@ -162,13 +152,8 @@ public class Row implements BinaryRowEx, SchemaAware { return off < 0 ? 0 : chunk(isKeyCol).getShort(offset(off)); } - /** - * Reads value for specified column. - * - * @param col Column index. - * @return Column value. - * @throws InvalidTypeException If actual column type does not match the requested column type. - */ + /** {@inheritDoc} */ + @Override public Short shortValueBoxed(int col) throws InvalidTypeException { boolean isKeyCol = schema.isKeyColumn(col); @@ -177,13 +162,8 @@ public class Row implements BinaryRowEx, SchemaAware { return off < 0 ? null : chunk(isKeyCol).getShort(offset(off)); } - /** - * Reads value for specified column. - * - * @param col Column index. - * @return Column value. - * @throws InvalidTypeException If actual column type does not match the requested column type. - */ + /** {@inheritDoc} */ + @Override public int intValue(int col) throws InvalidTypeException { boolean isKeyCol = schema.isKeyColumn(col); @@ -192,13 +172,8 @@ public class Row implements BinaryRowEx, SchemaAware { return off < 0 ? 0 : chunk(isKeyCol).getInt(offset(off)); } - /** - * Reads value for specified column. - * - * @param col Column index. - * @return Column value. - * @throws InvalidTypeException If actual column type does not match the requested column type. - */ + /** {@inheritDoc} */ + @Override public Integer intValueBoxed(int col) throws InvalidTypeException { boolean isKeyCol = schema.isKeyColumn(col); @@ -207,13 +182,8 @@ public class Row implements BinaryRowEx, SchemaAware { return off < 0 ? null : chunk(isKeyCol).getInt(offset(off)); } - /** - * Reads value for specified column. - * - * @param col Column index. - * @return Column value. - * @throws InvalidTypeException If actual column type does not match the requested column type. - */ + /** {@inheritDoc} */ + @Override public long longValue(int col) throws InvalidTypeException { boolean isKeyCol = schema.isKeyColumn(col); @@ -222,13 +192,8 @@ public class Row implements BinaryRowEx, SchemaAware { return off < 0 ? 0 : chunk(isKeyCol).getLong(offset(off)); } - /** - * Reads value for specified column. - * - * @param col Column index. - * @return Column value. - * @throws InvalidTypeException If actual column type does not match the requested column type. - */ + /** {@inheritDoc} */ + @Override public Long longValueBoxed(int col) throws InvalidTypeException { boolean isKeyCol = schema.isKeyColumn(col); @@ -237,13 +202,8 @@ public class Row implements BinaryRowEx, SchemaAware { return off < 0 ? null : chunk(isKeyCol).getLong(offset(off)); } - /** - * Reads value for specified column. - * - * @param col Column index. - * @return Column value. - * @throws InvalidTypeException If actual column type does not match the requested column type. - */ + /** {@inheritDoc} */ + @Override public float floatValue(int col) throws InvalidTypeException { boolean isKeyCol = schema.isKeyColumn(col); @@ -252,13 +212,8 @@ public class Row implements BinaryRowEx, SchemaAware { return off < 0 ? 0.f : chunk(isKeyCol).getFloat(offset(off)); } - /** - * Reads value for specified column. - * - * @param col Column index. - * @return Column value. - * @throws InvalidTypeException If actual column type does not match the requested column type. - */ + /** {@inheritDoc} */ + @Override public Float floatValueBoxed(int col) throws InvalidTypeException { boolean isKeyCol = schema.isKeyColumn(col); @@ -267,13 +222,8 @@ public class Row implements BinaryRowEx, SchemaAware { return off < 0 ? null : chunk(isKeyCol).getFloat(offset(off)); } - /** - * Reads value for specified column. - * - * @param col Column index. - * @return Column value. - * @throws InvalidTypeException If actual column type does not match the requested column type. - */ + /** {@inheritDoc} */ + @Override public double doubleValue(int col) throws InvalidTypeException { boolean isKeyCol = schema.isKeyColumn(col); @@ -282,13 +232,8 @@ public class Row implements BinaryRowEx, SchemaAware { return off < 0 ? 0.d : chunk(isKeyCol).getDouble(offset(off)); } - /** - * Reads value for specified column. - * - * @param col Column index. - * @return Column value. - * @throws InvalidTypeException If actual column type does not match the requested column type. - */ + /** {@inheritDoc} */ + @Override public Double doubleValueBoxed(int col) throws InvalidTypeException { boolean isKeyCol = schema.isKeyColumn(col); @@ -297,13 +242,8 @@ public class Row implements BinaryRowEx, SchemaAware { return off < 0 ? null : chunk(isKeyCol).getDouble(offset(off)); } - /** - * Reads value from specified column. - * - * @param col Column index. - * @return Column value. - * @throws InvalidTypeException If actual column type does not match the requested column type. - */ + /** {@inheritDoc} */ + @Override public BigDecimal decimalValue(int col) throws InvalidTypeException { boolean isKeyCol = schema.isKeyColumn(col); @@ -323,13 +263,8 @@ public class Row implements BinaryRowEx, SchemaAware { return new BigDecimal(new BigInteger(bytes), type.scale()); } - /** - * Reads value from specified column. - * - * @param col Column index. - * @return Column value. - * @throws InvalidTypeException If actual column type does not match the requested column type. - */ + /** {@inheritDoc} */ + @Override public BigInteger numberValue(int col) throws InvalidTypeException { boolean isKeyCol = schema.isKeyColumn(col); @@ -345,13 +280,8 @@ public class Row implements BinaryRowEx, SchemaAware { return new BigInteger(readBytes(chunk(isKeyCol), off, len)); } - /** - * Reads value for specified column. - * - * @param col Column index. - * @return Column value. - * @throws InvalidTypeException If actual column type does not match the requested column type. - */ + /** {@inheritDoc} */ + @Override public String stringValue(int col) throws InvalidTypeException { boolean isKeyCol = schema.isKeyColumn(col); @@ -373,13 +303,8 @@ public class Row implements BinaryRowEx, SchemaAware { } } - /** - * Reads value for specified column. - * - * @param col Column index. - * @return Column value. - * @throws InvalidTypeException If actual column type does not match the requested column type. - */ + /** {@inheritDoc} */ + @Override public byte[] bytesValue(int col) throws InvalidTypeException { boolean isKeyCol = schema.isKeyColumn(col); @@ -395,13 +320,8 @@ public class Row implements BinaryRowEx, SchemaAware { return readBytes(chunk(isKeyCol), off, len); } - /** - * Reads value for specified column. - * - * @param col Column index. - * @return Column value. - * @throws InvalidTypeException If actual column type does not match the requested column type. - */ + /** {@inheritDoc} */ + @Override public UUID uuidValue(int col) throws InvalidTypeException { boolean isKeyCol = schema.isKeyColumn(col); @@ -421,13 +341,8 @@ public class Row implements BinaryRowEx, SchemaAware { return new UUID(msb, lsb); } - /** - * Reads value for specified column. - * - * @param col Column index. - * @return Column value. - * @throws InvalidTypeException If actual column type does not match the requested column type. - */ + /** {@inheritDoc} */ + @Override public BitSet bitmaskValue(int col) throws InvalidTypeException { boolean isKeyCol = schema.isKeyColumn(col); @@ -443,13 +358,8 @@ public class Row implements BinaryRowEx, SchemaAware { return BitSet.valueOf(readBytes(chunk(isKeyCol), off, len)); } - /** - * Reads value for specified column. - * - * @param col Column index. - * @return Column value. - * @throws InvalidTypeException If actual column type does not match the requested column type. - */ + /** {@inheritDoc} */ + @Override public LocalDate dateValue(int col) throws InvalidTypeException { boolean isKeyCol = schema.isKeyColumn(col); @@ -464,13 +374,8 @@ public class Row implements BinaryRowEx, SchemaAware { return readDate(chunk(isKeyCol), off); } - /** - * Reads value for specified column. - * - * @param col Column index. - * @return Column value. - * @throws InvalidTypeException If actual column type does not match the requested column type. - */ + /** {@inheritDoc} */ + @Override public LocalTime timeValue(int col) throws InvalidTypeException { boolean isKeyCol = schema.isKeyColumn(col); @@ -487,13 +392,8 @@ public class Row implements BinaryRowEx, SchemaAware { return readTime(chunk(isKeyCol), off, type); } - /** - * Reads value for specified column. - * - * @param col Column index. - * @return Column value. - * @throws InvalidTypeException If actual column type does not match the requested column type. - */ + /** {@inheritDoc} */ + @Override public LocalDateTime dateTimeValue(int col) throws InvalidTypeException { boolean isKeyCol = schema.isKeyColumn(col); @@ -512,13 +412,8 @@ public class Row implements BinaryRowEx, SchemaAware { return LocalDateTime.of(readDate(chunk, off), readTime(chunk, off + 3, type)); } - /** - * Reads value for specified column. - * - * @param col Column index. - * @return Column value. - * @throws InvalidTypeException If actual column type does not match the requested column type. - */ + /** {@inheritDoc} */ + @Override public Instant timestampValue(int col) throws InvalidTypeException { boolean isKeyCol = schema.isKeyColumn(col); @@ -544,6 +439,12 @@ public class Row implements BinaryRowEx, SchemaAware { return Instant.ofEpochSecond(seconds, nanos); } + /** {@inheritDoc} */ + @Override + public boolean hasNullValue(int col) { + return hasNullValue(col, null); + } + /** * Checks whether the given column contains a null value. * @@ -551,7 +452,7 @@ public class Row implements BinaryRowEx, SchemaAware { * @param expectedType Column type (needed for type checking). * @return {@code true} if this column contains a null value, {@code false} otherwise. */ - public boolean hasNullValue(int col, NativeTypeSpec expectedType) { + public boolean hasNullValue(int col, @Nullable NativeTypeSpec expectedType) { boolean isKeyCol = schema.isKeyColumn(col); return findColumn(col, expectedType, isKeyCol) < 0; @@ -627,7 +528,9 @@ public class Row implements BinaryRowEx, SchemaAware { cols = schema.valueColumns(); } - if (cols.column(colIdx).type().spec() != type) { + NativeTypeSpec actualType = cols.column(colIdx).type().spec(); + + if (type != null && actualType != type) { throw new InvalidTypeException("Invalid column type requested [requested=" + type + ", column=" + cols.column(colIdx) + ']'); } @@ -643,7 +546,7 @@ public class Row implements BinaryRowEx, SchemaAware { dataOffset += format.vartableLength(format.readVartableSize(chunk, dataOffset)); - return type.fixedLength() + return actualType.fixedLength() ? fixedSizeColumnOffset(chunk, dataOffset, cols, colIdx, nullMapLen > 0) : varlenColumnOffsetAndLength(chunk, dataOffset, cols, colIdx, nullMapLen, format); }