Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

replace carry with indexedarray #261

Merged
merged 28 commits into from
Jun 30, 2020
Merged
Show file tree
Hide file tree
Changes from 16 commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
a29d2ef
following discussion with Jim to finish what Aditya Puranik started i…
ianna May 12, 2020
37ef9a2
add a copy flag for carry
ianna Jun 16, 2020
49b3929
switch to indexedarray in carry and comment out the segfalting tests:
ianna Jun 16, 2020
887353c
use an eager projection
ianna Jun 17, 2020
5bb7dfa
add comarison to IndexedArray64 for a lazy carry
ianna Jun 17, 2020
6db41c5
substitute results for failing tests
ianna Jun 17, 2020
9500950
fix listoffsetarray test
ianna Jun 17, 2020
efbeb0b
fix unionarray project
ianna Jun 17, 2020
812e264
remove comment
ianna Jun 17, 2020
429c625
add comments for failing tests
ianna Jun 17, 2020
d3dfaff
eager carry in gettiem
ianna Jun 17, 2020
97119d0
Merge branch 'master' of https://github.com/scikit-hep/awkward-1.0 in…
ianna Jun 17, 2020
96bd348
address Jim's comments
ianna Jun 18, 2020
c195654
lazy carry
ianna Jun 18, 2020
5d6ca9a
revert adding a line
ianna Jun 18, 2020
616573d
add more identity tests
ianna Jun 19, 2020
4a8612d
eager carry record array on field slicing
ianna Jun 22, 2020
41e2f15
don't sort array second time
ianna Jun 23, 2020
07120fd
carry is always eager except for combinations
ianna Jun 28, 2020
c27a4e5
allow lazy carry explicitly
ianna Jun 29, 2020
58e5603
Step 1: consistently name second 'carry' parameter as 'allow_lazy'.
jpivarski Jun 30, 2020
0fa8402
Step 2: explicit 'allow_lazy' in all calling sites, rather than defau…
jpivarski Jun 30, 2020
ee73b59
Step 3: most IndexedArray methods calling 'carry' should be eager, wi…
jpivarski Jun 30, 2020
0aaaddd
Step 4: fixing one infinite loop, all getitem_next for at, range, arr…
jpivarski Jun 30, 2020
a18221d
Step 5: far from introducing a bug, this change actually revealed a l…
jpivarski Jun 30, 2020
17d1292
A few last fixes for consistency: all jagged slices should allow_lazy…
jpivarski Jun 30, 2020
b04a08a
Merge branch 'master' into ianna/recordarray-carry-to-return-indexeda…
jpivarski Jun 30, 2020
088c48a
One last consistency-fix (in broadcast_tooffsets64) ensures that reco…
jpivarski Jun 30, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion include/awkward/Content.h
Original file line number Diff line number Diff line change
Expand Up @@ -479,7 +479,7 @@ namespace awkward {
/// {@link ListArrayOf ListArray}, only the `starts` and `stops` get
/// duplicated, not the `content` (and similarly for all other node types).
virtual const ContentPtr
carry(const Index64& carry) const = 0;
carry(const Index64& carry, bool must_be_eager = false) const = 0;

/// @brief The parameter associated with `key` at the first level
/// that has a non-null value, descending only as deep as the first
Expand Down
2 changes: 1 addition & 1 deletion include/awkward/array/BitMaskedArray.h
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ namespace awkward {
const Index64& advanced) const override;

const ContentPtr
carry(const Index64& carry) const override;
carry(const Index64& carry, bool must_be_eager) const override;

int64_t
numfields() const override;
Expand Down
2 changes: 1 addition & 1 deletion include/awkward/array/ByteMaskedArray.h
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ namespace awkward {
const Index64& advanced) const override;

const ContentPtr
carry(const Index64& carry) const override;
carry(const Index64& carry, bool must_be_eager) const override;

int64_t
numfields() const override;
Expand Down
2 changes: 1 addition & 1 deletion include/awkward/array/EmptyArray.h
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ namespace awkward {
getitem_fields(const std::vector<std::string>& keys) const override;

const ContentPtr
carry(const Index64& carry) const override;
carry(const Index64& carry, bool must_be_eager) const override;

int64_t
numfields() const override;
Expand Down
2 changes: 1 addition & 1 deletion include/awkward/array/IndexedArray.h
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ namespace awkward {
const Index64& advanced) const override;

const ContentPtr
carry(const Index64& carry) const override;
carry(const Index64& carry, bool must_be_eager) const override;

int64_t
numfields() const override;
Expand Down
2 changes: 1 addition & 1 deletion include/awkward/array/ListArray.h
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ namespace awkward {
getitem_fields(const std::vector<std::string>& keys) const override;

const ContentPtr
carry(const Index64& carry) const override;
carry(const Index64& carry, bool must_be_eager) const override;

int64_t
numfields() const override;
Expand Down
2 changes: 1 addition & 1 deletion include/awkward/array/ListOffsetArray.h
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ namespace awkward {
const Slice& tail) const override;

const ContentPtr
carry(const Index64& carry) const override;
carry(const Index64& carry, bool must_be_eager) const override;

int64_t
numfields() const override;
Expand Down
2 changes: 1 addition & 1 deletion include/awkward/array/None.h
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ namespace awkward {

/// @exception std::runtime_error is always thrown
const ContentPtr
carry(const Index64& carry) const override;
carry(const Index64& carry, bool must_be_eager) const override;

/// @exception std::runtime_error is always thrown
int64_t
Expand Down
2 changes: 1 addition & 1 deletion include/awkward/array/NumpyArray.h
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,7 @@ namespace awkward {
const Index64& advanced) const override;

const ContentPtr
carry(const Index64& carry) const override;
carry(const Index64& carry, bool must_be_eager) const override;

int64_t
numfields() const override;
Expand Down
6 changes: 3 additions & 3 deletions include/awkward/array/RawArray.h
Original file line number Diff line number Diff line change
Expand Up @@ -658,7 +658,7 @@ namespace awkward {
}

const ContentPtr
carry(const Index64& carry) const override {
carry(const Index64& carry, bool must_be_eager) const override {
std::shared_ptr<T> ptr(new T[(size_t)carry.length()],
util::array_deleter<T>());
struct Error err = awkward_numpyarray_getitem_next_null_64(
Expand Down Expand Up @@ -1077,7 +1077,7 @@ namespace awkward {
nextcarryptr[i] = start + step*i;
}

return carry(nextcarry);
return carry(nextcarry, false);
}
}

Expand All @@ -1098,7 +1098,7 @@ namespace awkward {
flathead.length(),
length_);
util::handle_error(err, classname(), identities_.get());
return carry(flathead);
return carry(flathead, false);
}

const ContentPtr
Expand Down
2 changes: 1 addition & 1 deletion include/awkward/array/Record.h
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ namespace awkward {

/// @exception std::runtime_error is always thrown
const ContentPtr
carry(const Index64& carry) const override;
carry(const Index64& carry, bool must_be_eager) const override;

int64_t
purelist_depth() const override;
Expand Down
2 changes: 1 addition & 1 deletion include/awkward/array/RecordArray.h
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ namespace awkward {
const Index64& advanced) const override;

const ContentPtr
carry(const Index64& carry) const override;
carry(const Index64& carry, bool must_be_eager) const override;

int64_t
numfields() const override;
Expand Down
2 changes: 1 addition & 1 deletion include/awkward/array/RegularArray.h
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ namespace awkward {
getitem_fields(const std::vector<std::string>& keys) const override;

const ContentPtr
carry(const Index64& carry) const override;
carry(const Index64& carry, bool must_be_eager) const override;

int64_t
numfields() const override;
Expand Down
2 changes: 1 addition & 1 deletion include/awkward/array/UnionArray.h
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ namespace awkward {
const Index64& advanced) const override;

const ContentPtr
carry(const Index64& carry) const override;
carry(const Index64& carry, bool must_be_eager) const override;

int64_t
numfields() const override;
Expand Down
2 changes: 1 addition & 1 deletion include/awkward/array/UnmaskedArray.h
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ namespace awkward {
const Index64& advanced) const override;

const ContentPtr
carry(const Index64& carry) const override;
carry(const Index64& carry, bool must_be_eager) const override;

int64_t
numfields() const override;
Expand Down
2 changes: 1 addition & 1 deletion include/awkward/array/VirtualArray.h
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ namespace awkward {
getitem_fields(const std::vector<std::string>& keys) const override;

const ContentPtr
carry(const Index64& carry) const override;
carry(const Index64& carry, bool must_be_eager) const override;

const std::string
purelist_parameter(const std::string& key) const override;
Expand Down
4 changes: 2 additions & 2 deletions src/libawkward/array/BitMaskedArray.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -626,8 +626,8 @@ namespace awkward {
}

const ContentPtr
BitMaskedArray::carry(const Index64& carry) const {
return toByteMaskedArray().get()->carry(carry);
BitMaskedArray::carry(const Index64& carry, bool must_be_eager) const {
return toByteMaskedArray().get()->carry(carry, must_be_eager);
}

int64_t
Expand Down
6 changes: 3 additions & 3 deletions src/libawkward/array/ByteMaskedArray.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ namespace awkward {
valid_when_);
util::handle_error(err2, classname(), identities_.get());

return content_.get()->carry(nextcarry);
return content_.get()->carry(nextcarry, true);
}

const ContentPtr
Expand Down Expand Up @@ -639,7 +639,7 @@ namespace awkward {
}

const ContentPtr
ByteMaskedArray::carry(const Index64& carry) const {
ByteMaskedArray::carry(const Index64& carry, bool must_be_eager) const {
Index8 nextmask(carry.length());
struct Error err = awkward_bytemaskedarray_getitem_carry_64(
nextmask.ptr().get(),
Expand Down Expand Up @@ -1036,7 +1036,7 @@ namespace awkward {
Index64 nextcarry = pair.first;
Index64 outindex = pair.second;

ContentPtr next = content_.get()->carry(nextcarry);
ContentPtr next = content_.get()->carry(nextcarry, false);
ContentPtr out = next.get()->combinations(n,
replacement,
recordlookup,
Expand Down
2 changes: 1 addition & 1 deletion src/libawkward/array/EmptyArray.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ namespace awkward {
}

const ContentPtr
EmptyArray::carry(const Index64& carry) const {
EmptyArray::carry(const Index64& carry, bool must_be_eager) const {
return shallow_copy();
}

Expand Down
18 changes: 9 additions & 9 deletions src/libawkward/array/IndexedArray.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,7 @@ namespace awkward {
content_.get()->length());
util::handle_error(err2, classname(), identities_.get());

return content_.get()->carry(nextcarry);
return content_.get()->carry(nextcarry, true);
}
else {
Index64 nextcarry(length());
Expand All @@ -371,7 +371,7 @@ namespace awkward {
content_.get()->length());
util::handle_error(err, classname(), identities_.get());

return content_.get()->carry(nextcarry);
return content_.get()->carry(nextcarry, true);
}
}

Expand Down Expand Up @@ -1140,7 +1140,7 @@ namespace awkward {
Index64 nextcarry = pair.first;
IndexOf<T> outindex = pair.second;

ContentPtr next = content_.get()->carry(nextcarry);
ContentPtr next = content_.get()->carry(nextcarry, true);
ContentPtr out = next.get()->getitem_next(head, tail, advanced);
IndexedArrayOf<T, ISOPTION> out2(identities_,
parameters_,
Expand All @@ -1158,7 +1158,7 @@ namespace awkward {
content_.get()->length());
util::handle_error(err, classname(), identities_.get());

ContentPtr next = content_.get()->carry(nextcarry);
ContentPtr next = content_.get()->carry(nextcarry, true);
return next.get()->getitem_next(head, tail, advanced);
}
}
Expand Down Expand Up @@ -1189,7 +1189,7 @@ namespace awkward {

template <typename T, bool ISOPTION>
const ContentPtr
IndexedArrayOf<T, ISOPTION>::carry(const Index64& carry) const {
IndexedArrayOf<T, ISOPTION>::carry(const Index64& carry, bool must_be_eager) const {
IndexOf<T> nextindex(carry.length());
struct Error err = util::awkward_indexedarray_getitem_carry_64<T>(
nextindex.ptr().get(),
Expand Down Expand Up @@ -1664,7 +1664,7 @@ namespace awkward {
content_.get()->length());
util::handle_error(err2, classname(), identities_.get());

ContentPtr next = content_.get()->carry(nextcarry);
ContentPtr next = content_.get()->carry(nextcarry, true);

SliceItemPtr slicecontent = next.get()->asslice();
if (SliceArray64* raw =
Expand Down Expand Up @@ -1961,7 +1961,7 @@ namespace awkward {
Index64 nextcarry = pair.first;
IndexOf<T> outindex = pair.second;

ContentPtr next = content_.get()->carry(nextcarry);
ContentPtr next = content_.get()->carry(nextcarry, false);
ContentPtr out = next.get()->combinations(n,
replacement,
recordlookup,
Expand Down Expand Up @@ -2281,7 +2281,7 @@ namespace awkward {
Index64 nextcarry = pair.first;
IndexOf<T> outindex = pair.second;

ContentPtr next = content_.get()->carry(nextcarry);
ContentPtr next = content_.get()->carry(nextcarry, true);
ContentPtr out = next.get()->getitem_next_jagged(slicestarts,
slicestops,
slicecontent,
Expand All @@ -2302,7 +2302,7 @@ namespace awkward {
content_.get()->length());
util::handle_error(err, classname(), identities_.get());

ContentPtr next = content_.get()->carry(nextcarry);
ContentPtr next = content_.get()->carry(nextcarry, true);
return next.get()->getitem_next_jagged(slicestarts,
slicestops,
slicecontent,
Expand Down
4 changes: 2 additions & 2 deletions src/libawkward/array/ListArray.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -683,7 +683,7 @@ namespace awkward {

template <typename T>
const ContentPtr
ListArrayOf<T>::carry(const Index64& carry) const {
ListArrayOf<T>::carry(const Index64& carry, bool must_be_eager) const {
int64_t lenstarts = starts_.length();
if (stops_.length() < lenstarts) {
util::handle_error(
Expand Down Expand Up @@ -1357,7 +1357,7 @@ namespace awkward {

ContentPtrVec contents;
for (auto ptr : tocarry) {
contents.push_back(content_.get()->carry(Index64(ptr, 0, totallen)));
contents.push_back(content_.get()->carry(Index64(ptr, 0, totallen), false));
}
ContentPtr recordarray = std::make_shared<RecordArray>(
Identities::none(),
Expand Down
4 changes: 2 additions & 2 deletions src/libawkward/array/ListOffsetArray.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -695,7 +695,7 @@ namespace awkward {

template <typename T>
const ContentPtr
ListOffsetArrayOf<T>::carry(const Index64& carry) const {
ListOffsetArrayOf<T>::carry(const Index64& carry, bool must_be_eager) const {
IndexOf<T> starts = util::make_starts(offsets_);
IndexOf<T> stops = util::make_stops(offsets_);
IndexOf<T> nextstarts(carry.length());
Expand Down Expand Up @@ -1661,7 +1661,7 @@ namespace awkward {

ContentPtrVec contents;
for (auto ptr : tocarry) {
contents.push_back(content_.get()->carry(Index64(ptr, 0, totallen)));
contents.push_back(content_.get()->carry(Index64(ptr, 0, totallen), false));
}
ContentPtr recordarray = std::make_shared<RecordArray>(
Identities::none(), parameters, contents, recordlookup);
Expand Down
2 changes: 1 addition & 1 deletion src/libawkward/array/None.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ namespace awkward {
}

const ContentPtr
None::carry(const Index64& carry) const {
None::carry(const Index64& carry, bool must_be_eager) const {
throw std::runtime_error("undefined operation: None::carry");
}

Expand Down
2 changes: 1 addition & 1 deletion src/libawkward/array/NumpyArray.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1222,7 +1222,7 @@ namespace awkward {
}

const ContentPtr
NumpyArray::carry(const Index64& carry) const {
NumpyArray::carry(const Index64& carry, bool must_be_eager) const {
std::shared_ptr<void> ptr(
new uint8_t[(size_t)(carry.length()*strides_[0])],
util::array_deleter<uint8_t>());
Expand Down
2 changes: 1 addition & 1 deletion src/libawkward/array/Record.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ namespace awkward {
}

const ContentPtr
Record::carry(const Index64& carry) const {
Record::carry(const Index64& carry, bool must_be_eager) const {
throw std::runtime_error("undefined operation: Record::carry");
}

Expand Down
29 changes: 19 additions & 10 deletions src/libawkward/array/RecordArray.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -737,20 +737,29 @@ namespace awkward {
}

const ContentPtr
RecordArray::carry(const Index64& carry) const {
ContentPtrVec contents;
for (auto content : contents_) {
contents.push_back(content.get()->carry(carry));
}
RecordArray::carry(const Index64& carry, bool must_be_eager) const {
IdentitiesPtr identities(nullptr);
if (identities_.get() != nullptr) {
identities = identities_.get()->getitem_carry_64(carry);
}
return std::make_shared<RecordArray>(identities,
parameters_,
contents,
recordlookup_,
carry.length());
if (must_be_eager) {
ContentPtrVec contents;
for (auto content : contents_) {
contents.push_back(content.get()->carry(carry, must_be_eager));
}
return std::make_shared<RecordArray>(identities,
parameters_,
contents,
recordlookup_,
carry.length());

}
else {
return std::make_shared<IndexedArray64>(identities,
util::Parameters(),
carry,
shallow_copy());
}
}

int64_t
Expand Down
Loading