-
Notifications
You must be signed in to change notification settings - Fork 238
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
[compiler] don't force TableRead to produce a TableValue #13229
Changes from 3 commits
ce9ec06
5e8ecdd
56cb6e2
9f2051c
3b817ba
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 |
---|---|---|
|
@@ -429,7 +429,7 @@ object LoweredTableReader { | |
tableStage, | ||
keyType.fieldNames.map(f => SortField(f, Ascending)), | ||
RTable(rowRType, globRType, FastSeq()) | ||
).lower(ctx, TableType(tableStage.rowType, keyType.fieldNames, globals.typ.asInstanceOf[TStruct])) | ||
)._lower(ctx, TableType(tableStage.rowType, keyType.fieldNames, globals.typ.asInstanceOf[TStruct])) | ||
} | ||
} | ||
} | ||
|
@@ -481,7 +481,10 @@ trait TableReaderWithExtraUID extends TableReader { | |
abstract class TableReader { | ||
def pathsUsed: Seq[String] | ||
|
||
def apply(ctx: ExecuteContext, requestedType: TableType, dropRows: Boolean): TableValue | ||
def toExecuteIntermediate(ctx: ExecuteContext, requestedType: TableType, dropRows: Boolean): TableExecuteIntermediate = { | ||
assert(!dropRows) | ||
TableExecuteIntermediate(_lower(ctx, requestedType)) | ||
} | ||
|
||
def partitionCounts: Option[IndexedSeq[Long]] | ||
|
||
|
@@ -506,8 +509,20 @@ abstract class TableReader { | |
def lowerGlobals(ctx: ExecuteContext, requestedGlobalsType: TStruct): IR = | ||
throw new LowererUnsupportedOperation(s"${ getClass.getSimpleName }.lowerGlobals not implemented") | ||
|
||
def lower(ctx: ExecuteContext, requestedType: TableType): TableStage = | ||
throw new LowererUnsupportedOperation(s"${ getClass.getSimpleName }.lower not implemented") | ||
final def lower(ctx: ExecuteContext, requestedType: TableType, dropRows: Boolean): TableStage = | ||
if (dropRows) { | ||
val globals = lowerGlobals(ctx, requestedType.globalType) | ||
|
||
TableStage( | ||
globals, | ||
RVDPartitioner.empty(ctx, requestedType.keyType), | ||
TableStageDependency.none, | ||
MakeStream(FastIndexedSeq(), TStream(TStruct.empty)), | ||
(_: Ref) => MakeStream(FastIndexedSeq(), TStream(requestedType.rowType))) | ||
} else | ||
_lower(ctx, requestedType) | ||
|
||
def _lower(ctx: ExecuteContext, requestedType: TableType): TableStage | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not sure what this change adds other than a template pattern which I generally avoid whenever possible. I preferred keeping this logic in How is There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is a pattern we use occasionally. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What I was trying to understand is why do we need There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah, I understand now. That's fair. Addressed. |
||
} | ||
|
||
object TableNativeReader { | ||
|
@@ -1409,9 +1424,6 @@ class TableNativeReader( | |
VirtualTypeWithReq(tcoerce[PStruct](spec.globalsComponent.rvdSpec(ctx.fs, params.path) | ||
.typedCodecSpec.encodedType.decodedPType(requestedType.globalType))) | ||
|
||
def apply(ctx: ExecuteContext, requestedType: TableType, dropRows: Boolean): TableValue = | ||
TableExecuteIntermediate(lower(ctx, requestedType)).asTableValue(ctx) | ||
|
||
override def toJValue: JValue = { | ||
implicit val formats: Formats = DefaultFormats | ||
decomposeWithName(params, "TableNativeReader") | ||
|
@@ -1440,7 +1452,7 @@ class TableNativeReader( | |
0) | ||
} | ||
|
||
override def lower(ctx: ExecuteContext, requestedType: TableType): TableStage = { | ||
override def _lower(ctx: ExecuteContext, requestedType: TableType): TableStage = { | ||
val globals = lowerGlobals(ctx, requestedType.globalType) | ||
val rowsSpec = spec.rowsSpec | ||
val specPart = rowsSpec.partitioner(ctx.stateManager) | ||
|
@@ -1525,9 +1537,6 @@ case class TableNativeZippedReader( | |
(t, mk) | ||
} | ||
|
||
override def apply(ctx: ExecuteContext, requestedType: TableType, dropRows: Boolean): TableValue = | ||
TableExecuteIntermediate(lower(ctx, requestedType)).asTableValue(ctx) | ||
|
||
override def lowerGlobals(ctx: ExecuteContext, requestedGlobalsType: TStruct): IR = { | ||
val globalsSpec = specLeft.globalsSpec | ||
val globalsPath = specLeft.globalsComponent.absolutePath(pathLeft) | ||
|
@@ -1539,7 +1548,7 @@ case class TableNativeZippedReader( | |
0) | ||
} | ||
|
||
override def lower(ctx: ExecuteContext, requestedType: TableType): TableStage = { | ||
override def _lower(ctx: ExecuteContext, requestedType: TableType): TableStage = { | ||
val globals = lowerGlobals(ctx, requestedType.globalType) | ||
val rowsSpec = specLeft.rowsSpec | ||
val specPart = rowsSpec.partitioner(ctx.stateManager) | ||
|
@@ -1612,7 +1621,7 @@ case class TableFromBlockMatrixNativeReader( | |
override def globalRequiredness(ctx: ExecuteContext, requestedType: TableType): VirtualTypeWithReq = | ||
VirtualTypeWithReq(PCanonicalStruct.empty(required = true)) | ||
|
||
override def apply(ctx: ExecuteContext, requestedType: TableType, dropRows: Boolean): TableValue = { | ||
override def toExecuteIntermediate(ctx: ExecuteContext, requestedType: TableType, dropRows: Boolean): TableExecuteIntermediate = { | ||
val rowsRDD = new BlockMatrixReadRowBlockedRDD( | ||
ctx.fsBc, params.path, partitionRanges, requestedType.rowType, metadata, | ||
maybeMaximumCacheMemoryInBytes = params.maximumCacheMemoryInBytes) | ||
|
@@ -1622,9 +1631,12 @@ case class TableFromBlockMatrixNativeReader( | |
|
||
val rowTyp = PType.canonical(requestedType.rowType, required = true).asInstanceOf[PStruct] | ||
val rvd = RVD(RVDType(rowTyp, fullType.key.filter(rowTyp.hasField)), partitioner, ContextRDD(rowsRDD)) | ||
TableValue(ctx, requestedType, BroadcastRow.empty(ctx), rvd) | ||
TableExecuteIntermediate(TableValue(ctx, requestedType, BroadcastRow.empty(ctx), rvd)) | ||
} | ||
|
||
def _lower(ctx: ExecuteContext, requestedType: TableType): TableStage = | ||
throw new LowererUnsupportedOperation(s"${ getClass.getSimpleName }.lower not implemented") | ||
|
||
override def toJValue: JValue = { | ||
decomposeWithName(params, "TableFromBlockMatrixNativeReader")(TableReader.formats) | ||
} | ||
|
@@ -1666,7 +1678,7 @@ case class TableRead(typ: TableType, dropRows: Boolean, tr: TableReader) extends | |
} | ||
|
||
protected[ir] override def execute(ctx: ExecuteContext, r: LoweringAnalyses): TableExecuteIntermediate = | ||
new TableValueIntermediate(tr.apply(ctx, typ, dropRows)) | ||
tr.toExecuteIntermediate(ctx, typ, dropRows) | ||
} | ||
|
||
case class TableParallelize(rowsAndGlobal: IR, nPartitions: Option[Int] = None) extends TableIR { | ||
|
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 like this interface change. One thing I'd suggest is to remove the
TableExecuteIntermediate
companion object and constructTableStageIntermediate
andTableValueIntermediate
directly.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.
That's not a bad change, but given that it will all be going away when everything is lowered, I don't think there's much benefit.