Skip to content

Commit

Permalink
more
Browse files Browse the repository at this point in the history
  • Loading branch information
Baunsgaard committed Oct 22, 2024
1 parent 1f9c468 commit 254fa9e
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 35 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -262,13 +262,13 @@ public void set(int rl, int ru, Array<T> value) {
if((dict != null && dc.dict != null // If both dicts are not null
&& (dc.dict.size() != dict.size() // then if size of the dicts are not equivalent
|| (FrameBlock.debug && !dc.dict.equals(dict))) // or then if debugging do full equivalence check
) || map.getUnique() < dc.map.getUnique() // this map is not able to contain values of other.
) || map.getUnique() < dc.map.getUnique() // this map is not able to contain values of other.
)
throw new DMLCompressionException("Invalid setting of DDC Array, of incompatible instance." + //
"\ndict1 is null: " + (dict == null) + //
"\ndict2 is null: " + (dc.dict == null) +//
"\ndict1 is null: " + (dict == null) + //
"\ndict2 is null: " + (dc.dict == null) + //
"\nmap1 unique: " + (map.getUnique()) + //
"\nmap2 unique: " + (dc.map.getUnique()) );
"\nmap2 unique: " + (dc.map.getUnique()));

final AMapToData tm = dc.map;
for(int i = rl; i <= ru; i++) {
Expand All @@ -279,7 +279,6 @@ public void set(int rl, int ru, Array<T> value) {
throw new DMLCompressionException("Invalid to set value in CompressedArray");
}


@Override
public void set(int rl, int ru, Array<T> value, int rlSrc) {
if(value instanceof DDCArray) {
Expand All @@ -288,13 +287,13 @@ public void set(int rl, int ru, Array<T> value, int rlSrc) {
if((dict != null && dc.dict != null // If both dicts are not null
&& (dc.dict.size() != dict.size() // then if size of the dicts are not equivalent
|| (FrameBlock.debug && !dc.dict.equals(dict))) // or then if debugging do full equivalence check
) || map.getUnique() < dc.map.getUnique() // this map is not able to contain values of other.
) || map.getUnique() < dc.map.getUnique() // this map is not able to contain values of other.
)
throw new DMLCompressionException("Invalid setting of DDC Array, of incompatible instance." + //
"\ndict1 is null: " + (dict == null) + //
"\ndict2 is null: " + (dc.dict == null) +//
"\ndict1 is null: " + (dict == null) + //
"\ndict2 is null: " + (dc.dict == null) + //
"\nmap1 unique: " + (map.getUnique()) + //
"\nmap2 unique: " + (dc.map.getUnique()) );
"\nmap2 unique: " + (dc.map.getUnique()));

final AMapToData tm = dc.map;
for(int i = rl, off = rlSrc; i <= ru; i++, off++) {
Expand Down Expand Up @@ -419,7 +418,7 @@ else if(l > dict.size())

@Override
public ArrayCompressionStatistics statistics(int nSamples) {
final long memSize = getInMemorySize();
final long memSize = getInMemorySize();
final int memSizePerElement = estMemSizePerElement(getValueType(), memSize);

return new ArrayCompressionStatistics(memSizePerElement, //
Expand All @@ -428,29 +427,36 @@ public ArrayCompressionStatistics statistics(int nSamples) {

@Override
public void setM(Map<T, Long> map, int si, AMapToData m, int i) {
if(dict instanceof HashIntegerArray){
m.set(i, map.get(((HashIntegerArray)dict).getInt(this.map.getIndex(i))).intValue()-1);
}
else if (dict instanceof HashLongArray){
m.set(i, map.get(((HashLongArray)dict).getLong(this.map.getIndex(i))).intValue()-1);
}
else if (dict instanceof OptionalArray){
OptionalArray<T> opt = (OptionalArray<T>) dict;

if(opt._n.get(i)){
if(opt._a instanceof HashIntegerArray)
m.set(i, map.get(((HashIntegerArray)opt._a).getInt(this.map.getIndex(i))).intValue()-1);
else if (opt._a instanceof HashLongArray)
m.set(i, map.get(((HashLongArray)opt._a).getLong(this.map.getIndex(i))).intValue()-1);
else
m.set(i, map.get(opt._a.get(this.map.getIndex(i))).intValue()-1);
try{

if(dict instanceof HashIntegerArray) {
m.set(i, map.get(((HashIntegerArray) dict).getInt(this.map.getIndex(i))).intValue() - 1);
}
else if(dict instanceof HashLongArray) {
m.set(i, map.get(((HashLongArray) dict).getLong(this.map.getIndex(i))).intValue() - 1);
}
else {
m.set(i, si);
else if(dict instanceof OptionalArray) {
OptionalArray<T> opt = (OptionalArray<T>) dict;

if(opt._n.get(i)) {
if(opt._a instanceof HashIntegerArray)
m.set(i, map.get(((HashIntegerArray) opt._a).getInt(this.map.getIndex(i))).intValue() - 1);
else if(opt._a instanceof HashLongArray)
m.set(i, map.get(((HashLongArray) opt._a).getLong(this.map.getIndex(i))).intValue() - 1);
else
m.set(i, map.get(opt._a.get(this.map.getIndex(i))).intValue() - 1);
}
else {
m.set(i, si);
}
}
else
m.set(i, map.get(dict.get(this.map.getIndex(i))).intValue() - 1);
}
catch(Exception e) {
String error = "expected: " + get(i) + " to be in map: " + map;
throw new RuntimeException(error, e);
}
else
m.set(i, map.get(dict.get(this.map.getIndex(i))).intValue()-1);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -525,11 +525,9 @@ public void setM(Map<T, Long> map, int si, AMapToData m, int i) {

@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);
if(v == null)
id++;

if(_n.get(i)) {
id = _a.addValRecodeMap(map, id, i);
}
return id;
}
Expand Down

0 comments on commit 254fa9e

Please sign in to comment.