Skip to content

Commit cba0660

Browse files
authored
Add int-based bank column accessors (#826)
* add column-index accessors * implement unsupported/missing methods * add more column-index methods * add newly-missing methods
1 parent 9cf5379 commit cba0660

File tree

3 files changed

+175
-6
lines changed

3 files changed

+175
-6
lines changed

common-tools/clas-io/src/main/java/org/jlab/io/base/BasicDataBank.java

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -588,5 +588,65 @@ public TableModel getTableModel(String mask) {
588588
}
589589
return new DefaultTableModel(objects,columns);
590590
}
591+
592+
@Override
593+
public double getDouble(int element, int index) {
594+
throw new UnsupportedOperationException("Not supported yet."); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/GeneratedMethodBody
595+
}
596+
597+
@Override
598+
public void setDouble(int element, int row, double value) {
599+
throw new UnsupportedOperationException("Not supported yet."); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/GeneratedMethodBody
600+
}
601+
602+
@Override
603+
public float getFloat(int element, int index) {
604+
throw new UnsupportedOperationException("Not supported yet."); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/GeneratedMethodBody
605+
}
606+
607+
@Override
608+
public void setFloat(int element, int row, float value) {
609+
throw new UnsupportedOperationException("Not supported yet."); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/GeneratedMethodBody
610+
}
611+
612+
@Override
613+
public int getInt(int element, int index) {
614+
throw new UnsupportedOperationException("Not supported yet."); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/GeneratedMethodBody
615+
}
616+
617+
@Override
618+
public void setInt(int element, int row, int value) {
619+
throw new UnsupportedOperationException("Not supported yet."); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/GeneratedMethodBody
620+
}
621+
622+
@Override
623+
public short getShort(int element, int index) {
624+
throw new UnsupportedOperationException("Not supported yet."); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/GeneratedMethodBody
625+
}
626+
627+
@Override
628+
public void setShort(int element, int row, short value) {
629+
throw new UnsupportedOperationException("Not supported yet."); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/GeneratedMethodBody
630+
}
631+
632+
@Override
633+
public byte getByte(int element, int index) {
634+
throw new UnsupportedOperationException("Not supported yet."); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/GeneratedMethodBody
635+
}
636+
637+
@Override
638+
public void setByte(int element, int row, byte value) {
639+
throw new UnsupportedOperationException("Not supported yet."); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/GeneratedMethodBody
640+
}
641+
642+
@Override
643+
public long getLong(int element, int index) {
644+
throw new UnsupportedOperationException("Not supported yet."); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/GeneratedMethodBody
645+
}
646+
647+
@Override
648+
public void setLong(int element, int row, long value) {
649+
throw new UnsupportedOperationException("Not supported yet."); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/GeneratedMethodBody
650+
}
591651

592652
}

