+
    JV-ji%  ã                   ób   € R t ^ RIt ! R R4      tR tR tR tR tR tR	 t	R
 t
R tR tR tR# )a‹  
Functions to interact with Arrow memory allocated by Arrow Java.

These functions convert the objects holding the metadata, the actual
data is not copied at all.

This will only work with a JVM running in the same process such as provided
through jpype. Modules that talk to a remote JVM like py4j will not work as the
memory addresses reported by them are not reachable in the python process.
Nc                   ó4   a € ] tR t^t o RtRtR tR tRtV t	R# )Ú_JvmBufferNannyzT
An object that keeps a org.apache.arrow.memory.ArrowBuf's underlying
memory alive.
Nc                óR   € VP                  4       pVP                  4        W n        R # ©N)ÚgetReferenceManagerÚretainÚref_manager)ÚselfÚjvm_bufr   s   && Ú\/Volumes/fast/ai/experiments/ui-tars-smoke/.venv/lib/python3.14/site-packages/pyarrow/jvm.pyÚ__init__Ú_JvmBufferNanny.__init__&   s$   € Ø×1Ñ1Ó3ˆð 	×ÑÔØ&Öó    c                óZ   € V P                   e   V P                   P                  4        R # R # r   )r   Úrelease)r	   s   &r   Ú__del__Ú_JvmBufferNanny.__del__.   s%   € Ø×ÑÒ'Ø×Ñ×$Ñ$Ö&ñ (r   )r   )
Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__r   r   r   Ú__static_attributes__Ú__classdictcell__)Ú__classdict__s   @r   r   r      s    ø‡ € ñð €Kò'÷'ð 'r   r   c                óˆ   € \        V 4      pV P                  4       pV P                  4       p\        P                  ! W#VR7      # )a  
Construct an Arrow buffer from org.apache.arrow.memory.ArrowBuf

Parameters
----------

jvm_buf: org.apache.arrow.memory.ArrowBuf
    Arrow Buffer representation on the JVM.

Returns
-------
pyarrow.Buffer
    Python Buffer that references the JVM memory.
)Úbase)r   ÚmemoryAddressÚcapacityÚpaÚforeign_buffer)r
   ÚnannyÚaddressÚsizes   &   r   Ú
jvm_bufferr$   3   s=   € ô ˜GÓ$€EØ×#Ñ#Ó%€GØ×ÑÓ€DÜ×Ò˜W°Ô7Ð7r   c                ó  € V P                  4       pV P                  4       '       ds   V^8X  d   \        P                  ! 4       # V^8X  d   \        P                  ! 4       # V^ 8X  d   \        P
                  ! 4       # V^@8X  d   \        P                  ! 4       # R# V^8X  d   \        P                  ! 4       # V^8X  d   \        P                  ! 4       # V^ 8X  d   \        P                  ! 4       # V^@8X  d   \        P                  ! 4       # R# )z­
Convert a JVM int type to its Python equivalent.

Parameters
----------
jvm_type : org.apache.arrow.vector.types.pojo.ArrowType$Int

Returns
-------
typ : pyarrow.DataType
N)ÚgetBitWidthÚgetIsSignedr   Úint8Úint16Úint32Úint64Úuint8Úuint16Úuint32Úuint64)Újvm_typeÚ	bit_widths   & r   Ú_from_jvm_int_typer2   H   sÅ   € ð ×$Ñ$Ó&€IØ×Ñ×ÒØ˜Œ>Ü—7’7“9ÐØ˜"Œ_Ü—8’8“:ÐØ˜"Œ_Ü—8’8“:ÐØ˜"Œ_Ü—8’8“:Ðñ ð ˜Œ>Ü—8’8“:ÐØ˜"Œ_Ü—9’9“;ÐØ˜"Œ_Ü—9’9“;ÐØ˜"Œ_Ü—9’9“;Ðñ r   c                óê   € V P                  4       P                  4       pVR8X  d   \        P                  ! 4       # VR8X  d   \        P                  ! 4       # VR8X  d   \        P
                  ! 4       # R# )z·
