1
0
mirror of https://github.com/mariadb-corporation/mariadb-columnstore-engine.git synced 2025-07-27 21:01:50 +03:00

MCOL-4412 Introduce TypeHandler::getEmptyValueForType to return const ptr for an empty value

WE changes for SQL DML and DDL operations

Changes for bulk operations

Changes for scanning operations

Cleanup
This commit is contained in:
Roman Nozdrin
2021-01-15 16:02:10 +00:00
parent 16b52860e8
commit 5fce19df0a
27 changed files with 741 additions and 580 deletions

View File

@ -1750,7 +1750,6 @@ TypeHandlerStr::getNullValueForTypeVarcharText(const SystemCatalog::TypeAttribut
return value; return value;
} }
boost::any boost::any
TypeHandlerBlob::getNullValueForType(const SystemCatalog::TypeAttributesStd &attr) const TypeHandlerBlob::getNullValueForType(const SystemCatalog::TypeAttributesStd &attr) const
{ {
@ -2083,6 +2082,215 @@ TypeHandlerUDecimal128::convertFromString(const SystemCatalog::TypeAttributesStd
} }
/****************************************************************************/
const uint8_t*
getEmptyTypeHandlerSInt8()
{
const static uint8_t TINYINTEMPTYROW = joblist::TINYINTEMPTYROW;
return &TINYINTEMPTYROW;
}
const uint8_t*
TypeHandlerSInt8::getEmptyValueForType(const SystemCatalog::TypeAttributesStd &attr) const
{
return getEmptyTypeHandlerSInt8();
}
const uint8_t*
getEmptyTypeHandlerSInt16()
{
const static uint16_t SMALLINTEMPTYROW = joblist::SMALLINTEMPTYROW;
return reinterpret_cast<const uint8_t*>(&SMALLINTEMPTYROW);
}
const uint8_t*
TypeHandlerSInt16::getEmptyValueForType(const SystemCatalog::TypeAttributesStd &attr) const
{
return getEmptyTypeHandlerSInt16();
}
const uint8_t*
getEmptyTypeHandlerSInt32()
{
const static uint32_t INTEMPTYROW = joblist::INTEMPTYROW;
return reinterpret_cast<const uint8_t*>(&INTEMPTYROW);
}
const uint8_t*
TypeHandlerSInt24::getEmptyValueForType(const SystemCatalog::TypeAttributesStd &attr) const
{
return getEmptyTypeHandlerSInt32();
}
const uint8_t*
TypeHandlerSInt32::getEmptyValueForType(const SystemCatalog::TypeAttributesStd &attr) const
{
return getEmptyTypeHandlerSInt32();
}
const uint8_t*
getEmptyTypeHandlerSInt64()
{
const static uint64_t BIGINTEMPTYROW = joblist::BIGINTEMPTYROW;
return reinterpret_cast<const uint8_t*>(&BIGINTEMPTYROW);
}
const uint8_t*
TypeHandlerSInt64::getEmptyValueForType(const SystemCatalog::TypeAttributesStd &attr) const
{
return getEmptyTypeHandlerSInt64();
}
const uint8_t*
TypeHandlerUInt8::getEmptyValueForType(const SystemCatalog::TypeAttributesStd &attr) const
{
const static uint8_t UTINYINTEMPTYROW = joblist::UTINYINTEMPTYROW;
return reinterpret_cast<const uint8_t*>(&UTINYINTEMPTYROW);
}
const uint8_t*
TypeHandlerUInt16::getEmptyValueForType(const SystemCatalog::TypeAttributesStd &attr) const
{
const static uint16_t USMALLINTEMPTYROW = joblist::USMALLINTEMPTYROW;
return reinterpret_cast<const uint8_t*>(&USMALLINTEMPTYROW);
}
const uint8_t*
getEmptyTypeHandlerUInt32()
{
const static uint32_t UINTEMPTYROW = joblist::UINTEMPTYROW;
return reinterpret_cast<const uint8_t*>(&UINTEMPTYROW);
}
const uint8_t*
TypeHandlerUInt24::getEmptyValueForType(const SystemCatalog::TypeAttributesStd &attr) const
{
return getEmptyTypeHandlerUInt32();
}
const uint8_t*
TypeHandlerUInt32::getEmptyValueForType(const SystemCatalog::TypeAttributesStd &attr) const
{
return getEmptyTypeHandlerUInt32();
}
const uint8_t*
TypeHandlerUInt64::getEmptyValueForType(const SystemCatalog::TypeAttributesStd &attr) const
{
const static uint64_t UBIGINTEMPTYROW = joblist::UBIGINTEMPTYROW;
return reinterpret_cast<const uint8_t*>(&UBIGINTEMPTYROW);
}
const uint8_t*
getEmptyTypeHandlerFloat(const SystemCatalog::TypeAttributesStd &attr)
{
const static uint32_t FLOATEMPTYROW = joblist::FLOATEMPTYROW;
return reinterpret_cast<const uint8_t*>(&FLOATEMPTYROW);
}
const uint8_t*
TypeHandlerUFloat::getEmptyValueForType(const SystemCatalog::TypeAttributesStd &attr) const
{
return getEmptyTypeHandlerFloat(attr);
}
const uint8_t*
TypeHandlerSFloat::getEmptyValueForType(const SystemCatalog::TypeAttributesStd &attr) const
{
return getEmptyTypeHandlerFloat(attr);
}
const uint8_t*
getEmptyTypeHandlerDouble(const SystemCatalog::TypeAttributesStd &attr)
{
const static uint64_t DOUBLEEMPTYROW = joblist::DOUBLEEMPTYROW;
return reinterpret_cast<const uint8_t*>(&DOUBLEEMPTYROW);
}
const uint8_t*
TypeHandlerUDouble::getEmptyValueForType(const SystemCatalog::TypeAttributesStd &attr) const
{
return getEmptyTypeHandlerDouble(attr);
}
const uint8_t*
TypeHandlerSDouble::getEmptyValueForType(const SystemCatalog::TypeAttributesStd &attr) const
{
return getEmptyTypeHandlerDouble(attr);
}
// returns a ptr to an empty magic value for TypeHandlerStr types
// args
// attr - width, precision and scale
// offset - offset value to reduce width for VARCHAR by 1
const uint8_t*
getEmptyTypeHandlerStr(const SystemCatalog::TypeAttributesStd &attr, int8_t offset)
{
const static uint8_t CHAR1EMPTYROW = joblist::CHAR1EMPTYROW;
const static uint16_t CHAR2EMPTYROW = joblist::CHAR2EMPTYROW;
const static uint32_t CHAR4EMPTYROW = joblist::CHAR4EMPTYROW;
const static uint64_t CHAR8EMPTYROW = joblist::CHAR8EMPTYROW;
if (attr.colWidth == (2 + offset))
return reinterpret_cast<const uint8_t*>(&CHAR2EMPTYROW);
else if (attr.colWidth >= (3 + offset) && attr.colWidth <= (4 + offset))
return reinterpret_cast<const uint8_t*>(&CHAR4EMPTYROW);
else if (attr.colWidth >= (5 + offset))
return reinterpret_cast<const uint8_t*>(&CHAR8EMPTYROW);
return reinterpret_cast<const uint8_t*>(&CHAR1EMPTYROW);
}
const uint8_t*
TypeHandlerStr::getEmptyValueForType(const SystemCatalog::TypeAttributesStd &attr) const
{
return getEmptyTypeHandlerStr(attr, 0);
}
const uint8_t*
TypeHandlerVarchar::getEmptyValueForType(const SystemCatalog::TypeAttributesStd &attr) const
{
return getEmptyTypeHandlerStr(attr, -1);
}
inline const uint8_t*
getEmptyValueForDecimal64(const SystemCatalog::TypeAttributesStd &attr)
{
if (attr.colWidth <= 1)
return getEmptyTypeHandlerSInt8();
else if (attr.colWidth <= 2)
return getEmptyTypeHandlerSInt16();
else if (attr.colWidth <= 4)
return getEmptyTypeHandlerSInt32();
else
return getEmptyTypeHandlerSInt64();
}
const uint8_t*
TypeHandlerSDecimal64::getEmptyValueForType(const SystemCatalog::TypeAttributesStd &attr) const
{
return getEmptyValueForDecimal64(attr);
}
const uint8_t*
TypeHandlerUDecimal64::getEmptyValueForType(const SystemCatalog::TypeAttributesStd &attr) const
{
return getEmptyValueForDecimal64(attr);
}
const uint8_t*
TypeHandlerSDecimal128::getEmptyValueForType(const SystemCatalog::TypeAttributesStd &attr) const
{
return reinterpret_cast<const uint8_t*>(&datatypes::Decimal128Empty);
}
const uint8_t*
TypeHandlerUDecimal128::getEmptyValueForType(const SystemCatalog::TypeAttributesStd &attr) const
{
return reinterpret_cast<const uint8_t*>(&datatypes::Decimal128Empty);
}
/****************************************************************************/ /****************************************************************************/
} // end of namespace datatypes } // end of namespace datatypes

View File

