@Test public void testGenericMap() { Map javaMap = new HashMap(); javaMap.put(6, BinaryString.fromString("6")); javaMap.put(5, BinaryString.fromString("5")); javaMap.put(666, BinaryString.fromString("666")); javaMap.put(0, null); GenericMap genericMap = new GenericMap(javaMap); BinaryRow row = new BinaryRow(1); BinaryRowWriter rowWriter = new BinaryRowWriter(row); BaseMapSerializer serializer = new BaseMapSerializer( DataTypes.INT().getLogicalType(), DataTypes.STRING().getLogicalType(), new ExecutionConfig()); rowWriter.writeMap(0, genericMap, serializer); rowWriter.complete(); Map map = row.getMap(0).toJavaMap(DataTypes.INT().getLogicalType(), DataTypes.STRING().getLogicalType()); assertEquals(BinaryString.fromString("6"), map.get(6)); assertEquals(BinaryString.fromString("5"), map.get(5)); assertEquals(BinaryString.fromString("666"), map.get(666)); assertTrue(map.containsKey(0)); assertNull(map.get(0)); }
@Override public BaseMap getMap(int pos) { assertIndexIsValid(pos); return BinaryMap.readBinaryMapFieldFromSegments(segments, offset, getLong(pos)); }
BinaryRow extends BinaryFormat implements BaseRow { @Override public BaseMap getMap(int pos) { assertIndexIsValid(pos); return BinaryMap.readBinaryMapFieldFromSegments(segments, offset, getLong(pos)); } }
BinaryRow extends BinaryFormat implements BaseRow { @Override public BaseMap getMap(int pos) { assertIndexIsValid(pos); return BinaryMap.readBinaryMapFieldFromSegments(segments, offset, getLong(pos)); } BinaryRow(int arity); }
BinaryRow extends BinaryFormat implements BaseRow { @Override public BaseMap getMap(int pos) { assertIndexIsValid(pos); return BinaryMap.readBinaryMapFieldFromSegments(segments, offset, getLong(pos)); } BinaryRow(int arity); static int calculateBitSetWidthInBytes(int arity); static int calculateFixPartSizeInBytes(int arity); static boolean isInFixedLengthPart(LogicalType type); static boolean isMutable(LogicalType type); int getFixedLengthPartSize(); @Override int getArity(); @Override byte getHeader(); @Override void setHeader(byte header); void setTotalSize(int sizeInBytes); @Override boolean isNullAt(int pos); @Override void setNullAt(int i); @Override void setInt(int pos, int value); @Override void setLong(int pos, long value); @Override void setDouble(int pos, double value); @Override void setDecimal(int pos, Decimal value, int precision); @Override void setBoolean(int pos, boolean value); @Override void setShort(int pos, short value); @Override void setByte(int pos, byte value); @Override void setFloat(int pos, float value); @Override boolean getBoolean(int pos); @Override byte getByte(int pos); @Override short getShort(int pos); @Override int getInt(int pos); @Override long getLong(int pos); @Override float getFloat(int pos); @Override double getDouble(int pos); @Override BinaryString getString(int pos); @Override Decimal getDecimal(int pos, int precision, int scale); @Override BinaryGeneric<T> getGeneric(int pos); @Override byte[] getBinary(int pos); @Override BaseArray getArray(int pos); @Override BaseMap getMap(int pos); @Override BaseRow getRow(int pos, int numFields); boolean anyNull(); boolean anyNull(int[] fields); BinaryRow copy(); BinaryRow copy(BinaryRow reuse); void clear(); @Override int hashCode(); String toOriginString(LogicalType... types); static String toOriginString(BaseRow row, LogicalType[] types); boolean equalsWithoutHeader(BaseRow o); }
BinaryRow extends BinaryFormat implements BaseRow { @Override public BaseMap getMap(int pos) { assertIndexIsValid(pos); return BinaryMap.readBinaryMapFieldFromSegments(segments, offset, getLong(pos)); } BinaryRow(int arity); static int calculateBitSetWidthInBytes(int arity); static int calculateFixPartSizeInBytes(int arity); static boolean isInFixedLengthPart(LogicalType type); static boolean isMutable(LogicalType type); int getFixedLengthPartSize(); @Override int getArity(); @Override byte getHeader(); @Override void setHeader(byte header); void setTotalSize(int sizeInBytes); @Override boolean isNullAt(int pos); @Override void setNullAt(int i); @Override void setInt(int pos, int value); @Override void setLong(int pos, long value); @Override void setDouble(int pos, double value); @Override void setDecimal(int pos, Decimal value, int precision); @Override void setBoolean(int pos, boolean value); @Override void setShort(int pos, short value); @Override void setByte(int pos, byte value); @Override void setFloat(int pos, float value); @Override boolean getBoolean(int pos); @Override byte getByte(int pos); @Override short getShort(int pos); @Override int getInt(int pos); @Override long getLong(int pos); @Override float getFloat(int pos); @Override double getDouble(int pos); @Override BinaryString getString(int pos); @Override Decimal getDecimal(int pos, int precision, int scale); @Override BinaryGeneric<T> getGeneric(int pos); @Override byte[] getBinary(int pos); @Override BaseArray getArray(int pos); @Override BaseMap getMap(int pos); @Override BaseRow getRow(int pos, int numFields); boolean anyNull(); boolean anyNull(int[] fields); BinaryRow copy(); BinaryRow copy(BinaryRow reuse); void clear(); @Override int hashCode(); String toOriginString(LogicalType... types); static String toOriginString(BaseRow row, LogicalType[] types); boolean equalsWithoutHeader(BaseRow o); static final boolean LITTLE_ENDIAN; static final int HEADER_SIZE_IN_BITS; }