decster commented on a change in pull request #3580:
URL: https://github.com/apache/incubator-doris/pull/3580#discussion_r425733678



##########
File path: be/src/olap/memory/column.cpp
##########
@@ -105,19 +108,102 @@ Status Column::capture_version(uint64_t version, 
vector<ColumnDelta*>* deltas,
     return Status::OK();
 }
 
-void Column::capture_latest(vector<ColumnDelta*>* deltas) const {
+void Column::capture_latest(vector<ColumnDelta*>* deltas, uint64_t* version) 
const {
     deltas->reserve(_versions.size() - _base_idx - 1);
     for (size_t i = _base_idx + 1; i < _versions.size(); i++) {
         deltas->emplace_back(_versions[i].delta.get());
     }
+    *version = _versions.back().version;
 }
 
 Status Column::read(uint64_t version, std::unique_ptr<ColumnReader>* reader) {
-    return Status::NotSupported("not supported");
+    ColumnType type = schema().type();
+    bool nullable = schema().is_nullable();
+    vector<ColumnDelta*> deltas;
+    uint64_t real_version;
+    RETURN_IF_ERROR(capture_version(version, &deltas, &real_version));
+
+#define CREATE_READER(T)                                                       
                   \
+    if (nullable) {                                                            
                   \
+        (*reader).reset(                                                       
                   \
+                new TypedColumnReader<T, true>(this, version, real_version, 
std::move(deltas)));  \
+    } else {                                                                   
                   \
+        (*reader).reset(                                                       
                   \
+                new TypedColumnReader<T, false>(this, version, real_version, 
std::move(deltas))); \
+    }
+
+    switch (type) {
+    case OLAP_FIELD_TYPE_BOOL:
+    case OLAP_FIELD_TYPE_TINYINT:
+        CREATE_READER(int8_t)
+        break;
+    case OLAP_FIELD_TYPE_SMALLINT:
+        CREATE_READER(int16_t)
+        break;
+    case OLAP_FIELD_TYPE_INT:
+        CREATE_READER(int32_t)
+        break;
+    case OLAP_FIELD_TYPE_BIGINT:
+        CREATE_READER(int64_t)
+        break;
+    case OLAP_FIELD_TYPE_LARGEINT:
+        CREATE_READER(int128_t)
+        break;
+    case OLAP_FIELD_TYPE_FLOAT:
+        CREATE_READER(float)
+        break;
+    case OLAP_FIELD_TYPE_DOUBLE:
+        CREATE_READER(double)
+        break;
+    default:
+        return Status::NotSupported("create column reader: type not 
supported");
+    }

Review comment:
       fixed




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to