@@ -760,9 +760,9 @@ private ActiveDirectoryAuthentication() {
760760 }
761761 }
762762
763- private static final String VECTOR_SUPPORT_OFF = "off" ;
764- private static final String VECTOR_SUPPORT_V1 = "v1" ;
765- private static final String VECTOR_SUPPORT_V2 = "v2" ;
763+ private static final String VECTOR_SUPPORT_OFF = "off" ; // vector not supported; will return json formatted string
764+ private static final String VECTOR_SUPPORT_V1 = "v1" ; // supports float32 vector type
765+ private static final String VECTOR_SUPPORT_V2 = "v2" ; // supports float32 and float16 vector types
766766
767767 final static int TNIR_FIRST_ATTEMPT_TIMEOUT_MS = 500 ; // fraction of timeout to use for fast failover connections
768768
@@ -1106,13 +1106,15 @@ public void setBulkCopyForBatchInsertAllowEncryptedValueModifications(
11061106 * A string that indicates the vector type support during connection initialization.
11071107 * Valid values are :
11081108 * - "off" (vector types are returned as strings)
1109- * - "v1" (vectors of type FLOAT32 are returned as vectors )
1110- * - "v2" (vectors of type FLOAT32 and FLOAT16 are returned as vectors )
1109+ * - "v1" (supports float32 vector type )
1110+ * - "v2" (supports float32 and float16 vector types )
11111111 * Default is "v1".
11121112 */
1113- private String vectorTypeSupport = VECTOR_SUPPORT_V1 ;
1113+ private String vectorTypeSupport = SQLServerDriverStringProperty . VECTOR_TYPE_SUPPORT . getDefaultValue () ;
11141114
1115- /** negotiated vector version between client and server */
1115+ /**
1116+ * Negotiated vector version between client and server
1117+ */
11161118 private byte negotiatedVectorVersion = TDS .VECTORSUPPORT_NOT_SUPPORTED ;
11171119
11181120 /**
@@ -1133,8 +1135,8 @@ public String getVectorTypeSupport() {
11331135 * A string that indicates the vector type support during connection initialization.
11341136 * Valid values are :
11351137 * - "off" (vector types are returned as strings)
1136- * - "v1" (vectors of type FLOAT32 are returned as vectors )
1137- * - "v2" (vectors of type FLOAT32 and FLOAT16 are returned as vectors )
1138+ * - "v1" (supports float32 vector type )
1139+ * - "v2" (supports float32 and float16 vector types )
11381140 * Default is "v1".
11391141 */
11401142 @ Override
@@ -5917,15 +5919,19 @@ int writeVectorSupportFeatureRequest(boolean write,
59175919 tdsWriter .writeInt (1 );
59185920
59195921 byte clientVectorSupportVersion ;
5920- if (VECTOR_SUPPORT_V2 .equalsIgnoreCase (vectorTypeSupport )) {
5921- clientVectorSupportVersion = TDS .VECTORSUPPORT_VERSION_2 ;
5922- } else if (VECTOR_SUPPORT_V1 .equalsIgnoreCase (vectorTypeSupport )) {
5923- clientVectorSupportVersion = TDS .VECTORSUPPORT_VERSION_1 ;
5924- } else {
5925- // Should not reach here due to prior validation.
5926- clientVectorSupportVersion = TDS .VECTORSUPPORT_VERSION_1 ;
5922+ switch (vectorTypeSupport ) {
5923+ case VECTOR_SUPPORT_V2 :
5924+ clientVectorSupportVersion = TDS .VECTORSUPPORT_VERSION_2 ;
5925+ break ;
5926+ case VECTOR_SUPPORT_V1 :
5927+ clientVectorSupportVersion = TDS .VECTORSUPPORT_VERSION_1 ;
5928+ break ;
5929+ case VECTOR_SUPPORT_OFF :
5930+ default :
5931+ // Should not reach here due to prior validation.
5932+ clientVectorSupportVersion = TDS .VECTORSUPPORT_VERSION_1 ;
5933+ break ;
59275934 }
5928-
59295935 tdsWriter .writeByte (clientVectorSupportVersion );
59305936 }
59315937 return len ;
@@ -7200,27 +7206,32 @@ private void onFeatureExtAck(byte featureId, byte[] data) throws SQLServerExcept
72007206 * @return The negotiated vector version
72017207 */
72027208 private byte negotiateVectorVersion (String clientVectorSupport , byte serverVersion ) {
7203- // If client has vector support disabled, return "off"
7204- if (VECTOR_SUPPORT_OFF .equalsIgnoreCase (clientVectorSupport )) {
7205- return TDS .VECTORSUPPORT_NOT_SUPPORTED ;
7206- }
72077209
7208- // If server doesn't support vectors, return " off"
7210+ // If server doesn't support vectors, negotiation is off
72097211 if (serverVersion == TDS .VECTORSUPPORT_NOT_SUPPORTED ) {
72107212 return TDS .VECTORSUPPORT_NOT_SUPPORTED ;
72117213 }
72127214
7213- // Determine client's maximum supported version
72147215 byte clientMaxVersion ;
7215- if (VECTOR_SUPPORT_V2 .equalsIgnoreCase (clientVectorSupport )) {
7216- clientMaxVersion = TDS .VECTORSUPPORT_VERSION_2 ;
7217- } else if (VECTOR_SUPPORT_V1 .equalsIgnoreCase (clientVectorSupport )) {
7218- clientMaxVersion = TDS .VECTORSUPPORT_VERSION_1 ;
7219- } else {
7220- return TDS .VECTORSUPPORT_NOT_SUPPORTED ; // Invalid client setting
7216+
7217+ switch (clientVectorSupport .toLowerCase ()) {
7218+ case VECTOR_SUPPORT_OFF :
7219+ return TDS .VECTORSUPPORT_NOT_SUPPORTED ;
7220+
7221+ case VECTOR_SUPPORT_V2 :
7222+ clientMaxVersion = TDS .VECTORSUPPORT_VERSION_2 ;
7223+ break ;
7224+
7225+ case VECTOR_SUPPORT_V1 :
7226+ clientMaxVersion = TDS .VECTORSUPPORT_VERSION_1 ;
7227+ break ;
7228+
7229+ default :
7230+ // Invalid client setting
7231+ return TDS .VECTORSUPPORT_NOT_SUPPORTED ;
72217232 }
72227233
7223- // Negotiate version: use minimum of client and server versions
7234+ // Negotiate using the minimum supported version
72247235 return (byte ) Math .min (clientMaxVersion , serverVersion );
72257236 }
72267237
@@ -7531,6 +7542,7 @@ final boolean complete(LogonCommand logonCommand, TDSReader tdsReader) throws SQ
75317542
75327543 // request vector support
75337544 len += writeVectorSupportFeatureRequest (false , tdsWriter );
7545+
75347546 // request JSON support
75357547 len += writeJSONSupportFeatureRequest (false , tdsWriter );
75367548
0 commit comments