Package com.lancedb.lance.spark.utils
Class VectorUtils
java.lang.Object
com.lancedb.lance.spark.utils.VectorUtils
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic StringcreateVectorSizePropertyKey(String columnName) Create a property key for specifying vector dimensions in table properties.static intgetVectorArrowDimension(org.apache.arrow.vector.types.pojo.Field field) Get the vector dimension from an Arrow FixedSizeList field.static longgetVectorDimension(org.apache.spark.sql.types.StructField field) Get the vector dimension from a Spark field's metadata.static booleanisVectorArrowField(org.apache.arrow.vector.types.pojo.Field field) Check if an Arrow field is a vector field (FixedSizeList).static booleanisVectorField(org.apache.spark.sql.types.StructField field) Check if a Spark field is a vector field (FixedSizeList) based on its metadata.static booleanshouldBeFixedSizeList(org.apache.spark.sql.types.DataType dataType, org.apache.spark.sql.types.Metadata metadata) Check if a Spark DataType should be treated as a FixedSizeList based on metadata.
-
Field Details
-
ARROW_FIXED_SIZE_LIST_SIZE_KEY
- See Also:
-
-
Constructor Details
-
VectorUtils
public VectorUtils()
-
-
Method Details
-
isVectorField
public static boolean isVectorField(org.apache.spark.sql.types.StructField field) Check if a Spark field is a vector field (FixedSizeList) based on its metadata.- Parameters:
field- the Spark struct field to check- Returns:
- true if the field is a vector field, false otherwise
-
getVectorDimension
public static long getVectorDimension(org.apache.spark.sql.types.StructField field) Get the vector dimension from a Spark field's metadata.- Parameters:
field- the Spark struct field- Returns:
- the vector dimension, or -1 if not a vector field
-
isVectorArrowField
public static boolean isVectorArrowField(org.apache.arrow.vector.types.pojo.Field field) Check if an Arrow field is a vector field (FixedSizeList).- Parameters:
field- the Arrow field to check- Returns:
- true if the field is a vector field, false otherwise
-
getVectorArrowDimension
public static int getVectorArrowDimension(org.apache.arrow.vector.types.pojo.Field field) Get the vector dimension from an Arrow FixedSizeList field.- Parameters:
field- the Arrow field- Returns:
- the vector dimension, or -1 if not a vector field
-
shouldBeFixedSizeList
public static boolean shouldBeFixedSizeList(org.apache.spark.sql.types.DataType dataType, org.apache.spark.sql.types.Metadata metadata) Check if a Spark DataType should be treated as a FixedSizeList based on metadata.- Parameters:
dataType- the Spark data typemetadata- the field metadata- Returns:
- true if it should be a FixedSizeList, false otherwise
-
createVectorSizePropertyKey
Create a property key for specifying vector dimensions in table properties. This is used in CREATE TABLE statements.- Parameters:
columnName- the name of the column- Returns:
- the property key for specifying vector dimension
-