MCPcopy Index your code
hub / github.com/feast-dev/feast / Array

Class Array

sdk/python/feast/types.py:177–218  ·  view source on GitHub ↗

An Array represents a list of types. Attributes: base_type: The base type of the array.

Source from the content-addressed store, hash-verified

175
176
177class Array(ComplexFeastType):
178 """
179 An Array represents a list of types.
180
181 Attributes:
182 base_type: The base type of the array.
183 """
184
185 base_type: Union[PrimitiveFeastType, ComplexFeastType]
186
187 def __init__(self, base_type: Union[PrimitiveFeastType, "ComplexFeastType"]):
188 # Allow Struct, Array, and Set as base types for nested collections
189 if (
190 not isinstance(base_type, (Struct, Array, Set))
191 and base_type not in SUPPORTED_BASE_TYPES
192 ):
193 raise ValueError(
194 f"Type {type(base_type)} is currently not supported as a base type for Array."
195 )
196
197 self.base_type = base_type
198
199 def to_value_type(self) -> ValueType:
200 if isinstance(self.base_type, Struct):
201 return ValueType.STRUCT_LIST
202 if isinstance(self.base_type, (Array, Set)):
203 return ValueType.VALUE_LIST
204 assert isinstance(self.base_type, PrimitiveFeastType)
205 value_type_name = PRIMITIVE_FEAST_TYPES_TO_VALUE_TYPES[self.base_type.name]
206 value_type_list_name = value_type_name + "_LIST"
207 return ValueType[value_type_list_name]
208
209 def __eq__(self, other):
210 if isinstance(other, Array):
211 return self.base_type == other.base_type
212 return False
213
214 def __hash__(self):
215 return hash(("Array", hash(self.base_type)))
216
217 def __str__(self):
218 return f"Array({self.base_type})"
219
220
221class Set(ComplexFeastType):

Calls

no outgoing calls