Skip to content

Commit

Permalink
faster copy
Browse files Browse the repository at this point in the history
  • Loading branch information
Baunsgaard committed Oct 22, 2024
1 parent 848e6b2 commit 992bd00
Show file tree
Hide file tree
Showing 8 changed files with 72 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,18 @@ public void set(int n, Integer v) {
*/
public abstract void set(int n, int v);

/**
* set a range of values from another map.
*
* The given tm must only contain supported values, and it is not verified.
*
* @param l lower bound
* @param u upper bound (not inclusive)
* @param off offset to take values from tm
* @param tm the other map to copy values from
*/
public abstract void set(int l, int u, int off, AMapToData tm);

/**
* Set the index to the value and get the contained value after.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,13 @@ public void set(int n, int v) {
_data[wIdx] &= ~(1L << n);
}

@Override
public void set(int l, int u, int off, AMapToData tm){
for(int i = l; i < u; i++, off++) {
set(i, tm.getIndex(off));
}
}

@Override
public int setAndGet(int n, int v) {
set(n, v);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,23 @@ public void set(int n, int v) {
_data[n] = (byte) v;
}

@Override
public void set(int l, int u, int off, AMapToData tm){
if(tm instanceof MapToByte){
MapToByte tbm = (MapToByte)tm;
byte[] tbv = tbm._data;
for(int i = l; i < u; i++, off++) {
_data[i] = tbv[off];
}
}
else{

for(int i = l; i < u; i++, off++) {
_data[i] = (byte)tm.getIndex(off);
}
}
}

@Override
public int setAndGet(int n, int v) {
_data[n] = (byte) v;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,22 @@ public void set(int n, char v) {
_data[n] = v;
}

@Override
public void set(int l, int u, int off, AMapToData tm) {
if(tm instanceof MapToChar) {
MapToChar tbm = (MapToChar) tm;
char[] tbv = tbm._data;
for(int i = l; i < u; i++, off++) {
_data[i] = tbv[off];
}
}
else {
for(int i = l; i < u; i++, off++) {
set(i, tm.getIndex(off));
}
}
}

@Override
public int setAndGet(int n, int v) {
return _data[n] = (char) v;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,13 @@ public void set(int n, int v) {
_data_b[n] = (byte) (m >> 16);
}

@Override
public void set(int l, int u, int off, AMapToData tm){
for(int i = l; i < u; i++, off++) {
set(i, tm.getIndex(off));
}
}

@Override
public int setAndGet(int n, int v) {
int m = v & 0xffffff;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,13 @@ public void set(int n, int v) {
_data[n] = v;
}

@Override
public void set(int l, int u, int off, AMapToData tm){
for(int i = l; i < u; i++, off++) {
set(i, tm.getIndex(off));
}
}

@Override
public int setAndGet(int n, int v) {
return _data[n] = v;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,11 @@ public void set(int n, int v) {
// do nothing
}

@Override
public void set(int l, int u, int off, AMapToData tm){
// do nothing
}

@Override
public int setAndGet(int n, int v) {
return 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -295,10 +295,7 @@ public void set(int rl, int ru, Array<T> value, int rlSrc) {
"\nmap1 unique: " + (map.getUnique()) + //
"\nmap2 unique: " + (dc.map.getUnique()));

final AMapToData tm = dc.map;
for(int i = rl, off = rlSrc; i <= ru; i++, off++) {
map.set(i, tm.getIndex(off));
}
map.set(rl, ru + 1, rlSrc, dc.map);
}
else
throw new DMLCompressionException("Invalid to set value in CompressedArray");
Expand Down

0 comments on commit 992bd00

Please sign in to comment.