-
Notifications
You must be signed in to change notification settings - Fork 248
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
[query] Add query_matrix_table an analogue to query_table #14806
base: main
Are you sure you want to change the base?
Changes from all commits
b5a6eb6
44909bd
97653ea
e56847b
84a77a1
419e6c5
e823be8
d4fff08
4999e0f
7825bd3
3a7b9e5
6bc01af
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 |
---|---|---|
|
@@ -943,6 +943,7 @@ case class PartitionNativeIntervalReader( | |
lazy val partitioner = rowsSpec.partitioner(sm) | ||
|
||
lazy val contextType: Type = RVDPartitioner.intervalIRRepresentation(partitioner.kType) | ||
require(partitioner.kType.size > 0) | ||
|
||
def toJValue: JValue = Extraction.decompose(this)(PartitionReader.formats) | ||
|
||
|
@@ -1509,6 +1510,61 @@ case class PartitionZippedNativeReader(left: PartitionReader, right: PartitionRe | |
} | ||
} | ||
|
||
private[this] class PartitionEntriesNativeIntervalReader( | ||
sm: HailStateManager, | ||
entriesPath: String, | ||
entriesSpec: AbstractTableSpec, | ||
uidFieldName: String, | ||
rowsTableSpec: AbstractTableSpec, | ||
) extends PartitionNativeIntervalReader(sm, entriesPath, entriesSpec, uidFieldName) { | ||
override lazy val partitioner = rowsTableSpec.rowsSpec.partitioner(sm) | ||
} | ||
|
||
case class PartitionZippedNativeIntervalReader( | ||
sm: HailStateManager, | ||
mtPath: String, | ||
mtSpec: AbstractMatrixTableSpec, | ||
uidFieldName: String, | ||
) extends PartitionReader { | ||
require(mtSpec.indexed) | ||
|
||
// XXX: rows and entries paths are hardcoded, see MatrixTableSpec | ||
private lazy val rowsReader = | ||
PartitionNativeIntervalReader(sm, mtPath + "/rows", mtSpec.rowsSpec, "__dummy") | ||
|
||
private lazy val entriesReader = | ||
new PartitionEntriesNativeIntervalReader( | ||
sm, | ||
mtPath + "/entries", | ||
mtSpec.entriesSpec, | ||
uidFieldName, | ||
rowsReader.tableSpec, | ||
) | ||
|
||
private lazy val zippedReader = PartitionZippedNativeReader(rowsReader, entriesReader) | ||
|
||
def contextType = rowsReader.contextType | ||
def fullRowType = zippedReader.fullRowType | ||
Comment on lines
+1513
to
+1547
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. Forgive me Chris, I'm not really following what's mandating all these |
||
def rowRequiredness(requestedType: TStruct): RStruct = zippedReader.rowRequiredness(requestedType) | ||
def toJValue: JValue = Extraction.decompose(this)(PartitionReader.formats) | ||
|
||
def emitStream( | ||
ctx: ExecuteContext, | ||
cb: EmitCodeBuilder, | ||
mb: EmitMethodBuilder[_], | ||
codeContext: EmitCode, | ||
requestedType: TStruct, | ||
): IEmitCode = { | ||
val zipContextType: TBaseStruct = tcoerce(zippedReader.contextType) | ||
val valueContext = cb.memoize(codeContext) | ||
val contexts: IndexedSeq[EmitCode] = FastSeq(valueContext, valueContext) | ||
val st = SStackStruct(zipContextType, contexts.map(_.emitType)) | ||
val context = EmitCode.present(mb, st.fromEmitCodes(cb, contexts)) | ||
|
||
zippedReader.emitStream(ctx, cb, mb, context, requestedType) | ||
} | ||
} | ||
|
||
case class PartitionZippedIndexedNativeReader( | ||
specLeft: AbstractTypedCodecSpec, | ||
specRight: AbstractTypedCodecSpec, | ||
|
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.
@patrick-schultz I'm getting an NPE in initialization, I think it's because this assertion in PartitionReader is running before
zippedReader
is initialized. Thoughts on resolving that?hail/hail/hail/src/is/hail/expr/ir/IR.scala
Lines 1300 to 1301 in ecaa96b
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 annoying. My first thought is to make the sub-readers lazy vals. Maybe try that for now, and we can think more if there's any more satisfying fix.
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.
Thanks for the suggestion. It worked. I guess
lazy val
can force initialization, butval
is only truly valid after full initialization of the class.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.
Right,
lazy val foo = init
is basicallyprivate var _foo = null
anddef foo = { if (_foo == null) _foo = init; _foo }
. So it will be initialized the first time it's accessed, rather than when the class initializer is run. Usually that means it's initialized later than the class, but in this case it happens earlier.