common-tools/clas-io/src/main/java/org/jlab/io/base/DataBank.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,15 @@ public interface DataBank {
2424
*/
2525
double[] getDouble(String path);
2626
double getDouble(String path, int index);
27+
double getDouble(int element, int index);
2728
/**
2829
* Adds array of doubles into the bank under the name.
2930
* @param path - name of the array.
3031
* @param arr primitive type array of doubles.
3132
*/
3233
void setDouble(String path, double[] arr);
3334
void setDouble(String path, int row, double value);
35+
void setDouble(int element, int row, double value);
3436
/**
3537
* Appends an array to existing array with the same name.
3638
* The resulting array will increase in size by arr.length.
@@ -41,32 +43,42 @@ public interface DataBank {
4143

4244
float[] getFloat(String path);
4345
float getFloat(String path, int index);
46+
float getFloat(int element, int index);
4447
void setFloat(String path, float[] arr);
4548
void setFloat(String path, int row, float value);
49+
void setFloat(int element, int row, float value);
4650
void appendFloat(String path, float[] arr);
4751

4852
int[] getInt(String path);
4953
int getInt(String path, int index);
54+
int getInt(int element, int index);
5055
void setInt(String path, int[] arr);
5156
void setInt(String path, int row, int value);
57+
void setInt(int element, int row, int value);
5258
void appendInt(String path, int[] arr);
5359

5460
short[] getShort(String path);
5561
short getShort(String path, int index);
62+
short getShort(int element, int index);
5663
void setShort(String path, short[] arr);
5764
void setShort(String path, int row, short value);
65+
void setShort(int element, int row, short value);
5866
void appendShort(String path, short[] arr);
5967

6068
byte[] getByte(String path);
6169
byte getByte(String path, int index);
70+
byte getByte(int element, int index);
6271
void setByte(String path, byte[] arr);
6372
void setByte(String path, int row, byte value);
73+
void setByte(int element, int row, byte value);
6474
void appendByte(String path, byte[] arr);
6575

6676
long[] getLong(String path);
6777
long getLong(String path, int index);
78+
long getLong(int element, int index);
6879
void setLong(String path, long[] arr);
6980
void setLong(String path, int row, long value);
81+
void setLong(int element, int row, long value);
7082
void appendLong(String path, long[] arr);
7183
/**
7284
* Returns the number of columns in the bank. columns are number of

common-tools/clas-io/src/main/java/org/jlab/io/hipo/HipoDataBank.java

Lines changed: 103 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,9 @@ public double getDouble(String path, int index) {
5757

5858
@Override
5959
public void setDouble(String path, double[] arr) {
60-
throw new UnsupportedOperationException("Not supported yet.");
60+
int nrows = this.hipoGroup.getRows();
61+
for (int i=0; i<nrows; i++)
62+
this.hipoGroup.putDouble(path, i, arr[i]);
6163
}
6264

6365
@Override
@@ -85,7 +87,9 @@ public float getFloat(String path, int index) {
8587

8688
@Override
8789
public void setFloat(String path, float[] arr) {
88-
throw new UnsupportedOperationException("Not supported yet.");
90+
int nrows = this.hipoGroup.getRows();
91+
for (int i=0; i<nrows; i++)
92+
this.hipoGroup.putFloat(path, i, arr[i]);
8993
}
9094

9195
@Override
@@ -113,7 +117,9 @@ public int getInt(String path, int index) {
113117

114118
@Override
115119
public void setInt(String path, int[] arr) {
116-
throw new UnsupportedOperationException("Not supported yet.");
120+
int nrows = this.hipoGroup.getRows();
121+
for (int i=0; i<nrows; i++)
122+
this.hipoGroup.putInt(path, i, arr[i]);
117123
}
118124

119125
@Override
@@ -141,7 +147,9 @@ public short getShort(String path, int index) {
141147

142148
@Override
143149
public void setShort(String path, short[] arr) {
144-
throw new UnsupportedOperationException("Not supported yet.");
150+
int nrows = this.hipoGroup.getRows();
151+
for (int i=0; i<nrows; i++)
152+
this.hipoGroup.putShort(path, i, arr[i]);
145153
}
146154

147155
@Override
@@ -169,7 +177,9 @@ public long getLong(String path, int index) {
169177

170178
@Override
171179
public void setLong(String path, long[] arr) {
172-
throw new UnsupportedOperationException("Not supported yet.");
180+
int nrows = this.hipoGroup.getRows();
181+
for (int i=0; i<nrows; i++)
182+
this.hipoGroup.putLong(path, i, arr[i]);
173183
}
174184

175185
@Override
@@ -197,7 +207,9 @@ public byte getByte(String path, int index) {
197207

198208
@Override
199209
public void setByte(String path, byte[] arr) {
200-
throw new UnsupportedOperationException("Not supported yet.");
210+
int nrows = this.hipoGroup.getRows();
211+
for (int i=0; i<nrows; i++)
212+
this.hipoGroup.putByte(path, i, arr[i]);
201213
}
202214

203215
@Override
@@ -241,4 +253,89 @@ public TableModel getTableModel(String mask) {
241253
return null;
242254
}
243255

256+
@Override
257+
public byte getByte(int element, int index) {
258+
return this.hipoGroup.getByte(element, index);
259+
}
260+
@Override
261+
public short getShort(int element, int index) {
262+
return this.hipoGroup.getShort(element, index);
263+
}
264+
@Override
265+
public int getInt(int element, int index) {
266+
return this.hipoGroup.getInt(element, index);
267+
}
268+
@Override
269+
public long getLong(int element, int index) {
270+
return this.hipoGroup.getLong(element, index);
271+
}
272+
@Override
273+
public float getFloat(int element, int index) {
274+
return this.hipoGroup.getFloat(element, index);
275+
}
276+
@Override
277+
public double getDouble(int element, int index) {
278+
return this.hipoGroup.getDouble(element, index);
279+
}
280+
281+
public void setFloat(int element, float[] arr) {
282+
int nrows = this.hipoGroup.getRows();
283+
for (int i=0; i<nrows; i++)
284+
this.hipoGroup.putFloat(element, i, arr[i]);
285+
}
286+
public void setDouble(int element, double[] arr) {
287+
int nrows = this.hipoGroup.getRows();
288+
for (int i=0; i<nrows; i++)
289+
this.hipoGroup.putDouble(element, i, arr[i]);
290+
}
291+
public void setByte(int element, byte[] arr) {
292+
int nrows = this.hipoGroup.getRows();
293+
for (int i=0; i<nrows; i++)
294+
this.hipoGroup.putByte(element, i, arr[i]);
295+
}
296+
public void setShort(int element, short[] arr) {
297+
int nrows = this.hipoGroup.getRows();
298+
for (int i=0; i<nrows; i++)
299+
this.hipoGroup.putShort(element, i, arr[i]);
300+
}
301+
public void setInt(int element, int[] arr) {
302+
int nrows = this.hipoGroup.getRows();
303+
for (int i=0; i<nrows; i++)
304+
this.hipoGroup.putInt(element, i, arr[i]);
305+
}
306+
public void setLong(int element, long[] arr) {
307+
int nrows = this.hipoGroup.getRows();
308+
for (int i=0; i<nrows; i++)
309+
this.hipoGroup.putLong(element, i, arr[i]);
310+
}
311+
312+
@Override
313+
public void setDouble(int element, int row, double value) {
314+
this.hipoGroup.putDouble(element, row, value);
315+
}
316+
317+
@Override
318+
public void setFloat(int element, int row, float value) {
319+
this.hipoGroup.putFloat(element, row, value);
320+
}
321+
322+
@Override
323+
public void setInt(int element, int row, int value) {
324+
this.hipoGroup.putInt(element, row, value);
325+
}
326+
327+
@Override
328+
public void setShort(int element, int row, short value) {
329+
this.hipoGroup.putShort(element, row, value);
330+
}
331+
332+
@Override
333+
public void setByte(int element, int row, byte value) {
334+
this.hipoGroup.putByte(element, row, value);
335+
}
336+
337+
@Override
338+
public void setLong(int element, int row, long value) {
339+
this.hipoGroup.putLong(element, row, value);
340+
}
244341
}

0 commit comments

Comments
 (0)