-
Notifications
You must be signed in to change notification settings - Fork 75
Add move before #1474
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
base: master
Are you sure you want to change the base?
Add move before #1474
Changes from 18 commits
84b89f7
b8fdbdf
e1724f3
326fac9
68cad6a
bd9d7fe
fb7ebf7
fee8091
639762e
1a995e5
eb1f516
e7e24db
e78b100
7a23bc7
1009089
a44b15a
0202f7b
d365add
512f6b4
5839b57
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,21 +6,25 @@ import org.jetbrains.kotlinx.dataframe.DataColumn | |
import org.jetbrains.kotlinx.dataframe.DataFrame | ||
import org.jetbrains.kotlinx.dataframe.api.ColumnsSelectionDsl | ||
import org.jetbrains.kotlinx.dataframe.api.MoveClause | ||
import org.jetbrains.kotlinx.dataframe.api.after | ||
import org.jetbrains.kotlinx.dataframe.api.asColumnGroup | ||
import org.jetbrains.kotlinx.dataframe.api.cast | ||
import org.jetbrains.kotlinx.dataframe.api.getColumn | ||
import org.jetbrains.kotlinx.dataframe.api.getColumnGroup | ||
import org.jetbrains.kotlinx.dataframe.api.getColumnWithPath | ||
import org.jetbrains.kotlinx.dataframe.api.move | ||
import org.jetbrains.kotlinx.dataframe.api.toDataFrame | ||
import org.jetbrains.kotlinx.dataframe.columns.ColumnPath | ||
import org.jetbrains.kotlinx.dataframe.columns.ColumnWithPath | ||
import org.jetbrains.kotlinx.dataframe.columns.UnresolvedColumnsPolicy | ||
import org.jetbrains.kotlinx.dataframe.columns.toColumnSet | ||
import org.jetbrains.kotlinx.dataframe.impl.DataFrameReceiver | ||
import org.jetbrains.kotlinx.dataframe.impl.asList | ||
import org.jetbrains.kotlinx.dataframe.impl.columns.toColumnWithPath | ||
import org.jetbrains.kotlinx.dataframe.impl.columns.tree.ColumnPosition | ||
import org.jetbrains.kotlinx.dataframe.impl.columns.tree.getOrPut | ||
import org.jetbrains.kotlinx.dataframe.path | ||
|
||
// TODO: support 'before' mode | ||
internal fun <T, C> MoveClause<T, C>.afterOrBefore(column: ColumnSelector<T, *>, isAfter: Boolean): DataFrame<T> { | ||
val removeResult = df.removeImpl(columns = columns) | ||
|
||
|
@@ -78,7 +82,16 @@ internal fun <T, C> MoveClause<T, C>.afterOrBefore(column: ColumnSelector<T, *>, | |
} | ||
ColumnToInsert(path, sourceCol.data, refNode) | ||
} | ||
return removeResult.df.insertImpl(toInsert) | ||
if (isAfter) { | ||
return removeResult.df.insertImpl(toInsert) | ||
} | ||
|
||
// move target after last of toInsert | ||
|
||
val logicOfAfter = removeResult.df.insertImpl(toInsert) | ||
val lastOfInsertedCols = toInsert.last().insertionPath | ||
val siblingsOfTargetAndTarget = removeResult.df[parentPath].asColumnGroup().columns().map { parentPath + it.path } | ||
val target = siblingsOfTargetAndTarget.filter { it.last() == targetPath.last() } | ||
return logicOfAfter.move { target.toColumnSet() }.after { lastOfInsertedCols } | ||
} | ||
|
||
internal fun <T, C> MoveClause<T, C>.moveImpl( | ||
|
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.
no need to add these deprecated overloads :)
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'll remove them