Skip to content
This repository was archived by the owner on Mar 8, 2020. It is now read-only.

Filter implementation #109

Merged
merged 8 commits into from
Aug 14, 2019
Merged

Filter implementation #109

merged 8 commits into from
Aug 14, 2019

Conversation

bzz
Copy link
Contributor

@bzz bzz commented Aug 13, 2019

Addresses the last major part of the #83 - XPath query/filter implementation

TODOs

  • XPath query for native nodes
  • XPath query for managed nodes
  • high-level API in client for both cases
  • make all tests pass
  • addressing the last FIXME

This change is Reviewable

@bzz bzz requested review from creachadair and dennwc August 13, 2019 01:02
@bzz
Copy link
Contributor Author

bzz commented Aug 13, 2019

Overall, all moving parts are there and it's ready for the feedback.

CI is expected to fail; will fix the last todo item, a failing test, first thing in the morning.

@bzz bzz self-assigned this Aug 13, 2019
@ncordon ncordon self-requested a review August 13, 2019 11:13
bzz added 2 commits August 13, 2019 20:14
Signed-off-by: Alexander Bezzubov <[email protected]>
Signed-off-by: Alexander Bezzubov <[email protected]>
@bzz bzz force-pushed the iterator-filter branch from d72248e to c8bebf6 Compare August 13, 2019 18:14
@bzz
Copy link
Contributor Author

bzz commented Aug 13, 2019

@creachadair CI is green and it's ready for a review

@bzz bzz mentioned this pull request Aug 13, 2019
17 tasks
Copy link
Contributor

@creachadair creachadair left a comment

Choose a reason for hiding this comment

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

I just have a couple of small comments; otherwise I think this looks good.

Reviewed 9 of 17 files at r1, 8 of 8 files at r3, 2 of 3 files at r4.
Reviewable status: 16 of 17 files reviewed, 4 unresolved discussions (waiting on @bzz, @creachadair, @dennwc, and @ncordon)


src/main/native/org_bblfsh_client_v2_libuast_Libuast.cc, line 157 at r3 (raw file):

  // Filter queries an external UAST.
  // Borrows the reference.

Does this mean that while the filter is active, it is not safe to use the node? (That's ok if so: But we should probably document it, since I think it may mean we must fully exhaust or explicitly release the iterator to ensure the node returns to a valid state in case of error)


src/main/scala/org/bblfsh/client/v2/libuast/Libuast.scala, line 17 at r4 (raw file):

  if (!loaded) {
    println("Loading native libscalauast")

Is this meant to be to stderr and/or a log? (Otherwise anyone who imports this library will spam their stdout)


src/test/scala/org/bblfsh/client/v2/FilterManagedTest.scala, line 22 at r4 (raw file):

  override def beforeAll() = {
    println(s"Libuast.loaded: ${Libuast.loaded}")

Was this mean to be a log and/or to stderr?


src/test/scala/org/bblfsh/client/v2/FilterNativeTest.scala, line 42 at r3 (raw file):

    val pos = it.toList
    pos should have size (8)

Please add a comment to say a bit about what this means—why 8 instead of 37? (I think the answer is "Tiny.java contains 8 tokens" or something like that)

bzz added 2 commits August 14, 2019 13:47
Signed-off-by: Alexander Bezzubov <[email protected]>
Signed-off-by: Alexander Bezzubov <[email protected]>
@bzz bzz force-pushed the iterator-filter branch from 4298f05 to 7341ef2 Compare August 14, 2019 12:07
Copy link
Contributor Author

@bzz bzz left a comment

Choose a reason for hiding this comment

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

Reviewable status: 13 of 17 files reviewed, all discussions resolved (waiting on @creachadair, @dennwc, and @ncordon)


src/main/native/org_bblfsh_client_v2_libuast_Libuast.cc, line 157 at r3 (raw file):

Does this mean that while the filter is active, it is not safe to use the node?

No, not really - lifetime of the node is managed by the context and the same node can be used by multiple filters.

We use this language consistently to signify that the references to the managed JVM Node object is not retained on the native side, and thus no extra JNI cleanup is needed afterwards.


src/main/scala/org/bblfsh/client/v2/libuast/Libuast.scala, line 17 at r4 (raw file):

Previously, creachadair (M. J. Fromberger) wrote…

Is this meant to be to stderr and/or a log? (Otherwise anyone who imports this library will spam their stdout)

Yes it is. Changed to stderr that should play nice with the logging.


src/test/scala/org/bblfsh/client/v2/FilterManagedTest.scala, line 22 at r4 (raw file):

Previously, creachadair (M. J. Fromberger) wrote…

Was this mean to be a log and/or to stderr?

Yes, updated.


src/test/scala/org/bblfsh/client/v2/FilterNativeTest.scala, line 42 at r3 (raw file):

Previously, creachadair (M. J. Fromberger) wrote…

Please add a comment to say a bit about what this means—why 8 instead of 37? (I think the answer is "Tiny.java contains 8 tokens" or something like that)

Done

@bzz
Copy link
Contributor Author

bzz commented Aug 14, 2019

All feedback has been addressed, it's ready for another round.

Copy link
Contributor

@creachadair creachadair left a comment

Choose a reason for hiding this comment

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

Reviewed 5 of 5 files at r5.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @dennwc and @ncordon)


src/main/native/org_bblfsh_client_v2_libuast_Libuast.cc, line 157 at r3 (raw file):

Previously, bzz (Alexander) wrote…

Does this mean that while the filter is active, it is not safe to use the node?

No, not really - lifetime of the node is managed by the context and the same node can be used by multiple filters.

We use this language consistently to signify that the references to the managed JVM Node object is not retained on the native side, and thus no extra JNI cleanup is needed afterwards.

👍

@bzz bzz merged commit 7e551cc into bblfsh:master Aug 14, 2019
@bzz bzz deleted the iterator-filter branch August 14, 2019 18:15
@ncordon
Copy link
Member

ncordon commented Aug 14, 2019

Looked good to me, sorry, I arrived late, but I did looked at the code. I was filing an issue non-related to this PR in the repo :)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants