-
Notifications
You must be signed in to change notification settings - Fork 25.2k
Adds usage stats for vectors: #44512
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
Merged
mayya-sharipova
merged 5 commits into
elastic:master
from
mayya-sharipova:add-vector-usage-stats
Jul 30, 2019
Merged
Changes from 1 commit
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
7b93ada
Adds usage stats for vectors:
mayya-sharipova ce13592
Merge remote-tracking branch 'upstream/master' into add-vector-usage-…
mayya-sharipova 5e7e3e2
Merge remote-tracking branch 'upstream/master' into add-vector-usage-…
mayya-sharipova ad477d7
Correct error in SpatialInfoTransportActionTests
mayya-sharipova 3c724a4
Check for state != null
mayya-sharipova 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
50 changes: 50 additions & 0 deletions
50
.../core/src/test/java/org/elasticsearch/xpack/core/vectors/VectorsFeatureSetUsageTests.java
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 |
---|---|---|
@@ -0,0 +1,50 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
package org.elasticsearch.xpack.core.vectors; | ||
|
||
import org.elasticsearch.common.io.stream.Writeable; | ||
import org.elasticsearch.test.AbstractWireSerializingTestCase; | ||
|
||
import java.io.IOException; | ||
|
||
public class VectorsFeatureSetUsageTests extends AbstractWireSerializingTestCase<VectorsFeatureSetUsage> { | ||
|
||
@Override | ||
protected VectorsFeatureSetUsage createTestInstance() { | ||
boolean available = randomBoolean(); | ||
boolean enabled = randomBoolean(); | ||
if (available && enabled) { | ||
return new VectorsFeatureSetUsage(available, enabled, randomIntBetween(0, 100000), randomIntBetween(0, 100000), | ||
randomIntBetween(0, 1024)); | ||
} else { | ||
return new VectorsFeatureSetUsage(available, enabled, 0, 0, 0); | ||
} | ||
} | ||
|
||
@Override | ||
protected VectorsFeatureSetUsage mutateInstance(VectorsFeatureSetUsage instance) throws IOException { | ||
boolean available = instance.available(); | ||
boolean enabled = instance.enabled(); | ||
int numDenseVectorFields = instance.numDenseVectorFields(); | ||
int numSparseVectorFields = instance.numSparseVectorFields(); | ||
int avgDenseVectorDims = instance.avgDenseVectorDims(); | ||
|
||
if (available == false || enabled == false) { | ||
available = true; | ||
enabled = true; | ||
} | ||
numDenseVectorFields = randomValueOtherThan(numDenseVectorFields, () -> randomIntBetween(0, 100000)); | ||
numSparseVectorFields = randomValueOtherThan(numSparseVectorFields, () -> randomIntBetween(0, 100000)); | ||
avgDenseVectorDims = randomValueOtherThan(avgDenseVectorDims, () -> randomIntBetween(0, 1024)); | ||
return new VectorsFeatureSetUsage(available, enabled, numDenseVectorFields, numSparseVectorFields, avgDenseVectorDims); | ||
} | ||
|
||
@Override | ||
protected Writeable.Reader<VectorsFeatureSetUsage> instanceReader() { | ||
return VectorsFeatureSetUsage::new; | ||
} | ||
|
||
} |
46 changes: 46 additions & 0 deletions
46
x-pack/plugin/src/test/resources/rest-api-spec/test/vectors/50_vector_stats.yml
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 |
---|---|---|
@@ -0,0 +1,46 @@ | ||
setup: | ||
- skip: | ||
features: headers | ||
version: " - 7.3.99" | ||
reason: "vector stats was added from 7.4" | ||
|
||
--- | ||
"Usage stats on vector fields": | ||
- do: {xpack.usage: {}} | ||
- match: { vectors.available: true } | ||
- match: { vectors.enabled: true } | ||
- match: { vectors.dense_vector_fields_count: 0 } | ||
- match: { vectors.sparse_vector_fields_count: 0 } | ||
- match: { vectors.dense_vector_dims_avg_count: 0 } | ||
|
||
- do: | ||
indices.create: | ||
index: test-index1 | ||
body: | ||
mappings: | ||
properties: | ||
my_dense_vector1: | ||
type: dense_vector | ||
dims: 10 | ||
my_dense_vector2: | ||
type: dense_vector | ||
dims: 30 | ||
|
||
- do: | ||
indices.create: | ||
index: test-index2 | ||
body: | ||
mappings: | ||
properties: | ||
my_dense_vector3: | ||
type: dense_vector | ||
dims: 20 | ||
my_sparse_vector1: | ||
type: sparse_vector | ||
|
||
- do: {xpack.usage: {}} | ||
- match: { vectors.available: true } | ||
- match: { vectors.enabled: true } | ||
- match: { vectors.dense_vector_fields_count: 3 } | ||
- match: { vectors.sparse_vector_fields_count: 1 } | ||
- match: { vectors.dense_vector_dims_avg_count: 20 } |
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
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.
Uh oh!
There was an error while loading. Please reload this page.