| 58 | } |
| 59 | |
| 60 | int64_t Tuple::VarlenByteSize(const TupleDescriptor& desc, bool assume_smallify) const { |
| 61 | int64_t result = 0; |
| 62 | vector<SlotDescriptor*>::const_iterator slot = desc.string_slots().begin(); |
| 63 | for (; slot != desc.string_slots().end(); ++slot) { |
| 64 | DCHECK((*slot)->type().IsVarLenStringType()); |
| 65 | if (IsNull((*slot)->null_indicator_offset())) continue; |
| 66 | const StringValue* string_val = GetStringSlot((*slot)->tuple_offset()); |
| 67 | result += string_val->ExternalLen(assume_smallify); |
| 68 | } |
| 69 | |
| 70 | slot = desc.collection_slots().begin(); |
| 71 | for (; slot != desc.collection_slots().end(); ++slot) { |
| 72 | DCHECK((*slot)->type().IsCollectionType()); |
| 73 | if (IsNull((*slot)->null_indicator_offset())) continue; |
| 74 | const CollectionValue* coll_value = GetCollectionSlot((*slot)->tuple_offset()); |
| 75 | uint8_t* coll_data = coll_value->ptr; |
| 76 | const TupleDescriptor& item_desc = *(*slot)->children_tuple_descriptor(); |
| 77 | for (int i = 0; i < coll_value->num_tuples; ++i) { |
| 78 | Tuple* tuple = reinterpret_cast<Tuple*>(coll_data); |
| 79 | result += tuple->TotalByteSize(item_desc, assume_smallify); |
| 80 | coll_data += item_desc.byte_size(); |
| 81 | } |
| 82 | } |
| 83 | return result; |
| 84 | } |
| 85 | |
| 86 | Tuple* Tuple::DeepCopy(const TupleDescriptor& desc, MemPool* pool) const { |
| 87 | Tuple* result = reinterpret_cast<Tuple*>(pool->Allocate(desc.byte_size())); |