@ -941,6 +941,9 @@ public:
const ConvertFromStringParam& prm, const ConvertFromStringParam& prm,
const std::string& str, const std::string& str,
bool& pushWarning) const = 0; bool& pushWarning) const = 0;
virtual const uint8_t* getEmptyValueForType(const SystemCatalog::TypeAttributesStd &attr)
const = 0;
}; };
@ -1003,6 +1006,12 @@ class TypeHandlerBit: public TypeHandler
const ConvertFromStringParam& prm, const ConvertFromStringParam& prm,
const std::string& str, const std::string& str,
bool& pushWarning) const override; bool& pushWarning) const override;
const uint8_t* getEmptyValueForType(const SystemCatalog::TypeAttributesStd &attr) const override
{
idbassert(0);
return nullptr;
}
}; };
@ -1074,6 +1083,7 @@ public:
const ConvertFromStringParam& prm, const ConvertFromStringParam& prm,
const std::string& str, const std::string& str,
bool& pushWarning) const override; bool& pushWarning) const override;
const uint8_t* getEmptyValueForType(const SystemCatalog::TypeAttributesStd &attr) const override;
}; };
@ -1130,6 +1140,7 @@ public:
const ConvertFromStringParam& prm, const ConvertFromStringParam& prm,
const std::string& str, const std::string& str,
bool& pushWarning) const override; bool& pushWarning) const override;
const uint8_t* getEmptyValueForType(const SystemCatalog::TypeAttributesStd &attr) const override;
}; };
@ -1188,6 +1199,7 @@ class TypeHandlerSInt24: public TypeHandlerInt
const ConvertFromStringParam& prm, const ConvertFromStringParam& prm,
const std::string& str, const std::string& str,
bool& pushWarning) const override; bool& pushWarning) const override;
const uint8_t* getEmptyValueForType(const SystemCatalog::TypeAttributesStd &attr) const override;
}; };
@ -1246,6 +1258,7 @@ class TypeHandlerSInt32: public TypeHandlerInt
const ConvertFromStringParam& prm, const ConvertFromStringParam& prm,
const std::string& str, const std::string& str,
bool& pushWarning) const override; bool& pushWarning) const override;
const uint8_t* getEmptyValueForType(const SystemCatalog::TypeAttributesStd &attr) const override;
}; };
@ -1301,6 +1314,7 @@ class TypeHandlerSInt64: public TypeHandlerInt
const ConvertFromStringParam& prm, const ConvertFromStringParam& prm,
const std::string& str, const std::string& str,
bool& pushWarning) const override; bool& pushWarning) const override;
const uint8_t* getEmptyValueForType(const SystemCatalog::TypeAttributesStd &attr) const override;
}; };
@ -1383,6 +1397,7 @@ class TypeHandlerUInt8: public TypeHandlerInt
const ConvertFromStringParam& prm, const ConvertFromStringParam& prm,
const std::string& str, const std::string& str,
bool& pushWarning) const override; bool& pushWarning) const override;
const uint8_t* getEmptyValueForType(const SystemCatalog::TypeAttributesStd &attr) const override;
}; };
@ -1464,6 +1479,7 @@ class TypeHandlerUInt16: public TypeHandlerInt
const ConvertFromStringParam& prm, const ConvertFromStringParam& prm,
const std::string& str, const std::string& str,
bool& pushWarning) const override; bool& pushWarning) const override;
const uint8_t* getEmptyValueForType(const SystemCatalog::TypeAttributesStd &attr) const override;
}; };
@ -1548,6 +1564,7 @@ class TypeHandlerUInt24: public TypeHandlerInt
const ConvertFromStringParam& prm, const ConvertFromStringParam& prm,
const std::string& str, const std::string& str,
bool& pushWarning) const override; bool& pushWarning) const override;
const uint8_t* getEmptyValueForType(const SystemCatalog::TypeAttributesStd &attr) const override;
}; };
@ -1632,6 +1649,7 @@ class TypeHandlerUInt32: public TypeHandlerInt
const ConvertFromStringParam& prm, const ConvertFromStringParam& prm,
const std::string& str, const std::string& str,
bool& pushWarning) const override; bool& pushWarning) const override;
const uint8_t* getEmptyValueForType(const SystemCatalog::TypeAttributesStd &attr) const override;
}; };
@ -1713,6 +1731,7 @@ class TypeHandlerUInt64: public TypeHandlerInt
const ConvertFromStringParam& prm, const ConvertFromStringParam& prm,
const std::string& str, const std::string& str,
bool& pushWarning) const override; bool& pushWarning) const override;
const uint8_t* getEmptyValueForType(const SystemCatalog::TypeAttributesStd &attr) const override;
}; };
@ -1853,6 +1872,7 @@ public:
const ConvertFromStringParam& prm, const ConvertFromStringParam& prm,
const std::string& str, const std::string& str,
bool& pushWarning) const override; bool& pushWarning) const override;
const uint8_t* getEmptyValueForType(const SystemCatalog::TypeAttributesStd &attr) const override;
}; };
@ -1933,6 +1953,7 @@ public:
const ConvertFromStringParam& prm, const ConvertFromStringParam& prm,
const std::string& str, const std::string& str,
bool& pushWarning) const override; bool& pushWarning) const override;
const uint8_t* getEmptyValueForType(const SystemCatalog::TypeAttributesStd &attr) const override;
}; };
@ -2015,6 +2036,7 @@ public:
const ConvertFromStringParam& prm, const ConvertFromStringParam& prm,
const std::string& str, const std::string& str,
bool& pushWarning) const override; bool& pushWarning) const override;
const uint8_t* getEmptyValueForType(const SystemCatalog::TypeAttributesStd &attr) const override;
}; };
@ -2093,6 +2115,7 @@ public:
const ConvertFromStringParam& prm, const ConvertFromStringParam& prm,
const std::string& str, const std::string& str,
bool& pushWarning) const override; bool& pushWarning) const override;
const uint8_t* getEmptyValueForType(const SystemCatalog::TypeAttributesStd &attr) const override;
}; };
@ -2152,6 +2175,7 @@ class TypeHandlerSFloat: public TypeHandlerReal
const ConvertFromStringParam& prm, const ConvertFromStringParam& prm,
const std::string& str, const std::string& str,
bool& pushWarning) const override; bool& pushWarning) const override;
const uint8_t* getEmptyValueForType(const SystemCatalog::TypeAttributesStd &attr) const override;
}; };
@ -2186,6 +2210,7 @@ class TypeHandlerSDouble: public TypeHandlerReal
const ConvertFromStringParam& prm, const ConvertFromStringParam& prm,
const std::string& str, const std::string& str,
bool& pushWarning) const override; bool& pushWarning) const override;
const uint8_t* getEmptyValueForType(const SystemCatalog::TypeAttributesStd &attr) const override;
}; };
@ -2220,6 +2245,7 @@ class TypeHandlerUFloat: public TypeHandlerReal
const ConvertFromStringParam& prm, const ConvertFromStringParam& prm,
const std::string& str, const std::string& str,
bool& pushWarning) const override; bool& pushWarning) const override;
const uint8_t* getEmptyValueForType(const SystemCatalog::TypeAttributesStd &attr) const override;
}; };
@ -2254,6 +2280,7 @@ class TypeHandlerUDouble: public TypeHandlerReal
const ConvertFromStringParam& prm, const ConvertFromStringParam& prm,
const std::string& str, const std::string& str,
bool& pushWarning) const override; bool& pushWarning) const override;
const uint8_t* getEmptyValueForType(const SystemCatalog::TypeAttributesStd &attr) const override;
}; };
@ -2294,6 +2321,276 @@ class TypeHandlerSLongDouble: public TypeHandlerReal
throw logging::QueryDataExcept("convertColumnData: unknown column data type.", logging::dataTypeErr); throw logging::QueryDataExcept("convertColumnData: unknown column data type.", logging::dataTypeErr);
return boost::any(); return boost::any();
} }
const uint8_t* getEmptyValueForType(const SystemCatalog::TypeAttributesStd &attr) const override
{
idbassert(0);
return nullptr;
}
};
const uint8_t* getEmptyTypeHandlerStr(const SystemCatalog::TypeAttributesStd &attr, int8_t offset);
class TypeHandlerStr: public TypeHandler
{
protected:
std::string formatPartitionInfoSmallCharVarchar(
const SystemCatalog::TypeAttributesStd &attr,
const MinMaxInfo &i)
const;
boost::any getNullValueForTypeVarcharText(const SystemCatalog::TypeAttributesStd &attr)
const;
public:
int storeValueToFieldCharVarchar(rowgroup::Row &row, int pos,
StoreField *f) const;
int storeValueToFieldBlobText(rowgroup::Row &row, int pos,
StoreField *f) const;
std::string formatPartitionInfo(const SystemCatalog::TypeAttributesStd &attr,
const MinMaxInfo &i)
const override
{
// QQ: Check with Roman if this correct:
return formatPartitionInfoSInt64(attr, i);
}
execplan::SimpleColumn *newSimpleColumn(const DatabaseQualifiedColumnName &name,
SystemCatalog::TypeHolderStd &ct,
const SimpleColumnParam &prm)
const override;
SimpleValue toSimpleValue(const SessionParam &sp,
const SystemCatalog::TypeAttributesStd &attr,
const char *str, round_style_t & rf) const override;
const uint8_t* getEmptyValueForType(const SystemCatalog::TypeAttributesStd &attr) const override;
};
class TypeHandlerChar: public TypeHandlerStr
{
const string &name() const override;
code_t code() const override
{
return SystemCatalog::CHAR;
}
const string print(const SystemCatalog::TypeAttributesStd &attr) const override
{
ostringstream oss;
oss << name () << "(" << attr.colWidth << ")";
return oss.str();
}
bool CP_type(const SystemCatalog::TypeAttributesStd &attr) const override
{
return attr.colWidth <= 8;
}
size_t ColWriteBatch(WriteBatchField *field,
const unsigned char *buf,
bool nullVal,
ColBatchWriter & writer) const override
{
return field->ColWriteBatchChar(buf, nullVal, writer);
}
int storeValueToField(rowgroup::Row &row, int pos,
StoreField *f) const override
{
return storeValueToFieldCharVarchar(row, pos, f);
}
std::string format(const SimpleValue &v,
const SystemCatalog::TypeAttributesStd &attr) const override;
std::string formatPartitionInfo(const SystemCatalog::TypeAttributesStd &attr,
const MinMaxInfo &i)
const override;
MinMaxPartitionInfo getExtentPartitionInfo(const SystemCatalog::TypeAttributesStd &attr,
BRM::DBRM &em,
const BRM::EMEntry &entry,
int *state) const override;
boost::any getNullValueForType(const SystemCatalog::TypeAttributesStd &attr)
const override;
boost::any convertFromString(const SystemCatalog::TypeAttributesStd& colType,
const ConvertFromStringParam& prm,
const std::string& str,
bool& pushWarning) const override;
};
class TypeHandlerVarchar: public TypeHandlerStr
{
const string &name() const override;
code_t code() const override
{
return SystemCatalog::VARCHAR;
}
const string print(const SystemCatalog::TypeAttributesStd &attr) const override
{
ostringstream oss;
oss << name () << "(" << attr.colWidth << ")";
return oss.str();
}
bool CP_type(const SystemCatalog::TypeAttributesStd &attr) const override
{
return attr.colWidth <= 7;
}
size_t ColWriteBatch(WriteBatchField *field,
const unsigned char *buf,
bool nullVal,
ColBatchWriter & writer) const override
{
return field->ColWriteBatchVarchar(buf, nullVal, writer);
}
int storeValueToField(rowgroup::Row &row, int pos,
StoreField *f) const override
{
return storeValueToFieldCharVarchar(row, pos, f);
}
std::string format(const SimpleValue &v,
const SystemCatalog::TypeAttributesStd &attr) const override;
std::string formatPartitionInfo(const SystemCatalog::TypeAttributesStd &attr,
const MinMaxInfo &i)
const override;
MinMaxPartitionInfo getExtentPartitionInfo(const SystemCatalog::TypeAttributesStd &attr,
BRM::DBRM &em,
const BRM::EMEntry &entry,
int *state) const override;
boost::any getNullValueForType(const SystemCatalog::TypeAttributesStd &attr)
const override
{
return getNullValueForTypeVarcharText(attr);
}
boost::any convertFromString(const SystemCatalog::TypeAttributesStd& colType,
const ConvertFromStringParam& prm,
const std::string& str,
bool& pushWarning) const override;
const uint8_t* getEmptyValueForType(const SystemCatalog::TypeAttributesStd &attr) const override;
};
class TypeHandlerVarbinary: public TypeHandlerStr
{
const string &name() const override;
code_t code() const override
{
return SystemCatalog::VARBINARY;
}
size_t ColWriteBatch(WriteBatchField *field,
const unsigned char *buf,
bool nullVal,
ColBatchWriter & writer) const override
{
return field->ColWriteBatchVarbinary(buf, nullVal, writer);
}
int storeValueToField(rowgroup::Row &row, int pos,
StoreField *f) const override;
std::string format(const SimpleValue &v,
const SystemCatalog::TypeAttributesStd &attr) const override;
boost::any getNullValueForType(const SystemCatalog::TypeAttributesStd &attr)
const override;
boost::any convertFromString(const SystemCatalog::TypeAttributesStd& colType,
const ConvertFromStringParam& prm,
const std::string& str,
bool& pushWarning) const override;
};
class TypeHandlerBlob: public TypeHandlerStr
{
const string &name() const override;
code_t code() const override
{
return SystemCatalog::BLOB;
}
size_t ColWriteBatch(WriteBatchField *field,
const unsigned char *buf,
bool nullVal,
ColBatchWriter & writer) const override
{
return field->ColWriteBatchBlob(buf, nullVal, writer);
}
int storeValueToField(rowgroup::Row &row, int pos,
StoreField *f) const override
{
return storeValueToFieldBlobText(row, pos, f);
}
std::string format(const SimpleValue &v,
const SystemCatalog::TypeAttributesStd &attr) const override
{
return "0"; // QQ
}
boost::any getNullValueForType(const SystemCatalog::TypeAttributesStd &attr)
const override;
boost::any convertFromString(const SystemCatalog::TypeAttributesStd& colType,
const ConvertFromStringParam& prm,
const std::string& str,
bool& pushWarning) const override;
};
class TypeHandlerText: public TypeHandlerStr
{
const string &name() const override;
code_t code() const override
{
return SystemCatalog::TEXT;
}
size_t ColWriteBatch(WriteBatchField *field,
const unsigned char *buf,
bool nullVal,
ColBatchWriter & writer) const override
{
return field->ColWriteBatchBlob(buf, nullVal, writer);
}
int storeValueToField(rowgroup::Row &row, int pos,
StoreField *f) const override
{
return storeValueToFieldBlobText(row, pos, f);
}
std::string format(const SimpleValue &v,
const SystemCatalog::TypeAttributesStd &attr) const override
{
return "0"; // QQ
}
boost::any getNullValueForType(const SystemCatalog::TypeAttributesStd &attr)
const override
{
return getNullValueForTypeVarcharText(attr);
}
boost::any convertFromString(const SystemCatalog::TypeAttributesStd& colType,
const ConvertFromStringParam& prm,
const std::string& str,
bool& pushWarning) const override;
};
class TypeHandlerClob: public TypeHandlerStr
{
const string &name() const override;
code_t code() const override
{
return SystemCatalog::CLOB;
}
size_t ColWriteBatch(WriteBatchField *field,
const unsigned char *buf,
bool nullVal,
ColBatchWriter & writer) const override
{
idbassert(0); // QQ
return 0;
}
int storeValueToField(rowgroup::Row &row, int pos,
StoreField *f) const override
{
idbassert(0); // QQ
return 1;
}
std::string format(const SimpleValue &v,
const SystemCatalog::TypeAttributesStd &attr) const override
{
return "0"; // QQ
}
boost::any getNullValueForType(const SystemCatalog::TypeAttributesStd &attr)
const override
{
return boost::any(); // QQ
}
boost::any convertFromString(const SystemCatalog::TypeAttributesStd& colType,
const ConvertFromStringParam& prm,
const std::string& str,
bool& pushWarning) const override;
}; };
@ -2310,6 +2607,10 @@ public:
SystemCatalog::TypeHolderStd &ct, SystemCatalog::TypeHolderStd &ct,
const SimpleColumnParam &prm) const SimpleColumnParam &prm)
const override; const override;
const uint8_t* getEmptyValueForType(const SystemCatalog::TypeAttributesStd &attr) const override
{
return getEmptyTypeHandlerStr(attr, 0);
}
}; };
@ -2448,269 +2749,6 @@ class TypeHandlerTimestamp: public TypeHandlerTemporal
bool& pushWarning) const override; bool& pushWarning) const override;
}; };
class TypeHandlerStr: public TypeHandler
{
protected:
std::string formatPartitionInfoSmallCharVarchar(
const SystemCatalog::TypeAttributesStd &attr,
const MinMaxInfo &i)
const;
boost::any getNullValueForTypeVarcharText(const SystemCatalog::TypeAttributesStd &attr)
const;
public:
int storeValueToFieldCharVarchar(rowgroup::Row &row, int pos,
StoreField *f) const;
int storeValueToFieldBlobText(rowgroup::Row &row, int pos,
StoreField *f) const;
std::string formatPartitionInfo(const SystemCatalog::TypeAttributesStd &attr,
const MinMaxInfo &i)
const override
{
// QQ: Check with Roman if this correct:
return formatPartitionInfoSInt64(attr, i);
}
execplan::SimpleColumn *newSimpleColumn(const DatabaseQualifiedColumnName &name,
SystemCatalog::TypeHolderStd &ct,
const SimpleColumnParam &prm)
const override;
SimpleValue toSimpleValue(const SessionParam &sp,
const SystemCatalog::TypeAttributesStd &attr,
const char *str, round_style_t & rf) const override;
};
class TypeHandlerChar: public TypeHandlerStr
{
const string &name() const override;
code_t code() const override
{
return SystemCatalog::CHAR;
}
const string print(const SystemCatalog::TypeAttributesStd &attr) const override
{
ostringstream oss;
oss << name () << "(" << attr.colWidth << ")";
return oss.str();
}
bool CP_type(const SystemCatalog::TypeAttributesStd &attr) const override
{
return attr.colWidth <= 8;
}
size_t ColWriteBatch(WriteBatchField *field,
const unsigned char *buf,
bool nullVal,
ColBatchWriter & writer) const override
{
return field->ColWriteBatchChar(buf, nullVal, writer);
}
int storeValueToField(rowgroup::Row &row, int pos,
StoreField *f) const override
{
return storeValueToFieldCharVarchar(row, pos, f);
}
std::string format(const SimpleValue &v,
const SystemCatalog::TypeAttributesStd &attr) const override;
std::string formatPartitionInfo(const SystemCatalog::TypeAttributesStd &attr,
const MinMaxInfo &i)
const override;
MinMaxPartitionInfo getExtentPartitionInfo(const SystemCatalog::TypeAttributesStd &attr,
BRM::DBRM &em,
const BRM::EMEntry &entry,
int *state) const override;
boost::any getNullValueForType(const SystemCatalog::TypeAttributesStd &attr)
const override;
boost::any convertFromString(const SystemCatalog::TypeAttributesStd& colType,
const ConvertFromStringParam& prm,
const std::string& str,
bool& pushWarning) const override;
};
class TypeHandlerVarchar: public TypeHandlerStr
{
const string &name() const override;
code_t code() const override
{
return SystemCatalog::VARCHAR;
}
const string print(const SystemCatalog::TypeAttributesStd &attr) const override
{
ostringstream oss;
oss << name () << "(" << attr.colWidth << ")";
return oss.str();
}
bool CP_type(const SystemCatalog::TypeAttributesStd &attr) const override
{
return attr.colWidth <= 7;
}
size_t ColWriteBatch(WriteBatchField *field,
const unsigned char *buf,
bool nullVal,
ColBatchWriter & writer) const override
{
return field->ColWriteBatchVarchar(buf, nullVal, writer);
}
int storeValueToField(rowgroup::Row &row, int pos,
StoreField *f) const override
{
return storeValueToFieldCharVarchar(row, pos, f);
}
std::string format(const SimpleValue &v,
const SystemCatalog::TypeAttributesStd &attr) const override;
std::string formatPartitionInfo(const SystemCatalog::TypeAttributesStd &attr,
const MinMaxInfo &i)
const override;
MinMaxPartitionInfo getExtentPartitionInfo(const SystemCatalog::TypeAttributesStd &attr,
BRM::DBRM &em,
const BRM::EMEntry &entry,
int *state) const override;
boost::any getNullValueForType(const SystemCatalog::TypeAttributesStd &attr)
const override
{
return getNullValueForTypeVarcharText(attr);
}
boost::any convertFromString(const SystemCatalog::TypeAttributesStd& colType,
const ConvertFromStringParam& prm,
const std::string& str,
bool& pushWarning) const override;
};
class TypeHandlerVarbinary: public TypeHandlerStr
{
const string &name() const override;
code_t code() const override
{
return SystemCatalog::VARBINARY;
}
size_t ColWriteBatch(WriteBatchField *field,
const unsigned char *buf,
bool nullVal,
ColBatchWriter & writer) const override
{
return field->ColWriteBatchVarbinary(buf, nullVal, writer);
}
int storeValueToField(rowgroup::Row &row, int pos,
StoreField *f) const override;
std::string format(const SimpleValue &v,
const SystemCatalog::TypeAttributesStd &attr) const override;
boost::any getNullValueForType(const SystemCatalog::TypeAttributesStd &attr)
const override;
boost::any convertFromString(const SystemCatalog::TypeAttributesStd& colType,
const ConvertFromStringParam& prm,
const std::string& str,
bool& pushWarning) const override;
};
class TypeHandlerBlob: public TypeHandlerStr
{
const string &name() const override;
code_t code() const override
{
return SystemCatalog::BLOB;
}
size_t ColWriteBatch(WriteBatchField *field,
const unsigned char *buf,
bool nullVal,
ColBatchWriter & writer) const override
{
return field->ColWriteBatchBlob(buf, nullVal, writer);
}
int storeValueToField(rowgroup::Row &row, int pos,
StoreField *f) const override
{
return storeValueToFieldBlobText(row, pos, f);
}
std::string format(const SimpleValue &v,
const SystemCatalog::TypeAttributesStd &attr) const override
{
return "0"; // QQ
}
boost::any getNullValueForType(const SystemCatalog::TypeAttributesStd &attr)
const override;
boost::any convertFromString(const SystemCatalog::TypeAttributesStd& colType,
const ConvertFromStringParam& prm,
const std::string& str,
bool& pushWarning) const override;
};
class TypeHandlerText: public TypeHandlerStr
{
const string &name() const override;
code_t code() const override
{
return SystemCatalog::TEXT;
}
size_t ColWriteBatch(WriteBatchField *field,
const unsigned char *buf,
bool nullVal,
ColBatchWriter & writer) const override
{
return field->ColWriteBatchBlob(buf, nullVal, writer);
}
int storeValueToField(rowgroup::Row &row, int pos,
StoreField *f) const override
{
return storeValueToFieldBlobText(row, pos, f);
}
std::string format(const SimpleValue &v,
const SystemCatalog::TypeAttributesStd &attr) const override
{
return "0"; // QQ
}
boost::any getNullValueForType(const SystemCatalog::TypeAttributesStd &attr)
const override
{
return getNullValueForTypeVarcharText(attr);
}
boost::any convertFromString(const SystemCatalog::TypeAttributesStd& colType,
const ConvertFromStringParam& prm,
const std::string& str,
bool& pushWarning) const override;
};
class TypeHandlerClob: public TypeHandlerStr
{
const string &name() const override;
code_t code() const override
{
return SystemCatalog::CLOB;
}
size_t ColWriteBatch(WriteBatchField *field,
const unsigned char *buf,
bool nullVal,
ColBatchWriter & writer) const override
{
idbassert(0); // QQ
return 0;
}
int storeValueToField(rowgroup::Row &row, int pos,
StoreField *f) const override
{
idbassert(0); // QQ
return 1;
}
std::string format(const SimpleValue &v,
const SystemCatalog::TypeAttributesStd &attr) const override
{
return "0"; // QQ
}
boost::any getNullValueForType(const SystemCatalog::TypeAttributesStd &attr)
const override
{
return boost::any(); // QQ
}
boost::any convertFromString(const SystemCatalog::TypeAttributesStd& colType,
const ConvertFromStringParam& prm,
const std::string& str,
bool& pushWarning) const override;
};
}// end of namespace datatypes }// end of namespace datatypes
#endif //MCS_DATATYPE_H_INCLUDED #endif //MCS_DATATYPE_H_INCLUDED

