Skip to content

Commit

Permalink
[query] MatrixBlockMatrixWriter can be lowered (hail-is#12695)
Browse files Browse the repository at this point in the history
Efficiency can wait.
  • Loading branch information
chrisvittal authored Feb 13, 2023
1 parent 52feb78 commit 9c0854e
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions hail/src/main/scala/is/hail/expr/ir/MatrixWriter.scala
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ abstract class MatrixWriter {
ctx: ExecuteContext, ts: TableStage, t: TableIR, r: RTable, relationalLetsAbove: Map[String, IR]): IR =
throw new LowererUnsupportedOperation(s"${ this.getClass } does not have defined lowering!")

def canLowerEfficiently: Boolean = false
def canLowerEfficiently: Boolean
}

case class MatrixNativeWriter(
Expand All @@ -78,7 +78,7 @@ case class MatrixNativeWriter(
) extends MatrixWriter {
def apply(ctx: ExecuteContext, mv: MatrixValue): Unit = mv.write(ctx, path, overwrite, stageLocally, codecSpecJSONStr, partitions, partitionsTypeStr, checkpointFile)

override def canLowerEfficiently: Boolean = !stageLocally && checkpointFile == null
def canLowerEfficiently: Boolean = !stageLocally && checkpointFile == null

override def lower(colsFieldName: String, entriesFieldName: String, colKey: IndexedSeq[String],
ctx: ExecuteContext, tablestage: TableStage, t: TableIR, r: RTable, relationalLetsAbove: Map[String, IR]): IR = {
Expand Down Expand Up @@ -409,7 +409,8 @@ case class MatrixVCFWriter(
ctx, ts, tl, BaseTypeWithRequiredness(tv.typ).asInstanceOf[RTable], Map()))
}

override def canLowerEfficiently: Boolean = true
def canLowerEfficiently: Boolean = true

override def lower(colsFieldName: String, entriesFieldName: String, colKey: IndexedSeq[String],
ctx: ExecuteContext, ts: TableStage, t: TableIR, r: RTable, relationalLetsAbove: Map[String, IR]): IR = {
require(exportType != ExportType.PARALLEL_COMPOSABLE)
Expand Down Expand Up @@ -841,7 +842,7 @@ case class MatrixGENWriter(
ctx, ts, tl, BaseTypeWithRequiredness(tv.typ).asInstanceOf[RTable], Map()))
}

override def canLowerEfficiently: Boolean = true
def canLowerEfficiently: Boolean = true

override def lower(colsFieldName: String, entriesFieldName: String, colKey: IndexedSeq[String],
ctx: ExecuteContext, ts: TableStage, t: TableIR, r: RTable, relationalLetsAbove: Map[String, IR]): IR = {
Expand Down Expand Up @@ -963,7 +964,8 @@ case class MatrixBGENWriter(
ctx, ts, tl, BaseTypeWithRequiredness(tv.typ).asInstanceOf[RTable], Map()))
}

override def canLowerEfficiently: Boolean = true
def canLowerEfficiently: Boolean = true

override def lower(colsFieldName: String, entriesFieldName: String, colKey: IndexedSeq[String],
ctx: ExecuteContext, ts: TableStage, t: TableIR, r: RTable, relationalLetsAbove: Map[String, IR]): IR = {

Expand Down Expand Up @@ -1241,7 +1243,8 @@ case class MatrixPLINKWriter(
ctx, ts, tl, BaseTypeWithRequiredness(tv.typ).asInstanceOf[RTable], Map()))
}

override def canLowerEfficiently: Boolean = true
def canLowerEfficiently: Boolean = true

override def lower(colsFieldName: String, entriesFieldName: String, colKey: IndexedSeq[String],
ctx: ExecuteContext, ts: TableStage, t: TableIR, r: RTable, relationalLetsAbove: Map[String, IR]): IR = {
val tm = MatrixType.fromTableType(t.typ, colsFieldName, entriesFieldName, colKey)
Expand Down Expand Up @@ -1400,6 +1403,8 @@ case class MatrixBlockMatrixWriter(
) extends MatrixWriter {
def apply(ctx: ExecuteContext, mv: MatrixValue): Unit = MatrixWriteBlockMatrix(ctx, mv, entryField, path, overwrite, blockSize)

def canLowerEfficiently: Boolean = true

override def lower(colsFieldName: String, entriesFieldName: String, colKey: IndexedSeq[String],
ctx: ExecuteContext, ts: TableStage, t: TableIR, r: RTable, relationalLetsAbove: Map[String, IR]): IR = {

Expand Down

0 comments on commit 9c0854e

Please sign in to comment.