-
Notifications
You must be signed in to change notification settings - Fork 286
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[NA] Bulk insert improvements (#179)
* [NA] Bulk insert improvements * Add fix for dataset items and experiment item insertion
- Loading branch information
1 parent
126ef51
commit 43c044b
Showing
6 changed files
with
50 additions
and
26 deletions.
There are no files selected for viewing
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
17 changes: 7 additions & 10 deletions
17
apps/opik-backend/src/main/java/com/comet/opik/utils/TemplateUtils.java
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 |
---|---|---|
@@ -1,29 +1,26 @@ | ||
package com.comet.opik.utils; | ||
|
||
import java.util.Collection; | ||
import lombok.RequiredArgsConstructor; | ||
|
||
import java.util.List; | ||
import java.util.stream.IntStream; | ||
|
||
public class TemplateUtils { | ||
|
||
@RequiredArgsConstructor | ||
public static class QueryItem { | ||
public final int index; | ||
public final boolean hasNext; | ||
|
||
public QueryItem(int index, boolean hasNext) { | ||
this.index = index; | ||
this.hasNext = hasNext; | ||
} | ||
} | ||
|
||
public static List<QueryItem> getQueryItemPlaceHolder(Collection<?> items) { | ||
public static List<QueryItem> getQueryItemPlaceHolder(int size) { | ||
|
||
if (items == null || items.isEmpty()) { | ||
if (size == 0) { | ||
return List.of(); | ||
} | ||
|
||
return IntStream.range(0, items.size()) | ||
.mapToObj(i -> new QueryItem(i, i < items.size() - 1)) | ||
return IntStream.range(0, size) | ||
.mapToObj(i -> new QueryItem(i, i < size - 1)) | ||
.toList(); | ||
} | ||
} |