MCPcopy Create free account
hub / github.com/apache/cloudberry / SetNextFileSegForRead

Function SetNextFileSegForRead

src/backend/access/appendonly/appendonlyam.c:141–326  ·  view source on GitHub ↗

* Open the next file segment to scan and allocate all resources needed for it. */

Source from the content-addressed store, hash-verified

139 * Open the next file segment to scan and allocate all resources needed for it.
140 */
141bool
142SetNextFileSegForRead(AppendOnlyScanDesc scan)
143{
144 Relation reln = scan->aos_rd;
145 int segno = -1;
146 int64 eof = 0;
147 int formatversion = -2; /* some invalid value */
148 bool finished_all_files = true; /* assume */
149 int32 fileSegNo;
150 bool isParallel = false;
151 ParallelBlockTableScanDesc pbscan = NULL;
152
153 if (scan->rs_base.rs_parallel != NULL)
154 {
155 isParallel = true;
156 pbscan = (ParallelBlockTableScanDesc) scan->rs_base.rs_parallel;
157 }
158
159
160 Assert(scan->aos_need_new_segfile); /* only call me when last segfile
161 * completed */
162 Assert(!scan->aos_done_all_segfiles); /* don't call me if I told you to
163 * stop */
164
165
166 if (!scan->initedStorageRoutines)
167 {
168 PGFunction *fns = NULL;
169 RelationOpenSmgr(reln);
170
171 AppendOnlyStorageRead_Init(
172 &scan->storageRead,
173 scan->aoScanInitContext,
174 scan->usableBlockSize,
175 NameStr(scan->aos_rd->rd_rel->relname),
176 RelationGetRelid(scan->aos_rd),
177 scan->title,
178 &scan->storageAttributes,
179 &scan->aos_rd->rd_node, reln->rd_smgr->smgr_ao);
180
181 /*
182 * There is no guarantee that the current memory context will be
183 * preserved between calls, so switch to a safe memory context for
184 * retrieving compression information.
185 */
186 MemoryContext oldMemoryContext = MemoryContextSwitchTo(scan->aoScanInitContext);
187
188 /* Get the relation specific compression functions */
189
190 fns = get_funcs_for_compression(scan->storageAttributes.compressType);
191 scan->storageRead.compression_functions = fns;
192
193 if (scan->storageRead.compression_functions != NULL)
194 {
195 PGFunction cons = fns[COMPRESSION_CONSTRUCTOR];
196 CompressionState *cs;
197 StorageAttributes sa;
198

Callers 2

getNextBlockFunction · 0.85
appendonly_getsegmentFunction · 0.85

Tested by

no test coverage detected