Skip to content
This repository has been archived by the owner on Jan 18, 2023. It is now read-only.

Commit

Permalink
Merge pull request #45 from milvus-io/add-timestamp
Browse files Browse the repository at this point in the history
support travel_timestamp and guarantee_timestamp
  • Loading branch information
czhen-zilliz authored Nov 3, 2021
2 parents 28d011f + 33a2df4 commit 0102854
Show file tree
Hide file tree
Showing 5 changed files with 135 additions and 50 deletions.
26 changes: 24 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -572,7 +572,7 @@ Commands:
#### `import`

```
milvus_cli > import --help
milvus_cli > import --help
Usage: milvus_cli.py import [OPTIONS] PATH
Import data from csv file with headers and insert into target collection.
Expand All @@ -587,7 +587,15 @@ Usage: milvus_cli.py import [OPTIONS] PATH
Processed 50001 lines.
Import successfully.
Inserting ...
Insert successfully.
-------------------------- ------------------
Total insert entities: 50000
Total collection entities: 150000
Milvus timestamp: 428849214449254403
-------------------------- ------------------
Options:
-c, --collection TEXT The name of collection to be imported.
Expand Down Expand Up @@ -746,6 +754,12 @@ Usage: milvus_cli.py search [OPTIONS]
The names of partitions to search (split by "," if multiple) ['_default']
[]: _default
timeout []:
Guarantee Timestamp(It instructs Milvus to see all operations performed before a provided timestamp. If no such timestamp is provided, then Milvus will search all operations performed to date) [0]:
Travel Timestamp(Specify a timestamp in a search to get results based on a data view) [0]:
Example-2(collection has index):
Collection name (car, test_collection): car
Expand Down Expand Up @@ -783,6 +797,10 @@ Usage: milvus_cli.py search [OPTIONS]
timeout []:
Guarantee Timestamp(It instructs Milvus to see all operations performed before a provided timestamp. If no such timestamp is provided, then Milvus will search all operations performed to date) [0]:
Travel Timestamp(Specify a timestamp in a search to get results based on a data view) [0]:
Example-3(collection has no index):
Collection name (car, car2): car
Expand All @@ -805,6 +823,10 @@ Usage: milvus_cli.py search [OPTIONS]
Timeout []:
Guarantee Timestamp(It instructs Milvus to see all operations performed before a provided timestamp. If no such timestamp is provided, then Milvus will search all operations performed to date) [0]:
Travel Timestamp(Specify a timestamp in a search to get results based on a data view) [0]:
Options:
--help Show this message and exit.
```
Expand Down
24 changes: 20 additions & 4 deletions milvus_cli/Validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,10 @@ def validateIndexParameter(indexType, metricType, params):
raise ParameterException('Index params are duplicated.')


def validateSearchParams(data, annsField, metricType, params, limit, expr, partitionNames, timeout, roundDecimal, hasIndex=True):
def validateSearchParams(data, annsField, metricType, params,
limit, expr, partitionNames, timeout,
roundDecimal, hasIndex=True,
guarantee_timestamp=None, travel_timestamp=None):
import json
result = {}
# Validate data
Expand Down Expand Up @@ -144,6 +147,19 @@ def validateSearchParams(data, annsField, metricType, params, limit, expr, parti
result['timeout'] = float(timeout)
if roundDecimal:
result['round_decimal'] = int(roundDecimal)
# Validate guarantee_timestamp and travel_timestamp
if guarantee_timestamp:
try:
result['guarantee_timestamp'] = int(guarantee_timestamp)
except Exception as e:
raise ParameterException(
'Format(int) "guarantee_timestamp" error! {}'.format(str(e)))
if travel_timestamp:
try:
result['travel_timestamp'] = int(travel_timestamp)
except Exception as e:
raise ParameterException(
'Format(int) "travel_timestamp" error! {}'.format(str(e)))
return result


Expand All @@ -170,12 +186,12 @@ def validateQueryParams(expr, partitionNames, outputFields, timeout):


def validateQueryParams(leftVectorMeta, rightVectorMeta, metric_type, sqrt, dim, timeout):
result = { 'params': {} }
result = {'params': {}}
vectors_left = validateVectorMeta(leftVectorMeta)
result['vectors_left'] = vectors_left
vectors_right = validateVectorMeta(rightVectorMeta)
result['vectors_right'] = vectors_right
params=result['params']
params = result['params']
params['metric_type'] = metric_type
if metric_type not in MetricTypes:
raise ParameterException(
Expand Down Expand Up @@ -230,6 +246,6 @@ def validateVectorMeta(vectorMeta):
noSquareBrackets = noWhiteSpace[1:-1]
# "b'\x94', b'N', b'Ê'"
strList = noSquareBrackets.split(', ')
binMap = map(lambda x:x[2:-1].encode('unicode_escape'), strList)
binMap = map(lambda x: x[2:-1].encode('unicode_escape'), strList)
result[vectorMeta['type']] = list(binMap)
return result
Loading

0 comments on commit 0102854

Please sign in to comment.