Skip to content

Commit

Permalink
Change Complicated to Composite
Browse files Browse the repository at this point in the history
  • Loading branch information
byrnHDF committed Jan 6, 2025
1 parent 530a331 commit 2b8f51d
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1290,6 +1290,12 @@ else if (baseTypeDataProvider instanceof RefDataProvider) {
*/
theValue = retrieveArrayOfArrayElements(dataBuf, columnIndex, bufIndex);
}
else if (baseTypeDataProvider instanceof ComplexDataProvider) {
/*
* TODO: assign to global arrayElements.
*/
theValue = retrieveArrayOfComplexElements(dataBuf, columnIndex, bufIndex);
}
else {
/*
* TODO: assign to global arrayElements.
Expand Down Expand Up @@ -1329,6 +1335,9 @@ else if (baseTypeDataProvider instanceof ArrayDataProvider) {
else if (baseTypeDataProvider instanceof RefDataProvider) {
theValue = retrieveArrayOfArrayElements(obj, columnIndex, rowIndex);
}
else if (baseTypeDataProvider instanceof ComplexDataProvider) {
theValue = retrieveArrayOfComplexElements(obj, columnIndex, rowIndex);
}
else {
theValue = retrieveArrayOfAtomicElements(obj, rowIndex);
}
Expand Down Expand Up @@ -1389,6 +1398,34 @@ private Object[] retrieveArrayOfArrayElements(Object objBuf, int columnIndex, in
return tempArray;
}

private Object[] retrieveArrayOfComplexElements(Object objBuf, int columnIndex, int startRowIndex)
{
log.debug("retrieveArrayOfComplexElements(): objBuf={}", objBuf);
ArrayList<byte[]> vlElements = ((ArrayList[]) objBuf)[startRowIndex];
log.debug("retrieveArrayOfComplexElements(): vlElements={}", vlElements);
long vlSize = vlElements.size();
log.debug("retrieveArrayOfComplexElements(): vlSize={} length={}", vlSize, vlElements.size());
Object[] tempArray = new Object[(int) vlSize];

for (int i = 0; i < vlSize; i++) {
ArrayList<byte[]> ref_value = vlElements;
StringBuilder sb = new StringBuilder();
sb.append("{");
for (int m = 0; m < ref_value.size(); m++) {
if (m > 0)
sb.append(", ");
byte[] byteElements = ref_value.get(m);
log.trace("retrieveArrayOfComplexElements byteElements={}", byteElements);
sb.append(baseTypeDataProvider.getDataValue(byteElements, columnIndex, i * 2));
}
sb.append("}");
tempArray[i] = sb.toString();
log.trace("retrieveArrayOfComplexElements(tempArray[{}]={}): start", i, tempArray);
}

return tempArray;
}

private Object[] retrieveArrayOfAtomicElements(Object objBuf, int rowStartIdx)
{
ArrayList vlElements = ((ArrayList[])objBuf)[rowStartIdx];
Expand Down
12 changes: 6 additions & 6 deletions src/org.hdfgroup.object/hdf/object/h5/H5Datatype.java
Original file line number Diff line number Diff line change
Expand Up @@ -2818,16 +2818,16 @@ else if (this.isCompound()) {
return topTID;
}

private boolean datatypeIsComplicated(long tid)
private boolean datatypeIsComposite(long tid)
{
long tclass = HDF5Constants.H5T_NO_CLASS;

try {
tclass = H5.H5Tget_class(tid);
log.trace("datatypeIsComplicated():{}", tclass);
log.trace("datatypeIsComposite():{}", tclass);
}
catch (Exception ex) {
log.debug("datatypeIsComplicated():", ex);
log.debug("datatypeIsComposite():", ex);
}

boolean retVal = (tclass == HDF5Constants.H5T_COMPOUND);
Expand Down Expand Up @@ -2855,14 +2855,14 @@ private boolean datatypeIsReference(long tid)

private boolean datatypeIsAtomic(long tid)
{
boolean retVal = !(datatypeIsComplicated(tid) | datatypeIsReference(tid) | isRef());
boolean retVal = !(datatypeIsComposite(tid) | datatypeIsReference(tid) | isRef());
retVal |= isOpaque();
retVal |= isBitField();

return retVal;
}

private boolean datatypeClassIsComplicated(long tclass)
private boolean datatypeClassIsComposite(long tclass)
{
boolean retVal = (tclass == HDF5Constants.H5T_COMPOUND);
retVal |= (tclass == HDF5Constants.H5T_ENUM);
Expand All @@ -2879,7 +2879,7 @@ private boolean datatypeClassIsComplicated(long tclass)

private boolean datatypeClassIsAtomic(long tclass)
{
boolean retVal = !(datatypeClassIsComplicated(tclass) | datatypeClassIsReference(tclass));
boolean retVal = !(datatypeClassIsComposite(tclass) | datatypeClassIsReference(tclass));
retVal |= (tclass == Datatype.CLASS_OPAQUE);
retVal |= (tclass == Datatype.CLASS_BITFIELD);

Expand Down
2 changes: 1 addition & 1 deletion src/org.hdfgroup.object/hdf/object/h5/H5ScalarAttr.java
Original file line number Diff line number Diff line change
Expand Up @@ -1225,7 +1225,7 @@ else if (dsDatatype.isCompound()) {
for (int j = 0; j < lsize; j++)
strs[j] = "";
try {
log.trace("AttributeCommonIO():read ioType H5AreadComplicated");
log.trace("AttributeCommonIO():read ioType H5AreadComposite");
H5.H5AreadComplex(attr_id, tid, strs);
}
catch (Exception ex) {
Expand Down

0 comments on commit 2b8f51d

Please sign in to comment.