Exemple #1
0
    def test_basic_windowing(self, db_session, windowsize, expected):
        """Check that windowing returns the correct batches of rows."""
        testdata = [{"name": l, "enabled": True} for l in string.lowercase]
        db_session.execute(test_cw.insert().values(testdata))

        windows = column_windows(db_session, test_cw.c.name, windowsize=windowsize)

        assert window_query_results(db_session, windows) == expected
Exemple #2
0
    def test_basic_windowing(self, db_session, windowsize, expected):
        """Check that windowing returns the correct batches of rows."""
        testdata = [{'name': l, 'enabled': True} for l in string.lowercase]
        db_session.execute(test_cw.insert().values(testdata))

        windows = column_windows(db_session,
                                 test_cw.c.name,
                                 windowsize=windowsize)

        assert window_query_results(db_session, windows) == expected
Exemple #3
0
    def test_filtered_windowing(self, db_session, windowsize, expected):
        """Check that windowing respects the where clause."""
        testdata = []
        enabled = string.lowercase[:13]
        disabled = string.lowercase[13:]
        testdata.extend([{"name": l, "enabled": True} for l in enabled])
        testdata.extend([{"name": l, "enabled": False} for l in disabled])
        db_session.execute(test_cw.insert().values(testdata))

        filter_ = test_cw.c.enabled
        windows = column_windows(db_session, test_cw.c.name, windowsize=windowsize, where=filter_)

        assert window_query_results(db_session, windows, filter_) == expected
Exemple #4
0
def _all_annotations(session, windowsize=2000):
    # This is using a windowed query for loading all annotations in batches.
    # It is the most performant way of loading a big set of records from
    # the database while still supporting eagerloading of associated
    # document data.
    windows = column_windows(session=session,
                             column=models.Annotation.updated,  # implicit ASC
                             windowsize=windowsize,
                             where=_annotation_filter())
    query = _eager_loaded_annotations(session).filter(_annotation_filter())

    for window in windows:
        for a in query.filter(window):
            yield a
Exemple #5
0
def _all_annotations(session, windowsize=2000):
    # This is using a windowed query for loading all annotations in batches.
    # It is the most performant way of loading a big set of records from
    # the database while still supporting eagerloading of associated
    # document data.
    windows = column_windows(session=session,
                             column=models.Annotation.updated,  # implicit ASC
                             windowsize=windowsize,
                             where=_annotation_filter())
    query = _eager_loaded_annotations(session).filter(_annotation_filter())

    for window in windows:
        for a in query.filter(window):
            yield a
Exemple #6
0
    def test_filtered_windowing(self, db_session, windowsize, expected):
        """Check that windowing respects the where clause."""
        testdata = []
        enabled = string.lowercase[:13]
        disabled = string.lowercase[13:]
        testdata.extend([{'name': l, 'enabled': True} for l in enabled])
        testdata.extend([{'name': l, 'enabled': False} for l in disabled])
        db_session.execute(test_cw.insert().values(testdata))

        filter_ = test_cw.c.enabled
        windows = column_windows(db_session,
                                 test_cw.c.name,
                                 windowsize=windowsize,
                                 where=filter_)

        assert window_query_results(db_session, windows, filter_) == expected