Skip to content

Commit

Permalink
call down
Browse files Browse the repository at this point in the history
  • Loading branch information
Baunsgaard committed Oct 21, 2024
1 parent e71d506 commit cd205b5
Show file tree
Hide file tree
Showing 4 changed files with 84 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ protected Map<T, Long> createRecodeMap(int estimate) {
return map;
}

private long addValRecodeMap(Map<T, Long> map, long id, int i) {
protected long addValRecodeMap(Map<T, Long> map, long id, int i) {
T val = get(i);
if(val != null) {
Long v = map.putIfAbsent(val, id);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,12 @@
import java.io.DataOutput;
import java.io.IOException;
import java.util.Arrays;
import java.util.Map;

import org.apache.commons.lang3.NotImplementedException;
import org.apache.sysds.common.Types.ValueType;
import org.apache.sysds.runtime.DMLRuntimeException;
import org.apache.sysds.runtime.compress.colgroup.mapping.AMapToData;
import org.apache.sysds.runtime.frame.data.columns.ArrayFactory.FrameArrayType;
import org.apache.sysds.runtime.matrix.data.Pair;
import org.apache.sysds.runtime.util.UtilFunctions;
Expand Down Expand Up @@ -435,6 +437,27 @@ public boolean possiblyContainsNaN() {
return false;
}

@Override
protected long addValRecodeMap(Map<Object, Long> map, long id, int i) {
Long val = getLong(i);
Long v = map.putIfAbsent(val, id);
if(v == null)
id++;
return id;
}

@Override
public void setM(Map<Object, Long> map, AMapToData m, int i){
m.set(i, map.get(getInt(i)).intValue() - 1);
}

@Override
public void setM(Map<Object, Long> map, int si, AMapToData m, int i) {
final Integer v = getInt(i);
m.set(i, map.get(v).intValue() - 1);
}


@Override
public String toString() {
StringBuilder sb = new StringBuilder(_size * 5 + 2);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,12 @@
import java.io.DataOutput;
import java.io.IOException;
import java.util.Arrays;
import java.util.Map;

import org.apache.commons.lang3.NotImplementedException;
import org.apache.sysds.common.Types.ValueType;
import org.apache.sysds.runtime.DMLRuntimeException;
import org.apache.sysds.runtime.compress.colgroup.mapping.AMapToData;
import org.apache.sysds.runtime.frame.data.columns.ArrayFactory.FrameArrayType;
import org.apache.sysds.runtime.matrix.data.Pair;
import org.apache.sysds.runtime.util.UtilFunctions;
Expand Down Expand Up @@ -432,6 +434,26 @@ public boolean possiblyContainsNaN() {
return false;
}

@Override
protected long addValRecodeMap(Map<Object, Long> map, long id, int i) {
Integer val = getInt(i);
Long v = map.putIfAbsent(val, id);
if(v == null)
id++;

return id;
}

@Override
public void setM(Map<Object, Long> map, AMapToData m, int i){
m.set(i, map.get(getLong(i)).intValue() - 1);
}

@Override
public void setM(Map<Object, Long> map, int si, AMapToData m, int i) {
m.set(i, map.get(getLong(i)).intValue() - 1);
}

@Override
public String toString() {
StringBuilder sb = new StringBuilder(_size * 5 + 2);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@

import org.apache.sysds.common.Types.ValueType;
import org.apache.sysds.runtime.DMLRuntimeException;
import org.apache.sysds.runtime.compress.colgroup.mapping.AMapToData;
import org.apache.sysds.runtime.frame.data.columns.ArrayFactory.FrameArrayType;
import org.apache.sysds.runtime.matrix.data.Pair;
import org.apache.sysds.runtime.util.UtilFunctions;
Expand Down Expand Up @@ -473,6 +474,7 @@ public boolean possiblyContainsNaN() {
}

@Override
@SuppressWarnings("unchecked")
protected Map<T, Long> createRecodeMap(int estimate) {
if(getValueType() == ValueType.BOOLEAN) {
// shortcut for boolean arrays, since we only
Expand All @@ -484,11 +486,46 @@ protected Map<T, Long> createRecodeMap(int estimate) {

return map;
}
else if(getValueType() == ValueType.HASH32){
Map<Object, Long> map = new HashMap<>(estimate);
HashIntegerArray b = (HashIntegerArray)_a;
long id = 1;
for(int i = 0; i < size(); i++){
if(_n.get(i))
id = b.addValRecodeMap(map, id, i);
}
return (Map<T, Long>)map;
}
else if(getValueType() == ValueType.HASH64){
Map<Object, Long> map = new HashMap<>(estimate);
HashLongArray b = (HashLongArray)_a;
long id = 1;
for(int i = 0; i < size(); i++){
if(_n.get(i))
id = b.addValRecodeMap(map, id, i);
}
return (Map<T, Long>)map;
}
else
return super.createRecodeMap(estimate);
}

private long addValRecodeMap(Map<T, Long> map, long id, int i) {
@Override
public void setM(Map<T, Long> map, AMapToData m, int i){
_a.setM(map,m,i);
}

@Override
public void setM(Map<T, Long> map, int si, AMapToData m, int i) {
if(_n.get(i))
_a.setM(map,si,m,i);
else
m.set(i, si);
}


@Override
protected long addValRecodeMap(Map<T, Long> map, long id, int i) {
T val = get(i);
if(val != null) {
Long v = map.putIfAbsent(val, id);
Expand All @@ -498,7 +535,6 @@ private long addValRecodeMap(Map<T, Long> map, long id, int i) {
return id;
}


@Override
public String toString() {
StringBuilder sb = new StringBuilder(_size + 2);
Expand Down

0 comments on commit cd205b5

Please sign in to comment.