@@ -54,14 +54,7 @@ class VectorDecoder extends BaseBuffer {
54
54
errors . throwErr ( errors . ERR_VECTOR_VERSION_NOT_SUPPORTED , version ) ;
55
55
const flags = this . readUInt16BE ( ) ;
56
56
const vectorFormat = this . readUInt8 ( ) ;
57
- let numElements ;
58
- if ( flags & constants . TNS_VECTOR_FLAG_DIM_UINT8 ) {
59
- numElements = this . readUInt8 ( ) ;
60
- } else if ( flags & constants . TNS_VECTOR_FLAG_DIM_UINT32 ) {
61
- numElements = this . readUInt32BE ( ) ;
62
- } else {
63
- numElements = this . readUInt16BE ( ) ;
64
- }
57
+ const numElements = this . readUInt32BE ( ) ;
65
58
let elementSize , result ;
66
59
if ( vectorFormat === constants . VECTOR_FORMAT_FLOAT32 ) {
67
60
elementSize = 4 ;
@@ -117,27 +110,15 @@ class VectorEncoder extends GrowableBuffer {
117
110
}
118
111
119
112
// Let server generate the norm (TNS_VECTOR_FLAG_NORMSRC)
120
- let flags = constants . TNS_VECTOR_FLAG_NORM
113
+ const flags = constants . TNS_VECTOR_FLAG_NORM
121
114
| constants . TNS_VECTOR_FLAG_NORMSRC ;
122
- const numElements = value . length ;
123
- if ( numElements < 256 ) {
124
- flags |= constants . TNS_VECTOR_FLAG_DIM_UINT8 ;
125
- } else if ( numElements > 65535 ) {
126
- flags |= constants . TNS_VECTOR_FLAG_DIM_UINT32 ;
127
- }
128
115
129
116
// write header
130
117
this . writeUInt8 ( constants . TNS_VECTOR_MAGIC_BYTE ) ;
131
118
this . writeUInt8 ( constants . TNS_VECTOR_VERSION ) ;
132
119
this . writeUInt16BE ( flags ) ;
133
120
this . writeUInt8 ( vectorFormat ) ;
134
- if ( numElements < 256 ) {
135
- this . writeUInt8 ( numElements ) ;
136
- } else if ( numElements < 65536 ) {
137
- this . writeUInt16BE ( numElements ) ;
138
- } else {
139
- this . writeUInt32BE ( numElements ) ;
140
- }
121
+ this . writeUInt32BE ( value . length ) ;
141
122
this . reserveBytes ( 8 ) ;
142
123
143
124
// write data
0 commit comments