diff --git a/hail/hail/src/is/hail/expr/ir/Parser.scala b/hail/hail/src/is/hail/expr/ir/Parser.scala index ca4dbcf75f1..bf034f66670 100644 --- a/hail/hail/src/is/hail/expr/ir/Parser.scala +++ b/hail/hail/src/is/hail/expr/ir/Parser.scala @@ -454,13 +454,6 @@ object IRParser { punctuation(it, "}") val fields = args.zipWithIndex.map { case ((id, t), i) => PField(id, t, i) } PCanonicalStruct(fields, req) - case "PSubsetStruct" => - punctuation(it, "{") - val parent = ptype_expr(rgs)(it).asInstanceOf[PStruct] - punctuation(it, "{") - val args = repsepUntil(it, identifier, PunctuationToken(","), PunctuationToken("}")) - punctuation(it, "}") - PSubsetStruct(parent, args) } assert(typ.required == req) typ diff --git a/hail/hail/src/is/hail/types/physical/PSubsetStruct.scala b/hail/hail/src/is/hail/types/physical/PSubsetStruct.scala deleted file mode 100644 index 08d67065074..00000000000 --- a/hail/hail/src/is/hail/types/physical/PSubsetStruct.scala +++ /dev/null @@ -1,180 +0,0 @@ -package is.hail.types.physical - -import is.hail.annotations.{Annotation, Region} -import is.hail.asm4s.{Code, Value} -import is.hail.collection.implicits.toRichIterable -import is.hail.expr.ir.EmitCodeBuilder -import is.hail.types.physical.stypes.SValue -import is.hail.types.physical.stypes.concrete.SStructView -import is.hail.types.physical.stypes.interfaces.{SBaseStruct, SBaseStructValue} -import is.hail.types.virtual.TStruct -import is.hail.utils._ - -object PSubsetStruct { - def apply(ps: PStruct, fieldNames: String*): PSubsetStruct = - PSubsetStruct(ps, fieldNames.toFastSeq) -} - -// Semantics: PSubsetStruct is a non-constructible view of another PStruct, which is not allowed to mutate -// that underlying PStruct's region data -final case class PSubsetStruct(ps: PStruct, _fieldNames: IndexedSeq[String]) - extends PStruct with Logging { - val fields: IndexedSeq[PField] = _fieldNames.zipWithIndex.map { case (name, i) => - PField(name, ps.fieldType(name), i) - } - - val required = ps.required - - if (fields == ps.fields) { - logger.warn("PSubsetStruct used without subsetting input PStruct") - } - - private val idxMap: IndexedSeq[Int] = _fieldNames.map(f => ps.fieldIdx(f)) - - lazy val missingIdx: IndexedSeq[Int] = idxMap.map(i => ps.missingIdx(i)) - lazy val nMissing: Int = missingIdx.length - - override lazy val virtualType = TStruct(fields.map(f => (f.name -> f.typ.virtualType)): _*) - override val types: IndexedSeq[PType] = fields.map(_.typ) - - override val byteSize: Long = 8 - - override def _pretty(sb: StringBuilder, indent: Int, compact: Boolean): Unit = { - sb ++= "PSubsetStruct{" - ps.pretty(sb, indent, compact) - sb += '{' - fieldNames.foreachBetween(f => sb ++= prettyIdentifier(f))(sb += ',') - sb += '}' - sb += '}' - } - - override def rename(m: Map[String, String]): PStruct = { - val newNames = fieldNames.map(fieldName => m.getOrElse(fieldName, fieldName)) - val newPStruct = ps.rename(m) - - PSubsetStruct(newPStruct, newNames) - } - - override def isFieldMissing(cb: EmitCodeBuilder, structAddress: Code[Long], fieldName: String) - : Value[Boolean] = - ps.isFieldMissing(cb, structAddress, fieldName) - - override def fieldOffset(structAddress: Code[Long], fieldName: String): Code[Long] = - ps.fieldOffset(structAddress, fieldName) - - override def isFieldDefined(structAddress: Long, fieldIdx: Int): Boolean = - ps.isFieldDefined(structAddress, idxMap(fieldIdx)) - - override def isFieldMissing(cb: EmitCodeBuilder, structAddress: Code[Long], fieldIdx: Int) - : Value[Boolean] = - ps.isFieldMissing(cb, structAddress, idxMap(fieldIdx)) - - override def fieldOffset(structAddress: Long, fieldIdx: Int): Long = - ps.fieldOffset(structAddress, idxMap(fieldIdx)) - - override def fieldOffset(structAddress: Code[Long], fieldIdx: Int): Code[Long] = - ps.fieldOffset(structAddress, idxMap(fieldIdx)) - - override def loadField(structAddress: Code[Long], fieldName: String): Code[Long] = - ps.loadField(structAddress, fieldName) - - override def loadField(structAddress: Long, fieldIdx: Int): Long = - ps.loadField(structAddress, idxMap(fieldIdx)) - - override def loadField(structAddress: Code[Long], fieldIdx: Int): Code[Long] = - ps.loadField(structAddress, idxMap(fieldIdx)) - - override def setFieldPresent(cb: EmitCodeBuilder, structAddress: Code[Long], fieldName: String) - : Unit = ??? - - override def setFieldMissing(cb: EmitCodeBuilder, structAddress: Code[Long], fieldName: String) - : Unit = ??? - - override def setFieldMissing(structAddress: Long, fieldIdx: Int): Unit = ??? - - override def setFieldMissing(cb: EmitCodeBuilder, structAddress: Code[Long], fieldIdx: Int) - : Unit = ??? - - override def setFieldPresent(structAddress: Long, fieldIdx: Int): Unit = ??? - - override def setFieldPresent(cb: EmitCodeBuilder, structAddress: Code[Long], fieldIdx: Int) - : Unit = ??? - - override def insertFields(fieldsToInsert: IterableOnce[(String, PType)]): PSubsetStruct = ??? - - override def initialize(structAddress: Long, setMissing: Boolean): Unit = - ps.initialize(structAddress, setMissing) - - override def stagedInitialize(cb: EmitCodeBuilder, structAddress: Code[Long], setMissing: Boolean) - : Unit = - ps.stagedInitialize(cb, structAddress, setMissing) - - override def allocate(region: Region): Long = - ps.allocate(region) - - override def allocate(region: Code[Region]): Code[Long] = - ps.allocate(region) - - override def setRequired(required: Boolean): PType = - PSubsetStruct(ps.setRequired(required).asInstanceOf[PStruct], _fieldNames) - - override def copyFromAddress( - region: Region, - srcPType: PType, - srcAddress: Long, - deepCopy: Boolean, - ): Long = - throw new UnsupportedOperationException - - override def _copyFromAddress( - region: Region, - srcPType: PType, - srcAddress: Long, - deepCopy: Boolean, - ): Long = - throw new UnsupportedOperationException - - override def sType: SBaseStruct = - SStructView.subset(_fieldNames, ps.sType) - - override def store(cb: EmitCodeBuilder, region: Value[Region], value: SValue, deepCopy: Boolean) - : Value[Long] = - throw new UnsupportedOperationException - - override def storeAtAddress( - cb: EmitCodeBuilder, - addr: Code[Long], - region: Value[Region], - value: SValue, - deepCopy: Boolean, - ): Unit = - throw new UnsupportedOperationException - - override def loadCheapSCode(cb: EmitCodeBuilder, addr: Code[Long]): SBaseStructValue = - throw new UnsupportedOperationException - - override def unstagedStoreAtAddress( - addr: Long, - region: Region, - srcPType: PType, - srcAddress: Long, - deepCopy: Boolean, - ): Unit = - throw new UnsupportedOperationException - - override def loadFromNested(addr: Code[Long]): Code[Long] = addr - - override def unstagedLoadFromNested(addr: Long): Long = addr - - override def unstagedStoreJavaObject(annotation: Annotation, region: Region): Long = - throw new UnsupportedOperationException - - override def unstagedStoreJavaObjectAtAddress( - addr: Long, - annotation: Annotation, - region: Region, - ): Unit = - throw new UnsupportedOperationException - - override def copiedType: PType = ??? // PSubsetStruct on its way out -} diff --git a/hail/hail/test/src/is/hail/types/physical/PhysicalTestUtils.scala b/hail/hail/test/src/is/hail/types/physical/PhysicalTestUtils.scala index 77299768777..2ecba3df932 100644 --- a/hail/hail/test/src/is/hail/types/physical/PhysicalTestUtils.scala +++ b/hail/hail/test/src/is/hail/types/physical/PhysicalTestUtils.scala @@ -25,10 +25,7 @@ abstract class PhysicalTestUtils extends Logging { val srcRegion = Region(pool = pool) val region = Region(pool = pool) - val srcAddress = sourceType match { - case x: PSubsetStruct => ScalaToRegionValue(srcRegion, x.ps, sourceValue) - case _ => ScalaToRegionValue(srcRegion, sourceType, sourceValue) - } + val srcAddress = ScalaToRegionValue(srcRegion, sourceType, sourceValue) if (interpret) { try {