-
Notifications
You must be signed in to change notification settings - Fork 834
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Make streaming the default LightGBM data transfer mode (#2088)
* Make streaming the default * revert to test * test again * group id fixes * nit fix * nit fix --------- Co-authored-by: Mark Hamilton <[email protected]>
- Loading branch information
1 parent
b08b33d
commit 2f31f74
Showing
8 changed files
with
64 additions
and
3 deletions.
There are no files selected for viewing
45 changes: 45 additions & 0 deletions
45
lightgbm/src/main/scala/com/microsoft/azure/synapse/ml/lightgbm/GroupIdManager.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
// Copyright (C) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. See LICENSE in project root for information. | ||
|
||
package com.microsoft.azure.synapse.ml.lightgbm | ||
|
||
import scala.collection.mutable | ||
import scala.language.existentials | ||
|
||
/** Class for converting column values to group ID. | ||
* | ||
* Ints can just be returned, but a map of Long and String values is maintained so that unique and | ||
* consistent values can be returned. | ||
*/ | ||
class GroupIdManager { | ||
private val stringGroupIds = mutable.Map[String, Int]() | ||
private val longGroupIds = mutable.Map[Long, Int]() | ||
private[this] val lock = new Object() | ||
|
||
/** Convert a group ID into a unique Int. | ||
* | ||
* @param groupValue The original group ID value | ||
*/ | ||
def getUniqueIdForGroup(groupValue: Any): Int = { | ||
groupValue match { | ||
case iVal: Int => | ||
iVal // If it's already an Int, just return | ||
case lVal: Long => | ||
lock.synchronized { | ||
if (!longGroupIds.contains(lVal)) { | ||
longGroupIds(lVal) = longGroupIds.size | ||
} | ||
longGroupIds(lVal) | ||
} | ||
case sVal: String => | ||
lock.synchronized { | ||
if (!stringGroupIds.contains(sVal)) { | ||
stringGroupIds(sVal) = longGroupIds.size | ||
} | ||
stringGroupIds(sVal) | ||
} | ||
case _ => | ||
throw new IllegalArgumentException(s"Unsupported group column type: '${groupValue.getClass.getName}'") | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters