Hi all, I am trying to implement predicate-pushdown in my PostgreSQL->ORC 
foreign data wrapper (FDW). 

If I understand correctly, I should be able to:

1) skip the entire file based on the statistics returned by 
Reader::getStatistics()

2) skip individual stripes based on the statistics returned by 
Reader::getStripeStatistics(stripeNumber)

3) skip individual row groups based on the stats returned by 
StripeStatistics::getRowIndexStatistics(columnId, indexId)

Is that correct so far? I understand that will have to apply the predicate 
expression to the min/max value for each of the above-mentioned stats.

I’m having trouble figuring out how to actually skip around within the file.

The file that I am experimenting with is the demo-11-none.orc file from the 
examples directory.

Here are the details of this file:

stt=# SELECT * FROM 
orc_get_file_info('/work/stt/orc/examples/demo-11-none.orc');
┌─[ RECORD 1 ]───────────┬───────────┐
│ file_size              │ 5147970   │
│ columns                │ 10        │
│ rows                   │ 1920800   │
│ stripes                │ 385       │
│ version                │ 0.11      │
│ writer_id              │ orc_java  │
│ compression_kind       │ none      │
│ writer_version         │ HIVE-8732 │
│ row_index_stride       │ 10000     │
│ stripe_stat_count      │ 385       │
│ content_length         │ 5069718   │
│ strip_stats_length     │ 70748     │
│ file_footer_length     │ 7481      │
│ file_postscript_length │ 22        │
└────────────────────────┴───────────┘

I’m using a RowReader to scan my way through the file - when I call 
RowReader::createRowBatch(), I specify a batch size of 1000 rows.

I can figure out how to use the stats returned by Reader::getStatistics() - 
I’ll just skip to the next file of the predicate expression cannot be satisfied 
according to those stats.

I can read the stats for each stripe and can evaluate the predicate.  But my 
question is, how do I skip to the next stripe?

Do I just do something like this: 

if (predicateRefutes(stripeStats))
{
   rowReader->seekToRow(rowReader->getRowNumber() + 
stripeInfo->getNumerOfRows());
   rowReader->next(myColumnVectorBatch);
}

In other words, is seekToRow() the proper way to move from stripe to stripe?  

Does the batch size (1000 rows in my case) have anything to do with this?

Thanks.
    
             — Korry

Reply via email to