Skip to content

ARROW-657: [C++/Python] Expose Tensor IPC in Python. Add equals method. Add pyarrow.create_memory_map/memory_map functions - #483

Closed
wesm wants to merge 6 commits into
apache:masterfrom
wesm:ARROW-657
Closed

wesm wants to merge 6 commits into
apache:masterfrom
wesm:ARROW-657

Conversation

@wesm

@wesm wesm commented Apr 3, 2017

Copy link
Copy Markdown
Member

This adds a MemoryMappedFile::Create C++ function for allocating new memory maps of a particular size, with a Python wrapper. I combined the Cython header declarations for the main libarrow libraries into a single pxd file.

I am also checking in some tests from ARROW-718 that got left off the patch.

… function

and memory_map factory

Change-Id: I88bfef0abcef8337a928f25c05f3a7ecc1b3fa10
@wesm

wesm commented Apr 3, 2017

Copy link
Copy Markdown
Member Author

Example code

mmap = pa.create_memory_map(path, 1024)

pa.write_tensor(tensor, mmap)

mmap.seek(0)
result = pa.read_tensor(mmap)

assert result.equals(tensor)

wesm added 4 commits April 2, 2017 21:45
Change-Id: Ifb22f75199860bb13d047789f04c5c709afeac36
Change-Id: I42038f71ab0600c5c9383d3ad88893676c05acd8
Change-Id: I82151d3965a8be0592e3de7c0445777c0d851d61
// TODO: speed up. See https://graphics.stanford.edu/~seander/bithacks.html
// "Conditionally set or clear bits without branching"
bits[i / 8] ^= static_cast<uint8_t>(-bit_is_set ^ bits[i / 8]) & kBitmask[i % 8];
if (bit_is_set) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are we reverting this here again?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I couldn't figure out how to port the bit twiddling code in a way that MSVC was happy about. Since we're only using this function in CopyBitmap right now, I left a TODO and figured we can return to it later

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We'll probably also want to start a util-benchmark.cc when working on this so we aren't guessing about what's more performant (the Stanford link claims 5-15% faster without branching, but it would be good to know for sure)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I created ARROW-764 to remember to look at this. Merging the PR

Comment thread python/pyarrow/io.pyx Outdated

def __cinit__(self, path, mode='r'):
def __cinit__(self):
self.is_readable = self.is_writeable = 0

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would prefer if we refrain from using this syntax. It might save a line but it less readable.

@wesm wesm Apr 3, 2017 •

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

Change-Id: I2a6164ade56d01564d04a4cfc924a1c1476eab22
@asfgit asfgit closed this in 7d1d4e7 Apr 3, 2017
@wesm
wesm deleted the ARROW-657 branch April 3, 2017 22:05
wesm pushed a commit to wesm/arrow that referenced this pull request Sep 8, 2018
This is required before we can remove some duplicate or little-used APIs in ARROW-2950.

Author: Antoine Pitrou <antoine@python.org>

Closes apache#483 from pitrou/PARQUET-1366-arrow-bit-util and squashes the following commits:

1eb6ef0 [Antoine Pitrou] Avoid using FirstTimeBitmapWriter for now (this Arrow API is too recent)
57aa82c [Antoine Pitrou] Fix line size
86c4ca5 [Antoine Pitrou] PARQUET-1366: [C++] Streamline use of Arrow bit-util.h

Change-Id: Ibf665b155781541dd4c468a52b17630da11f1859
pribor pushed a commit to GlobalWebIndex/arrow that referenced this pull request Oct 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants