Skip to content

Commit

Permalink
Remove sorting.py (#8000)
Browse files Browse the repository at this point in the history
Co-authored-by: Przemysław Uznański <[email protected]>
GitOrigin-RevId: 9871913a06a1688ac33bd077377943f8ac71e104
  • Loading branch information
2 people authored and Manul from Pathway committed Jan 14, 2025
1 parent 7ca7667 commit 6afb042
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 243 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm

### Changed
- **BREAKING**: `pw.io.deltalake.read` now requires explicit specification of primary key fields.
- **BREAKING**: `pw.indexing.build_sorted_index`, `pw.indexing.retrieve_prev_next_values`, `pw.indexing.sort_from_index` and `pw.indexing.SortedIndex` are removed. Sorting is now done with `pw.Table.sort`.

### Fixed
- `generate_class` method in `Schema` now correctly renders columns of `UnionType` and `None` types.
Expand Down
10 changes: 0 additions & 10 deletions python/pathway/stdlib/indexing/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,6 @@
UsearchKnnFactory,
)
from .retrievers import AbstractRetrieverFactory
from .sorting import (
SortedIndex,
build_sorted_index,
retrieve_prev_next_values,
sort_from_index,
)
from .vector_document_index import (
default_brute_force_knn_document_index,
default_lsh_knn_document_index,
Expand All @@ -48,13 +42,9 @@
"TantivyBM25Factory",
"HybridIndex",
"HybridIndexFactory",
"SortedIndex",
"default_vector_document_index",
"default_lsh_knn_document_index",
"default_usearch_knn_document_index",
"default_brute_force_knn_document_index",
"default_full_text_document_index",
"retrieve_prev_next_values",
"sort_from_index",
"build_sorted_index",
]
230 changes: 0 additions & 230 deletions python/pathway/stdlib/indexing/sorting.py

This file was deleted.

27 changes: 24 additions & 3 deletions python/pathway/stdlib/statistical/_interpolate.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,29 @@ class InterpolateMode(Enum):
LINEAR = 0


def _retrieving_prev_next_value(tab: pw.Table) -> pw.Table:
return tab.with_columns(
prev_value=pw.coalesce(
pw.this.prev_value, tab.ix(pw.this.prev, optional=True).prev_value
),
next_value=pw.coalesce(
pw.this.next_value, tab.ix(pw.this.next, optional=True).next_value
),
)


def _retrieve_prev_next_values(ordered_table: pw.Table) -> pw.Table:

ordered_table = ordered_table[["prev", "next", "value"]]
ordered_table = ordered_table.with_columns(
prev_value=pw.require(pw.this.id, pw.this.value),
next_value=pw.require(pw.this.id, pw.this.value),
)
return pw.iterate(_retrieving_prev_next_value, tab=ordered_table)[
["prev_value", "next_value"]
]


@trace_user_frame
def interpolate(
self: pw.Table,
Expand Down Expand Up @@ -78,8 +101,6 @@ def interpolate(
6 | 6.0 | 60.0
"""

from pathway.stdlib.indexing.sorting import retrieve_prev_next_values

if mode != InterpolateMode.LINEAR:
raise ValueError(
"""interpolate: Invalid mode. Only Interpolate.LINEAR is currently available."""
Expand Down Expand Up @@ -119,7 +140,7 @@ def interpolate(
timestamp=timestamp, value=value
)

table_with_prev_next = retrieve_prev_next_values(sorted_timestamp_value)
table_with_prev_next = _retrieve_prev_next_values(sorted_timestamp_value)

interpolated_table = table_with_prev_next + sorted_timestamp_value

Expand Down

0 comments on commit 6afb042

Please sign in to comment.