View File

@ -48,8 +48,6 @@ using namespace rowgroup;
#include "messageids.h" #include "messageids.h"
using namespace logging; using namespace logging;
#include "emptyvaluemanip.h"
#ifdef _MSC_VER #ifdef _MSC_VER
#define llabs labs #define llabs labs
#endif #endif
@ -177,65 +175,36 @@ void ColumnCommand::loadData()
else if (lastBlockReached && _isScan) else if (lastBlockReached && _isScan)
{ {
// fill remaining blocks with empty values when col scan // fill remaining blocks with empty values when col scan
int blockLen = BLOCK_SIZE / colType.colWidth; uint32_t blockLen = BLOCK_SIZE / colType.colWidth;
ByteStream::hexbyte* hPtr = NULL; auto attrs = datatypes::SystemCatalog::TypeAttributesStd(colType.colWidth,
ByteStream::octbyte* oPtr = NULL; 0,
ByteStream::quadbyte* qPtr = NULL; -1);
ByteStream::byte* bPtr = NULL; const auto* typeHandler = datatypes::TypeHandler::find(colType.colDataType,
ByteStream::doublebyte* dPtr = NULL; attrs);
const uint8_t* emptyValue = typeHandler->getEmptyValueForType(attrs);
uint8_t* blockDataPtr = &bpp->blockData[i * BLOCK_SIZE];
if (colType.colWidth == 1) idbassert(blockDataPtr);
bPtr = reinterpret_cast<ByteStream::byte*>(&bpp->blockData[i * BLOCK_SIZE]); if (colType.colWidth == sizeof(ByteStream::byte))
//@Bug 1812. Added two bytes column handling
if (colType.colWidth == 2)
dPtr = reinterpret_cast<ByteStream::doublebyte*>(&bpp->blockData[i * BLOCK_SIZE]);
if (colType.colWidth == 4)
qPtr = reinterpret_cast<ByteStream::quadbyte*>(&bpp->blockData[i * BLOCK_SIZE]);
if (colType.colWidth == 8)
oPtr = reinterpret_cast<ByteStream::octbyte*>(&bpp->blockData[i * BLOCK_SIZE]);
if (colType.colWidth == 16)
hPtr = reinterpret_cast<ByteStream::hexbyte*>(&bpp->blockData[i * BLOCK_SIZE]);
for (int idx = 0; idx < blockLen; idx++)
{ {
if (bPtr && colType.colWidth == 1) fillEmptyBlock<ByteStream::byte>(blockDataPtr, emptyValue, blockLen);
{ }
ByteStream::byte b; if (colType.colWidth == sizeof(ByteStream::doublebyte))
utils::getEmptyRowValue(colType.colDataType, colType.colWidth, (uint8_t*)&b); {
bPtr[idx] = b; fillEmptyBlock<ByteStream::doublebyte>(blockDataPtr, emptyValue, blockLen);
} }
//@Bug 1812. Added two bytes column handling if (colType.colWidth == sizeof(ByteStream::quadbyte))
else if (dPtr && colType.colWidth == 2) {
{ fillEmptyBlock<ByteStream::quadbyte>(blockDataPtr, emptyValue, blockLen);
ByteStream::doublebyte d; }
utils::getEmptyRowValue(colType.colDataType, colType.colWidth, (uint8_t*)&d); if (colType.colWidth == sizeof(ByteStream::octbyte))
dPtr[idx] = d; {
} fillEmptyBlock<ByteStream::octbyte>(blockDataPtr, emptyValue, blockLen);
else if (qPtr && colType.colWidth == 4) }
{ if (colType.colWidth == sizeof(ByteStream::hexbyte))
ByteStream::quadbyte q; {
utils::getEmptyRowValue(colType.colDataType, colType.colWidth, (uint8_t*)&q); fillEmptyBlock<ByteStream::hexbyte>(blockDataPtr, emptyValue, blockLen);
qPtr[idx] = q;
}
else if (oPtr && colType.colWidth == 8)
{
ByteStream::octbyte o;
utils::getEmptyRowValue(colType.colDataType, colType.colWidth, (uint8_t*)&o);
oPtr[idx] = o;
}
else if (colType.colWidth == 16)
{
ByteStream::hexbyte h;
utils::getEmptyRowValue(colType.colDataType, colType.colWidth, (uint8_t*)&h);
datatypes::TSInt128::storeUnaligned(hPtr + idx, h);
}
} }
}// else }// else
if ( (primMsg->LBID + i) == oidLastLbid) if ( (primMsg->LBID + i) == oidLastLbid)

View File

@ -129,6 +129,10 @@ private:
void makeScanMsg(); void makeScanMsg();
void makeStepMsg(); void makeStepMsg();
void setLBID(uint64_t rid); void setLBID(uint64_t rid);
template<typename T>
inline void fillEmptyBlock(uint8_t* dst,
const uint8_t*emptyValue,
const uint32_t number) const;
bool _isScan; bool _isScan;
@ -171,6 +175,35 @@ private:
friend class RTSCommand; friend class RTSCommand;
}; };
template<typename T>
inline void ColumnCommand::fillEmptyBlock(uint8_t* dst,
const uint8_t*emptyValue,
const uint32_t number) const
{
T* typedDst = reinterpret_cast<T*>(dst);
const T* typedEmptyValue = reinterpret_cast<const T*>(emptyValue);
for (uint32_t idx = 0; idx < number; idx = idx + 4)
{
typedDst[idx] = *typedEmptyValue;
typedDst[idx+1] = *typedEmptyValue;
typedDst[idx+2] = *typedEmptyValue;
typedDst[idx+3] = *typedEmptyValue;
}
}
template<>
inline void ColumnCommand::fillEmptyBlock<messageqcpp::ByteStream::hexbyte>(uint8_t* dst,
const uint8_t*emptyValue,
const uint32_t number) const
{
for (uint32_t idx = 0; idx < number; idx++)
{
datatypes::TSInt128::assignPtrPtr(dst + idx * sizeof(messageqcpp::ByteStream::hexbyte),
emptyValue);
}
}
} }
#endif #endif

View File

@ -10,8 +10,7 @@ set(common_LIB_SRCS
MonitorProcMem.cpp MonitorProcMem.cpp
nullvaluemanip.cpp nullvaluemanip.cpp
threadnaming.cpp threadnaming.cpp
utils_utf8.cpp utils_utf8.cpp)
emptyvaluemanip.cpp)
add_library(common SHARED ${common_LIB_SRCS}) add_library(common SHARED ${common_LIB_SRCS})

View File

