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

set autostart to false #36

Closed
wants to merge 6 commits into from

Conversation

jeswr
Copy link
Collaborator

@jeswr jeswr commented Feb 14, 2022

No description provided.

if (removeOptions)
options = undefined;
}

// Set transformation steps from the options
options = options || (!isSourceExpression(source) ? source : null as any);
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This was the only cause of some problems in the testing - since passing option = { autoStart: true } means that the source is not used even if it is not a source expression.

I've got around this by setting the options to undefined if the only key is autoStart - but I'm thinking that the tests should just be changed instead

Copy link
Owner

Choose a reason for hiding this comment

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

I'm sorry, I've been looking at this for 15 minutes now but still don't understand.

So the logic of the SimpleTransformIterator is that both of its parameters (source and options) are optional.

So what the original line 1224 is doing is determining whether options is the first or the second argument (given that source is optional, it might change position). The easy case is when options is non-nullish: then options is the second argument. If options is nullish, then options is the first argument—if that first argument is not a source.

None of that should change, regardless of the autoStart default. So probably a test change indeed.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Makes sense - will do a test change then :)

@coveralls
Copy link

coveralls commented Feb 14, 2022

Coverage Status

Coverage remained the same at 100.0% when pulling e21fa90 on jeswr:breaking/false-autostart into 98565fd on RubenVerborgh:main.

Copy link
Owner

@RubenVerborgh RubenVerborgh left a comment

Choose a reason for hiding this comment

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

Looking good; I think we'll get there!

asynciterator.ts Show resolved Hide resolved
Comment on lines 46 to 49
describe('An ArrayIterator undefined iterator and autostart', () => {
let iterator;
before(() => {
iterator = new ArrayIterator();
iterator = new ArrayIterator(undefined, { autoStart: true });
Copy link
Owner

Choose a reason for hiding this comment

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

That is a bit weird to me; I'll investigate.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Was using undefined to emulate the existing test with no sources. An empty array should work as well instead.

Comment on lines 30 to 33
describe('A BufferedIterator without arguments', () => {
let iterator;
before(() => {
iterator = new BufferedIterator();
iterator = new BufferedIterator({ autoStart: true });
Copy link
Owner

Choose a reason for hiding this comment

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

This is where this change will get a bit annoying, but I think it's important that the test structure remains the same. So first "without arguments" (so don't pass anything) and then the other cases.

(Note that the description and code are out of sync too.)

Copy link
Owner

@RubenVerborgh RubenVerborgh left a comment

Choose a reason for hiding this comment

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

Looking good!

I think we just need to add autoStart to all implementations now. So basically any class deriving from AsyncIterator (except from AsyncIterator itself, it seems).

Or, instead of adding the autoStart option, we need to change the behavior of SingletonIterator to just not automatically start (which is now the default).

Comment on lines +599 to +602
describe('An ArrayIterator undefined iterator and autostart', () => {
let iterator;
before(() => {
iterator = new ArrayIterator(undefined, { autoStart: true });
Copy link
Owner

Choose a reason for hiding this comment

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

Suggested change
describe('An ArrayIterator undefined iterator and autostart', () => {
let iterator;
before(() => {
iterator = new ArrayIterator(undefined, { autoStart: true });
describe('An ArrayIterator without source with autostart', () => {
let iterator;
before(() => {
iterator = new ArrayIterator({ autoStart: true });

(should be made to work if it doesn't)

Comment on lines +1472 to +1473
{ autoStart = false, ...options }: BufferedIteratorOptions = {}) {
super({ autoStart, ...options });
Copy link
Owner

Choose a reason for hiding this comment

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

I wouldn't deconstruct here; we can just use options.autoStart below. The original was needed because we didn't want to repeat the !== false cast, which is no longer needed (as in 6f3af33).

expect(iterator.read()).to.be.null;
});
});

describe('An ArrayIterator with an empty array without autoStart', () => {
Copy link
Owner

Choose a reason for hiding this comment

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

Suggested change
describe('An ArrayIterator with an empty array without autoStart', () => {
describe('An ArrayIterator with an empty array', () => {

@jeswr
Copy link
Collaborator Author

jeswr commented Feb 15, 2022

I think we just need to add autoStart to all implementations now. So basically any class deriving from AsyncIterator (except from AsyncIterator itself, it seems).

In order to handle #35 (comment) both solutions essentially are determining whether or not to autoStart the end event when there is no data so I think we will need to add it to AsyncIterator as well if we also want to solve this issue in this PR.

Also FYI @rubensworks with the current status of the PR only 15 tests from 7 test suites fail in the whole of comunica. Most of these issues arise from metadata tests in which on('metadata', ...) is called instead of on('data', ...) - this could either be solved directly in Comunica - or in this PR by making the waitForDataListener more generic and able to trigger flow mode on other event types.

@rubensworks
Copy link
Collaborator

Also FYI @rubensworks with the current status of the PR only 15 tests from 7 test suites fail in the whole of comunica. Most of these issues arise from metadata tests in which on('metadata', ...) is called instead of on('data', ...) - this could either be solved directly in Comunica - or in this PR by making the waitForDataListener more generic and able to trigger flow mode on other event types.

I'm fine with either option, whatever is easiest.
The on('metadata', ...) calls in Comunica are usually pretty deep internally, so it's ok if we have to do some additional things in Comunica here. (as long as we properly document this in the code)

@rubensworks rubensworks mentioned this pull request Feb 19, 2022
@jeswr jeswr closed this Feb 20, 2022
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.

4 participants