Skip to content

Commit

Permalink
Using the new map factory.
Browse files Browse the repository at this point in the history
  • Loading branch information
cnuernber committed Feb 8, 2022
1 parent 0ad54aa commit 2ae3f0c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion java_test/deps.edn
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{:paths ["classes"
;;Parquet logging is just over the top. We eliminate a lot of noise here.
"logback"]
:deps {techascent/tech.ml.dataset {:mvn/version "6.057"
:deps {techascent/tech.ml.dataset {:mvn/version "6.059"

;;smile has bindings to slf4j that error out with an
;;exception if there is no logging backend so I
Expand Down
7 changes: 4 additions & 3 deletions java_test/java/jtest/TMDDemo.java
Original file line number Diff line number Diff line change
Expand Up @@ -466,7 +466,8 @@ public long readLong(long idx) {
//Here is a somewhat advanced example. We have a dataset composed of events where each
//row has a start,end date. We want to tally information based the days per a given month
//that the event happened which means we need to expand the dataset into days then reduce
//it to tally over months.
//it to tally over months. Finally we do another crosswise summation to pull out statistics
//based on row information in the dataset.
int nSims = 100;
int nPlacements = 50;
int nExpansion = 20;
Expand Down Expand Up @@ -495,7 +496,7 @@ public long readLong(long idx) {


//We are going to be creating a lot of these.
Function<List,Map> mapConstructor = FastStruct.createFactory(vector("year-month", "count"));
IFn mapFact = mapFactory(vector("year-month", "count"));
//We want to produce map of yearmonth to day counts.
BiFunction<YearMonth,Long,Long> incrementor = new BiFunction<YearMonth,Long,Long>() {
public Long apply(YearMonth k, Long v) {
Expand Down Expand Up @@ -523,7 +524,7 @@ public Object invoke(Object row) {
ArrayList<Map> retval = new ArrayList<Map>(tally.size());
tally.forEach(new BiConsumer<YearMonth,Long>() {
public void accept(YearMonth k, Long v) {
retval.add(mapConstructor.apply(vector(k,v)));
retval.add((Map)mapFact.invoke(k, v));
}
});
return retval;
Expand Down

0 comments on commit 2ae3f0c

Please sign in to comment.