Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
1968d3a
do the big rename
henrydavidge Oct 8, 2019
b13014f
Make tests pass
henrydavidge Oct 8, 2019
ee08118
imports
henrydavidge Oct 8, 2019
8c8a181
sg -> glow
henrydavidge Oct 8, 2019
2bf6a0a
Trigger CircleCI tests
karenfeng Oct 9, 2019
8eb72ba
Trigger CircleCI again
karenfeng Oct 9, 2019
ef980d1
Fix CircleCI config
karenfeng Oct 9, 2019
47381b8
Fix Python dir
karenfeng Oct 9, 2019
2e29b02
Rename datasources
karenfeng Oct 9, 2019
5850ad2
CircleCI wip
karenfeng Oct 9, 2019
7eea7c1
More CircleCI wip
karenfeng Oct 9, 2019
7e819fd
Continue Circleci wip
karenfeng Oct 9, 2019
0b4ccd1
WIP
karenfeng Oct 9, 2019
0193b06
Revert last change
karenfeng Oct 9, 2019
cb118c8
Un package-private
karenfeng Oct 9, 2019
1b0144b
More un package-private
karenfeng Oct 9, 2019
e15370f
Continue un package-private
karenfeng Oct 9, 2019
9221069
More un-package-private
karenfeng Oct 9, 2019
21d3289
Try again
karenfeng Oct 9, 2019
a6e7922
no core
henrydavidge Oct 9, 2019
26823c0
Merge branch 'rename' of github.com:henrydavidge/glow into rename
henrydavidge Oct 9, 2019
7cbf6d6
rename
henrydavidge Oct 9, 2019
4506775
compile
henrydavidge Oct 9, 2019
a8a1f72
fix test
henrydavidge Oct 9, 2019
b6b70e9
fix tests
henrydavidge Oct 9, 2019
f5d53e4
test file
henrydavidge Oct 9, 2019
217179d
no tabs
henrydavidge Oct 9, 2019
db1923a
less logging'
henrydavidge Oct 10, 2019
339eefc
update
henrydavidge Oct 10, 2019
db728ad
io
henrydavidge Oct 10, 2019
88d0e68
ignore unit tests
henrydavidge Oct 10, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .scalafmt.conf
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ includeCurlyBraceInSelectChains = false
includeNoParensInSelectChains = true
importSelectors = singleLine

rewrite.rules = [PreferCurlyFors, SortImports]
rewrite.rules = [PreferCurlyFors, SortImports]
3 changes: 2 additions & 1 deletion build.sbt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import Tests._
import scala.sys.process._

import sbt.Tests._

val sparkVersion = "2.4.3"
val scalaMajorMinor = "2.11"

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.databricks.hls.sql;
package org.projectglow.core.sql;

import org.apache.spark.sql.catalyst.util.GenericArrayData;
import org.apache.spark.unsafe.types.UTF8String;
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# Standard file formats
com.databricks.bgen.BgenFileFormat
com.databricks.bgen.BigBgenDatasource
com.databricks.vcf.BigVCFDatasource
com.databricks.vcf.VCFFileFormat
org.projectglow.core.bgen.BgenFileFormat
org.projectglow.core.bgen.BigBgenDatasource
org.projectglow.core.vcf.BigVCFDatasource
org.projectglow.core.vcf.VCFFileFormat

# Legacy file formats
com.databricks.bgen.ComDatabricksBgenFileFormat
com.databricks.bgen.ComDatabricksBigBgenDatasource
com.databricks.vcf.ComDatabricksBigVCFDatasource
com.databricks.vcf.ComDatabricksVCFFileFormat
org.projectglow.core.bgen.ComDatabricksBgenFileFormat
org.projectglow.core.bgen.ComDatabricksBigBgenDatasource
org.projectglow.core.vcf.ComDatabricksBigVCFDatasource
org.projectglow.core.vcf.ComDatabricksVCFFileFormat
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
org.projectglow.core.transformers.LiftOverVariantsTransformer
org.projectglow.core.transformers.normalizevariants.NormalizeVariantsTransformer
org.projectglow.core.transformers.pipe.PipeTransformer
org.projectglow.core.transformers.pipe.CleanupPipeTransformer
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
org.projectglow.core.transformers.pipe.CSVInputFormatterFactory
org.projectglow.core.transformers.pipe.UTF8TextInputFormatterFactory
org.projectglow.core.vcf.VCFInputFormatterFactory
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
org.projectglow.core.transformers.pipe.CSVOutputFormatterFactory
org.projectglow.core.transformers.pipe.UTF8TextOutputFormatterFactory
org.projectglow.core.vcf.VCFOutputFormatterFactory

This file was deleted.

77 changes: 8 additions & 69 deletions core/src/main/scala/org/apache/spark/sql/SQLUtils.scala
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
package org.apache.spark.sql