@ -1,110 +0,0 @@
/* Copyright (C) 2020 MariaDB Corporation
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; version 2 of
the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
MA 02110-1301, USA. */
#include "emptyvaluemanip.h"
namespace utils
{
void getEmptyRowValue(const execplan::CalpontSystemCatalog::ColDataType colDataType,
const int width, uint8_t* emptyVal)
{
switch (colDataType)
{
case execplan::CalpontSystemCatalog::TINYINT:
*(uint8_t*)emptyVal = joblist::TINYINTEMPTYROW;
break;
case execplan::CalpontSystemCatalog::SMALLINT:
*(uint16_t*)emptyVal = joblist::SMALLINTEMPTYROW;
break;
case execplan::CalpontSystemCatalog::MEDINT:
case execplan::CalpontSystemCatalog::INT:
*(uint32_t*)emptyVal = joblist::INTEMPTYROW;
break;
case execplan::CalpontSystemCatalog::BIGINT:
*(uint64_t*)emptyVal = joblist::BIGINTEMPTYROW;
break;
case execplan::CalpontSystemCatalog::UTINYINT:
*(uint8_t*)emptyVal = joblist::UTINYINTEMPTYROW;
break;
case execplan::CalpontSystemCatalog::USMALLINT:
*(uint16_t*)emptyVal = joblist::USMALLINTEMPTYROW;
break;
case execplan::CalpontSystemCatalog::UMEDINT:
case execplan::CalpontSystemCatalog::UINT:
*(uint32_t*)emptyVal = joblist::UINTEMPTYROW;
break;
case execplan::CalpontSystemCatalog::UBIGINT:
*(uint64_t*)emptyVal = joblist::UBIGINTEMPTYROW;
break;
case execplan::CalpontSystemCatalog::FLOAT:
case execplan::CalpontSystemCatalog::UFLOAT:
*(uint32_t*)emptyVal = joblist::FLOATEMPTYROW;
break;
case execplan::CalpontSystemCatalog::DOUBLE:
case execplan::CalpontSystemCatalog::UDOUBLE:
*(uint64_t*)emptyVal = joblist::DOUBLEEMPTYROW;
break;
case execplan::CalpontSystemCatalog::DECIMAL:
case execplan::CalpontSystemCatalog::UDECIMAL:
if (width <= 1)
*(uint8_t*)emptyVal = joblist::TINYINTEMPTYROW;
else if (width <= 2)
*(uint16_t*)emptyVal = joblist::SMALLINTEMPTYROW;
else if (width <= 4)
*(uint32_t*)emptyVal = joblist::INTEMPTYROW;
else if (width <= 8)
*(uint64_t*)emptyVal = joblist::BIGINTEMPTYROW;
else
datatypes::Decimal::setWideDecimalEmptyValue(*(reinterpret_cast<int128_t*>(emptyVal)));
break;
case execplan::CalpontSystemCatalog::CHAR:
case execplan::CalpontSystemCatalog::VARCHAR:
case execplan::CalpontSystemCatalog::DATE:
case execplan::CalpontSystemCatalog::DATETIME:
case execplan::CalpontSystemCatalog::TIMESTAMP:
case execplan::CalpontSystemCatalog::TIME:
case execplan::CalpontSystemCatalog::VARBINARY:
case execplan::CalpontSystemCatalog::BLOB:
case execplan::CalpontSystemCatalog::TEXT:
default:
*(uint8_t*)emptyVal = joblist::CHAR1EMPTYROW;
int offset = (colDataType == execplan::CalpontSystemCatalog::VARCHAR) ? -1 : 0;
if (width == (2 + offset))
*(uint16_t*)emptyVal = joblist::CHAR2EMPTYROW;
else if (width >= (3 + offset) && width <= (4 + offset))
*(uint32_t*)emptyVal = joblist::CHAR4EMPTYROW;
else if (width >= (5 + offset))
*(uint64_t*)emptyVal = joblist::CHAR8EMPTYROW;
break;
}
}
} // namespace utils

View File

@ -1,31 +0,0 @@
/* Copyright (C) 2020 MariaDB Corporation
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; version 2 of
the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
MA 02110-1301, USA. */
#ifndef EMPTY_VALUE_MANIP_H
#define EMPTY_VALUE_MANIP_H
#include "calpontsystemcatalog.h"
namespace utils
{
void getEmptyRowValue(const execplan::CalpontSystemCatalog::ColDataType colDataType,
const int width, uint8_t* emptyVal);
} // namespace utils
#endif // EMPTY_VALUE_MANIP_H

View File

