mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-30 19:42:00 +00:00
Fixed ColumnWithDictionary::serializeBinaryBulkWithMultipleStreams, added more comments.
This commit is contained in:
parent
559d944412
commit
caa86bc59a
@ -54,7 +54,7 @@ static DataTypes convertTypesWithDictionaryToNested(const DataTypes & types)
|
||||
res_types.push_back(type);
|
||||
}
|
||||
|
||||
return std::move(res_types);
|
||||
return res_types;
|
||||
}
|
||||
|
||||
AggregateFunctionPtr AggregateFunctionFactory::get(
|
||||
|
@ -145,7 +145,7 @@ private:
|
||||
void buildIndex();
|
||||
ColumnType * getRawColumnPtr() { return static_cast<ColumnType *>(column_holder->assumeMutable().get()); }
|
||||
const ColumnType * getRawColumnPtr() const { return static_cast<ColumnType *>(column_holder.get()); }
|
||||
IndexType insert(const StringRefWrapper<ColumnType> & ref, IndexType value);
|
||||
IndexType insertIntoMap(const StringRefWrapper<ColumnType> & ref, IndexType value);
|
||||
|
||||
};
|
||||
|
||||
@ -213,7 +213,7 @@ void ColumnUnique<ColumnType, IndexType>::buildIndex()
|
||||
}
|
||||
|
||||
template <typename ColumnType, typename IndexType>
|
||||
IndexType ColumnUnique<ColumnType, IndexType>::insert(const StringRefWrapper<ColumnType> & ref, IndexType value)
|
||||
IndexType ColumnUnique<ColumnType, IndexType>::insertIntoMap(const StringRefWrapper<ColumnType> & ref, IndexType value)
|
||||
{
|
||||
if (!index)
|
||||
buildIndex();
|
||||
@ -242,7 +242,7 @@ size_t ColumnUnique<ColumnType, IndexType>::uniqueInsert(const Field & x)
|
||||
return getDefaultValueIndex();
|
||||
|
||||
column->insert(x);
|
||||
auto pos = insert(StringRefWrapper<ColumnType>(column, prev_size), prev_size);
|
||||
auto pos = insertIntoMap(StringRefWrapper<ColumnType>(column, prev_size), prev_size);
|
||||
if (pos != prev_size)
|
||||
column->popBack(1);
|
||||
|
||||
@ -272,7 +272,7 @@ size_t ColumnUnique<ColumnType, IndexType>::uniqueInsertData(const char * pos, s
|
||||
if (!index->has(StringRefWrapper<ColumnType>(StringRef(pos, length))))
|
||||
{
|
||||
column->insertData(pos, length);
|
||||
return static_cast<size_t>(insert(StringRefWrapper<ColumnType>(StringRef(pos, length)), size));
|
||||
return static_cast<size_t>(insertIntoMap(StringRefWrapper<ColumnType>(StringRef(pos, length)), size));
|
||||
}
|
||||
|
||||
return size;
|
||||
@ -299,7 +299,7 @@ size_t ColumnUnique<ColumnType, IndexType>::uniqueInsertDataWithTerminatingZero(
|
||||
return getDefaultValueIndex();
|
||||
}
|
||||
|
||||
auto position = insert(StringRefWrapper<ColumnType>(column, prev_size), prev_size);
|
||||
auto position = insertIntoMap(StringRefWrapper<ColumnType>(column, prev_size), prev_size);
|
||||
if (position != prev_size)
|
||||
column->popBack(1);
|
||||
|
||||
@ -319,7 +319,7 @@ size_t ColumnUnique<ColumnType, IndexType>::uniqueDeserializeAndInsertFromArena(
|
||||
return getDefaultValueIndex();
|
||||
}
|
||||
|
||||
auto index_pos = insert(StringRefWrapper<ColumnType>(column, prev_size), prev_size);
|
||||
auto index_pos = insertIntoMap(StringRefWrapper<ColumnType>(column, prev_size), prev_size);
|
||||
if (index_pos != prev_size)
|
||||
column->popBack(1);
|
||||
|
||||
|
@ -71,17 +71,19 @@ void DataTypeWithDictionary::serializeBinaryBulkWithMultipleStreams(
|
||||
const ColumnWithDictionary & column_with_dictionary = typeid_cast<const ColumnWithDictionary &>(column);
|
||||
MutableColumnPtr sub_index;
|
||||
|
||||
if (limit == 0)
|
||||
limit = column.size();
|
||||
size_t max_limit = column.size() - offset;
|
||||
limit = limit ? std::min(limit, max_limit) : max_limit;
|
||||
|
||||
path.push_back(Substream::DictionaryKeys);
|
||||
if (auto stream = getter(path))
|
||||
{
|
||||
const auto & indexes = column_with_dictionary.getIndexesPtr();
|
||||
const auto & keys = column_with_dictionary.getUnique()->getNestedColumn();
|
||||
sub_index = (*indexes->cut(offset, limit - offset)).mutate();
|
||||
sub_index = (*indexes->cut(offset, limit)).mutate();
|
||||
ColumnPtr unique_indexes = makeSubIndex(*sub_index);
|
||||
/// unique_indexes->index(sub_index) == indexes[offset:offset + limit]
|
||||
auto used_keys = keys->index(unique_indexes, 0);
|
||||
/// (used_keys, sub_index) is ColumnWithDictionary for range [offset:offset + limit]
|
||||
|
||||
UInt64 used_keys_size = used_keys->size();
|
||||
writeIntBinary(used_keys_size, *stream);
|
||||
@ -94,7 +96,7 @@ void DataTypeWithDictionary::serializeBinaryBulkWithMultipleStreams(
|
||||
if (!sub_index)
|
||||
throw Exception("Dictionary keys wasn't serialized", ErrorCodes::LOGICAL_ERROR);
|
||||
|
||||
indexes_type->serializeBinaryBulk(*sub_index, *stream, offset, limit);
|
||||
indexes_type->serializeBinaryBulk(*sub_index, *stream, 0, limit);
|
||||
}
|
||||
}
|
||||
|
||||
@ -127,7 +129,8 @@ void DataTypeWithDictionary::deserializeBinaryBulkWithMultipleStreams(
|
||||
|
||||
auto index_col = indexes_type->createColumn();
|
||||
indexes_type->deserializeBinaryBulk(*index_col, *stream, limit, 0);
|
||||
column_with_dictionary.getIndexes()->insertRangeFrom(*indexes->index(std::move(index_col), 0), 0, limit);
|
||||
auto index_size = index_col->size();
|
||||
column_with_dictionary.getIndexes()->insertRangeFrom(*indexes->index(std::move(index_col), 0), 0, index_size);
|
||||
}
|
||||
}
|
||||
|
||||
@ -226,7 +229,7 @@ MutableColumnPtr DataTypeWithDictionary::createColumn() const
|
||||
if (!column)
|
||||
throw Exception("Unexpected numeric type: " + type->getName(), ErrorCodes::LOGICAL_ERROR);
|
||||
|
||||
return std::move(column);
|
||||
return column;
|
||||
}
|
||||
|
||||
throw Exception("Unexpected dictionary type for DataTypeWithDictionary: " + type->getName(),
|
||||
|
@ -158,7 +158,7 @@ private:
|
||||
template <typename ColumnType>
|
||||
MutableColumnPtr createColumnImpl() const;
|
||||
|
||||
friend class CreateColumnVector;
|
||||
friend struct CreateColumnVector;
|
||||
};
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user