Skip to content
Snippets Groups Projects
Select Git revision
  • 8dcfd14c196e7729ef3fd01fcfa027d3d21bdcd5
  • openEuler-1.0-LTS default protected
  • openEuler-22.09
  • OLK-5.10
  • openEuler-22.03-LTS
  • openEuler-22.03-LTS-Ascend
  • master
  • openEuler-22.03-LTS-LoongArch-NW
  • openEuler-22.09-HCK
  • openEuler-20.03-LTS-SP3
  • openEuler-21.09
  • openEuler-21.03
  • openEuler-20.09
  • 4.19.90-2210.5.0
  • 5.10.0-123.0.0
  • 5.10.0-60.63.0
  • 5.10.0-60.62.0
  • 4.19.90-2210.4.0
  • 5.10.0-121.0.0
  • 5.10.0-60.61.0
  • 4.19.90-2210.3.0
  • 5.10.0-60.60.0
  • 5.10.0-120.0.0
  • 5.10.0-60.59.0
  • 5.10.0-119.0.0
  • 4.19.90-2210.2.0
  • 4.19.90-2210.1.0
  • 5.10.0-118.0.0
  • 5.10.0-106.19.0
  • 5.10.0-60.58.0
  • 4.19.90-2209.6.0
  • 5.10.0-106.18.0
  • 5.10.0-106.17.0
33 results

vmwgfx_ttm_buffer.c

Blame
  • plan_test.go 2.67 KiB
    package querynode
    
    import (
    	"encoding/binary"
    	"math"
    	"testing"
    
    	"github.com/golang/protobuf/proto"
    	"github.com/stretchr/testify/assert"
    
    	"github.com/zilliztech/milvus-distributed/internal/proto/servicepb"
    )
    
    func TestPlan_Plan(t *testing.T) {
    	collectionName := "collection0"
    	collectionID := UniqueID(0)
    	collectionMeta := genTestCollectionMeta(collectionName, collectionID)
    	schemaBlob := proto.MarshalTextString(collectionMeta.Schema)
    	assert.NotEqual(t, "", schemaBlob)
    
    	collection := newCollection(collectionMeta.ID, schemaBlob)
    
    	dslString := "{\"bool\": { \n\"vector\": {\n \"vec\": {\n \"metric_type\": \"L2\", \n \"params\": {\n \"nprobe\": 10 \n},\n \"query\": \"$0\",\"topk\": 10 \n } \n } \n } \n }"
    
    	plan, err := createPlan(*collection, dslString)
    	assert.NoError(t, err)
    	assert.NotEqual(t, plan, nil)
    	topk := plan.getTopK()
    	assert.Equal(t, int(topk), 10)
    	metricType := plan.getMetricType()
    	assert.Equal(t, metricType, "L2")
    	plan.delete()
    	deleteCollection(collection)
    }
    
    func TestPlan_PlaceholderGroup(t *testing.T) {
    	collectionName := "collection0"
    	collectionID := UniqueID(0)
    	collectionMeta := genTestCollectionMeta(collectionName, collectionID)
    	schemaBlob := proto.MarshalTextString(collectionMeta.Schema)
    	assert.NotEqual(t, "", schemaBlob)
    
    	collection := newCollection(collectionMeta.ID, schemaBlob)
    
    	dslString := "{\"bool\": { \n\"vector\": {\n \"vec\": {\n \"metric_type\": \"L2\", \n \"params\": {\n \"nprobe\": 10 \n},\n \"query\": \"$0\",\"topk\": 10 \n } \n } \n } \n }"
    
    	plan, err := createPlan(*collection, dslString)
    	assert.NoError(t, err)
    	assert.NotNil(t, plan)
    
    	var searchRawData1 []byte
    	var searchRawData2 []byte
    	const DIM = 16
    	var vec = [DIM]float32{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16}
    	for i, ele := range vec {
    		buf := make([]byte, 4)
    		binary.LittleEndian.PutUint32(buf, math.Float32bits(ele+float32(i*2)))
    		searchRawData1 = append(searchRawData1, buf...)
    	}
    	for i, ele := range vec {
    		buf := make([]byte, 4)
    		binary.LittleEndian.PutUint32(buf, math.Float32bits(ele+float32(i*4)))
    		searchRawData2 = append(searchRawData2, buf...)
    	}
    	placeholderValue := servicepb.PlaceholderValue{
    		Tag:    "$0",
    		Type:   servicepb.PlaceholderType_VECTOR_FLOAT,
    		Values: [][]byte{searchRawData1, searchRawData2},
    	}
    
    	placeholderGroup := servicepb.PlaceholderGroup{
    		Placeholders: []*servicepb.PlaceholderValue{&placeholderValue},
    	}
    
    	placeGroupByte, err := proto.Marshal(&placeholderGroup)
    	assert.Nil(t, err)
    	holder, err := parserPlaceholderGroup(plan, placeGroupByte)
    	assert.NoError(t, err)
    	assert.NotNil(t, holder)
    	numQueries := holder.getNumOfQuery()
    	assert.Equal(t, int(numQueries), 2)
    
    	plan.delete()
    	holder.delete()
    	deleteCollection(collection)
    }