You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ignite.apache.org by GitBox <gi...@apache.org> on 2019/02/12 07:41:23 UTC
[GitHub] thatb96 commented on a change in pull request #6079: IGNITE-11234:
Add fillCache method to DataStreamGenerator
thatb96 commented on a change in pull request #6079: IGNITE-11234: Add fillCache method to DataStreamGenerator
URL: https://github.com/apache/ignite/pull/6079#discussion_r255832566
##########
File path: modules/ml/src/main/java/org/apache/ignite/ml/util/generators/DataStreamGenerator.java
##########
@@ -125,10 +135,54 @@ public default DataStreamGenerator blur(RandomProducer rnd) {
* @param upstreamTransformerBuilder Upstream transformer builder.
* @return Dataset builder.
*/
- public default DatasetBuilder<Vector, Double> asDatasetBuilder(int datasetSize, IgniteBiPredicate<Vector, Double> filter,
+ public default DatasetBuilder<Vector, Double> asDatasetBuilder(int datasetSize,
+ IgniteBiPredicate<Vector, Double> filter,
int partitions, UpstreamTransformerBuilder upstreamTransformerBuilder) {
return new DatasetBuilderAdapter(this, datasetSize, filter, partitions, upstreamTransformerBuilder);
}
+ /**
+ * Fills given cache with labeled vectors from this generator and user defined mapper from vectors to keys.
+ *
+ * @param datasetSize Rows count to put.
+ * @param cache Cache.
+ * @param keyMapper Mapping from vectors to keys.
+ * @param <K> Key type.
+ */
+ public default <K> void fillCacheWithCustomKey(int datasetSize, IgniteCache<K, LabeledVector<Double>> cache,
+ Function<LabeledVector<Double>, K> keyMapper) {
+
+ Map<K, LabeledVector<Double>> batch = new HashMap<>();
+ labeled().limit(datasetSize).forEach(vec -> {
+ batch.put(keyMapper.apply(vec), vec);
+ if (batch.size() == FILL_CACHE_BATCH_SIZE) {
+ cache.putAll(batch);
Review comment:
```suggestion
- cache.putAll(batch);
```
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services