@ -563,10 +563,9 @@ int BulkLoad::preProcess( Job& job, int tableNo,
job.jobTableList[tableNo].colList[i].weType = curColStruct.colType; job.jobTableList[tableNo].colList[i].weType = curColStruct.colType;
// set width to correct column width // set width to correct column width
job.jobTableList[tableNo].colList[i].width = curColStruct.colWidth; job.jobTableList[tableNo].colList[i].width = curColStruct.colWidth;
getEmptyRowValue( job.jobTableList[tableNo].colList[i].emptyVal =
job.jobTableList[tableNo].colList[i].dataType, getEmptyRowValue(job.jobTableList[tableNo].colList[i].dataType,
job.jobTableList[tableNo].colList[i].width, job.jobTableList[tableNo].colList[i].width);
(uint8_t*)&job.jobTableList[tableNo].colList[i].emptyVal);
// check HWM for column file // check HWM for column file
rc = BRMWrapper::getInstance()->getDbRootHWMInfo( curJobCol.mapOid, rc = BRMWrapper::getInstance()->getDbRootHWMInfo( curJobCol.mapOid,

View File

@ -115,9 +115,11 @@ int ColumnBuffer::writeToFile(int startOffset, int writeSize, bool fillUpWEmptie
{ {
BlockOp blockOp; BlockOp blockOp;
newBuf = new unsigned char[BYTE_PER_BLOCK]; newBuf = new unsigned char[BYTE_PER_BLOCK];
uint8_t* emptyVal = (uint8_t*) alloca(fColInfo->column.width); blockOp.findTypeHandler(fColInfo->column.width,
blockOp.getEmptyRowValue(fColInfo->column.dataType, fColInfo->column.dataType);
fColInfo->column.width, emptyVal); const uint8_t* emptyVal = blockOp.getEmptyRowValue(fColInfo->column.dataType,
fColInfo->column.width);
::memcpy(static_cast<void *>(newBuf), ::memcpy(static_cast<void *>(newBuf),
static_cast<const void *>(fBuffer + startOffset), writeSize); static_cast<const void *>(fBuffer + startOffset), writeSize);
blockOp.setEmptyBuf(newBuf + writeSize, BYTE_PER_BLOCK - writeSize, blockOp.setEmptyBuf(newBuf + writeSize, BYTE_PER_BLOCK - writeSize,

View File

@ -132,7 +132,7 @@ int ColumnBufferCompressed::resetToBeCompressedColBuf(
BlockOp::setEmptyBuf( fToBeCompressedBuffer, BlockOp::setEmptyBuf( fToBeCompressedBuffer,
IDBCompressInterface::UNCOMPRESSED_INBUF_LEN, IDBCompressInterface::UNCOMPRESSED_INBUF_LEN,
(uint8_t*)&fColInfo->column.emptyVal, fColInfo->column.emptyVal,
fColInfo->column.width ); fColInfo->column.width );
if (fLog->isDebug( DEBUG_2 )) if (fLog->isDebug( DEBUG_2 ))
@ -317,7 +317,7 @@ int ColumnBufferCompressed::writeToFile(int startOffset, int writeSize,
// Start over again loading a new to-be-compressed buffer // Start over again loading a new to-be-compressed buffer
BlockOp::setEmptyBuf( fToBeCompressedBuffer, BlockOp::setEmptyBuf( fToBeCompressedBuffer,
IDBCompressInterface::UNCOMPRESSED_INBUF_LEN, IDBCompressInterface::UNCOMPRESSED_INBUF_LEN,
(uint8_t*)&fColInfo->column.emptyVal, fColInfo->column.emptyVal,
fColInfo->column.width ); fColInfo->column.width );
fToBeCompressedCapacity = fToBeCompressedCapacity =
@ -628,7 +628,7 @@ int ColumnBufferCompressed::initToBeCompressedBuffer(long long& startFileOffset)
new unsigned char[IDBCompressInterface::UNCOMPRESSED_INBUF_LEN]; new unsigned char[IDBCompressInterface::UNCOMPRESSED_INBUF_LEN];
BlockOp::setEmptyBuf( fToBeCompressedBuffer, BlockOp::setEmptyBuf( fToBeCompressedBuffer,
IDBCompressInterface::UNCOMPRESSED_INBUF_LEN, IDBCompressInterface::UNCOMPRESSED_INBUF_LEN,
(uint8_t*)&fColInfo->column.emptyVal, fColInfo->column.emptyVal,
fColInfo->column.width ); fColInfo->column.width );
bNewBuffer = true; bNewBuffer = true;
} }
@ -743,7 +743,7 @@ int ColumnBufferCompressed::initToBeCompressedBuffer(long long& startFileOffset)
{ {
BlockOp::setEmptyBuf( fToBeCompressedBuffer, BlockOp::setEmptyBuf( fToBeCompressedBuffer,
IDBCompressInterface::UNCOMPRESSED_INBUF_LEN, IDBCompressInterface::UNCOMPRESSED_INBUF_LEN,
(uint8_t*)&fColInfo->column.emptyVal, fColInfo->column.emptyVal,
fColInfo->column.width ); fColInfo->column.width );
} }

View File

@ -297,6 +297,7 @@ void ColumnInfo::setupDelayedFileCreation(
column.mapOid, column.mapOid,
column.compressionType, column.compressionType,
dbRoot, partition, segment ); dbRoot, partition, segment );
colOp->findTypeHandler(column.width, column.dataType);
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
@ -896,7 +897,7 @@ int ColumnInfo::extendColumnOldExtent(
} }
rc = colOp->expandAbbrevColumnExtent( pFile, dbRootNext, rc = colOp->expandAbbrevColumnExtent( pFile, dbRootNext,
(uint8_t*)&column.emptyVal, column.width); column.emptyVal, column.width);
if (rc != NO_ERROR) if (rc != NO_ERROR)
{ {
@ -1422,6 +1423,7 @@ int ColumnInfo::setupInitialColumnExtent(
column.mapOid, column.mapOid,
column.compressionType, column.compressionType,
dbRoot, partition, segment ); dbRoot, partition, segment );
colOp->findTypeHandler(column.width, column.dataType);
// Open the column file // Open the column file
if (!colOp->exists(column.mapOid, dbRoot, partition, segment) ) if (!colOp->exists(column.mapOid, dbRoot, partition, segment) )

View File

@ -540,7 +540,7 @@ int ColumnInfoCompressed::extendColumnOldExtent(
int rc = colOp->fillCompColumnExtentEmptyChunks( int rc = colOp->fillCompColumnExtentEmptyChunks(
curCol.dataFile.fid, curCol.dataFile.fid,
curCol.colWidth, curCol.colWidth,
(uint8_t*)&column.emptyVal, column.emptyVal,
curCol.dataFile.fDbRoot, curCol.dataFile.fDbRoot,
curCol.dataFile.fPartition, curCol.dataFile.fPartition,
curCol.dataFile.fSegment, curCol.dataFile.fSegment,

View File

@ -423,9 +423,6 @@ uint8_t WE_DMLCommandProc::processSingleInsert(messageqcpp::ByteStream& bs, std:
// call the write engine to write the rows // call the write engine to write the rows
int error = NO_ERROR; int error = NO_ERROR;
// MCOL-641 WIP
fWEWrapper.setDebugLevel(WriteEngine::DEBUG_3);
cout << "inserting a row with transaction id " << txnid.id << endl;
fWEWrapper.setIsInsert(true); fWEWrapper.setIsInsert(true);
fWEWrapper.setBulkFlag(true); fWEWrapper.setBulkFlag(true);
fWEWrapper.setTransId(txnid.id); fWEWrapper.setTransId(txnid.id);

View File

@ -25,6 +25,7 @@
#include <string.h> #include <string.h>
#include "joblisttypes.h" #include "joblisttypes.h"
#include "mcs_datatype.h"
#include "we_blockop.h" #include "we_blockop.h"
@ -34,15 +35,13 @@
using namespace execplan; using namespace execplan;
#include "emptyvaluemanip.h"
namespace WriteEngine namespace WriteEngine
{ {
/** /**
* Constructor * Constructor
*/ */
BlockOp::BlockOp() BlockOp::BlockOp(): m_typeHandler(nullptr)
{} {}
/** /**
@ -84,11 +83,20 @@ bool BlockOp::calculateRowId(
* RETURN: * RETURN:
* emptyVal - the value of empty row * emptyVal - the value of empty row
***********************************************************/ ***********************************************************/
// TODO MCOL-641 Add support here const uint8_t* BlockOp::getEmptyRowValue(
void BlockOp::getEmptyRowValue( const CalpontSystemCatalog::ColDataType colDataType,
const CalpontSystemCatalog::ColDataType colDataType, const int width, uint8_t* emptyVal ) const const int width) const
{ {
utils::getEmptyRowValue(colDataType, width, emptyVal); auto attrs = datatypes::SystemCatalog::TypeAttributesStd(width, 0, -1);
// Bulk operation runtime should have m_typeHandler nullptr calling this
// Non-bulk operations runtime branch
if (m_typeHandler)
return m_typeHandler->getEmptyValueForType(attrs);
// Bulk operation branch
auto* typeHandler = datatypes::TypeHandler::find(colDataType,
attrs);
return typeHandler->getEmptyValueForType(attrs);
} }
/*********************************************************** /***********************************************************
@ -166,7 +174,10 @@ void BlockOp::resetBuf( unsigned char* buf, const int bufSize ) const
***********************************************************/ ***********************************************************/
/* static */ /* static */
void BlockOp::setEmptyBuf( void BlockOp::setEmptyBuf(
unsigned char* buf, const int bufSize, uint8_t* emptyVal, const int width ) unsigned char* buf,
const int bufSize,
const uint8_t* emptyVal,
const int width )
{ {
const int ARRAY_COUNT = 128; const int ARRAY_COUNT = 128;
const int NBYTES_IN_ARRAY = width * ARRAY_COUNT; const int NBYTES_IN_ARRAY = width * ARRAY_COUNT;
@ -214,7 +225,7 @@ void BlockOp::setEmptyBuf(
* none * none
***********************************************************/ ***********************************************************/
void BlockOp::writeBufValue( void BlockOp::writeBufValue(
unsigned char* buf, void* val, const size_t width, const bool clear ) const unsigned char* buf, const void* val, const size_t width, const bool clear ) const
{ {
if ( clear ) if ( clear )
memset( buf, 0, width ); memset( buf, 0, width );
@ -222,5 +233,16 @@ void BlockOp::writeBufValue(
memcpy( buf, val, width ); memcpy( buf, val, width );
} }
void BlockOp::findTypeHandler(const int colWidth,
const execplan::CalpontSystemCatalog::ColDataType colDataType)
{
auto attrs = datatypes::SystemCatalog::TypeAttributesStd(colWidth,
0,
-1);
m_typeHandler = datatypes::TypeHandler::find(colDataType,
attrs);
}
} //end of namespace } //end of namespace

View File

@ -89,9 +89,9 @@ public:
/** /**
* @brief Get an empty row value * @brief Get an empty row value
*/ */
EXPORT void getEmptyRowValue(const execplan::CalpontSystemCatalog::ColDataType colDataType, EXPORT const uint8_t* getEmptyRowValue(const execplan::CalpontSystemCatalog::ColDataType colDataType,
const int width, const int width) const;
uint8_t* emptyVal ) const;
/** /**
* @brief Calculate row id * @brief Calculate row id
@ -117,17 +117,23 @@ public:
*/ */
EXPORT void static setEmptyBuf( unsigned char* buf, EXPORT void static setEmptyBuf( unsigned char* buf,
const int bufSize, const int bufSize,
uint8_t* emptyVal, const int width ); const uint8_t* emptyVal,
const int width );
/** /**
* @brief Set a value in a buffer * @brief Set a value in a buffer
*/ */
EXPORT void writeBufValue( unsigned char* buf, EXPORT void writeBufValue( unsigned char* buf,
void* val, const void* val,
const size_t width, const size_t width,
const bool clear = false ) const; const bool clear = false ) const;
EXPORT void findTypeHandler( const int colWidth,
const execplan::CalpontSystemCatalog::ColDataType colDataType);
private:
const datatypes::TypeHandler* m_typeHandler;
}; };
} //end of namespace } //end of namespace
#undef EXPORT #undef EXPORT

View File

@ -306,8 +306,7 @@ void BulkRollbackFile::reInitTruncColumnExtent(
} }
// Initialize the remainder of the extent after the HWM block // Initialize the remainder of the extent after the HWM block
uint8_t* emptyVal = (uint8_t*) alloca(colWidth); const uint8_t* emptyVal = fDbFile.getEmptyRowValue( colType, colWidth );
fDbFile.getEmptyRowValue( colType, colWidth, emptyVal );
int rc = fDbFile.reInitPartialColumnExtent( pFile, int rc = fDbFile.reInitPartialColumnExtent( pFile,
startOffset, startOffset,

View File

@ -374,8 +374,7 @@ void BulkRollbackFileCompressed::reInitTruncColumnExtent(
if (nBlocksToInit > 0) if (nBlocksToInit > 0)
{ {
uint8_t* emptyVal = (uint8_t*) alloca(colWidth); const uint8_t* emptyVal = fDbFile.getEmptyRowValue( colType, colWidth );
fDbFile.getEmptyRowValue( colType, colWidth, emptyVal );
rc = fDbFile.reInitPartialColumnExtent( pFile, rc = fDbFile.reInitPartialColumnExtent( pFile,
(chunkPtrs[chunkIndex].first + restoredChunkLen), (chunkPtrs[chunkIndex].first + restoredChunkLen),
nBlocksToInit, nBlocksToInit,

View File

@ -821,8 +821,8 @@ int ChunkManager::fetchChunkFromFile(IDBDataFile* pFile, int64_t id, ChunkData*&
void ChunkManager::initializeColumnChunk(char* buf, CompFileData* fileData) void ChunkManager::initializeColumnChunk(char* buf, CompFileData* fileData)
{ {
int size = UNCOMPRESSED_CHUNK_SIZE; int size = UNCOMPRESSED_CHUNK_SIZE;
uint8_t* emptyVal = (uint8_t*) alloca(fileData->fColWidth); const uint8_t* emptyVal = fFileOp->getEmptyRowValue(fileData->fColDataType,
fFileOp->getEmptyRowValue(fileData->fColDataType, fileData->fColWidth, emptyVal); fileData->fColWidth);
fFileOp->setEmptyBuf((unsigned char*)buf, size, emptyVal, fileData->fColWidth); fFileOp->setEmptyBuf((unsigned char*)buf, size, emptyVal, fileData->fColWidth);
} }
@ -1343,7 +1343,7 @@ inline int ChunkManager::writeHeader_(CompFileData* fileData, int ptrSecSize)
// For the specified segment file (pFile), read in an abbreviated/compressed // For the specified segment file (pFile), read in an abbreviated/compressed
// chunk extent, uncompress, and expand to a full chunk for a full extent. // chunk extent, uncompress, and expand to a full chunk for a full extent.
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
int ChunkManager::expandAbbrevColumnExtent(IDBDataFile* pFile, uint8_t* emptyVal, int width) int ChunkManager::expandAbbrevColumnExtent(IDBDataFile* pFile, const uint8_t* emptyVal, int width)
{ {
map<IDBDataFile*, CompFileData*>::iterator i = fFilePtrMap.find(pFile); map<IDBDataFile*, CompFileData*>::iterator i = fFilePtrMap.find(pFile);

View File

@ -214,7 +214,7 @@ public:
void cleanUp(const std::map<FID, FID>& columOids); void cleanUp(const std::map<FID, FID>& columOids);
// @brief Expand an initial column, not dictionary, extent to a full extent. // @brief Expand an initial column, not dictionary, extent to a full extent.
int expandAbbrevColumnExtent(IDBDataFile* pFile, uint8_t* emptyVal, int width); int expandAbbrevColumnExtent(IDBDataFile* pFile, const uint8_t* emptyVal, int width);
// @brief Update column extent // @brief Update column extent
int updateColumnExtent(IDBDataFile* pFile, int addBlockCount); int updateColumnExtent(IDBDataFile* pFile, int addBlockCount);

View File

@ -161,7 +161,7 @@ int FileOp::createDir( const char* dirName, mode_t mode ) const
* ERR_FILE_CREATE if can not create the file * ERR_FILE_CREATE if can not create the file
***********************************************************/ ***********************************************************/
int FileOp::createFile( const char* fileName, int numOfBlock, int FileOp::createFile( const char* fileName, int numOfBlock,
uint8_t* emptyVal, int width, const uint8_t* emptyVal, int width,
uint16_t dbRoot ) uint16_t dbRoot )
{ {
IDBDataFile* pFile = IDBDataFile* pFile =
@ -228,7 +228,7 @@ int FileOp::createFile(FID fid,
uint16_t dbRoot, uint16_t dbRoot,
uint32_t partition, uint32_t partition,
execplan::CalpontSystemCatalog::ColDataType colDataType, execplan::CalpontSystemCatalog::ColDataType colDataType,
uint8_t* emptyVal, const uint8_t* emptyVal,
int width) int width)
{ {
//std::cout << "Creating file oid: " << fid << //std::cout << "Creating file oid: " << fid <<
@ -569,7 +569,7 @@ bool FileOp::existsOIDDir( FID fid ) const
***********************************************************/ ***********************************************************/
int FileOp::extendFile( int FileOp::extendFile(
OID oid, OID oid,
uint8_t* emptyVal, const uint8_t* emptyVal,
int width, int width,
HWM hwm, HWM hwm,
BRM::LBID_t startLbid, BRM::LBID_t startLbid,
@ -875,7 +875,7 @@ int FileOp::extendFile(
***********************************************************/ ***********************************************************/
int FileOp::addExtentExactFile( int FileOp::addExtentExactFile(
OID oid, OID oid,
uint8_t* emptyVal, const uint8_t* emptyVal,
int width, int width,
int& allocSize, int& allocSize,
uint16_t dbRoot, uint16_t dbRoot,
@ -1045,7 +1045,7 @@ int FileOp::initColumnExtent(
IDBDataFile* pFile, IDBDataFile* pFile,
uint16_t dbRoot, uint16_t dbRoot,
int nBlocks, int nBlocks,
uint8_t* emptyVal, const uint8_t* emptyVal,
int width, int width,
bool bNewFile, bool bNewFile,
bool bExpandExtent, bool bExpandExtent,
@ -1225,7 +1225,7 @@ int FileOp::initAbbrevCompColumnExtent(
IDBDataFile* pFile, IDBDataFile* pFile,
uint16_t dbRoot, uint16_t dbRoot,
int nBlocks, int nBlocks,
uint8_t* emptyVal, const uint8_t* emptyVal,
int width) int width)
{ {
// Reserve disk space for optimized abbreviated extent // Reserve disk space for optimized abbreviated extent
@ -1285,7 +1285,7 @@ int FileOp::writeInitialCompColumnChunk(
IDBDataFile* pFile, IDBDataFile* pFile,
int nBlocksAllocated, int nBlocksAllocated,
int nRows, int nRows,
uint8_t* emptyVal, const uint8_t* emptyVal,
int width, int width,
char* hdrs) char* hdrs)
{ {
@ -1366,7 +1366,7 @@ int FileOp::writeInitialCompColumnChunk(
***********************************************************/ ***********************************************************/
int FileOp::fillCompColumnExtentEmptyChunks(OID oid, int FileOp::fillCompColumnExtentEmptyChunks(OID oid,
int colWidth, int colWidth,
uint8_t* emptyVal, const uint8_t* emptyVal,
uint16_t dbRoot, uint16_t dbRoot,
uint32_t partition, uint32_t partition,
uint16_t segment, uint16_t segment,
@ -1671,7 +1671,7 @@ int FileOp::fillCompColumnExtentEmptyChunks(OID oid,
***********************************************************/ ***********************************************************/
int FileOp::expandAbbrevColumnChunk( int FileOp::expandAbbrevColumnChunk(
IDBDataFile* pFile, IDBDataFile* pFile,
uint8_t* emptyVal, const uint8_t* emptyVal,
int colWidth, int colWidth,
const CompChunkPtr& chunkInPtr, const CompChunkPtr& chunkInPtr,
CompChunkPtr& chunkOutPtr ) CompChunkPtr& chunkOutPtr )
@ -2036,7 +2036,7 @@ int FileOp::reInitPartialColumnExtent(
IDBDataFile* pFile, IDBDataFile* pFile,
long long startOffset, long long startOffset,
int nBlocks, int nBlocks,
uint8_t* emptyVal, const uint8_t* emptyVal,
int width ) int width )
{ {
int rc = setFileOffset( pFile, startOffset, SEEK_SET ); int rc = setFileOffset( pFile, startOffset, SEEK_SET );
@ -2845,7 +2845,7 @@ bool FileOp::isDiskSpaceAvail(const std::string& fileName, int nBlocks) const
int FileOp::expandAbbrevColumnExtent( int FileOp::expandAbbrevColumnExtent(
IDBDataFile* pFile, // FILE ptr to file where abbrev extent is to be expanded IDBDataFile* pFile, // FILE ptr to file where abbrev extent is to be expanded
uint16_t dbRoot, // The DBRoot of the file with the abbreviated extent uint16_t dbRoot, // The DBRoot of the file with the abbreviated extent
uint8_t* emptyVal,// Empty value to be used in expanding the extent const uint8_t* emptyVal,// Empty value to be used in expanding the extent
int width ) // Width of the column (in bytes) int width ) // Width of the column (in bytes)
{ {
// Based on extent size, see how many blocks to add to fill the extent // Based on extent size, see how many blocks to add to fill the extent

View File

@ -92,7 +92,7 @@ public:
int& allocSize, int& allocSize,
uint16_t dbRoot, uint32_t partition, uint16_t dbRoot, uint32_t partition,
execplan::CalpontSystemCatalog::ColDataType colDataType, execplan::CalpontSystemCatalog::ColDataType colDataType,
uint8_t* emptyVal, int width = 1 ) ; const uint8_t* emptyVal, int width = 1 ) ;
/** /**
@ -100,7 +100,7 @@ public:
* Changed to public for UT. * Changed to public for UT.
*/ */
int createFile( const char* fileName, int fileSize, int createFile( const char* fileName, int fileSize,
uint8_t* emptyVal, int width, const uint8_t* emptyVal, int width,
uint16_t dbRoot ); uint16_t dbRoot );
/** /**
@ -163,7 +163,7 @@ public:
EXPORT virtual int expandAbbrevColumnExtent( EXPORT virtual int expandAbbrevColumnExtent(
IDBDataFile* pFile, IDBDataFile* pFile,
uint16_t dbRoot, uint16_t dbRoot,
uint8_t* emptyVal, const uint8_t* emptyVal,
int width ); int width );
/** /**
@ -198,7 +198,7 @@ public:
* @param hdrs (in/out) Contents of headers, if file is compressed. * @param hdrs (in/out) Contents of headers, if file is compressed.
* @return returns NO_ERROR if success. * @return returns NO_ERROR if success.
*/ */
EXPORT int extendFile(OID oid, uint8_t* emptyVal, EXPORT int extendFile(OID oid, const uint8_t* emptyVal,
int width, int width,
HWM hwm, HWM hwm,
BRM::LBID_t startLbid, BRM::LBID_t startLbid,
@ -226,7 +226,7 @@ public:
* @param newFile (out) Indicates if a new file was created for the extent * @param newFile (out) Indicates if a new file was created for the extent
* @param hdrs (in/out) Contents of headers, if file is compressed. * @param hdrs (in/out) Contents of headers, if file is compressed.
*/ */
EXPORT int addExtentExactFile(OID oid, uint8_t* emptyVal, EXPORT int addExtentExactFile(OID oid, const uint8_t* emptyVal,
int width, int width,
int& allocSize, int& allocSize,
uint16_t dbRoot, uint16_t dbRoot,
@ -253,7 +253,7 @@ public:
*/ */
EXPORT int fillCompColumnExtentEmptyChunks(OID oid, EXPORT int fillCompColumnExtentEmptyChunks(OID oid,
int colWidth, int colWidth,
uint8_t* emptyVal, const uint8_t* emptyVal,
uint16_t dbRoot, uint16_t dbRoot,
uint32_t partition, uint32_t partition,
uint16_t segment, uint16_t segment,
@ -433,7 +433,7 @@ public:
EXPORT int reInitPartialColumnExtent( IDBDataFile* pFile, EXPORT int reInitPartialColumnExtent( IDBDataFile* pFile,
long long startOffset, long long startOffset,
int nBlocks, int nBlocks,
uint8_t* emptyVal, const uint8_t* emptyVal,
int width ); int width );
/** /**
@ -497,7 +497,7 @@ public:
int initColumnExtent( IDBDataFile* pFile, int initColumnExtent( IDBDataFile* pFile,
uint16_t dbRoot, uint16_t dbRoot,
int nBlocks, int nBlocks,
uint8_t* emptyVal, const uint8_t* emptyVal,
int width, int width,
bool bNewFile, bool bNewFile,
bool bExpandExtent, bool bExpandExtent,
@ -519,7 +519,7 @@ private:
FileOp& operator=(const FileOp& rhs); FileOp& operator=(const FileOp& rhs);
int expandAbbrevColumnChunk( IDBDataFile* pFile, int expandAbbrevColumnChunk( IDBDataFile* pFile,
uint8_t* emptyVal, const uint8_t* emptyVal,
int colWidth, int colWidth,
const compress::CompChunkPtr& chunkInPtr, const compress::CompChunkPtr& chunkInPtr,
compress::CompChunkPtr& chunkOutPt); compress::CompChunkPtr& chunkOutPt);
@ -527,7 +527,7 @@ private:
int initAbbrevCompColumnExtent( IDBDataFile* pFile, int initAbbrevCompColumnExtent( IDBDataFile* pFile,
uint16_t dbRoot, uint16_t dbRoot,
int nBlocks, int nBlocks,
uint8_t* emptyVal, const uint8_t* emptyVal,
int width); int width);
static void initDbRootExtentMutexes(); static void initDbRootExtentMutexes();
@ -536,7 +536,7 @@ private:
int writeInitialCompColumnChunk( IDBDataFile* pFile, int writeInitialCompColumnChunk( IDBDataFile* pFile,
int nBlocksAllocated, int nBlocksAllocated,
int nRows, int nRows,
uint8_t* emptyVal, const uint8_t* emptyVal,
int width, int width,
char* hdrs); char* hdrs);

View File

@ -347,7 +347,7 @@ struct JobColumn /** @brief Job Column Structure */
execplan::CalpontSystemCatalog::ColDataType dataType; /** @brief column data type */ execplan::CalpontSystemCatalog::ColDataType dataType; /** @brief column data type */
ColType weType; /** @brief write engine data type */ ColType weType; /** @brief write engine data type */
std::string typeName; /** @brief data type name */ std::string typeName; /** @brief data type name */
uint128_t emptyVal; /** @brief default empty value */ const uint8_t* emptyVal; /** @brief default empty value */
int width; /** @brief column width; for a dictionary column, this is "eventually" the token width */ int width; /** @brief column width; for a dictionary column, this is "eventually" the token width */
int definedWidth; /** @brief column width as defined in the table, used for non-dictionary strings */ int definedWidth; /** @brief column width as defined in the table, used for non-dictionary strings */
int dctnryWidth; /** @brief dictionary width */ int dctnryWidth; /** @brief dictionary width */
@ -370,7 +370,7 @@ struct JobColumn /** @brief Job Column Structure */
int128_t fDefaultWideDecimal; /** @brief Wide decimal column default */ int128_t fDefaultWideDecimal; /** @brief Wide decimal column default */
std::string fDefaultChr; /** @brief Char column default */ std::string fDefaultChr; /** @brief Char column default */
JobColumn() : mapOid(0), dataType(execplan::CalpontSystemCatalog::INT), weType(WR_INT), JobColumn() : mapOid(0), dataType(execplan::CalpontSystemCatalog::INT), weType(WR_INT),
typeName("integer"), emptyVal(0), typeName("integer"), emptyVal(nullptr),
width(0), definedWidth(0), dctnryWidth(0), width(0), definedWidth(0), dctnryWidth(0),
precision(0), scale(0), fNotNull(false), precision(0), scale(0), fNotNull(false),
fFldColRelation(BULK_FLDCOL_COLUMN_FIELD), colType(' '), fFldColRelation(BULK_FLDCOL_COLUMN_FIELD), colType(' '),

View File

@ -45,7 +45,6 @@ using namespace execplan;
using namespace idbdatafile; using namespace idbdatafile;
#include "emptyvaluemanip.h"
#include "mcs_decimal.h" #include "mcs_decimal.h"
namespace WriteEngine namespace WriteEngine
@ -88,7 +87,6 @@ ColumnOp::~ColumnOp()
* NO_ERROR if success * NO_ERROR if success
* rowIdArray - allocation of the row id left here * rowIdArray - allocation of the row id left here
***********************************************************/ ***********************************************************/
// TODO MCOL-641 add support here
int ColumnOp::allocRowId(const TxnID& txnid, bool useStartingExtent, int ColumnOp::allocRowId(const TxnID& txnid, bool useStartingExtent,
Column& column, uint64_t totalRow, RID* rowIdArray, HWM& hwm, bool& newExtent, uint64_t& rowsLeft, HWM& newHwm, Column& column, uint64_t totalRow, RID* rowIdArray, HWM& hwm, bool& newExtent, uint64_t& rowsLeft, HWM& newHwm,
bool& newFile, ColStructList& newColStructList, DctnryStructList& newDctnryStructList, std::vector<boost::shared_ptr<DBRootExtentTracker> >& dbRootExtentTrackers, bool& newFile, ColStructList& newColStructList, DctnryStructList& newDctnryStructList, std::vector<boost::shared_ptr<DBRootExtentTracker> >& dbRootExtentTrackers,
@ -129,9 +127,8 @@ int ColumnOp::allocRowId(const TxnID& txnid, bool useStartingExtent,
Column newCol; Column newCol;
unsigned char buf[BYTE_PER_BLOCK]; unsigned char buf[BYTE_PER_BLOCK];
unsigned char* curVal; unsigned char* curVal;
uint8_t* emptyVal = (uint8_t*) alloca(column.colWidth); const uint8_t* emptyVal = getEmptyRowValue(column.colDataType,
getEmptyRowValue(column.colDataType, column.colWidth, emptyVal); column.colWidth);
if (useStartingExtent) if (useStartingExtent)
{ {
// ZZ. For insert select, skip the hwm block and start inserting from the next block // ZZ. For insert select, skip the hwm block and start inserting from the next block
@ -191,8 +188,6 @@ int ColumnOp::allocRowId(const TxnID& txnid, bool useStartingExtent,
{ {
if (rc == ERR_FILE_EOF) if (rc == ERR_FILE_EOF)
{ {
uint8_t* emptyVal = (uint8_t*) alloca(column.colWidth);
getEmptyRowValue(column.colDataType, column.colWidth, emptyVal);
setEmptyBuf(buf, BYTE_PER_BLOCK, emptyVal, column.colWidth); setEmptyBuf(buf, BYTE_PER_BLOCK, emptyVal, column.colWidth);
RETURN_ON_ERROR(saveBlock(column.dataFile.pFile, buf, hwm)); RETURN_ON_ERROR(saveBlock(column.dataFile.pFile, buf, hwm));
} }
@ -290,8 +285,6 @@ int ColumnOp::allocRowId(const TxnID& txnid, bool useStartingExtent,
if (newColStructList[i].fCompressionType > 0) if (newColStructList[i].fCompressionType > 0)
{ {
uint8_t* emptyVal = (uint8_t*) alloca(newColStructList[i].colWidth);
getEmptyRowValue(newColStructList[i].colDataType, newColStructList[i].colWidth, emptyVal);
string errorInfo; string errorInfo;
rc = fileOp.fillCompColumnExtentEmptyChunks(newColStructList[i].dataOid, newColStructList[i].colWidth, rc = fileOp.fillCompColumnExtentEmptyChunks(newColStructList[i].dataOid, newColStructList[i].colWidth,
emptyVal, dbRoot, partition, segment, newHwm, segFile, errorInfo); emptyVal, dbRoot, partition, segment, newHwm, segFile, errorInfo);
@ -317,8 +310,6 @@ int ColumnOp::allocRowId(const TxnID& txnid, bool useStartingExtent,
return rc; return rc;
} }
uint8_t* emptyVal = (uint8_t*) alloca(newColStructList[i].colWidth);
getEmptyRowValue(newColStructList[i].colDataType, newColStructList[i].colWidth, emptyVal);
rc = fileOp.expandAbbrevColumnExtent( pFile, dbRoot, emptyVal, newColStructList[i].colWidth); rc = fileOp.expandAbbrevColumnExtent( pFile, dbRoot, emptyVal, newColStructList[i].colWidth);
//set hwm for this extent. //set hwm for this extent.
fileOp.closeFile(pFile); fileOp.closeFile(pFile);
@ -495,8 +486,6 @@ int ColumnOp::allocRowId(const TxnID& txnid, bool useStartingExtent,
{ {
if (rc == ERR_FILE_EOF) if (rc == ERR_FILE_EOF)
{ {
uint8_t* emptyVal = (uint8_t*) alloca(newCol.colWidth);
getEmptyRowValue(newCol.colDataType, newCol.colWidth, emptyVal);
setEmptyBuf(buf, BYTE_PER_BLOCK, emptyVal, newCol.colWidth); setEmptyBuf(buf, BYTE_PER_BLOCK, emptyVal, newCol.colWidth);
RETURN_ON_ERROR(saveBlock(newCol.dataFile.pFile, buf, newHwm)); RETURN_ON_ERROR(saveBlock(newCol.dataFile.pFile, buf, newHwm));
} }
@ -538,8 +527,6 @@ int ColumnOp::allocRowId(const TxnID& txnid, bool useStartingExtent,
{ {
if (rc == ERR_FILE_EOF) if (rc == ERR_FILE_EOF)
{ {
uint8_t* emptyVal = (uint8_t*) alloca(newCol.colWidth);
getEmptyRowValue(newCol.colDataType, newCol.colWidth, emptyVal);
setEmptyBuf(buf, BYTE_PER_BLOCK, emptyVal, newCol.colWidth); setEmptyBuf(buf, BYTE_PER_BLOCK, emptyVal, newCol.colWidth);
RETURN_ON_ERROR(saveBlock(newCol.dataFile.pFile, buf, newHwm)); RETURN_ON_ERROR(saveBlock(newCol.dataFile.pFile, buf, newHwm));
} }
@ -652,8 +639,8 @@ int ColumnOp::createColumn(Column& column,
int rc, newWidth, allocSize; int rc, newWidth, allocSize;
int compressionType = column.compressionType; int compressionType = column.compressionType;
setColParam(column, colNo, colWidth, colDataType, colType); setColParam(column, colNo, colWidth, colDataType, colType);
uint8_t* emptyVal = (uint8_t*) alloca(colWidth); const uint8_t* emptyVal = getEmptyRowValue(colDataType,
getEmptyRowValue(colDataType, colWidth, emptyVal); colWidth);
newWidth = getCorrectRowWidth(colDataType, colWidth); newWidth = getCorrectRowWidth(colDataType, colWidth);
column.dataFile.fid = dataFid; column.dataFile.fid = dataFid;
column.dataFile.fDbRoot = dbRoot; column.dataFile.fDbRoot = dbRoot;
@ -720,10 +707,10 @@ int ColumnOp::fillColumn(const TxnID& txnid, Column& column, Column& refCol, voi
config.initConfigCache(); config.initConfigCache();
std::vector<uint16_t> rootList; std::vector<uint16_t> rootList;
config.getRootIdList( rootList ); config.getRootIdList( rootList );
uint8_t* emptyVal = (uint8_t*) alloca(column.colWidth); const uint8_t* emptyVal = getEmptyRowValue(column.colDataType,
uint8_t* refEmptyVal = (uint8_t*) alloca(refCol.colWidth); column.colWidth);
getEmptyRowValue(column.colDataType, column.colWidth, emptyVal); const uint8_t* refEmptyVal = getEmptyRowValue(refCol.colDataType,
getEmptyRowValue(refCol.colDataType, refCol.colWidth, refEmptyVal); refCol.colWidth);
//find the dbroots which have rows for refrence column //find the dbroots which have rows for refrence column
unsigned int i = 0, k = 0; unsigned int i = 0, k = 0;
@ -1335,8 +1322,8 @@ int ColumnOp::extendColumn(
bool& newFile, bool& newFile,
char* hdrs) char* hdrs)
{ {
uint8_t* emptyVal = (uint8_t*) alloca(column.colWidth); const uint8_t* emptyVal = getEmptyRowValue(column.colDataType,
getEmptyRowValue(column.colDataType, column.colWidth, emptyVal); column.colWidth);
int rc = extendFile(column.dataFile.fid, int rc = extendFile(column.dataFile.fid,
emptyVal, emptyVal,
column.colWidth, column.colWidth,
@ -1377,8 +1364,8 @@ int ColumnOp::addExtent(
int& allocSize, int& allocSize,
char* hdrs) char* hdrs)
{ {
uint8_t* emptyVal = (uint8_t*) alloca(column.colWidth); const uint8_t* emptyVal = getEmptyRowValue(column.colDataType,
getEmptyRowValue(column.colDataType, column.colWidth, emptyVal); column.colWidth);
int rc = addExtentExactFile(column.dataFile.fid, int rc = addExtentExactFile(column.dataFile.fid,
emptyVal, emptyVal,
column.colWidth, column.colWidth,
@ -1406,8 +1393,8 @@ int ColumnOp::addExtent(
***********************************************************/ ***********************************************************/
int ColumnOp::expandAbbrevExtent(const Column& column) int ColumnOp::expandAbbrevExtent(const Column& column)
{ {
uint8_t* emptyVal = (uint8_t*) alloca(column.colWidth); const uint8_t* emptyVal = getEmptyRowValue(column.colDataType,
getEmptyRowValue(column.colDataType, column.colWidth, emptyVal); column.colWidth);
int rc = expandAbbrevColumnExtent(column.dataFile.pFile, int rc = expandAbbrevColumnExtent(column.dataFile.pFile,
column.dataFile.fDbRoot, column.dataFile.fDbRoot,
emptyVal, emptyVal,
@ -1463,7 +1450,9 @@ void ColumnOp::initColumn(Column& column) const
* RETURN: * RETURN:
* true if success, false otherwise * true if success, false otherwise
***********************************************************/ ***********************************************************/
inline bool ColumnOp::isEmptyRow(uint64_t* curVal, uint8_t* emptyVal, const int colWidth) inline bool ColumnOp::isEmptyRow(uint64_t* curVal,
const uint8_t* emptyVal,
const int colWidth)
{ {
// colWidth is either 1, 2, 4, 8, or 16 (Convertor::getCorrectRowWidth) // colWidth is either 1, 2, 4, 8, or 16 (Convertor::getCorrectRowWidth)
switch(colWidth){ switch(colWidth){
@ -1482,9 +1471,6 @@ inline bool ColumnOp::isEmptyRow(uint64_t* curVal, uint8_t* emptyVal, const int
case 16: case 16:
return *(uint128_t*)curVal == *(uint128_t*)emptyVal; return *(uint128_t*)curVal == *(uint128_t*)emptyVal;
//case 32:
// return ((curVal[0] == emptyVal) && (curVal[1] == emptyVal)
// && (curVal[2] == emptyVal) && (curVal[3] == emptyVal));
} }
return false; return false;
@ -1634,9 +1620,8 @@ int ColumnOp::writeRow(Column& curCol, uint64_t totalRow, const RID* rowIdArray,
int dataFbo, dataBio, curDataFbo = -1; int dataFbo, dataBio, curDataFbo = -1;
unsigned char dataBuf[BYTE_PER_BLOCK]; unsigned char dataBuf[BYTE_PER_BLOCK];
bool bExit = false, bDataDirty = false; bool bExit = false, bDataDirty = false;
void* pVal = 0; const void* pVal = 0;
char charTmpBuf[8]; char charTmpBuf[8];
uint8_t* emptyVal = (uint8_t*) alloca(curCol.colWidth);
int rc = NO_ERROR; int rc = NO_ERROR;
uint16_t rowsInBlock = BYTE_PER_BLOCK / curCol.colWidth; uint16_t rowsInBlock = BYTE_PER_BLOCK / curCol.colWidth;
@ -1745,8 +1730,8 @@ int ColumnOp::writeRow(Column& curCol, uint64_t totalRow, const RID* rowIdArray,
if (bDelete) if (bDelete)
{ {
utils::getEmptyRowValue(curCol.colDataType, curCol.colWidth, emptyVal); pVal = getEmptyRowValue(curCol.colDataType,
pVal = emptyVal; curCol.colWidth);
} }
// This is the write stuff // This is the write stuff
@ -1788,10 +1773,9 @@ int ColumnOp::writeRows(Column& curCol, uint64_t totalRow, const RIDList& ridLis
int dataFbo, dataBio, curDataFbo = -1; int dataFbo, dataBio, curDataFbo = -1;
unsigned char dataBuf[BYTE_PER_BLOCK]; unsigned char dataBuf[BYTE_PER_BLOCK];
bool bExit = false, bDataDirty = false; bool bExit = false, bDataDirty = false;
void* pVal = 0; const void* pVal = 0;
//void* pOldVal; //void* pOldVal;
char charTmpBuf[8]; char charTmpBuf[8];
uint8_t* emptyVal;
int rc = NO_ERROR; int rc = NO_ERROR;
while (!bExit) while (!bExit)
@ -1894,9 +1878,8 @@ int ColumnOp::writeRows(Column& curCol, uint64_t totalRow, const RIDList& ridLis
} }
else else
{ {
emptyVal = (uint8_t*) alloca(curCol.colWidth); pVal = getEmptyRowValue(curCol.colDataType,
getEmptyRowValue(curCol.colDataType, curCol.colWidth, emptyVal); curCol.colWidth);
pVal = emptyVal;
} }
writeBufValue(dataBuf + dataBio, pVal, curCol.colWidth); writeBufValue(dataBuf + dataBio, pVal, curCol.colWidth);

View File

@ -220,7 +220,9 @@ public:
/** /**
* @brief Check whether it is an empty row * @brief Check whether it is an empty row
*/ */
EXPORT virtual bool isEmptyRow(uint64_t* curVal, uint8_t* emptyVal, const int colWidth); EXPORT virtual bool isEmptyRow(uint64_t* curVal,
const uint8_t* emptyVal,
const int colWidth);
/** /**
* @brief Check whether it is a valid column * @brief Check whether it is a valid column

View File

@ -191,7 +191,7 @@ int ColumnOpCompress1::flushFile(int rc, std::map<FID, FID>& columnOids)
int ColumnOpCompress1::expandAbbrevColumnExtent( int ColumnOpCompress1::expandAbbrevColumnExtent(
IDBDataFile* pFile, uint16_t dbRoot, uint8_t* emptyVal, int width) IDBDataFile* pFile, uint16_t dbRoot, const uint8_t* emptyVal, int width)
{ {
// update the uncompressed initial chunk to full chunk // update the uncompressed initial chunk to full chunk
int rc = m_chunkManager->expandAbbrevColumnExtent(pFile, emptyVal, width); int rc = m_chunkManager->expandAbbrevColumnExtent(pFile, emptyVal, width);

View File

@ -111,7 +111,7 @@ public:
/** /**
* @brief virtual method in FileOp * @brief virtual method in FileOp
*/ */
int expandAbbrevColumnExtent(IDBDataFile* pFile, uint16_t dbRoot, uint8_t* emptyVal, int width); int expandAbbrevColumnExtent(IDBDataFile* pFile, uint16_t dbRoot, const uint8_t* emptyVal, int width);
/** /**
* @brief virtual method in ColumnOp * @brief virtual method in ColumnOp

View File

@ -624,6 +624,9 @@ int WriteEngineWrapper::createColumn(
int compress_op = op(compressionType); int compress_op = op(compressionType);
m_colOp[compress_op]->initColumn(curCol); m_colOp[compress_op]->initColumn(curCol);
m_colOp[compress_op]->findTypeHandler(dataWidth, dataType);
rc = m_colOp[compress_op]->createColumn(curCol, 0, dataWidth, dataType, rc = m_colOp[compress_op]->createColumn(curCol, 0, dataWidth, dataType,
WriteEngine::WR_CHAR, (FID)dataOid, dbRoot, partition); WriteEngine::WR_CHAR, (FID)dataOid, dbRoot, partition);
@ -708,8 +711,13 @@ int WriteEngineWrapper::fillColumn(const TxnID& txnid, const OID& dataOid,
Convertor::convertColType(refColDataType, refColWidth, refColType, isToken); Convertor::convertColType(refColDataType, refColWidth, refColType, isToken);
refColOp->setColParam(refCol, 0, refColOp->getCorrectRowWidth(refColDataType, refColWidth), refColOp->setColParam(refCol, 0, refColOp->getCorrectRowWidth(refColDataType, refColWidth),
refColDataType, refColType, (FID)refColOID, refCompressionType, dbRoot); refColDataType, refColType, (FID)refColOID, refCompressionType, dbRoot);
colOpNewCol->setColParam(newCol, 0, newDataWidth, refColOp->findTypeHandler(refColOp->getCorrectRowWidth(refColDataType,
refColWidth),
refColDataType);
colOpNewCol->setColParam(newCol, 0, newDataWidth,
colType.colDataType, newColType, (FID)dataOid, compressionType, dbRoot); colType.colDataType, newColType, (FID)dataOid, compressionType, dbRoot);
colOpNewCol->findTypeHandler(newDataWidth, colType.colDataType);
int size = sizeof(Token); int size = sizeof(Token);
@ -761,8 +769,6 @@ int WriteEngineWrapper::deleteRow(const TxnID& txnid, const vector<CSCTypesList>
setTransId(txnid); setTransId(txnid);
unsigned numExtents = colExtentsStruct.size(); unsigned numExtents = colExtentsStruct.size();
uint128_t emptyVal;
for (unsigned extent = 0; extent < numExtents; extent++) for (unsigned extent = 0; extent < numExtents; extent++)
{ {
colStructList = colExtentsStruct[extent]; colStructList = colExtentsStruct[extent];
@ -775,9 +781,13 @@ int WriteEngineWrapper::deleteRow(const TxnID& txnid, const vector<CSCTypesList>
cscColType = cscColTypeList[i]; cscColType = cscColTypeList[i];
Convertor::convertColType(&curColStruct); Convertor::convertColType(&curColStruct);
m_colOp[op(curColStruct.fCompressionType)]-> const uint8_t* emptyVal = m_colOp[op(curColStruct.fCompressionType)]->
getEmptyRowValue(curColStruct.colDataType, curColStruct.colWidth, (uint8_t*)&emptyVal); getEmptyRowValue(curColStruct.colDataType, curColStruct.colWidth);
curTuple.data = emptyVal;
if (curColStruct.colWidth == datatypes::MAXDECIMALWIDTH)
curTuple.data = *(int128_t*)emptyVal;
else
curTuple.data = *(int64_t*)emptyVal;
curTupleList.push_back(curTuple); curTupleList.push_back(curTuple);
colValueList.push_back(curTupleList); colValueList.push_back(curTupleList);
@ -854,6 +864,7 @@ int WriteEngineWrapper::deleteBadRows(const TxnID& txnid, ColStructList& colStru
colStructs[i].colDataType, colStructs[i].colType, colStructs[i].dataOid, colStructs[i].colDataType, colStructs[i].colType, colStructs[i].dataOid,
colStructs[i].fCompressionType, colStructs[i].fColDbRoot, colStructs[i].fCompressionType, colStructs[i].fColDbRoot,
colStructs[i].fColPartition, colStructs[i].fColSegment); colStructs[i].fColPartition, colStructs[i].fColSegment);
colOp->findTypeHandler(colStructs[i].colWidth, colStructs[i].colDataType);
string segFile; string segFile;
rc = colOp->openColumnFile(curCol, segFile, true, IO_BUFF_SIZE); // @bug 5572 HDFS tmp file rc = colOp->openColumnFile(curCol, segFile, true, IO_BUFF_SIZE); // @bug 5572 HDFS tmp file
@ -1085,6 +1096,8 @@ int WriteEngineWrapper::insertColumnRecs(const TxnID& txnid,
colOp->setColParam(curCol, colId, colStructList[i].colWidth, colStructList[i].colDataType, colOp->setColParam(curCol, colId, colStructList[i].colWidth, colStructList[i].colDataType,
colStructList[i].colType, colStructList[i].dataOid, colStructList[i].fCompressionType, colStructList[i].colType, colStructList[i].dataOid, colStructList[i].fCompressionType,
dbRoot, partitionNum, segmentNum); dbRoot, partitionNum, segmentNum);
colOp->findTypeHandler(colStructList[i].colWidth,
colStructList[i].colDataType);
rc = colOp->extendColumn(curCol, false, extents[i].startBlkOffset, extents[i].startLbid, extents[i].allocSize, dbRoot, rc = colOp->extendColumn(curCol, false, extents[i].startBlkOffset, extents[i].startLbid, extents[i].allocSize, dbRoot,
partitionNum, segmentNum, segFile, pFile, newFile); partitionNum, segmentNum, segFile, pFile, newFile);
@ -1314,9 +1327,11 @@ int WriteEngineWrapper::insertColumnRecs(const TxnID& txnid,
oldHwm = hwm; //Save this info for rollback oldHwm = hwm; //Save this info for rollback
//need to pass real dbRoot, partition, and segment to setColParam //need to pass real dbRoot, partition, and segment to setColParam
colOp->setColParam(curCol, colId, curColStruct.colWidth, curColStruct.colDataType, colOp->setColParam(curCol, colId, curColStruct.colWidth, curColStruct.colDataType,
curColStruct.colType, curColStruct.dataOid, curColStruct.fCompressionType, curColStruct.colType, curColStruct.dataOid, curColStruct.fCompressionType,
curColStruct.fColDbRoot, curColStruct.fColPartition, curColStruct.fColSegment); curColStruct.fColDbRoot, curColStruct.fColPartition, curColStruct.fColSegment);
colOp->findTypeHandler(curColStruct.colWidth,
curColStruct.colDataType);
rc = colOp->openColumnFile(curCol, segFile, useTmpSuffix); // @bug 5572 HDFS tmp file rc = colOp->openColumnFile(curCol, segFile, useTmpSuffix); // @bug 5572 HDFS tmp file
if (rc != NO_ERROR) if (rc != NO_ERROR)
@ -1377,6 +1392,8 @@ int WriteEngineWrapper::insertColumnRecs(const TxnID& txnid,
colStructList[k].fColDbRoot, colStructList[k].fColDbRoot,
colStructList[k].fColPartition, colStructList[k].fColPartition,
colStructList[k].fColSegment); colStructList[k].fColSegment);
colOp->findTypeHandler(colStructList[k].colWidth,
colStructList[k].colDataType);
rc = colOp->openColumnFile(expandCol, segFile, true); // @bug 5572 HDFS tmp file rc = colOp->openColumnFile(expandCol, segFile, true); // @bug 5572 HDFS tmp file
if (rc == NO_ERROR) if (rc == NO_ERROR)
@ -1844,6 +1861,8 @@ int WriteEngineWrapper::insertColumnRecsBinary(const TxnID& txnid,
colOp->setColParam(curCol, 0, colStructList[i].colWidth, colStructList[i].colDataType, colOp->setColParam(curCol, 0, colStructList[i].colWidth, colStructList[i].colDataType,
colStructList[i].colType, colStructList[i].dataOid, colStructList[i].fCompressionType, colStructList[i].colType, colStructList[i].dataOid, colStructList[i].fCompressionType,
dbRoot, partitionNum, segmentNum); dbRoot, partitionNum, segmentNum);
colOp->findTypeHandler(colStructList[i].colWidth,
colStructList[i].colDataType);
rc = colOp->extendColumn(curCol, false, extents[i].startBlkOffset, extents[i].startLbid, extents[i].allocSize, dbRoot, rc = colOp->extendColumn(curCol, false, extents[i].startBlkOffset, extents[i].startLbid, extents[i].allocSize, dbRoot,
partitionNum, segmentNum, segFile, pFile, newFile); partitionNum, segmentNum, segFile, pFile, newFile);
@ -2080,6 +2099,8 @@ int WriteEngineWrapper::insertColumnRecsBinary(const TxnID& txnid,
colOp->setColParam(curCol, colId, curColStruct.colWidth, curColStruct.colDataType, colOp->setColParam(curCol, colId, curColStruct.colWidth, curColStruct.colDataType,
curColStruct.colType, curColStruct.dataOid, curColStruct.fCompressionType, curColStruct.colType, curColStruct.dataOid, curColStruct.fCompressionType,
curColStruct.fColDbRoot, curColStruct.fColPartition, curColStruct.fColSegment); curColStruct.fColDbRoot, curColStruct.fColPartition, curColStruct.fColSegment);
colOp->findTypeHandler(curColStruct.colWidth,
curColStruct.colDataType);
rc = colOp->openColumnFile(curCol, segFile, useTmpSuffix); // @bug 5572 HDFS tmp file rc = colOp->openColumnFile(curCol, segFile, useTmpSuffix); // @bug 5572 HDFS tmp file
if (rc != NO_ERROR) if (rc != NO_ERROR)
@ -2144,6 +2165,8 @@ int WriteEngineWrapper::insertColumnRecsBinary(const TxnID& txnid,
colStructList[k].fColDbRoot, colStructList[k].fColDbRoot,
colStructList[k].fColPartition, colStructList[k].fColPartition,
colStructList[k].fColSegment); colStructList[k].fColSegment);
colOp->findTypeHandler(colStructList[k].colWidth,
colStructList[k].colDataType);
rc = colOp->openColumnFile(expandCol, segFile, true); // @bug 5572 HDFS tmp file rc = colOp->openColumnFile(expandCol, segFile, true); // @bug 5572 HDFS tmp file
if (rc == NO_ERROR) if (rc == NO_ERROR)
@ -2587,7 +2610,8 @@ int WriteEngineWrapper::insertColumnRec_SYS(const TxnID& txnid,
colOp->setColParam(curCol, 0, curColStruct.colWidth, curColStruct.colDataType, colOp->setColParam(curCol, 0, curColStruct.colWidth, curColStruct.colDataType,
curColStruct.colType, curColStruct.dataOid, curColStruct.fCompressionType, curColStruct.colType, curColStruct.dataOid, curColStruct.fCompressionType,
dbRoot, partitionNum, segmentNum); dbRoot, partitionNum, segmentNum);
colOp->findTypeHandler(curColStruct.colWidth,
curColStruct.colDataType);
string segFile; string segFile;
rc = colOp->openColumnFile(curCol, segFile, false); // @bug 5572 HDFS tmp file rc = colOp->openColumnFile(curCol, segFile, false); // @bug 5572 HDFS tmp file
@ -2698,6 +2722,8 @@ int WriteEngineWrapper::insertColumnRec_SYS(const TxnID& txnid,
dbRoot, dbRoot,
partitionNum, partitionNum,
segmentNum); segmentNum);
colOp->findTypeHandler(colStructList[k].colWidth,
colStructList[k].colDataType);
rc = colOp->openColumnFile(expandCol, segFile, false); // @bug 5572 HDFS tmp file rc = colOp->openColumnFile(expandCol, segFile, false); // @bug 5572 HDFS tmp file
if (rc == NO_ERROR) if (rc == NO_ERROR)
@ -2942,6 +2968,8 @@ int WriteEngineWrapper::insertColumnRec_SYS(const TxnID& txnid,
newColStructList[i].colWidth, newColStructList[i].colDataType, newColStructList[i].colWidth, newColStructList[i].colDataType,
newColStructList[i].colType, newColStructList[i].dataOid, newColStructList[i].colType, newColStructList[i].dataOid,
newColStructList[i].fCompressionType, dbRoot, partitionNum, segmentNum); newColStructList[i].fCompressionType, dbRoot, partitionNum, segmentNum);
colOp->findTypeHandler(newColStructList[i].colWidth,
newColStructList[i].colDataType);
rc = BRMWrapper::getInstance()->getLastHWM_DBroot( rc = BRMWrapper::getInstance()->getLastHWM_DBroot(
curColLocal.dataFile.fid, dbRoot, partitionNum, segmentNum, oldHwm, curColLocal.dataFile.fid, dbRoot, partitionNum, segmentNum, oldHwm,
@ -3257,7 +3285,8 @@ int WriteEngineWrapper::insertColumnRec_Single(const TxnID& txnid,
colOp->setColParam(curCol, colId, curColStruct.colWidth, curColStruct.colDataType, colOp->setColParam(curCol, colId, curColStruct.colWidth, curColStruct.colDataType,
curColStruct.colType, curColStruct.dataOid, curColStruct.fCompressionType, curColStruct.colType, curColStruct.dataOid, curColStruct.fCompressionType,
dbRoot, partitionNum, segmentNum); dbRoot, partitionNum, segmentNum);
colOp->findTypeHandler(curColStruct.colWidth,
curColStruct.colDataType);
string segFile; string segFile;
if (bUseStartExtent) if (bUseStartExtent)
@ -3392,6 +3421,8 @@ int WriteEngineWrapper::insertColumnRec_Single(const TxnID& txnid,
colStructList[k].fColDbRoot, colStructList[k].fColDbRoot,
colStructList[k].fColPartition, colStructList[k].fColPartition,
colStructList[k].fColSegment); colStructList[k].fColSegment);
colOp->findTypeHandler(colStructList[k].colWidth,
colStructList[k].colDataType);
rc = colOp->openColumnFile(expandCol, segFile, true); // @bug 5572 HDFS tmp file rc = colOp->openColumnFile(expandCol, segFile, true); // @bug 5572 HDFS tmp file
if (rc == NO_ERROR) if (rc == NO_ERROR)
@ -4363,7 +4394,8 @@ int WriteEngineWrapper::writeColumnRecords(const TxnID& txnid,
curColStruct.colDataType, curColStruct.colType, curColStruct.dataOid, curColStruct.colDataType, curColStruct.colType, curColStruct.dataOid,
curColStruct.fCompressionType, curColStruct.fCompressionType,
curColStruct.fColDbRoot, curColStruct.fColPartition, curColStruct.fColSegment); curColStruct.fColDbRoot, curColStruct.fColPartition, curColStruct.fColSegment);
colOp->findTypeHandler(curColStruct.colWidth,
curColStruct.colDataType);
ColExtsInfo aColExtsInfo = aTbaleMetaData->getColExtsInfo(curColStruct.dataOid); ColExtsInfo aColExtsInfo = aTbaleMetaData->getColExtsInfo(curColStruct.dataOid);
ColExtsInfo::iterator it = aColExtsInfo.begin(); ColExtsInfo::iterator it = aColExtsInfo.begin();
@ -4543,6 +4575,8 @@ int WriteEngineWrapper::writeColumnRec(const TxnID& txnid,
colStructList[i].colDataType, colStructList[i].colType, colStructList[i].dataOid, colStructList[i].colDataType, colStructList[i].colType, colStructList[i].dataOid,
colStructList[i].fCompressionType, colStructList[i].fColDbRoot, colStructList[i].fCompressionType, colStructList[i].fColDbRoot,
colStructList[i].fColPartition, colStructList[i].fColSegment); colStructList[i].fColPartition, colStructList[i].fColSegment);
colOp->findTypeHandler(colStructList[i].colWidth,
colStructList[i].colDataType);
ColExtsInfo aColExtsInfo = aTbaleMetaData->getColExtsInfo(colStructList[i].dataOid); ColExtsInfo aColExtsInfo = aTbaleMetaData->getColExtsInfo(colStructList[i].dataOid);
ColExtsInfo::iterator it = aColExtsInfo.begin(); ColExtsInfo::iterator it = aColExtsInfo.begin();
@ -4665,6 +4699,8 @@ int WriteEngineWrapper::writeColumnRec(const TxnID& txnid,
newColStructList[i].colDataType, newColStructList[i].colType, newColStructList[i].dataOid, newColStructList[i].colDataType, newColStructList[i].colType, newColStructList[i].dataOid,
newColStructList[i].fCompressionType, newColStructList[i].fColDbRoot, newColStructList[i].fCompressionType, newColStructList[i].fColDbRoot,
newColStructList[i].fColPartition, newColStructList[i].fColSegment); newColStructList[i].fColPartition, newColStructList[i].fColSegment);
colOp->findTypeHandler(newColStructList[i].colWidth,
newColStructList[i].colDataType);
ColExtsInfo aColExtsInfo = aTbaleMetaData->getColExtsInfo(newColStructList[i].dataOid); ColExtsInfo aColExtsInfo = aTbaleMetaData->getColExtsInfo(newColStructList[i].dataOid);
ColExtsInfo::iterator it = aColExtsInfo.begin(); ColExtsInfo::iterator it = aColExtsInfo.begin();
@ -4784,6 +4820,8 @@ int WriteEngineWrapper::writeColumnRec(const TxnID& txnid,
colStructList[i].colDataType, colStructList[i].colType, colStructList[i].dataOid, colStructList[i].colDataType, colStructList[i].colType, colStructList[i].dataOid,
colStructList[i].fCompressionType, colStructList[i].fColDbRoot, colStructList[i].fCompressionType, colStructList[i].fColDbRoot,
colStructList[i].fColPartition, colStructList[i].fColSegment); colStructList[i].fColPartition, colStructList[i].fColSegment);
colOp->findTypeHandler(colStructList[i].colWidth,
colStructList[i].colDataType);
rc = colOp->openColumnFile(curCol, segFile, useTmpSuffix, IO_BUFF_SIZE); // @bug 5572 HDFS tmp file rc = colOp->openColumnFile(curCol, segFile, useTmpSuffix, IO_BUFF_SIZE); // @bug 5572 HDFS tmp file
@ -4957,6 +4995,8 @@ int WriteEngineWrapper::writeColumnRecBinary(const TxnID& txnid,
colStructList[i].colDataType, colStructList[i].colType, colStructList[i].dataOid, colStructList[i].colDataType, colStructList[i].colType, colStructList[i].dataOid,
colStructList[i].fCompressionType, colStructList[i].fColDbRoot, colStructList[i].fCompressionType, colStructList[i].fColDbRoot,
colStructList[i].fColPartition, colStructList[i].fColSegment); colStructList[i].fColPartition, colStructList[i].fColSegment);
colOp->findTypeHandler(colStructList[i].colWidth,
colStructList[i].colDataType);
ColExtsInfo aColExtsInfo = aTbaleMetaData->getColExtsInfo(colStructList[i].dataOid); ColExtsInfo aColExtsInfo = aTbaleMetaData->getColExtsInfo(colStructList[i].dataOid);
ColExtsInfo::iterator it = aColExtsInfo.begin(); ColExtsInfo::iterator it = aColExtsInfo.begin();
@ -5106,6 +5146,8 @@ int WriteEngineWrapper::writeColumnRecBinary(const TxnID& txnid,
newColStructList[i].colDataType, newColStructList[i].colType, newColStructList[i].dataOid, newColStructList[i].colDataType, newColStructList[i].colType, newColStructList[i].dataOid,
newColStructList[i].fCompressionType, newColStructList[i].fColDbRoot, newColStructList[i].fCompressionType, newColStructList[i].fColDbRoot,
newColStructList[i].fColPartition, newColStructList[i].fColSegment); newColStructList[i].fColPartition, newColStructList[i].fColSegment);
colOp->findTypeHandler(newColStructList[i].colWidth,
newColStructList[i].colDataType);
ColExtsInfo aColExtsInfo = aTbaleMetaData->getColExtsInfo(newColStructList[i].dataOid); ColExtsInfo aColExtsInfo = aTbaleMetaData->getColExtsInfo(newColStructList[i].dataOid);
ColExtsInfo::iterator it = aColExtsInfo.begin(); ColExtsInfo::iterator it = aColExtsInfo.begin();
@ -5321,6 +5363,8 @@ int WriteEngineWrapper::writeColumnRec(const TxnID& txnid,
curColStruct.colDataType, curColStruct.colType, curColStruct.dataOid, curColStruct.colDataType, curColStruct.colType, curColStruct.dataOid,
curColStruct.fCompressionType, curColStruct.fColDbRoot, curColStruct.fCompressionType, curColStruct.fColDbRoot,
curColStruct.fColPartition, curColStruct.fColSegment); curColStruct.fColPartition, curColStruct.fColSegment);
colOp->findTypeHandler(curColStruct.colWidth,
curColStruct.colDataType);
ColExtsInfo aColExtsInfo = aTbaleMetaData->getColExtsInfo(curColStruct.dataOid); ColExtsInfo aColExtsInfo = aTbaleMetaData->getColExtsInfo(curColStruct.dataOid);