@@ -54,14 +54,7 @@ class VectorDecoder extends BaseBuffer {
5454 errors . throwErr ( errors . ERR_VECTOR_VERSION_NOT_SUPPORTED , version ) ;
5555 const flags = this . readUInt16BE ( ) ;
5656 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 ( ) ;
6558 let elementSize , result ;
6659 if ( vectorFormat === constants . VECTOR_FORMAT_FLOAT32 ) {
6760 elementSize = 4 ;
@@ -117,27 +110,15 @@ class VectorEncoder extends GrowableBuffer {
117110 }
118111
119112 // 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
121114 | 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- }
128115
129116 // write header
130117 this . writeUInt8 ( constants . TNS_VECTOR_MAGIC_BYTE ) ;
131118 this . writeUInt8 ( constants . TNS_VECTOR_VERSION ) ;
132119 this . writeUInt16BE ( flags ) ;
133120 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 ) ;
141122 this . reserveBytes ( 8 ) ;
142123
143124 // write data
0 commit comments