-
Notifications
You must be signed in to change notification settings - Fork 323
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
Implement Table.add_row_number
#6890
Conversation
c3362a0
to
0061994
Compare
distribution/lib/Standard/Database/0.0.0-dev/src/Data/Table.enso
Outdated
Show resolved
Hide resolved
distribution/lib/Standard/Table/0.0.0-dev/src/Internal/Add_Row_Number.enso
Outdated
Show resolved
Hide resolved
distribution/lib/Standard/Table/0.0.0-dev/src/Internal/Add_Row_Number.enso
Show resolved
Hide resolved
0061994
to
e52a4b3
Compare
import org.enso.table.data.column.storage.DateStorage; | ||
import org.enso.table.data.column.storage.datetime.DateStorage; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I moved 'classes' of related storages (datetime
and numeric
) into sub-packages, as the top-level storage
package grew quite a bit and I think this way it will be a bit more manageable.
package org.enso.table.data.column.storage.numeric; | ||
|
||
public class LongConstantStorage extends ComputedLongStorage { | ||
private final long constant; | ||
|
||
public LongConstantStorage(long constant, int size) { | ||
super(size); | ||
this.constant = constant; | ||
} | ||
|
||
@Override | ||
protected long computeItem(int idx) { | ||
return constant; | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This class, together with ComputedLongStorage
demonstrates how we can implement O(1) storages for constant columns.
At some point we may do a similar refactor for all other storage types (we should be able to share most of the code for the non-primitive storages, only DoubleStorage will also need special handling to avoid unnecessary boxing, like we are doing here) to support the constant columns better.
e52a4b3
to
e7a94c4
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me.
The start of refactoring the table is great. I'd like to understand performance of Multi_Value_Key in Enso vs Java.
Set_Mode.Update -> if self.java_table.getColumnByName renamed.name . is_nothing . not then True else | ||
Error.throw (Missing_Column.Error renamed.name) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not really part of this but we could do something using get here. Like:
Set_Mode.Update -> if self.java_table.getColumnByName renamed.name . is_nothing . not then True else | |
Error.throw (Missing_Column.Error renamed.name) | |
Set_Mode.Update -> if self.get renamed.name if_missing=(Error.throw (Missing_Column.Error renamed.name)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will work, but the other branch that is the reversed condition will not work that easily. And I'd prefer to keep the branches symmetric.
import org.enso.table.data.column.storage.DoubleStorage; | ||
import org.enso.table.data.column.storage.LongStorage; | ||
import org.enso.table.data.column.storage.Storage; | ||
import org.enso.table.data.column.storage.*; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we avoid *
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, sorry - my formatter sometimes brings these in.
...bits/table/src/main/java/org/enso/table/data/column/operation/map/numeric/LongNumericOp.java
Outdated
Show resolved
Hide resolved
e7a94c4
to
9a5bc94
Compare
9a5bc94
to
7558c56
Compare
Pull Request Description
Closes #5227
Important Notes
LongStorage
intoAbstractLongStorage
allowing it to provide alternative implementations of the underlying storage, in our caseLongRangeStorage
generating the values ad-hoc andLongConstantStorage
- currently unused but in the future it can be adapted to support constant columns (once we implement similar facilities for other types).Checklist
Please ensure that the following checklist has been satisfied before submitting the PR:
Scala,
Java,
and
Rust
style guides. In case you are using a language not listed above, follow the Rust style guide.
./run ide build
.