You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by GitBox <gi...@apache.org> on 2021/05/15 17:12:56 UTC

[GitHub] [arrow] domoritz opened a new pull request #10338: ARROW-12798: [JS] Use == null Comparison

domoritz opened a new pull request #10338:
URL: https://github.com/apache/arrow/pull/10338


   The `== null` check is a concise expression to identify nullish values (`null` and `undefined`).
   
   This refactoring replaces the following combinations of longer strict equality checks with the shorter `null` comparison:
   
   * `a === null || a === undefined` becomes `a == null`
   * `b !== null && b !== undefined` becomes `b != null`
   * `x.f(1, 2) === null || x.f(1, 2) === undefined` becomes `x.f(1, 2) == null`
   
   Learn More: [Equality comparisons and sameness (MDN)](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Equality_comparisons_and_sameness), [Equality table](https://dorey.github.io/JavaScript-Equality-Table/)
   
   When two similar-looking function calls have a side effect, this refactoring can change the behavior of the code.
   
   For example, the refactoring changes:
   
   ```javascript
   let a = f(1) === null || f(1) === undefined;
   ```
   
   into
   
   ```javascript
   let a = f(1) == null;
   ```
   
   If `f(1)` has a side effect, it would have been called once or twice before the refactoring, and once after the refactoring.
   This means that the side effect would have been called a different number of times, potentially changing the behavior.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to 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



[GitHub] [arrow] domoritz edited a comment on pull request #10338: ARROW-12798: [JS] Use == null Comparison

Posted by GitBox <gi...@apache.org>.
domoritz edited a comment on pull request #10338:
URL: https://github.com/apache/arrow/pull/10338#issuecomment-843688757


   I don't see a major difference in the benchmarks. 
   
   Master
   
   ```
   Running "Parse "tracks"" suite...
   Table.from 6,246 ops/s ±2.7%, 0.16 ms, 77 samples
   readBatches 7,314 ops/s ±0.64%, 0.14 ms, 87 samples
   Running "Get "tracks" values by index" suite...
   name: 'lat', length: 1,000,000, type: Float32 35 ops/s ±0.35%, 29 ms, 61 samples
   name: 'lng', length: 1,000,000, type: Float32 35 ops/s ±0.50%, 28 ms, 61 samples
   name: 'origin', length: 1,000,000, type: Dictionary<Int8, Utf8> 0.213 ops/s ±9.5%, 4,666 ms, 5 samples
   name: 'destination', length: 1,000,000, type: Dictionary<Int8, Utf8> 0.207 ops/s ±3.6%, 4,822 ms, 5 samples
   Running "Iterate "tracks" vectors" suite...
   name: 'lat', length: 1,000,000, type: Float32 34 ops/s ±0.75%, 30 ms, 58 samples
   name: 'lng', length: 1,000,000, type: Float32 36 ops/s ±0.70%, 28 ms, 62 samples
   name: 'origin', length: 1,000,000, type: Dictionary<Int8, Utf8> 0.217 ops/s ±12%, 4,842 ms, 5 samples
   name: 'destination', length: 1,000,000, type: Dictionary<Int8, Utf8> 0.229 ops/s ±1.1%, 4,369 ms, 5 samples
   Running "Slice toArray "tracks" vectors" suite...
   name: 'lat', length: 1,000,000, type: Float32 757 ops/s ±5.1%, 1.3 ms, 79 samples
   name: 'lng', length: 1,000,000, type: Float32 625 ops/s ±3.1%, 1.6 ms, 47 samples
   name: 'origin', length: 1,000,000, type: Dictionary<Int8, Utf8> 0.211 ops/s ±13%, 4,946 ms, 5 samples
   name: 'destination', length: 1,000,000, type: Dictionary<Int8, Utf8> 0.195 ops/s ±3.1%, 5,093 ms, 5 samples
   Running "Slice "tracks" vectors" suite...
   name: 'lat', length: 1,000,000, type: Float32 1,311,634 ops/s ±0.53%, 0.001 ms, 94 samples
   name: 'lng', length: 1,000,000, type: Float32 1,387,529 ops/s ±0.73%, 0.001 ms, 81 samples
   name: 'origin', length: 1,000,000, type: Dictionary<Int8, Utf8> 1,523,588 ops/s ±0.46%, 0.001 ms, 93 samples
   name: 'destination', length: 1,000,000, type: Dictionary<Int8, Utf8> 1,551,302 ops/s ±0.40%, 0.001 ms, 94 samples
   Running "DataFrame Iterate "tracks"" suite...
   length: 1,000,000 16.8 ops/s ±0.59%, 59 ms, 45 samples
   Running "DataFrame Count By "tracks"" suite...
   name: 'origin', length: 1,000,000, type: Dictionary<Int8, Utf8> 288 ops/s ±0.32%, 3.5 ms, 90 samples
   name: 'destination', length: 1,000,000, type: Dictionary<Int8, Utf8> 281 ops/s ±0.87%, 3.6 ms, 87 samples
   Running "DataFrame Filter-Scan Count "tracks"" suite...
   name: 'lat', length: 1,000,000, type: Float32, test: gt, value: 0 46 ops/s ±0.40%, 22 ms, 59 samples
   name: 'lng', length: 1,000,000, type: Float32, test: gt, value: 0 46 ops/s ±0.39%, 22 ms, 59 samples
   name: 'origin', length: 1,000,000, type: Dictionary<Int8, Utf8>, test: eq, value: Seattle 52 ops/s ±0.51%, 19 ms, 67 samples
   Running "DataFrame Filter-Iterate "tracks"" suite...
   name: 'lat', length: 1,000,000, type: Float32, test: gt, value: 0 0.586 ops/s ±6.6%, 1,661 ms, 6 samples
   name: 'lng', length: 1,000,000, type: Float32, test: gt, value: 0 0.597 ops/s ±1.3%, 1,676 ms, 6 samples
   name: 'origin', length: 1,000,000, type: Dictionary<Int8, Utf8>, test: eq, value: Seattle 85 ops/s ±0.26%, 12 ms, 73 samples
   Running "DataFrame Direct Count "tracks"" suite...
   name: 'lat', length: 1,000,000, type: Float32, test: gt, value: 0 279 ops/s ±0.33%, 3.6 ms, 88 samples
   name: 'lng', length: 1,000,000, type: Float32, test: gt, value: 0 277 ops/s ±0.25%, 3.6 ms, 86 samples
   name: 'origin', length: 1,000,000, type: Dictionary<Int8, Utf8>, test: eq, value: Seattle 0.191 ops/s ±4.0%, 5,282 ms, 5 samples
   ✨  Done in 535.05s.
   ```
   
   This branch
   
   ```
   Running "Parse "tracks"" suite...
   Table.from 7,963 ops/s ±1.1%, 0.12 ms, 84 samples
   readBatches 8,195 ops/s ±0.96%, 0.12 ms, 90 samples
   Running "Get "tracks" values by index" suite...
   name: 'lat', length: 1,000,000, type: Float32 32 ops/s ±1.4%, 31 ms, 57 samples
   name: 'lng', length: 1,000,000, type: Float32 33 ops/s ±0.87%, 30 ms, 58 samples
   name: 'origin', length: 1,000,000, type: Dictionary<Int8, Utf8> 0.273 ops/s ±2.2%, 3,667 ms, 5 samples
   name: 'destination', length: 1,000,000, type: Dictionary<Int8, Utf8> 0.273 ops/s ±1.1%, 3,676 ms, 5 samples
   Running "Iterate "tracks" vectors" suite...
   name: 'lat', length: 1,000,000, type: Float32 42 ops/s ±0.55%, 24 ms, 56 samples
   name: 'lng', length: 1,000,000, type: Float32 42 ops/s ±0.73%, 23 ms, 56 samples
   name: 'origin', length: 1,000,000, type: Dictionary<Int8, Utf8> 0.258 ops/s ±5.6%, 3,789 ms, 5 samples
   name: 'destination', length: 1,000,000, type: Dictionary<Int8, Utf8> 0.271 ops/s ±4.3%, 3,745 ms, 5 samples
   Running "Slice toArray "tracks" vectors" suite...
   name: 'lat', length: 1,000,000, type: Float32 553 ops/s ±4.7%, 1.8 ms, 67 samples
   name: 'lng', length: 1,000,000, type: Float32 557 ops/s ±3.1%, 1.8 ms, 63 samples
   name: 'origin', length: 1,000,000, type: Dictionary<Int8, Utf8> 0.265 ops/s ±1.6%, 3,769 ms, 5 samples
   name: 'destination', length: 1,000,000, type: Dictionary<Int8, Utf8> 0.273 ops/s ±3.6%, 3,634 ms, 5 samples
   Running "Slice "tracks" vectors" suite...
   name: 'lat', length: 1,000,000, type: Float32 1,942,284 ops/s ±0.91%, 0.001 ms, 90 samples
   name: 'lng', length: 1,000,000, type: Float32 1,968,746 ops/s ±0.59%, 0.001 ms, 90 samples
   name: 'origin', length: 1,000,000, type: Dictionary<Int8, Utf8> 2,075,285 ops/s ±0.63%, 0 ms, 93 samples
   name: 'destination', length: 1,000,000, type: Dictionary<Int8, Utf8> 2,094,251 ops/s ±0.57%, 0 ms, 92 samples
   Running "DataFrame Iterate "tracks"" suite...
   length: 1,000,000 21.5 ops/s ±1.2%, 46 ms, 40 samples
   Running "DataFrame Count By "tracks"" suite...
   name: 'origin', length: 1,000,000, type: Dictionary<Int8, Utf8> 391 ops/s ±0.64%, 2.6 ms, 89 samples
   name: 'destination', length: 1,000,000, type: Dictionary<Int8, Utf8> 399 ops/s ±0.50%, 2.5 ms, 89 samples
   Running "DataFrame Filter-Scan Count "tracks"" suite...
   name: 'lat', length: 1,000,000, type: Float32, test: gt, value: 0 65 ops/s ±0.62%, 15 ms, 67 samples
   name: 'lng', length: 1,000,000, type: Float32, test: gt, value: 0 65 ops/s ±0.56%, 16 ms, 67 samples
   name: 'origin', length: 1,000,000, type: Dictionary<Int8, Utf8>, test: eq, value: Seattle 72 ops/s ±0.70%, 14 ms, 74 samples
   Running "DataFrame Filter-Iterate "tracks"" suite...
   name: 'lat', length: 1,000,000, type: Float32, test: gt, value: 0 0.657 ops/s ±1.6%, 1,524 ms, 6 samples
   name: 'lng', length: 1,000,000, type: Float32, test: gt, value: 0 0.599 ops/s ±17%, 1,565 ms, 6 samples
   name: 'origin', length: 1,000,000, type: Dictionary<Int8, Utf8>, test: eq, value: Seattle 74 ops/s ±2.5%, 13 ms, 72 samples
   Running "DataFrame Direct Count "tracks"" suite...
   name: 'lat', length: 1,000,000, type: Float32, test: gt, value: 0 284 ops/s ±0.85%, 3.5 ms, 88 samples
   name: 'lng', length: 1,000,000, type: Float32, test: gt, value: 0 298 ops/s ±0.70%, 3.4 ms, 88 samples
   name: 'origin', length: 1,000,000, type: Dictionary<Int8, Utf8>, test: eq, value: Seattle 0.29 ops/s ±20%, 3,237 ms, 5 samples
   ✨  Done in 444.33s.
   ```


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to 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



[GitHub] [arrow] github-actions[bot] commented on pull request #10338: ARROW-12798: [JS] Use == null Comparison

Posted by GitBox <gi...@apache.org>.
github-actions[bot] commented on pull request #10338:
URL: https://github.com/apache/arrow/pull/10338#issuecomment-841695238


   https://issues.apache.org/jira/browse/ARROW-12798


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to 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



[GitHub] [arrow] domoritz commented on pull request #10338: ARROW-12798: [JS] Use == null Comparison

Posted by GitBox <gi...@apache.org>.
domoritz commented on pull request #10338:
URL: https://github.com/apache/arrow/pull/10338#issuecomment-843598659


   It looks like the performance should not be affected by this change. https://observablehq.com/@domoritz/coercion-vs-equality
   
   Will run the benchmarks to confirm. 
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to 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



[GitHub] [arrow] domoritz commented on pull request #10338: ARROW-12798: [JS] Use == null Comparison

Posted by GitBox <gi...@apache.org>.
domoritz commented on pull request #10338:
URL: https://github.com/apache/arrow/pull/10338#issuecomment-843688757


   Master
   
   ```
   Running "Parse "tracks"" suite...
   Table.from 6,246 ops/s ±2.7%, 0.16 ms, 77 samples
   readBatches 7,314 ops/s ±0.64%, 0.14 ms, 87 samples
   Running "Get "tracks" values by index" suite...
   name: 'lat', length: 1,000,000, type: Float32 35 ops/s ±0.35%, 29 ms, 61 samples
   name: 'lng', length: 1,000,000, type: Float32 35 ops/s ±0.50%, 28 ms, 61 samples
   name: 'origin', length: 1,000,000, type: Dictionary<Int8, Utf8> 0.213 ops/s ±9.5%, 4,666 ms, 5 samples
   name: 'destination', length: 1,000,000, type: Dictionary<Int8, Utf8> 0.207 ops/s ±3.6%, 4,822 ms, 5 samples
   Running "Iterate "tracks" vectors" suite...
   name: 'lat', length: 1,000,000, type: Float32 34 ops/s ±0.75%, 30 ms, 58 samples
   name: 'lng', length: 1,000,000, type: Float32 36 ops/s ±0.70%, 28 ms, 62 samples
   name: 'origin', length: 1,000,000, type: Dictionary<Int8, Utf8> 0.217 ops/s ±12%, 4,842 ms, 5 samples
   name: 'destination', length: 1,000,000, type: Dictionary<Int8, Utf8> 0.229 ops/s ±1.1%, 4,369 ms, 5 samples
   Running "Slice toArray "tracks" vectors" suite...
   name: 'lat', length: 1,000,000, type: Float32 757 ops/s ±5.1%, 1.3 ms, 79 samples
   name: 'lng', length: 1,000,000, type: Float32 625 ops/s ±3.1%, 1.6 ms, 47 samples
   name: 'origin', length: 1,000,000, type: Dictionary<Int8, Utf8> 0.211 ops/s ±13%, 4,946 ms, 5 samples
   name: 'destination', length: 1,000,000, type: Dictionary<Int8, Utf8> 0.195 ops/s ±3.1%, 5,093 ms, 5 samples
   Running "Slice "tracks" vectors" suite...
   name: 'lat', length: 1,000,000, type: Float32 1,311,634 ops/s ±0.53%, 0.001 ms, 94 samples
   name: 'lng', length: 1,000,000, type: Float32 1,387,529 ops/s ±0.73%, 0.001 ms, 81 samples
   name: 'origin', length: 1,000,000, type: Dictionary<Int8, Utf8> 1,523,588 ops/s ±0.46%, 0.001 ms, 93 samples
   name: 'destination', length: 1,000,000, type: Dictionary<Int8, Utf8> 1,551,302 ops/s ±0.40%, 0.001 ms, 94 samples
   Running "DataFrame Iterate "tracks"" suite...
   length: 1,000,000 16.8 ops/s ±0.59%, 59 ms, 45 samples
   Running "DataFrame Count By "tracks"" suite...
   name: 'origin', length: 1,000,000, type: Dictionary<Int8, Utf8> 288 ops/s ±0.32%, 3.5 ms, 90 samples
   name: 'destination', length: 1,000,000, type: Dictionary<Int8, Utf8> 281 ops/s ±0.87%, 3.6 ms, 87 samples
   Running "DataFrame Filter-Scan Count "tracks"" suite...
   name: 'lat', length: 1,000,000, type: Float32, test: gt, value: 0 46 ops/s ±0.40%, 22 ms, 59 samples
   name: 'lng', length: 1,000,000, type: Float32, test: gt, value: 0 46 ops/s ±0.39%, 22 ms, 59 samples
   name: 'origin', length: 1,000,000, type: Dictionary<Int8, Utf8>, test: eq, value: Seattle 52 ops/s ±0.51%, 19 ms, 67 samples
   Running "DataFrame Filter-Iterate "tracks"" suite...
   name: 'lat', length: 1,000,000, type: Float32, test: gt, value: 0 0.586 ops/s ±6.6%, 1,661 ms, 6 samples
   name: 'lng', length: 1,000,000, type: Float32, test: gt, value: 0 0.597 ops/s ±1.3%, 1,676 ms, 6 samples
   name: 'origin', length: 1,000,000, type: Dictionary<Int8, Utf8>, test: eq, value: Seattle 85 ops/s ±0.26%, 12 ms, 73 samples
   Running "DataFrame Direct Count "tracks"" suite...
   name: 'lat', length: 1,000,000, type: Float32, test: gt, value: 0 279 ops/s ±0.33%, 3.6 ms, 88 samples
   name: 'lng', length: 1,000,000, type: Float32, test: gt, value: 0 277 ops/s ±0.25%, 3.6 ms, 86 samples
   name: 'origin', length: 1,000,000, type: Dictionary<Int8, Utf8>, test: eq, value: Seattle 0.191 ops/s ±4.0%, 5,282 ms, 5 samples
   ✨  Done in 535.05s.
   ```
   
   This branch
   
   ```
   Running "Parse "tracks"" suite...
   Table.from 7,963 ops/s ±1.1%, 0.12 ms, 84 samples
   readBatches 8,195 ops/s ±0.96%, 0.12 ms, 90 samples
   Running "Get "tracks" values by index" suite...
   name: 'lat', length: 1,000,000, type: Float32 32 ops/s ±1.4%, 31 ms, 57 samples
   name: 'lng', length: 1,000,000, type: Float32 33 ops/s ±0.87%, 30 ms, 58 samples
   name: 'origin', length: 1,000,000, type: Dictionary<Int8, Utf8> 0.273 ops/s ±2.2%, 3,667 ms, 5 samples
   name: 'destination', length: 1,000,000, type: Dictionary<Int8, Utf8> 0.273 ops/s ±1.1%, 3,676 ms, 5 samples
   Running "Iterate "tracks" vectors" suite...
   name: 'lat', length: 1,000,000, type: Float32 42 ops/s ±0.55%, 24 ms, 56 samples
   name: 'lng', length: 1,000,000, type: Float32 42 ops/s ±0.73%, 23 ms, 56 samples
   name: 'origin', length: 1,000,000, type: Dictionary<Int8, Utf8> 0.258 ops/s ±5.6%, 3,789 ms, 5 samples
   name: 'destination', length: 1,000,000, type: Dictionary<Int8, Utf8> 0.271 ops/s ±4.3%, 3,745 ms, 5 samples
   Running "Slice toArray "tracks" vectors" suite...
   name: 'lat', length: 1,000,000, type: Float32 553 ops/s ±4.7%, 1.8 ms, 67 samples
   name: 'lng', length: 1,000,000, type: Float32 557 ops/s ±3.1%, 1.8 ms, 63 samples
   name: 'origin', length: 1,000,000, type: Dictionary<Int8, Utf8> 0.265 ops/s ±1.6%, 3,769 ms, 5 samples
   name: 'destination', length: 1,000,000, type: Dictionary<Int8, Utf8> 0.273 ops/s ±3.6%, 3,634 ms, 5 samples
   Running "Slice "tracks" vectors" suite...
   name: 'lat', length: 1,000,000, type: Float32 1,942,284 ops/s ±0.91%, 0.001 ms, 90 samples
   name: 'lng', length: 1,000,000, type: Float32 1,968,746 ops/s ±0.59%, 0.001 ms, 90 samples
   name: 'origin', length: 1,000,000, type: Dictionary<Int8, Utf8> 2,075,285 ops/s ±0.63%, 0 ms, 93 samples
   name: 'destination', length: 1,000,000, type: Dictionary<Int8, Utf8> 2,094,251 ops/s ±0.57%, 0 ms, 92 samples
   Running "DataFrame Iterate "tracks"" suite...
   length: 1,000,000 21.5 ops/s ±1.2%, 46 ms, 40 samples
   Running "DataFrame Count By "tracks"" suite...
   name: 'origin', length: 1,000,000, type: Dictionary<Int8, Utf8> 391 ops/s ±0.64%, 2.6 ms, 89 samples
   name: 'destination', length: 1,000,000, type: Dictionary<Int8, Utf8> 399 ops/s ±0.50%, 2.5 ms, 89 samples
   Running "DataFrame Filter-Scan Count "tracks"" suite...
   name: 'lat', length: 1,000,000, type: Float32, test: gt, value: 0 65 ops/s ±0.62%, 15 ms, 67 samples
   name: 'lng', length: 1,000,000, type: Float32, test: gt, value: 0 65 ops/s ±0.56%, 16 ms, 67 samples
   name: 'origin', length: 1,000,000, type: Dictionary<Int8, Utf8>, test: eq, value: Seattle 72 ops/s ±0.70%, 14 ms, 74 samples
   Running "DataFrame Filter-Iterate "tracks"" suite...
   name: 'lat', length: 1,000,000, type: Float32, test: gt, value: 0 0.657 ops/s ±1.6%, 1,524 ms, 6 samples
   name: 'lng', length: 1,000,000, type: Float32, test: gt, value: 0 0.599 ops/s ±17%, 1,565 ms, 6 samples
   name: 'origin', length: 1,000,000, type: Dictionary<Int8, Utf8>, test: eq, value: Seattle 74 ops/s ±2.5%, 13 ms, 72 samples
   Running "DataFrame Direct Count "tracks"" suite...
   name: 'lat', length: 1,000,000, type: Float32, test: gt, value: 0 284 ops/s ±0.85%, 3.5 ms, 88 samples
   name: 'lng', length: 1,000,000, type: Float32, test: gt, value: 0 298 ops/s ±0.70%, 3.4 ms, 88 samples
   name: 'origin', length: 1,000,000, type: Dictionary<Int8, Utf8>, test: eq, value: Seattle 0.29 ops/s ±20%, 3,237 ms, 5 samples
   ✨  Done in 444.33s.
   ```


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to 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



[GitHub] [arrow] TheNeuralBit closed pull request #10338: ARROW-12798: [JS] Use == null Comparison

Posted by GitBox <gi...@apache.org>.
TheNeuralBit closed pull request #10338:
URL: https://github.com/apache/arrow/pull/10338


   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to 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