mirror of
https://github.com/apache/arrow.git
synced 2026-10-29 00:56:31 +08:00
Cache column indices
Change-Id: Iacd2dc62f7379c7907bdc392658ea39ff80e1a33
This commit is contained in:
1 parent
0c3221318b
commit
c1fb93900f
1 file changed
+6
-5
@@ -44,6 +44,7 @@ cdef class ParquetReader:
|
||||
cdef:
|
||||
ParquetAllocator allocator
|
||||
unique_ptr[FileReader] reader
|
||||
column_idx_map
|
||||
|
||||
def __cinit__(self):
|
||||
self.allocator.set_pool(default_memory_pool())
|
||||
@@ -92,15 +93,15 @@ cdef class ParquetReader:
|
||||
Integer index of the position of the column
|
||||
"""
|
||||
cdef:
|
||||
c_string column_path = tobytes(column_name)
|
||||
const FileMetaData* metadata = self.reader.get().parquet_reader().metadata()
|
||||
int i = 0
|
||||
|
||||
for i in range(0, metadata.num_columns()):
|
||||
if metadata.schema().Column(i).path().get().ToDotString() == column_path:
|
||||
return i
|
||||
if self.column_idx_map is None:
|
||||
self.column_idx_map = {}
|
||||
for i in range(0, metadata.num_columns()):
|
||||
self.column_idx_map[str(metadata.schema().Column(i).path().get().ToDotString())] = i
|
||||
|
||||
return 0
|
||||
return self.column_idx_map[column_name]
|
||||
|
||||
def read_column(self, int column_index):
|
||||
cdef:
|
||||
|
||||
Reference in new issue
Block a user