Convert a JVM float type to its Python equivalent.

Parameters
----------
jvm_type: org.apache.arrow.vector.types.pojo.ArrowType$FloatingPoint

Returns
-------
typ: pyarrow.DataType
ÚHALFÚSINGLEÚDOUBLEN)ÚgetPrecisionÚtoStringr   Úfloat16Úfloat32Úfloat64)r0   Ú	precisions   & r   Ú_from_jvm_float_typer=   j   s\   € ð ×%Ñ%Ó'×0Ñ0Ó2€IØ�FÔÜ�zŠz‹|ÐØ	�hÔ	Ü�zŠz‹|ÐØ	�hÔ	Ü�zŠz‹|Ðñ 
r   c                óâ  € V P                  4       P                  4       pVR8X  d.   V P                  4       ^ 8X  g   Q h\        P                  ! R4      # VR8X  d.   V P                  4       ^ 8X  g   Q h\        P                  ! R4      # VR8X  d.   V P                  4       ^@8X  g   Q h\        P
                  ! R4      # VR8X  d.   V P                  4       ^@8X  g   Q h\        P
                  ! R4      # R	# )
z­
Convert a JVM time type to its Python equivalent.

Parameters
----------
jvm_type: org.apache.arrow.vector.types.pojo.ArrowType$Time

Returns
-------
typ: pyarrow.DataType
ÚSECONDÚsÚMILLISECONDÚmsÚMICROSECONDÚusÚ
NANOSECONDÚnsN)ÚgetUnitr8   r&   r   Útime32Útime64)r0   Ú	time_units   & r   Ú_from_jvm_time_typerK      sÔ   € ð × Ñ Ó"×+Ñ+Ó-€IØ�HÔØ×#Ñ#Ó%¨Ô+Ð+Ð+Ü�yŠy˜‹~ÐØ	�mÔ	#Ø×#Ñ#Ó%¨Ô+Ð+Ð+Ü�yŠy˜‹ÐØ	�mÔ	#Ø×#Ñ#Ó%¨Ô+Ð+Ð+Ü�yŠy˜‹ÐØ	�lÔ	"Ø×#Ñ#Ó%¨Ô+Ð+Ð+Ü�yŠy˜‹Ðñ 
#r   c                óx  € V P                  4       P                  4       pV P                  4       pVe   \        V4      pVR8X  d   \        P
                  ! RVR7      # VR8X  d   \        P
                  ! RVR7      # VR8X  d   \        P
                  ! RVR7      # VR	8X  d   \        P
                  ! R
VR7      # R# )z·
Convert a JVM timestamp type to its Python equivalent.

Parameters
----------
jvm_type: org.apache.arrow.vector.types.pojo.ArrowType$Timestamp

Returns
-------
typ: pyarrow.DataType
Nr?   r@   )ÚtzrA   rB   rC   rD   rE   rF   )rG   r8   ÚgetTimezoneÚstrr   Ú	timestamp)r0   rJ   Útimezones   &  r   Ú_from_jvm_timestamp_typerR   š   s¡   € ð × Ñ Ó"×+Ñ+Ó-€IØ×#Ñ#Ó%€HØÒÜ�x“=ˆØ�HÔÜ�|Š|˜C HÔ-Ð-Ø	�mÔ	#Ü�|Š|˜D XÔ.Ð.Ø	�mÔ	#Ü�|Š|˜D XÔ.Ð.Ø	�lÔ	"Ü�|Š|˜D XÔ.Ð.ñ 
#r   c                ó²   € V P                  4       P                  4       pVR8X  d   \        P                  ! 4       # VR8X  d   \        P                  ! 4       # R# )z¬
Convert a JVM date type to its Python equivalent

Parameters
----------
jvm_type: org.apache.arrow.vector.types.pojo.ArrowType$Date

