You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@arrow.apache.org by "ASF GitHub Bot (JIRA)" <ji...@apache.org> on 2018/03/04 15:54:00 UTC
[jira] [Commented] (ARROW-2252) [Python] Create buffer from address, size and base
[ https://issues.apache.org/jira/browse/ARROW-2252?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16385205#comment-16385205 ]
ASF GitHub Bot commented on ARROW-2252:
---------------------------------------
xhochy opened a new pull request #1693: ARROW-2252: [Python] Create buffer from address, size and base
URL: https://github.com/apache/arrow/pull/1693
Usage with Arrow Java vectors:
```
import jpype
import numpy as np
import pyarrow as pa
import sys
# Start JVM with Arrow and all of its dependencies.
jpype.startJVM(getDefaultJVMPath(), "-Djava.class.path=arrow-tools-0.9.0-SNAPSHOT-jar-with-dependencies.jar")
# Create vector
ra = jpype.JPackage("org").apache.arrow.memory.RootAllocator(sys.maxsize)
uint1 = jpype.JPackage("org").apache.arrow.vector.UInt1Vector("int", ra)
uint1.allocateNew(128)
for i in range(128):
uint1.setSafe(i, i)
uint1.setValueCount(128)
# Access it in Python
addr = uint1.getDataBuffer().unwrap().memoryAddress()
size = uint1.getDataBuffer().unwrap().capacity()
fb = pa.ForeignBuffer(addr, size, n)
np.asarray(fb)
```
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
> [Python] Create buffer from address, size and base
> --------------------------------------------------
>
> Key: ARROW-2252
> URL: https://issues.apache.org/jira/browse/ARROW-2252
> Project: Apache Arrow
> Issue Type: New Feature
> Components: Python
> Reporter: Uwe L. Korn
> Priority: Major
> Labels: pull-request-available
> Fix For: 0.9.0
>
>
> Given a memory address and a size, we should be able to construct an Arrow buffer from this. The additional base object will be used to hold a reference to the underlying, original buffer so that it does not go out of scope before the Arrow buffer.
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)