-
Notifications
You must be signed in to change notification settings - Fork 9
MAPRDB-397, MAPRDB-459 #1
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
Changes from all commits
b041a09
e5aee88
bbc01c9
692ac29
b0a7f0d
088c95e
bda32ba
efc72f1
dd5d22c
2a90e6f
2566a28
eebec18
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| .project | ||
| .classpath | ||
| .checkstyle | ||
| .settings/ | ||
| .idea/ | ||
| *.log | ||
| *.lck | ||
| *.iml | ||
| target/ | ||
| *.DS_Store | ||
| *.patch | ||
| *~ | ||
| git.properties |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,67 @@ | ||
| from entity.document.Document import Document | ||
| from entity.document.DocumentStore import DocumentStore | ||
| from entity.storage.ConnectionManager import ConnectionManager | ||
| from entity.storage.Connection import Connection | ||
|
|
||
|
|
||
| """Example for customer may works with Python client""" | ||
| """Create a connection, get store, insert new document into store""" | ||
| # create a connection by path:user@password | ||
| connection = Connection(ConnectionManager.get_connection(url="ojai:mapr:user@password")) | ||
|
|
||
| # Get a store and keep it as DocumentStore object | ||
| store = DocumentStore(connection.get_store(store_name="/test_name")) | ||
|
|
||
| # Json string or json map | ||
| json_string = "json string" | ||
|
|
||
| # Create new document from json_document | ||
| new_document = connection.new_document(json_string) | ||
|
|
||
| # Insert new document into the store | ||
| store.insert_or_replace(new_document) | ||
|
|
||
| # close | ||
| store.close() | ||
| connection.close() | ||
|
|
||
|
|
||
| """Create a connection, get store, find document by id""" | ||
| # create a connection by path:user@password | ||
| connection = Connection(ConnectionManager.get_connection(url="ojai:mapr:user@password")) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am going to update the functional spec with the new URL format, please update the example with a matching format.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You mean that its must looks like |
||
|
|
||
| # Get a store and keep it as DocumentStore object | ||
| store = DocumentStore(connection.get_store(store_name="/test_name")) | ||
|
|
||
| # Fetch document from store by id | ||
| json_document = store.find_by_id("id_005") | ||
|
|
||
| # close | ||
| store.close() | ||
| connection.close() | ||
|
|
||
|
|
||
| """Create a connection, get store, create a query, execute find query and got through document stream""" | ||
| # create a connection by path:user@password | ||
| connection = Connection(ConnectionManager.get_connection(url="ojai:mapr:user@password")) | ||
|
|
||
| # Get a store and keep it as DocumentStore object | ||
| store = DocumentStore(connection.get_store(store_name="/test_name")) | ||
|
|
||
| # Build query | ||
| query = connection.new_query().select("_id", "city").build() | ||
|
|
||
| # fetch all document from store by query | ||
| document_stream = store.find_query(query) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we need to wrap the return value in the constructor like above in case of
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think that the |
||
|
|
||
| # go to fetched records and pritnt them | ||
| for document in document_stream.result: | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Where is the |
||
| print document | ||
|
|
||
|
|
||
| # close | ||
| store.close() | ||
| connection.close() | ||
|
|
||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,169 @@ | ||
| from abc import ABCMeta, abstractmethod | ||
|
|
||
|
|
||
| class Document: | ||
| __metaclass__ = ABCMeta | ||
|
|
||
| @abstractmethod | ||
| def set_id(self, _id): | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can this single method accept both
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, here will check which _id type was given |
||
| raise NotImplementedError("Should have implemented this") | ||
|
|
||
| @abstractmethod | ||
| def get_id(self): | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Would this return
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Only in python3.5 and up |
||
| raise NotImplementedError("Should have implemented this") | ||
|
|
||
| @abstractmethod | ||
| def get_id_string(self): | ||
| raise NotImplementedError("Should have implemented this") | ||
|
|
||
| @abstractmethod | ||
| def get_id_binary(self): | ||
| raise NotImplementedError("Should have implemented this") | ||
|
|
||
| @abstractmethod | ||
| def size(self): | ||
| raise NotImplementedError("Should have implemented this") | ||
|
|
||
| @abstractmethod | ||
| def empty(self): | ||
| raise NotImplementedError("Should have implemented this") | ||
|
|
||
| @abstractmethod | ||
| def set(self, field_path, value): | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Similar to above declaration, if this method is supposed to pass a
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This method should work not only with
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In the Document abstract class we already have a method for each type, like set_time, set_map, set_document. So we can remove just set() method, or use it as a main method which will callable. |
||
| raise NotImplementedError("Should have implemented this") | ||
|
|
||
| @abstractmethod | ||
| def set_boolean(self, field_path, value): | ||
| raise NotImplementedError("Should have implemented this") | ||
|
|
||
| @abstractmethod | ||
| def set_byte(self, field_path, value): | ||
| raise NotImplementedError("Should have implemented this") | ||
|
|
||
| @abstractmethod | ||
| def set_long(self, field_path, value): | ||
| raise NotImplementedError("Should have implemented this") | ||
|
|
||
| @abstractmethod | ||
| def set_float(self, field_path, value): | ||
| raise NotImplementedError("Should have implemented this") | ||
|
|
||
| @abstractmethod | ||
| def set_decimal(self, field_path, value): | ||
| raise NotImplementedError("Should have implemented this") | ||
|
|
||
| @abstractmethod | ||
| def set_time(self, field_path, value): | ||
| raise NotImplementedError("Should have implemented this") | ||
|
|
||
| @abstractmethod | ||
| def set_date(self, field_path, value): | ||
| raise NotImplementedError("Should have implemented this") | ||
|
|
||
| @abstractmethod | ||
| def set_timestamp(self, field_path, value): | ||
| raise NotImplementedError("Should have implemented this") | ||
|
|
||
| @abstractmethod | ||
| def set_interval(self, field_path, value): | ||
| raise NotImplementedError("Should have implemented this") | ||
|
|
||
| @abstractmethod | ||
| def set_byte_array(self, field_path, value, offset=None, length=None): | ||
| raise NotImplementedError("Should have implemented this") | ||
|
|
||
| @abstractmethod | ||
| def set_map(self, field_path, value): | ||
| raise NotImplementedError("Should have implemented this") | ||
|
|
||
| @abstractmethod | ||
| def set_document(self, field_path, value): | ||
| raise NotImplementedError("Should have implemented this") | ||
|
|
||
| @abstractmethod | ||
| def set_value_obj(self, field_path, value): | ||
| raise NotImplementedError("Should have implemented this") | ||
|
|
||
| @abstractmethod | ||
| def set_array(self, field_path, values): | ||
| raise NotImplementedError("Should have implemented this") | ||
|
|
||
| @abstractmethod | ||
| def set_null(self, field_path): | ||
| raise NotImplementedError("Should have implemented this") | ||
|
|
||
| @abstractmethod | ||
| def delete(self, field_path): | ||
| raise NotImplementedError("Should have implemented this") | ||
|
|
||
| @abstractmethod | ||
| def get_string(self, field_path): | ||
| raise NotImplementedError("Should have implemented this") | ||
|
|
||
| @abstractmethod | ||
| def get_boolean(self, field_path): | ||
| raise NotImplementedError("Should have implemented this") | ||
|
|
||
| @abstractmethod | ||
| def get_byte(self, field_path): | ||
| raise NotImplementedError("Should have implemented this") | ||
|
|
||
| @abstractmethod | ||
| def get_int(self, field_path): | ||
| raise NotImplementedError("Should have implemented this") | ||
|
|
||
| @abstractmethod | ||
| def get_long(self, field_path): | ||
| raise NotImplementedError("Should have implemented this") | ||
|
|
||
| @abstractmethod | ||
| def get_float(self, field_path): | ||
| raise NotImplementedError("Should have implemented this") | ||
|
|
||
| @abstractmethod | ||
| def get_double(self, field_path): | ||
| raise NotImplementedError("Should have implemented this") | ||
|
|
||
| @abstractmethod | ||
| def get_decimal(self, field_path): | ||
| raise NotImplementedError("Should have implemented this") | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please note that
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sure |
||
|
|
||
| @abstractmethod | ||
| def get_time(self, field_path): | ||
| raise NotImplementedError("Should have implemented this") | ||
|
|
||
| @abstractmethod | ||
| def get_date(self, field_path): | ||
| raise NotImplementedError("Should have implemented this") | ||
|
|
||
| @abstractmethod | ||
| def get_timestamp(self, field_path): | ||
| raise NotImplementedError("Should have implemented this") | ||
|
|
||
| @abstractmethod | ||
| def get_binary(self, field_path): | ||
| raise NotImplementedError("Should have implemented this") | ||
|
|
||
| @abstractmethod | ||
| def get_interval(self, field_path): | ||
| raise NotImplementedError("Should have implemented this") | ||
|
|
||
| @abstractmethod | ||
| def get_value(self, field_path): | ||
| raise NotImplementedError("Should have implemented this") | ||
|
|
||
| @abstractmethod | ||
| def get_map(self, field_path): | ||
| raise NotImplementedError("Should have implemented this") | ||
|
|
||
| @abstractmethod | ||
| def get_list(self, field_path): | ||
| raise NotImplementedError("Should have implemented this") | ||
|
|
||
| @abstractmethod | ||
| def as_reader(self, field_path=None): | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since we won't implement
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sure |
||
| raise NotImplementedError("Should have implemented this") | ||
|
|
||
| @abstractmethod | ||
| def as_map(self): | ||
| raise NotImplementedError("Should have implemented this") | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use a valid JSON Document String, something like
{"name": "Joe", "age": 50, "address": {"street": "555 Moon Way", "city": "Gotham"}}There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed