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

RDBC-697 Time series session API #186

Merged
merged 7 commits into from
Nov 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions ravendb/constants.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
import sys

int_max = 0x7FFFFFF
min_normal = sys.float_info.min
json_serialize_method_name = "to_json"
nan_value = float("nan")


class Documents:
Expand Down
87 changes: 0 additions & 87 deletions ravendb/data/timeseries.py

This file was deleted.

42 changes: 35 additions & 7 deletions ravendb/documents/commands/batches.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@
DocumentCountersOperation,
CounterOperationType,
)
from ravendb.documents.operations.time_series import TimeSeriesOperation
from ravendb.documents.session.misc import TransactionMode, ForceRevisionStrategy
from ravendb.documents.time_series import TimeSeriesOperations
from ravendb.http.raven_command import RavenCommand
from ravendb.http.server_node import ServerNode
from ravendb.json.result import BatchCommandResult
Expand Down Expand Up @@ -236,13 +238,11 @@ def __init__(
name: str = None,
change_vector: str = None,
command_type: CommandType = None,
on_before_save_changes: Callable = None,
):
self._key = key
self._name = name
self._change_vector = change_vector
self._command_type = command_type
self._on_before_save_changes = on_before_save_changes

@property
def key(self) -> str:
Expand All @@ -260,11 +260,8 @@ def change_vector(self) -> str:
def command_type(self) -> CommandType:
return self._command_type

@property
def on_before_save_changes(
self,
) -> Callable[[InMemoryDocumentSessionOperations], None]:
return self._on_before_save_changes
def on_before_save_changes(self, session: InMemoryDocumentSessionOperations) -> None:
pass

@abstractmethod
def serialize(self, conventions: DocumentConventions) -> dict:
Expand Down Expand Up @@ -635,6 +632,37 @@ def serialize(self, conventions: DocumentConventions) -> dict:
return {"Id": self._key, "Name": self.name, "ChangeVector": self.change_vector, "Type": self.command_type}


class TimeSeriesBatchCommandData(CommandData):
def __init__(
self,
document_id: str,
name: str,
appends: Optional[List[TimeSeriesOperation.AppendOperation]],
deletes: Optional[List[TimeSeriesOperation.DeleteOperation]],
):
if not document_id:
raise ValueError("Document id cannot be None")
if not name:
raise ValueError("Name cannot be None")

super(TimeSeriesBatchCommandData, self).__init__(document_id, name, None, CommandType.TIME_SERIES)
self.time_series = TimeSeriesOperation()
self.time_series.name = name

if appends:
for append_operation in appends:
self.time_series.append(append_operation)
if deletes:
for delete_operation in deletes:
self.time_series.delete(delete_operation)

def serialize(self, conventions: DocumentConventions) -> dict:
return {"Id": self.key, "TimeSeries": self.time_series.to_json(), "Type": "TimeSeries"}

def on_before_save_changes(self, session: InMemoryDocumentSessionOperations) -> None:
pass


# ------------ OPTIONS ------------


Expand Down
4 changes: 4 additions & 0 deletions ravendb/documents/conventions.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@


class DocumentConventions(object):
@classmethod
def default_conventions(cls):
return cls()

__cached_default_type_collection_names: Dict[type, str] = {}

def __init__(self):
Expand Down
2 changes: 2 additions & 0 deletions ravendb/documents/operations/batch.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,8 @@ def get_command_type(obj_node: dict) -> CommandType:
pass
elif command_type == CommandType.COUNTERS:
self.__handle_counters(batch_result)
elif command_type == CommandType.TIME_SERIES:
break # todo: RavenDB-13474 add to time series cache
elif command_type == CommandType.TIME_SERIES_COPY or command_type == CommandType.BATCH_PATCH:
break
else:
Expand Down
Loading
Loading