Returns
-------
typ: pyarrow.DataType
ÚDAYrA   N)rG   r8   r   Údate32Údate64)r0   Úday_units   & r   Ú_from_jvm_date_typerX   ´   sH   € ð ×ÑÓ!×*Ñ*Ó,€HØ�5ÔÜ�yŠy‹{ÐØ	�]Ô	"Ü�yŠy‹{Ðñ 
#r   c                ó´  € \        V P                  4       4      pV P                  4       pRpVP                  4       '       Egj   VP	                  4       P                  4       pVR8X  d   \        P                  ! 4       pEM8VR8X  d   \        V4      pEM$VR8X  d   \        V4      pEMVR8X  d   \        P                  ! 4       pMóVR8X  d   \        P                  ! 4       pMÖVR8X  d&   \        P                  ! VP                  4       4      pMªVR8X  d   \        P                  ! 4       pM�VR	8X  d   \        V4      pMzVR
8X  d   \        V4      pMgVR8X  d   \!        V4      pMTVR8X  d5   \        P"                  ! VP%                  4       VP'                  4       4      pM\)        RV 24      h\)        R4      hV P+                  4       pV P-                  4       pVP/                  4       '       d   RpMNVP1                  4        Uu/ uF4  p\        VP3                  4       4      \        VP5                  4       4      bK6  	  pp\        P6                  ! WWW4      # u upi )z·
Construct a Field from a org.apache.arrow.vector.types.pojo.Field
instance.

Parameters
----------
jvm_field: org.apache.arrow.vector.types.pojo.Field

Returns
-------
pyarrow.Field
NÚNullÚIntÚFloatingPointÚUtf8ÚBinaryÚFixedSizeBinaryÚBoolÚTimeÚ	TimestampÚDateÚDecimalzUnsupported JVM type: z:JVM field conversion only implemented for primitive types.)rO   ÚgetNameÚgetTypeÚ	isComplexÚ	getTypeIDr8   r   Únullr2   r=   ÚstringÚbinaryÚgetByteWidthÚbool_rK   rR   rX   Ú
decimal128r7   ÚgetScaleÚNotImplementedErrorÚ
isNullableÚgetMetadataÚisEmptyÚentrySetÚgetKeyÚgetValueÚfield)	Ú	jvm_fieldÚnamer0   ÚtypÚtype_strÚnullableÚjvm_metadataÚmetadataÚentrys	   &        r   rw   rw   Ç   sú  € ô ˆy× Ñ Ó"Ó#€DØ× Ñ Ó"€Hà
€CØ×Ñ×ÓØ×%Ñ%Ó'×0Ñ0Ó2ˆØ�vÔÜ—'’'“)ŠCØ˜ÔÜ$ XÓ.ŠCØ˜Ô(Ü& xÓ0ŠCØ˜ÔÜ—)’)“+‰CØ˜Ô!Ü—)’)“+‰CØÐ*Ô*Ü—)’)˜H×1Ñ1Ó3Ó4‰CØ˜ÔÜ—(’(“*‰CØ˜ÔÜ% hÓ/‰CØ˜Ô$Ü*¨8Ó4‰CØ˜ÔÜ% hÓ/‰CØ˜Ô"Ü—-’- × 5Ñ 5Ó 7¸×9JÑ9JÓ9LÓM‰Cä%Ø(¨¨
Ð3ó5ð 5ô
 "ØHóJð 	Jð ×#Ñ#Ó%€HØ×(Ñ(Ó*€LØ×Ñ×ÒØ‰ð ".×!6Ñ!6Ô!8ó:Ù!8˜ô ˜Ÿ™›Ó'¬¨U¯^©^Ó-=Ó)>Ò>Ù!8ð 	ð :ä�8Š8�D˜xÓ2Ð2ùò:s   È:Ic                ó„  € V P                  4       pV Uu. uF  p\        V4      NK  	  ppV P                  4       pVP                  4       '       d   RpMNVP	                  4        Uu/ uF4  p\        VP                  4       4      \        VP                  4       4      bK6  	  pp\        P                  ! W4      # u upi u upi )z¼
