-
Notifications
You must be signed in to change notification settings - Fork 70
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Compiler plugin] support "replace unfold with DSL"
- Loading branch information
Showing
11 changed files
with
1,009 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
plugins/kotlin-dataframe/src/org/jetbrains/kotlinx/dataframe/plugin/impl/api/unfold.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package org.jetbrains.kotlinx.dataframe.plugin.impl.api | ||
|
||
import org.jetbrains.kotlinx.dataframe.plugin.impl.AbstractInterpreter | ||
import org.jetbrains.kotlinx.dataframe.plugin.impl.AbstractSchemaModificationInterpreter | ||
import org.jetbrains.kotlinx.dataframe.plugin.impl.Arguments | ||
import org.jetbrains.kotlinx.dataframe.plugin.impl.Interpreter | ||
import org.jetbrains.kotlinx.dataframe.plugin.impl.PluginDataFrameSchema | ||
import org.jetbrains.kotlinx.dataframe.plugin.impl.SimpleColumnGroup | ||
import org.jetbrains.kotlinx.dataframe.plugin.impl.SimpleFrameColumn | ||
import org.jetbrains.kotlinx.dataframe.plugin.impl.data.ColumnWithPathApproximation | ||
import org.jetbrains.kotlinx.dataframe.plugin.impl.data.ReplaceClauseApproximation | ||
import org.jetbrains.kotlinx.dataframe.plugin.impl.dataFrame | ||
import org.jetbrains.kotlinx.dataframe.plugin.impl.dsl | ||
|
||
class ReplaceUnfold1 : AbstractSchemaModificationInterpreter() { | ||
val Arguments.receiver: ReplaceClauseApproximation by arg() | ||
val Arguments.body by dsl() | ||
val Arguments.typeArg1: TypeApproximation by arg() | ||
|
||
override fun Arguments.interpret(): PluginDataFrameSchema { | ||
val configuration = CreateDataFrameDslImplApproximation() | ||
body(configuration, mapOf(Properties0.classExtraArgument to Interpreter.Success(typeArg1.type))) | ||
|
||
return receiver.df.map(receiver.columns.map { it.path.path }.toSet()) { a, column -> | ||
if (column is SimpleFrameColumn || column is SimpleColumnGroup) return@map column | ||
SimpleColumnGroup(column.name, configuration.columns) | ||
} | ||
} | ||
} | ||
|
||
class Replace0 : AbstractInterpreter<ReplaceClauseApproximation>() { | ||
val Arguments.receiver: PluginDataFrameSchema by dataFrame() | ||
val Arguments.columns: List<ColumnWithPathApproximation> by arg() | ||
|
||
override fun Arguments.interpret(): ReplaceClauseApproximation { | ||
return ReplaceClauseApproximation(receiver, columns) | ||
} | ||
} |
5 changes: 5 additions & 0 deletions
5
...aframe/src/org/jetbrains/kotlinx/dataframe/plugin/impl/data/ReplaceClauseApproximation.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package org.jetbrains.kotlinx.dataframe.plugin.impl.data | ||
|
||
import org.jetbrains.kotlinx.dataframe.plugin.impl.PluginDataFrameSchema | ||
|
||
class ReplaceClauseApproximation(val df: PluginDataFrameSchema, val columns: List<ColumnWithPathApproximation>) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.