import org.apache.spark.TaskContext
import org.apache.spark.ml.linalg.{VectorUDT, Vectors}
import org.apache.spark.ml.linalg.{MatrixUDT, VectorUDT}
import org.apache.spark.rdd.RDD
import org.apache.spark.sql.catalyst.InternalRow
import org.apache.spark.sql.catalyst.expressions.codegen.{CodegenContext, ExprCode}
import org.apache.spark.sql.catalyst.expressions.{Expression, ImplicitCastInputTypes, UnaryExpression}
import org.apache.spark.sql.catalyst.util.{ArrayData, GenericArrayData}
import org.apache.spark.sql.types._

object SQLUtils {
Expand Down Expand Up @@ -46,76 +43,18 @@ object SQLUtils {
def setTaskContext(context: TaskContext): Unit = {
TaskContext.setTaskContext(context)
}
}

case class ArrayToSparseVector(child: Expression)
extends UnaryExpression
with ImplicitCastInputTypes {

override def inputTypes: Seq[AbstractDataType] = Seq(ArrayType(DoubleType))
override def dataType: DataType = ArrayToSparseVector.vectorType
override def nullSafeEval(input: Any): Any = ArrayToSparseVector.fromDoubleArray(input)

override def doGenCode(ctx: CodegenContext, ev: ExprCode): ExprCode = {
nullSafeCodeGen(ctx, ev, c => {
s"""
|${ev.value} = org.apache.spark.sql.ArrayToSparseVector.fromDoubleArray($c);
""".stripMargin
})
def newMatrixUDT(): MatrixUDT = {
new MatrixUDT()
}
}

object ArrayToSparseVector {
lazy val vectorType: VectorUDT = new VectorUDT()

def fromDoubleArray(input: Any): InternalRow = {
val vector = Vectors.dense(input.asInstanceOf[ArrayData].toDoubleArray())
vectorType.serialize(vector.toSparse)
def newVectorUDT(): VectorUDT = {
new VectorUDT()
}
}

case class ArrayToDenseVector(child: Expression)
extends UnaryExpression
with ImplicitCastInputTypes {

override def inputTypes: Seq[AbstractDataType] = Seq(ArrayType(DoubleType))
override def dataType: DataType = ArrayToDenseVector.vectorType
override def nullSafeEval(input: Any): Any = ArrayToDenseVector.fromDoubleArray(input)

override def doGenCode(ctx: CodegenContext, ev: ExprCode): ExprCode = {
nullSafeCodeGen(ctx, ev, c => {
s"""
|${ev.value} = org.apache.spark.sql.ArrayToDenseVector.fromDoubleArray($c);
""".stripMargin
})
def newAnalysisException(msg: String): AnalysisException = {
new AnalysisException(msg)
}
}

object ArrayToDenseVector {
lazy val vectorType: VectorUDT = new VectorUDT()

def fromDoubleArray(input: Any): InternalRow = {
val vector = Vectors.dense(input.asInstanceOf[ArrayData].toDoubleArray())
vectorType.serialize(vector)
}
}

case class VectorToArray(child: Expression) extends UnaryExpression with ImplicitCastInputTypes {
override def inputTypes: Seq[AbstractDataType] = Seq(VectorToArray.vectorType)
override def dataType: DataType = ArrayType(DoubleType)
override def nullSafeEval(input: Any): Any = VectorToArray.toDoubleArray(input)
override def doGenCode(ctx: CodegenContext, ev: ExprCode): ExprCode = {
nullSafeCodeGen(ctx, ev, c => {
s"""
|${ev.value} = org.apache.spark.sql.VectorToArray.toDoubleArray($c);
""".stripMargin
})
}
}

object VectorToArray {
lazy val vectorType: VectorUDT = new VectorUDT()
def toDoubleArray(input: Any): ArrayData = {
new GenericArrayData(vectorType.deserialize(input).toArray)
}
type ADT = AbstractDataType
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package org.apache.spark.sql.catalyst.expressions

import org.apache.spark.sql.catalyst.InternalRow
import org.apache.spark.sql.catalyst.expressions.codegen._
import org.apache.spark.sql.catalyst.expressions.codegen.Block._
import org.apache.spark.sql.catalyst.expressions.codegen._

// Inlines QuaternaryExpression from Spark 3.0

Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
package com.databricks.hls
package org.projectglow.core

import java.util.ServiceLoader

import scala.collection.JavaConverters._

import org.apache.spark.sql.DataFrame

import com.databricks.hls.common.Named
import com.databricks.hls.transformers.util.{SnakeCaseMap, StringUtils}
import org.projectglow.core.common.Named
import org.projectglow.core.transformers.util.{SnakeCaseMap, StringUtils}

/**
* The entry point for all language specific functionality, meaning methods that cannot be expressed
Expand All @@ -16,7 +16,7 @@ import com.databricks.hls.transformers.util.{SnakeCaseMap, StringUtils}
* We should expose as little functionality as is necessary through this object and should prefer
* generic methods with stringly-typed arguments to reduce language-specific maintenance burden.
*/
object DBGenomics {
object Glow {

/**
* Apply a named transformation to a DataFrame of genomic data. All parameters apart from the
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package com.databricks.bgen
package org.projectglow.core.bgen

import java.util.{HashMap => JHashMap}

import org.apache.commons.math3.util.CombinatoricsUtils

// Tools for calculating ploidy or number of genotypes for unphased posterior probabilities
private[databricks] object BgenConverterUtils {
private[projectglow] object BgenConverterUtils {
var ploidyMap = new JHashMap[(Int, Int), Int] // (numGenotypes, numAlleles) to ploidy
var genotypesMap = new JHashMap[(Int, Int), Int] // (ploidy, numAlleles) to numGenotypes

Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package com.databricks.bgen

import scala.collection.JavaConverters._
package org.projectglow.core.bgen

import java.io.{BufferedReader, File, InputStreamReader}
import java.nio.file.Paths

import scala.collection.JavaConverters._

import com.google.common.io.LittleEndianDataInputStream
import com.google.common.util.concurrent.Striped
import org.apache.hadoop.conf.Configuration
Expand All @@ -19,10 +19,9 @@ import org.apache.spark.sql.types.StructType
import org.skife.jdbi.v2.DBI
import org.skife.jdbi.v2.util.LongMapper

import com.databricks.hls.common.logging._
import com.databricks.hls.common.{HLSLogging, WithUtils}
import com.databricks.hls.sql.util.SerializableConfiguration
import com.databricks.sql.ComDatabricksDataSource
import org.projectglow.core.common.logging.{HlsMetricDefinitions, HlsTagDefinitions, HlsTagValues, HlsUsageLogging}
import org.projectglow.core.common.{HLSLogging, WithUtils}
import org.projectglow.core.sql.util.{ComDatabricksDataSource, SerializableConfiguration}

class BgenFileFormat extends FileFormat with DataSourceRegister with Serializable with HLSLogging {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.databricks.bgen
package org.projectglow.core.bgen

import java.io.{ByteArrayInputStream, DataInput, DataInputStream}
import java.nio.charset.StandardCharsets
Expand All @@ -9,8 +9,7 @@ import com.google.common.io.LittleEndianDataInputStream
import org.apache.commons.math3.util.CombinatoricsUtils
import org.apache.hadoop.fs.FSDataInputStream

import com.databricks.hls.common.HLSLogging
import com.databricks.vcf.{BgenGenotype, BgenRow, VCFRow}
import org.projectglow.core.common.{BgenGenotype, BgenRow, HLSLogging, VCFRow}

/**
* Parses variant records of a BGEN file into the [[VCFRow]] schema. The iterator assumes that the
Expand All @@ -35,7 +34,7 @@ import com.databricks.vcf.{BgenGenotype, BgenRow, VCFRow}
* @param maxPos The maximum stream position from which variant blocks can be read. `hasNext` will
* return `false` once we've reached this position.
*/
private[databricks] class BgenFileIterator(
private[projectglow] class BgenFileIterator(
metadata: BgenMetadata,
stream: LittleEndianDataInputStream,
underlyingStream: FSDataInputStream,
Expand Down Expand Up @@ -287,7 +286,7 @@ private[databricks] class BgenFileIterator(
}
}

private[databricks] object BgenFileIterator {
private[projectglow] object BgenFileIterator {

/**
* Utility function to read a UTF8 string from a data stream. Included in the companion object
Expand All @@ -309,7 +308,8 @@ private[databricks] object BgenFileIterator {
* Read a BGEN header from a data stream. Performs basic validation on the header parameters
* according to what the reader currently supports.
*/
private[databricks] class BgenHeaderReader(stream: LittleEndianDataInputStream) extends HLSLogging {
private[projectglow] class BgenHeaderReader(stream: LittleEndianDataInputStream)
extends HLSLogging {

def readHeader(sampleIdsOpt: Option[Seq[String]] = None): BgenMetadata = {
val variantOffset = Integer.toUnsignedLong(stream.readInt()) + 4
Expand Down Expand Up @@ -381,7 +381,7 @@ private[databricks] class BgenHeaderReader(stream: LittleEndianDataInputStream)
}
}

private[databricks] case class BgenMetadata(
private[projectglow] case class BgenMetadata(
firstVariantOffset: Long,
nSamples: Long,
nVariantBlocks: Long,
Expand Down
Loading