Skip to content

Commit

Permalink
string offset column back to int32_t. added typedef so it can be easi…
Browse files Browse the repository at this point in the history
…ly changed again.
  • Loading branch information
mapdwei committed Feb 12, 2015
1 parent 6bc6057 commit 61abd3e
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 9 deletions.
10 changes: 5 additions & 5 deletions Chunk/Chunk.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ namespace Chunk_NS {
buffer = data_mgr->getChunkBuffer(subKey, mem_level, device_id, num_bytes);
subKey.pop_back();
subKey.push_back(2); // 2 for the index buffer
index_buf = data_mgr->getChunkBuffer(subKey, mem_level, device_id, (num_elems + 1) * sizeof(int64_t)); // always record n+1 offsets so string length can be calculated
index_buf = data_mgr->getChunkBuffer(subKey, mem_level, device_id, (num_elems + 1) * sizeof(StringOffsetT)); // always record n+1 offsets so string length can be calculated
} else
buffer = data_mgr->getChunkBuffer(key, mem_level, device_id, num_bytes);
}
Expand Down Expand Up @@ -88,7 +88,7 @@ namespace Chunk_NS {
it.skip = skip;
it.skip_size = column_desc->getStorageSize();
if (it.skip_size < 0) { // if it's variable length
it.current_pos = it.start_pos = index_buf->getMemoryPtr() + start_idx * sizeof(int64_t);
it.current_pos = it.start_pos = index_buf->getMemoryPtr() + start_idx * sizeof(StringOffsetT);
it.end_pos = index_buf->getMemoryPtr() + index_buf->size();
} else {
it.current_pos = it.start_pos = buffer->getMemoryPtr() + start_idx * it.skip_size;
Expand Down Expand Up @@ -209,11 +209,11 @@ namespace Chunk_NS {
it->current_pos += it->skip * it->skip_size;
} else {
// @TODO(wei) ignore uncompress flag for variable length?
int64_t offset = *(int64_t*)it->current_pos;
result->length = *((int64_t*)it->current_pos + 1) - offset;
StringOffsetT offset = *(StringOffsetT*)it->current_pos;
result->length = *((StringOffsetT*)it->current_pos + 1) - offset;
result->pointer = it->chunk->get_buffer()->getMemoryPtr() + offset;
result->is_null = false;
it->current_pos += it->skip * sizeof(int64_t);
it->current_pos += it->skip * sizeof(StringOffsetT);
}
}

Expand Down
6 changes: 3 additions & 3 deletions DataMgr/StringNoneEncoder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ ChunkMetadata
StringNoneEncoder::appendData(const std::vector<std::string> *srcData, const int start_idx, const size_t numAppendElems)
{
assert(index_buf != nullptr); // index_buf must be set before this.
size_t index_size = numAppendElems * sizeof(int64_t);
size_t index_size = numAppendElems * sizeof(StringOffsetT);
if (numElems == 0)
index_size += sizeof(int64_t); // plus one for the initial offset of 0.
index_size += sizeof(StringOffsetT); // plus one for the initial offset of 0.
index_buf->reserve(index_size);
// @TODO worry about locking
int64_t *index = (int64_t*)(index_buf->getMemoryPtr() + index_buf->size());
StringOffsetT *index = (StringOffsetT*)(index_buf->getMemoryPtr() + index_buf->size());
int i = 0;
if (numElems == 0) {
index[0] = 0; // write the inital 0 offset
Expand Down
2 changes: 2 additions & 0 deletions DataMgr/StringNoneEncoder.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@

using Data_Namespace::AbstractBuffer;

typedef int32_t StringOffsetT;

class StringNoneEncoder : public Encoder {

public:
Expand Down
1 change: 0 additions & 1 deletion Fragmenter/InsertOrderFragmenter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ void InsertOrderFragmenter::getChunkMetadata() {
ChunkKey insertKey = chunkKeyPrefix_; //database_id and table_id
insertKey.push_back(colIt->first); // column id
insertKey.push_back(lastFragmentId); // fragment id
cout << "Device id: " << deviceId << endl;
colIt->second.getChunkBuffer(dataMgr_, insertKey, defaultInsertLevel_, deviceId);
}
}
Expand Down

0 comments on commit 61abd3e

Please sign in to comment.