-
Notifications
You must be signed in to change notification settings - Fork 486
Test/test recall commit0303 #196
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
Open
liututu12
wants to merge
16
commits into
main
Choose a base branch
from
test/test_recall_commit0303
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+1,184
−57
Open
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
7e63deb
add recall cases
iaojnh c08f564
add test_collection_crash_recovery_insertdoc.py
iaojnh c32afdb
add test_collection_crash_recovery_updatedoc.py
iaojnh 0b35ec5
add test_collection_crash_recovery_upsertdoc.py
iaojnh 25317b7
add test_collection_crash_recovery_deletedoc.py
iaojnh 7e332c1
add test_collection_crash_recovery_createindex.py
iaojnh 44375e4
add test_collection_crash_recovery_deleteindex.py
iaojnh 32df5ff
test_collection_crash_recovery_addcolumn.py
iaojnh d3ef15e
test_collection_crash_recovery_addcolumn.py
iaojnh ec59a3b
add dropcolumn updatecolumn cases
iaojnh 6d713b6
update test_collection_crash_recovery_altercolumn.py
iaojnh 5678fa4
update test_collection_recall
iaojnh 88d69e7
update test_collection_crash_recovery_createindex.py
iaojnh 2147144
test_collection_recall.py
iaojnh ec8cde3
test_collection_recall.py
iaojnh 9bf07b4
feat: add recall test cases and optimize DML/DQL test cases
iaojnh File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 | ||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -7,17 +7,35 @@ | |||||||||||||||
|
|
||||||||||||||||
| import random | ||||||||||||||||
| import string | ||||||||||||||||
| import math | ||||||||||||||||
|
|
||||||||||||||||
|
|
||||||||||||||||
| def generate_constant_vector( | ||||||||||||||||
| i: int, dimension: int, dtype: Literal["int8", "float16", "float32"] = "float32" | ||||||||||||||||
| ): | ||||||||||||||||
| if dtype == "int8": | ||||||||||||||||
| vec = [i % 128] * dimension | ||||||||||||||||
| vec[i % dimension] = (i + 1) % 128 | ||||||||||||||||
| vec = [(i % 127)] * dimension | ||||||||||||||||
| vec[i % dimension] = (i + 1) % 127 | ||||||||||||||||
| else: | ||||||||||||||||
| vec = [i / 256.0] * dimension | ||||||||||||||||
| vec[i % dimension] = (i + 1) / 256.0 | ||||||||||||||||
| base_val = (i % 1000) / 256.0 | ||||||||||||||||
| special_val = ((i + 1) % 1000) / 256.0 | ||||||||||||||||
| vec = [base_val] * dimension | ||||||||||||||||
| vec[i % dimension] = special_val | ||||||||||||||||
|
|
||||||||||||||||
| return vec | ||||||||||||||||
|
|
||||||||||||||||
|
|
||||||||||||||||
| def generate_constant_vector_recall( | ||||||||||||||||
| i: int, dimension: int, dtype: Literal["int8", "float16", "float32"] = "float32" | ||||||||||||||||
| ): | ||||||||||||||||
| if dtype == "int8": | ||||||||||||||||
| vec = [(i % 127)] * dimension | ||||||||||||||||
| vec[i % dimension] = (i + 1) % 127 | ||||||||||||||||
| else: | ||||||||||||||||
| base_val = math.sin((i) * 1000) / 256.0 | ||||||||||||||||
| special_val = math.sin((i + 1) * 1000) / 256.0 | ||||||||||||||||
| vec = [base_val] * dimension | ||||||||||||||||
| vec[i % dimension] = special_val | ||||||||||||||||
|
|
||||||||||||||||
| return vec | ||||||||||||||||
|
|
||||||||||||||||
|
|
@@ -90,15 +108,73 @@ def generate_vectordict(i: int, schema: CollectionSchema) -> Doc: | |||||||||||||||
| return doc_fields, doc_vectors | ||||||||||||||||
|
|
||||||||||||||||
|
|
||||||||||||||||
| def generate_doc(i: int, schema: CollectionSchema) -> Doc: | ||||||||||||||||
| def generate_vectordict_recall(i: int, schema: CollectionSchema) -> Doc: | ||||||||||||||||
| doc_fields = {} | ||||||||||||||||
| doc_vectors = {} | ||||||||||||||||
| doc_fields, doc_vectors = generate_vectordict(i, schema) | ||||||||||||||||
| doc = Doc(id=str(i), fields=doc_fields, vectors=doc_vectors) | ||||||||||||||||
| return doc | ||||||||||||||||
| doc_fields = {} | ||||||||||||||||
| doc_vectors = {} | ||||||||||||||||
| for field in schema.fields: | ||||||||||||||||
| if field.data_type == DataType.BOOL: | ||||||||||||||||
| doc_fields[field.name] = i % 2 == 0 | ||||||||||||||||
| elif field.data_type == DataType.INT32: | ||||||||||||||||
| doc_fields[field.name] = i | ||||||||||||||||
| elif field.data_type == DataType.UINT32: | ||||||||||||||||
| doc_fields[field.name] = i | ||||||||||||||||
| elif field.data_type == DataType.INT64: | ||||||||||||||||
| doc_fields[field.name] = i | ||||||||||||||||
| elif field.data_type == DataType.UINT64: | ||||||||||||||||
| doc_fields[field.name] = i | ||||||||||||||||
| elif field.data_type == DataType.FLOAT: | ||||||||||||||||
| doc_fields[field.name] = float(i) + 0.1 | ||||||||||||||||
| elif field.data_type == DataType.DOUBLE: | ||||||||||||||||
| doc_fields[field.name] = float(i) + 0.11 | ||||||||||||||||
| elif field.data_type == DataType.STRING: | ||||||||||||||||
| doc_fields[field.name] = f"test_{i}" | ||||||||||||||||
| elif field.data_type == DataType.ARRAY_BOOL: | ||||||||||||||||
| doc_fields[field.name] = [i % 2 == 0, i % 3 == 0] | ||||||||||||||||
| elif field.data_type == DataType.ARRAY_INT32: | ||||||||||||||||
| doc_fields[field.name] = [i, i + 1, i + 2] | ||||||||||||||||
| elif field.data_type == DataType.ARRAY_UINT32: | ||||||||||||||||
| doc_fields[field.name] = [i, i + 1, i + 2] | ||||||||||||||||
| elif field.data_type == DataType.ARRAY_INT64: | ||||||||||||||||
| doc_fields[field.name] = [i, i + 1, i + 2] | ||||||||||||||||
| elif field.data_type == DataType.ARRAY_UINT64: | ||||||||||||||||
| doc_fields[field.name] = [i, i + 1, i + 2] | ||||||||||||||||
| elif field.data_type == DataType.ARRAY_FLOAT: | ||||||||||||||||
| doc_fields[field.name] = [float(i + 0.1), float(i + 1.1), float(i + 2.1)] | ||||||||||||||||
| elif field.data_type == DataType.ARRAY_DOUBLE: | ||||||||||||||||
| doc_fields[field.name] = [float(i + 0.11), float(i + 1.11), float(i + 2.11)] | ||||||||||||||||
| elif field.data_type == DataType.ARRAY_STRING: | ||||||||||||||||
| doc_fields[field.name] = [f"test_{i}", f"test_{i + 1}", f"test_{i + 2}"] | ||||||||||||||||
| else: | ||||||||||||||||
| raise ValueError(f"Unsupported field type: {field.data_type}") | ||||||||||||||||
| for vector in schema.vectors: | ||||||||||||||||
| if vector.data_type == DataType.VECTOR_FP16: | ||||||||||||||||
| doc_vectors[vector.name] = generate_constant_vector_recall( | ||||||||||||||||
| i, vector.dimension, "float16" | ||||||||||||||||
| ) | ||||||||||||||||
| elif vector.data_type == DataType.VECTOR_FP32: | ||||||||||||||||
| doc_vectors[vector.name] = generate_constant_vector_recall( | ||||||||||||||||
| i, vector.dimension, "float32" | ||||||||||||||||
| ) | ||||||||||||||||
| elif vector.data_type == DataType.VECTOR_INT8: | ||||||||||||||||
| doc_vectors[vector.name] = generate_constant_vector_recall( | ||||||||||||||||
| i, | ||||||||||||||||
| vector.dimension, | ||||||||||||||||
| "int8", | ||||||||||||||||
| ) | ||||||||||||||||
| elif vector.data_type == DataType.SPARSE_VECTOR_FP32: | ||||||||||||||||
| doc_vectors[vector.name] = generate_sparse_vector(i) | ||||||||||||||||
| elif vector.data_type == DataType.SPARSE_VECTOR_FP16: | ||||||||||||||||
| doc_vectors[vector.name] = generate_sparse_vector(i) | ||||||||||||||||
| else: | ||||||||||||||||
| raise ValueError(f"Unsupported vector type: {vector.data_type}") | ||||||||||||||||
| return doc_fields, doc_vectors | ||||||||||||||||
|
|
||||||||||||||||
|
|
||||||||||||||||
| def generate_update_doc(i: int, schema: CollectionSchema) -> Doc: | ||||||||||||||||
| def generate_vectordict_update(i: int, schema: CollectionSchema) -> Doc: | ||||||||||||||||
| doc_fields = {} | ||||||||||||||||
| doc_vectors = {} | ||||||||||||||||
| doc_fields = {} | ||||||||||||||||
| doc_vectors = {} | ||||||||||||||||
|
Comment on lines
+176
to
+179
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. duplicate variable declarations - remove lines 173-174
Suggested change
|
||||||||||||||||
| for field in schema.fields: | ||||||||||||||||
|
|
@@ -115,60 +191,71 @@ def generate_update_doc(i: int, schema: CollectionSchema) -> Doc: | |||||||||||||||
| elif field.data_type == DataType.FLOAT: | ||||||||||||||||
| doc_fields[field.name] = float(i + 1) + 0.1 | ||||||||||||||||
| elif field.data_type == DataType.DOUBLE: | ||||||||||||||||
| doc_fields[field.name] = float(i) + 0.11 | ||||||||||||||||
| doc_fields[field.name] = float(i + 1) + 0.11 | ||||||||||||||||
| elif field.data_type == DataType.STRING: | ||||||||||||||||
| doc_fields[field.name] = f"test_{i + 1}" | ||||||||||||||||
| elif field.data_type == DataType.ARRAY_BOOL: | ||||||||||||||||
| doc_fields[field.name] = [(i + 1) % 2 == 0, (i + 1) % 3 == 0] | ||||||||||||||||
| elif field.data_type == DataType.ARRAY_INT32: | ||||||||||||||||
| doc_fields[field.name] = [i + 1, (i + 1) + 1, (i + 1) + 2] | ||||||||||||||||
| doc_fields[field.name] = [i + 1, i + 1, i + 2] | ||||||||||||||||
| elif field.data_type == DataType.ARRAY_UINT32: | ||||||||||||||||
| doc_fields[field.name] = [i + 1, (i + 1) + 1, (i + 1) + 2] | ||||||||||||||||
| doc_fields[field.name] = [i + 1, i + 1, i + 2] | ||||||||||||||||
| elif field.data_type == DataType.ARRAY_INT64: | ||||||||||||||||
| doc_fields[field.name] = [i + 1, (i + 1) + 1, (i + 1) + 2] | ||||||||||||||||
| doc_fields[field.name] = [i + 1, i + 1, i + 2] | ||||||||||||||||
| elif field.data_type == DataType.ARRAY_UINT64: | ||||||||||||||||
| doc_fields[field.name] = [i + 1, (i + 1) + 1, (i + 1) + 2] | ||||||||||||||||
| doc_fields[field.name] = [i + 1, i + 1, i + 2] | ||||||||||||||||
| elif field.data_type == DataType.ARRAY_FLOAT: | ||||||||||||||||
| doc_fields[field.name] = [ | ||||||||||||||||
| float((i + 1) + 0.1), | ||||||||||||||||
| float((i + 1) + 1.1), | ||||||||||||||||
| float((i + 1) + 2.1), | ||||||||||||||||
| ] | ||||||||||||||||
| doc_fields[field.name] = [float(i + 1.1), float(i + 2.1), float(i + 3.1)] | ||||||||||||||||
| elif field.data_type == DataType.ARRAY_DOUBLE: | ||||||||||||||||
| doc_fields[field.name] = [ | ||||||||||||||||
| float((i + 1) + 0.11), | ||||||||||||||||
| float((i + 1) + 1.11), | ||||||||||||||||
| float((i + 1) + 2.11), | ||||||||||||||||
| ] | ||||||||||||||||
| doc_fields[field.name] = [float(i + 1.11), float(i + 2.11), float(i + 3.11)] | ||||||||||||||||
| elif field.data_type == DataType.ARRAY_STRING: | ||||||||||||||||
| doc_fields[field.name] = [ | ||||||||||||||||
| f"test_{i + 1}", | ||||||||||||||||
| f"test_{(i + 1) + 1}", | ||||||||||||||||
| f"test_{(i + 1) + 2}", | ||||||||||||||||
| ] | ||||||||||||||||
| doc_fields[field.name] = [f"test_{i + 1}", f"test_{i + 2}", f"test_{i + 3}"] | ||||||||||||||||
| else: | ||||||||||||||||
| raise ValueError(f"Unsupported field type: {field.data_type}") | ||||||||||||||||
| for vector in schema.vectors: | ||||||||||||||||
| if vector.data_type == DataType.VECTOR_FP16: | ||||||||||||||||
| doc_vectors[vector.name] = generate_constant_vector( | ||||||||||||||||
| i + 1, DEFAULT_VECTOR_DIMENSION, "float16" | ||||||||||||||||
| i + 1, vector.dimension, "float16" | ||||||||||||||||
| ) | ||||||||||||||||
| elif vector.data_type == DataType.VECTOR_FP32: | ||||||||||||||||
| doc_vectors[vector.name] = generate_constant_vector( | ||||||||||||||||
| i + 1, DEFAULT_VECTOR_DIMENSION, "float32" | ||||||||||||||||
| i + 1, vector.dimension, "float32" | ||||||||||||||||
| ) | ||||||||||||||||
| elif vector.data_type == DataType.VECTOR_INT8: | ||||||||||||||||
| doc_vectors[vector.name] = generate_constant_vector( | ||||||||||||||||
| i + 1, | ||||||||||||||||
| DEFAULT_VECTOR_DIMENSION, | ||||||||||||||||
| vector.dimension, | ||||||||||||||||
| "int8", | ||||||||||||||||
| ) | ||||||||||||||||
| elif vector.data_type == DataType.SPARSE_VECTOR_FP32: | ||||||||||||||||
| doc_vectors[vector.name] = generate_sparse_vector(i) | ||||||||||||||||
| doc_vectors[vector.name] = generate_sparse_vector(i + 1) | ||||||||||||||||
| elif vector.data_type == DataType.SPARSE_VECTOR_FP16: | ||||||||||||||||
| doc_vectors[vector.name] = generate_sparse_vector(i) | ||||||||||||||||
| doc_vectors[vector.name] = generate_sparse_vector(i + 1) | ||||||||||||||||
| else: | ||||||||||||||||
| raise ValueError(f"Unsupported vector type: {vector.data_type}") | ||||||||||||||||
| return doc_fields, doc_vectors | ||||||||||||||||
|
|
||||||||||||||||
|
|
||||||||||||||||
| def generate_doc(i: int, schema: CollectionSchema) -> Doc: | ||||||||||||||||
| doc_fields = {} | ||||||||||||||||
| doc_vectors = {} | ||||||||||||||||
| doc_fields, doc_vectors = generate_vectordict(i, schema) | ||||||||||||||||
| doc = Doc(id=str(i), fields=doc_fields, vectors=doc_vectors) | ||||||||||||||||
| return doc | ||||||||||||||||
|
|
||||||||||||||||
|
|
||||||||||||||||
| def generate_doc_recall(i: int, schema: CollectionSchema) -> Doc: | ||||||||||||||||
| doc_fields = {} | ||||||||||||||||
| doc_vectors = {} | ||||||||||||||||
| doc_fields, doc_vectors = generate_vectordict_recall(i, schema) | ||||||||||||||||
| doc = Doc(id=str(i), fields=doc_fields, vectors=doc_vectors) | ||||||||||||||||
| return doc | ||||||||||||||||
|
|
||||||||||||||||
|
|
||||||||||||||||
| def generate_update_doc(i: int, schema: CollectionSchema) -> Doc: | ||||||||||||||||
| doc_fields = {} | ||||||||||||||||
| doc_vectors = {} | ||||||||||||||||
| doc_fields, doc_vectors = generate_vectordict_update(i, schema) | ||||||||||||||||
| doc = Doc(id=str(i), fields=doc_fields, vectors=doc_vectors) | ||||||||||||||||
| return doc | ||||||||||||||||
|
|
||||||||||||||||
|
|
@@ -357,15 +444,15 @@ def generate_vectordict_random(schema: CollectionSchema): | |||||||||||||||
| for vector in schema.vectors: | ||||||||||||||||
| if vector.data_type == DataType.VECTOR_FP16: | ||||||||||||||||
| doc_vectors[vector.name] = generate_constant_vector( | ||||||||||||||||
| random.randint(1, 100), DEFAULT_VECTOR_DIMENSION, "float16" | ||||||||||||||||
| random.randint(1, 100), vector.dimension, "float16" | ||||||||||||||||
| ) | ||||||||||||||||
| elif vector.data_type == DataType.VECTOR_FP32: | ||||||||||||||||
| doc_vectors[vector.name] = generate_constant_vector( | ||||||||||||||||
| random.randint(1, 100), DEFAULT_VECTOR_DIMENSION, "float32" | ||||||||||||||||
| random.randint(1, 100), vector.dimension, "float32" | ||||||||||||||||
| ) | ||||||||||||||||
| elif vector.data_type == DataType.VECTOR_INT8: | ||||||||||||||||
| doc_vectors[vector.name] = generate_constant_vector( | ||||||||||||||||
| random.randint(1, 100), DEFAULT_VECTOR_DIMENSION, "int8" | ||||||||||||||||
| random.randint(1, 100), vector.dimension, "int8" | ||||||||||||||||
| ) | ||||||||||||||||
| elif vector.data_type == DataType.SPARSE_VECTOR_FP32: | ||||||||||||||||
| doc_vectors[vector.name] = generate_sparse_vector(random.randint(1, 100)) | ||||||||||||||||
|
|
||||||||||||||||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
duplicate variable declarations - remove lines 110-111