Construct a Schema from a org.apache.arrow.vector.types.pojo.Schema
instance.

Parameters
----------
jvm_schema: org.apache.arrow.vector.types.pojo.Schema

Returns
-------
pyarrow.Schema
N)
Ú	getFieldsrw   ÚgetCustomMetadatars   rt   rO   ru   rv   r   Úschema)Ú
jvm_schemaÚfieldsÚfr}   r~   r   s   &     r   rƒ   rƒ     s¬   € ð ×!Ñ!Ó#€FÙ &Ó'¡˜1Œe�AŽh¡€FÐ'Ø×/Ñ/Ó1€LØ×Ñ×ÒØ‰ð ".×!6Ñ!6Ô!8ó:Ù!8˜ô ˜Ÿ™›Ó'¬¨U¯^©^Ó-=Ó)>Ò>Ù!8ð 	ð :ä�9Š9�VÓ&Ð&ùò (ùò
:s   •B8Á&:B=c                óD  € V P                  4       P                  4       P                  4       '       d.   V P                  4       P	                  4       p\        RV R24      h\        V P                  4       4      P                  p\        V P                  R4      4       Uu. uF  p\        V4      NK  	  pp\        V4      ^ 8X  d   \        P                  ! . VR7      # V P                  4       pV P                  4       p\        P                   P#                  W%WF4      # u upi )zœ
Construct an (Python) Array from its JVM equivalent.

Parameters
----------
jvm_array : org.apache.arrow.vector.ValueVector

Returns
-------
array : Array
z'Cannot convert JVM Arrow array of type z$, complex types not yet implemented.F)Útype)ÚgetFieldrf   rg   ÚgetMinorTyper8   rp   rw   rˆ   ÚlistÚ
getBuffersr$   Úlenr   ÚarrayÚgetValueCountÚgetNullCountÚArrayÚfrom_buffers)Ú	jvm_arrayÚminor_type_strÚdtypeÚbufÚbuffersÚlengthÚ
null_counts   &      r   rŽ   rŽ     s  € ð ×ÑÓ×#Ñ#Ó%×/Ñ/×1Ò1Ø"×/Ñ/Ó1×:Ñ:Ó<ˆÜ!Ø5°nÐ5Eð F1ð 1ó2ð 	2ô �)×$Ñ$Ó&Ó'×,Ñ,€Eä˜y×3Ñ3°EÓ:Ô;ó=Ù;�3ô ˜#ŽÙ;ð ð =ô ˆ7ƒ|�qÔÜ�xŠx˜ Ô'Ð'à×$Ñ$Ó&€FØ×'Ñ'Ó)€JÜ�8‰8× Ñ  °ÓDÐDùò=s   ÂDc                ó  € \        V P                  4       4      p. pVP                   F,  pVP                  \	        V P                  V4      4      4       K.  	  \        P                  P                  VVP                  VP                  R7      # )zÊ
Construct a (Python) RecordBatch from a JVM VectorSchemaRoot

Parameters
----------
jvm_vector_schema_root : org.apache.arrow.vector.VectorSchemaRoot

Returns
-------
record_batch: pyarrow.RecordBatch
)r~   )
rƒ   Ú	getSchemaÚnamesÚappendrŽ   Ú	getVectorr   ÚRecordBatchÚfrom_arraysr~   )Újvm_vector_schema_rootÚ	pa_schemaÚarraysry   s   &   r   Úrecord_batchr¤   9  sy   € ô Ð-×7Ñ7Ó9Ó:€Ià€FØ—”ˆØ�‰”eÐ2×<Ñ<¸TÓBÓCÖDñ  ô �>‰>×%Ñ%ØØ�‰Ø×#Ñ#ð &ó ð r   )r   Úpyarrowr   r   r$   r2   r=   rK   rR   rX   rw   rƒ   rŽ   r¤   © r   r   Ú<module>r§      sN   ðñ"	ó ÷'ñ 'ò(8ò*òDò*ò6/ò4ò&93òx'ò0Eô<r   