diff --git a/README.md b/README.md
index 86676c2..48e45ab 100644
--- a/README.md
+++ b/README.md
@@ -1,6 +1,6 @@
# Python Client for Pilosa
-
+
@@ -12,7 +12,7 @@ Python client for Pilosa high performance distributed row index.
## What's New?
-See: [CHANGELOG](CHANGELOG.md)
+See: [CHANGELOG](https://github.com/pilosa/python-pilosa/blob/master/CHANGELOG.md)
## Requirements
@@ -50,10 +50,10 @@ myfield = myindex.field("myfield")
# make sure the index and field exists on the server
client.sync_schema(schema)
-# Send a SetBit query. PilosaError is thrown if execution of the query fails.
+# Send a Set query. PilosaError is thrown if execution of the query fails.
client.query(myfield.set(5, 42))
-# Send a Bitmap query. PilosaError is thrown if execution of the query fails.
+# Send a Row query. PilosaError is thrown if execution of the query fails.
response = client.query(myfield.row(5))
# Get the result
@@ -73,27 +73,27 @@ response = client.query(
)
for result in response.results:
# Act on the result
- print(result)
+ print(result.row.columns)
```
## Documentation
### Data Model and Queries
-See: [Data Model and Queries](docs/data-model-queries.md)
+See: [Data Model and Queries](https://github.com/pilosa/python-pilosa/blob/master/docs/data-model-queries.md)
### Executing Queries
-See: [Server Interaction](docs/server-interaction.md)
+See: [Server Interaction](https://github.com/pilosa/python-pilosa/blob/master/docs/server-interaction.md)
### Importing and Exporting Data
-See: [Importing and Exporting Data](docs/imports.md)
+See: [Importing and Exporting Data](https://github.com/pilosa/python-pilosa/blob/master/docs/imports.md)
## Contributing
-See: [CONTRIBUTING](CONTRIBUTING.md)
+See: [CONTRIBUTING](https://github.com/pilosa/python-pilosa/blob/master/CONTRIBUTING.md)
## License
-See: [LICENSE](LICENSE)
+See: [LICENSE](https://github.com/pilosa/python-pilosa/blob/master/LICENSE)
diff --git a/docs/data-model-queries.md b/docs/data-model-queries.md
index ddf33ae..0c7decd 100644
--- a/docs/data-model-queries.md
+++ b/docs/data-model-queries.md
@@ -17,7 +17,7 @@ Fields are created with a call to `index.field` method:
stargazer = repository.field("stargazer")
```
-Similar to index objects, you can pass custom options to the `index.field` method:
+You can pass custom options to the `index.field` method:
```python
stargazer = repository.field("stargazer", time_quantum=pilosa.TimeQuantum.YEAR_MONTH_DAY)
@@ -30,7 +30,7 @@ Once you have indexes and field objects created, you can create queries for them
For instance, `Row` queries work on rows; use a field object to create those queries:
```python
-row_query = stargazer.row(1) # corresponds to PQL: Bitmap(field='stargazer', row=1)
+row_query = stargazer.row(1) # corresponds to PQL: Row(stargazer=1)
```
`Union` queries work on columns; use the index object to create them:
@@ -47,10 +47,10 @@ query = repository.batch_query(
repository.union(stargazer.row(100), stargazer.row(5)))
```
-The recommended way of creating query objects is, using dedicated methods attached to index and field objects. But sometimes it would be desirable to send raw queries to Pilosa. You can use the `index.raw_query` method for that. Note that, query string is not validated before sending to the server:
+The recommended way of creating query objects is, using dedicated methods attached to index and field objects. But sometimes it would be desirable to send raw queries to Pilosa. You can use the `index.raw_query` method for that. Note that, the query string is not validated before sending to the server:
```python
-query = repository.raw_query("Bitmap(field='stargazer', row=5)")
+query = repository.raw_query("Row(stargazer=5)")
```
This client supports [Range encoded fields](https://www.pilosa.com/docs/latest/query-language/#range-bsi). Read [Range Encoded Bitmaps](https://www.pilosa.com/blog/range-encoded-bitmaps/) blog post for more information about the BSI implementation of range encoding in Pilosa.
@@ -58,30 +58,30 @@ This client supports [Range encoded fields](https://www.pilosa.com/docs/latest/q
In order to use range encoded fields, a field should be created with one or more integer fields. Each field should have their minimums and maximums set. Here's how you would do that using this library:
```python
index = schema.index("animals")
-field = index.field("traits", fields=[pilosa.IntField.int("captivity", min=0, max=956)])
+traits = index.field("traits", int_min=0, int_max=956)
+captivity = index.field("captivity")
client.sync_schema(schema)
```
-If the field with the necessary field already exists on the server, you don't need to create the field instance, `client.syncSchema(schema)` would load that to `schema`. You can then add some data:
+If the field with the necessary field already exists on the server, you don't need to create the field instance, `client.sync_schema(schema)` would load that to `schema`. You can then add some data:
```python
# Add the captivity values to the field.
-captivity = field.field("captivity")
data = [3, 392, 47, 956, 219, 14, 47, 504, 21, 0, 123, 318]
query = index.batch_query()
for i, x in enumerate(data):
column = i + 1
- query.add(captivity.setvalue(column, x))
+ query.add(traits.setvalue(column, x))
client.query(query)
```
Let's write a range query:
```python
# Query for all animals with more than 100 specimens
-response = client.query(captivity.gt(100))
+response = client.query(traits.gt(100))
print(response.result.row.columns)
# Query for the total number of animals in captivity
-response = client.query(captivity.sum())
+response = client.query(traits.sum())
print(response.result.value)
```
@@ -93,7 +93,7 @@ client.query(index.batch_query(
field.set(42, 6)
))
# Query for the total number of animals in captivity where row 42 is set
-response = client.query(captivity.sum(field.row(42)))
+response = client.query(traits.sum(captivity.row(42)))
print(response.result.value)
```
diff --git a/docs/imports.md b/docs/imports.md
index e3cd629..3727371 100644
--- a/docs/imports.md
+++ b/docs/imports.md
@@ -1,6 +1,6 @@
# Importing Data
-If you have large amounts of data, it is more efficient to import it to Pilosa instead of several `SetBit` queries.
+If you have large amounts of data, it is more efficient to import it to Pilosa instead of several `Set` queries.
This library supports importing columns in the CSV (comma separated values) format:
```
diff --git a/docs/server-interaction.md b/docs/server-interaction.md
index c536705..b67b8f2 100644
--- a/docs/server-interaction.md
+++ b/docs/server-interaction.md
@@ -42,7 +42,7 @@ client = pilosa.Client()
To use a a custom server address, pass the address in the first argument:
```python
-client = pilosa.Client("http://db1.pilosa.com:15000")
+client = pilosa.Client("http://node1.pilosa.com:15000")
```
If you are running a cluster of Pilosa servers, you can create a `pilosa.Cluster` object that keeps addresses of those servers:
@@ -87,11 +87,11 @@ You can send queries to a Pilosa server using the `query` method of client objec
response = client.query(field.row(5))
```
-`query` method accepts optional `columns` argument:
+`query` method accepts optional arguments, including `column_attrs`, `exclude_columns`, `exclude_attrs` and `shards`.
```python
response = client.query(field.row(5),
- columns=True # return column data in the response
+ column_attrs=True # return column data in the response
)
```
@@ -114,7 +114,7 @@ for result in response.results:
# act on the result
```
-Similarly, a `QueryResponse` object may include a number of column objects, if `columns=True` query option was used:
+Similarly, a `QueryResponse` object may include a number of column objects, if `column_attrs=True` query option was used:
```python
# check that there's a column object and act on it
@@ -133,7 +133,7 @@ for column in response.columns:
* `count_items` property to retrieve column count per row ID entries returned from `topn` queries,
* `count` attribute to retrieve the number of rows per the given row ID returned from `count` queries.
* `value` attribute to retrieve the result of `Min`, `Max` or `Sum` queries.
-* `changed` attribute shows whether a `SetBit` or `ClearBit` query changed a bit.
+* `changed` attribute shows whether a `Set` or `Clear` query changed a bit.
```python
result = response.result
diff --git a/pilosa/orm.py b/pilosa/orm.py
index 33e3fe3..8543f99 100644
--- a/pilosa/orm.py
+++ b/pilosa/orm.py
@@ -201,7 +201,7 @@ def copy(self, fields=True):
def field(self, name, time_quantum=TimeQuantum.NONE,
cache_type=CacheType.DEFAULT, cache_size=0,
- int_min=0, int_max=0):
+ int_min=0, int_max=0, keys=None):
"""Creates a field object with the specified name and defaults.
:param str name: field name
@@ -210,13 +210,14 @@ def field(self, name, time_quantum=TimeQuantum.NONE,
:param int cache_size: Values greater than 0 sets the cache size. Otherwise uses the default cache size
:param int int_min: Minimum for the integer field
:param int int_max: Maximum for the integer field
+ :param bool keys: Whether the field uses string keys
:return: Pilosa field
:rtype: pilosa.Field
"""
field = self._fields.get(name)
if field is None:
field = Field(self, name, time_quantum,
- cache_type, cache_size, int_min, int_max)
+ cache_type, cache_size, int_min, int_max, keys)
self._fields[name] = field
return field
@@ -345,7 +346,7 @@ class Field:
"""
def __init__(self, index, name, time_quantum,
- cache_type, cache_size, int_min, int_max):
+ cache_type, cache_size, int_min, int_max, keys):
validate_field_name(name)
if int_max < int_min:
raise ValidationError("Max should be greater than min for int fields")
@@ -357,6 +358,7 @@ def __init__(self, index, name, time_quantum,
self.cache_size = cache_size
self.int_min = int_min
self.int_max = int_max
+ self.keys = keys
def __eq__(self, other):
if id(self) == id(other):
@@ -377,7 +379,8 @@ def __ne__(self, other):
def copy(self):
return Field(self.index, self.name, self.time_quantum,
- self.cache_type, self.cache_size, self.int_min, self.int_max)
+ self.cache_type, self.cache_size,
+ self.int_min, self.int_max, self.keys)
def row(self, row_idkey):
"""Creates a Row query.
@@ -625,6 +628,8 @@ def _value_query(self, op, row):
def _get_options_string(self):
data = {}
+ if self.keys is not None:
+ data["keys"] = self.keys
if self.time_quantum != TimeQuantum.NONE:
data["type"] = "time"
data["timeQuantum"] = str(self.time_quantum)
diff --git a/tests/test_orm.py b/tests/test_orm.py
index d1bfd18..1f69c5f 100644
--- a/tests/test_orm.py
+++ b/tests/test_orm.py
@@ -397,9 +397,8 @@ def test_field_set_value(self):
def test_get_options_string(self):
field = sampleIndex.field("stargazer_id",
time_quantum=TimeQuantum.DAY_HOUR,
- cache_type=CacheType.RANKED,
- cache_size=1000)
- target = '{"options": {"timeQuantum": "DH", "type": "time"}}'
+ keys=True)
+ target = '{"options": {"keys": true, "timeQuantum": "DH", "type": "time"}}'
self.assertEquals(target, field._get_options_string())