Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit70d38e3

Browse files
committed
Allow ReadStream to be consumed as raw block numbers.
Commits041b968 and6377e12 changed the interface ofscan_analyze_next_block() to take a ReadStream instead of a BlockNumberand a BufferAccessStrategy, and to return a value to indicate when thestream has run out of blocks.This caused integration problems for at least one known extension thatuses specially encoded BlockNumber values that map to differentunderlying storage, because acquire_sample_rows() sets up the stream sothat read_stream_next_buffer() reads blocks from the main fork of therelation's SMgrRelation.Provide read_stream_next_block(), as a way for such an extension toaccess the stream of raw BlockNumbers directly and forward them to itsown ReadBuffer() calls after decoding, as it could in earlier releases.The new function returns the BlockNumber and BufferAccessStrategy thatwere previously passed directly to scan_analyze_next_block().Alternatively, an extension could wrap the stream of BlockNumbers inanother ReadStream with a callback that performs any decoding requiredto arrive at real storage manager BlockNumber values, so that it couldbenefit from the I/O combining and concurrency provided byread_stream.c.Another class of table access method that does nothing inscan_analyze_next_block() because it is not block-oriented could usethis function to control the number of block sampling loops. It couldmatch the previous behavior with "return read_stream_next_block(stream,&bas) != InvalidBlockNumber".Ongoing work is expected to provide better ANALYZE support for tableaccess methods that don't behave like heapam with respect to storageblocks, but that will be for future releases.Back-patch to 17.Reported-by: Mats Kindahl <mats@timescale.com>Reviewed-by: Mats Kindahl <mats@timescale.com>Discussion:https://postgr.es/m/CA%2B14425%2BCcm07ocG97Fp%2BFrD9xUXqmBKFvecp0p%2BgV2YYR258Q%40mail.gmail.com
1 parent918e21d commit70d38e3

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

‎src/backend/storage/aio/read_stream.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -797,6 +797,20 @@ read_stream_next_buffer(ReadStream *stream, void **per_buffer_data)
797797
returnbuffer;
798798
}
799799

800+
/*
801+
* Transitional support for code that would like to perform or skip reads
802+
* itself, without using the stream. Returns, and consumes, the next block
803+
* number that would be read by the stream's look-ahead algorithm, or
804+
* InvalidBlockNumber if the end of the stream is reached. Also reports the
805+
* strategy that would be used to read it.
806+
*/
807+
BlockNumber
808+
read_stream_next_block(ReadStream*stream,BufferAccessStrategy*strategy)
809+
{
810+
*strategy=stream->ios[0].op.strategy;
811+
returnread_stream_get_block(stream,NULL);
812+
}
813+
800814
/*
801815
* Reset a read stream by releasing any queued up buffers, allowing the stream
802816
* to be used again for different blocks. This can be used to clear an

‎src/include/storage/read_stream.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,8 @@ extern ReadStream *read_stream_begin_relation(int flags,
6868
void*callback_private_data,
6969
size_tper_buffer_data_size);
7070
externBufferread_stream_next_buffer(ReadStream*stream,void**per_buffer_data);
71+
externBlockNumberread_stream_next_block(ReadStream*stream,
72+
BufferAccessStrategy*strategy);
7173
externReadStream*read_stream_begin_smgr_relation(intflags,
7274
BufferAccessStrategystrategy,
7375
SMgrRelationsmgr,

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp