Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ReverseScannableDataInterface #23

Closed
kamarton opened this issue Sep 19, 2019 · 2 comments
Closed

ReverseScannableDataInterface #23

kamarton opened this issue Sep 19, 2019 · 2 comments

Comments

@kamarton
Copy link
Contributor

What steps will reproduce the problem?

There may be times when data needs to be scanned as reversed. Currently there is no specific interface defined, but can using with reversed Sort orders.

  • RDBMS: supported partially or with sort
  • NoSQL:
    • mongoDb: supported by sort
    • Apache HBase: supported by scanner level
    • Google Bigtable: not supported

What is the expected result?

$reader->withReverseScanning()->read();
condition of data reader result
if supported it, or partially supported scanning in reverse mode
if not supported it, but supported sorting reverses sorting immediately before scanning
If not supported it throw exception, or
implement it at PHP level after reading the data, if possible.

examples:

  • if supported it or partially supported
SELECT * FROM (
    SELECT *
    FROM ...
    WHERE id > :first
    ORDER BY id DESC
) ORDER BY id ASC LIMIT 3  -- this is not real reverse scanning
  • if not supported it, but supported sorting
    exmaple in IteratorDataReader
  • If not supported it
    Depending on the number of data, use the array_reverse() function, but for example, if the number of data can be hundreds of millions, can decide to throw an exception based on the withLimit(). (typically with noSQL)

What do you get instead?

// reverse sorting
foreach ($order as &$sorting) {
$sorting = $sorting === 'asc' ? 'desc' : 'asc';
}
unset($sorting);
$dataReader = $dataReader->withSort($sort->withOrder($order));

Additional info

Also consider giving Sort awithInversed() or withReverseSorting() method.

Q A
Version 1.0.0 under development
PHP version -
Operating system -
@samdark
Copy link
Member

samdark commented Sep 19, 2019

What's the practical use case for it? Is it going to be required in paginators?

@kamarton
Copy link
Contributor Author

Yes, she came up with the Paginator. Unnecessary abstraction. I thought the DataReader layer is easier to handle reverse scanning if this is supported or not.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants