Github user navsan commented on a diff in the pull request: https://github.com/apache/incubator-quickstep/pull/100#discussion_r79695934 --- Diff: storage/SplitRowStoreTupleStorageSubBlock.cpp --- @@ -88,6 +88,67 @@ inline std::size_t CalculateVariableSizeWithRemappedAttributes( return total_size; } + +/** + * A struct which holds the offset information for a non-remapping insert + * operation + */ +struct BasicInsertInfo { + BasicInsertInfo( + const CatalogRelationSchema &relation) + : num_attrs_(relation.size()), + num_nullable_attrs_(relation.numNullableAttributes()), + max_var_length_(relation.getMaximumVariableByteLength()), + fixed_len_offset_(BitVector<true>::BytesNeeded(num_nullable_attrs_)), + var_len_offset_(fixed_len_offset_ + relation.getFixedByteLength()), + is_variable_(num_attrs_), + is_nullable_(num_attrs_), + fixed_len_offsets_(num_attrs_), + fixed_len_sizes_(num_attrs_), + var_len_offsets_(num_attrs_) { + attribute_id accessor_attr_id = 0; + for (CatalogRelationSchema::const_iterator attr_it = relation.begin(); + attr_it != relation.end(); + ++attr_it, ++accessor_attr_id) { + DCHECK_EQ(accessor_attr_id, attr_it->getID()); + + const int nullable_idx = relation.getNullableAttributeIndex(accessor_attr_id); + const int variable_idx = relation.getVariableLengthAttributeIndex(accessor_attr_id); + is_nullable_.setBit(accessor_attr_id, nullable_idx != -1); + + if (variable_idx == -1) { + is_variable_.setBit(accessor_attr_id, false); + fixed_len_offsets_[accessor_attr_id] = relation.getFixedLengthAttributeOffset(accessor_attr_id); + fixed_len_sizes_[accessor_attr_id] = relation.getAttributeById( + accessor_attr_id)->getType().maximumByteLength(); + var_len_offsets_[accessor_attr_id] = -1; + } else { + is_variable_.setBit(accessor_attr_id, true); + fixed_len_offsets_[accessor_attr_id] = 0; + fixed_len_sizes_[accessor_attr_id] = 0; + var_len_offsets_[accessor_attr_id] = relation.getVariableLengthAttributeIndex(accessor_attr_id); + } + } + } + + std::size_t num_attrs_; + std::size_t num_nullable_attrs_; + std::size_t max_var_length_; + + // byte offset from the beginning of a tuple to the first fixed length attribute + std::uint32_t fixed_len_offset_; + // byte offset from the beginning of a tuple to the first variable length offset/length pair + std::uint32_t var_len_offset_; + + BitVector<true> is_variable_; --- End diff -- Actually, I think it's even better to just create one struct for each column, with all the info we care about for that column, like whether it's nullable/variable length and what its size is. That way, InsertInfo will have a vector<struct> which is better than a bunch of vector<int>s you have (because the struct packed with all the info you need can just be unpacked into registers directly, whereas the vector will force you to do memory loads for each column for each tuple insertion. See my bulkInsert function in PackedRowStore.
--- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. ---