-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #161 from poissoncorp/v5.2
Bulk Insert
- Loading branch information
Showing
19 changed files
with
790 additions
and
57 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import json | ||
from typing import Optional | ||
|
||
import requests | ||
|
||
from ravendb.http.server_node import ServerNode | ||
from ravendb.http.raven_command import RavenCommand, VoidRavenCommand | ||
|
||
|
||
class GetNextOperationIdCommand(RavenCommand[int]): | ||
def __init__(self): | ||
super(GetNextOperationIdCommand, self).__init__(int) | ||
self._node_tag = 0 | ||
|
||
def is_read_request(self) -> bool: | ||
return False # disable caching | ||
|
||
def create_request(self, node: ServerNode) -> requests.Request: | ||
return requests.Request("GET", f"{node.url}/databases/{node.database}/operations/next-operation-id") | ||
|
||
def set_response(self, response: Optional[str], from_cache: bool) -> None: | ||
json_node = json.loads(response) | ||
self.result = json_node.get("Id", None) | ||
self._node_tag = json_node.get("NodeTag", None) | ||
|
||
|
||
class KillOperationCommand(VoidRavenCommand): | ||
def __init__(self, operation_id: int, node_tag: Optional[str] = None): | ||
super(KillOperationCommand, self).__init__() | ||
self._id = operation_id | ||
self._selected_node_tag = node_tag | ||
|
||
def create_request(self, node: ServerNode) -> requests.Request: | ||
return requests.Request("POST", f"{node.url}/databases/{node.database}/operations/kill?id={self._id}") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
from typing import Optional | ||
|
||
from ravendb.exceptions.raven_exceptions import RavenException | ||
|
||
|
||
class BulkInsertAbortedException(RavenException): | ||
def __init__(self, message: str, cause: Optional[Exception] = None): | ||
super(BulkInsertAbortedException, self).__init__(message, cause) | ||
|
||
|
||
class BulkInsertProtocolViolationException(RavenException): | ||
def __init__(self, message: str, cause: Optional[Exception] = None): | ||
super(BulkInsertProtocolViolationException, self).__init__(message, cause) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
ravendb/tests/jvm_migrated_tests/attachments_tests/test_bulk_insert_attachments.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
from ravendb.tests.test_base import TestBase | ||
|
||
|
||
class TestBulkInsertAttachments(TestBase): | ||
def setUp(self): | ||
super(TestBulkInsertAttachments, self).setUp() | ||
|
||
def test_store_async_null_id(self): | ||
def callback(): | ||
with self.store.bulk_insert() as bulk_insert: | ||
bulk_insert.attachments_for(None) | ||
|
||
self.assertRaisesWithMessage(callback, ValueError, "Document id cannot be None or empty.") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.