Skip to content

Commit

Permalink
Wip
Browse files Browse the repository at this point in the history
  • Loading branch information
jpmcmu committed Sep 25, 2024
1 parent 168d835 commit 1567f6c
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,11 @@ public HpccSrcType getSourceType()
return this.srcType;
}

public void setSourceType(HpccSrcType srcType)
{
this.srcType = srcType;
}

/**
* Length of data or minimum length if variable.
*
Expand Down Expand Up @@ -307,7 +312,7 @@ public boolean isUnsigned()
/**
* Is the underlying value biased?
*
* @return true when biased
* @return true when biased
*/
public boolean isBiased()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -517,11 +517,6 @@ private static int getTypeID(FieldDef field) throws Exception
case INTEGER:
{
typeID = type_int;
if (field.isUnsigned())
{
typeID |= FLAG_UNSIGNED;
}

HpccSrcType srcType = field.getSourceType();
if (srcType == HpccSrcType.KEYED_INTEGER)
{
Expand All @@ -535,6 +530,12 @@ else if (srcType == HpccSrcType.BIAS_SWAPPED_INTEGER)
{
typeID = type_biasedswapint;
}

if (field.isUnsigned())
{
typeID |= FLAG_UNSIGNED;
}

break;
}
case DECIMAL:
Expand Down Expand Up @@ -642,7 +643,7 @@ else if (srcType == HpccSrcType.UTF16LE || srcType == HpccSrcType.UTF16BE)
*/
private static int getTypeHash(FieldDef field) throws Exception
{
int numHashComponents = 2 + field.getNumDefs();
int numHashComponents = 4 + field.getNumDefs();
if (field.getFieldType() == FieldType.DECIMAL)
{
numHashComponents += 2;
Expand All @@ -651,8 +652,10 @@ private static int getTypeHash(FieldDef field) throws Exception
long[] hashComponents = new long[numHashComponents];
hashComponents[0] = getTypeID(field);
hashComponents[1] = field.getDataLen();
hashComponents[2] = field.getSourceType().ordinal();
hashComponents[3] = field.getAdditionalFlags();

int hashCompIndex = 2;
int hashCompIndex = 4;
for (int i = 0; i < field.getNumDefs(); i++, hashCompIndex++)
{
hashComponents[hashCompIndex] = getTypeHash(field.getDef(i));
Expand Down Expand Up @@ -760,7 +763,8 @@ private static int getJsonTypeDefinition(FieldDef field, HashMap<Integer, Intege
{
char delim = 0x0001;
childJson.put("xpath", childField.getFieldName() + delim + "Row");
} else if (childField.getFieldType() == FieldType.SET)
}
else if (childField.getFieldType() == FieldType.SET)
{
char delim = 0x0001;
childJson.put("xpath", childField.getFieldName() + delim + "Item");
Expand All @@ -779,6 +783,18 @@ private static int getJsonTypeDefinition(FieldDef field, HashMap<Integer, Intege
}
}

if (field.isBiased())
{
FieldDef nonKeyedField = new FieldDef(field);
nonKeyedField.setSourceType(HpccSrcType.LITTLE_ENDIAN);
nonKeyedField.setIsBiased(false);

int childTypeHash = getJsonTypeDefinition(nonKeyedField, typeDefinitionMap, typeDefinitions);
int childTypeIndex = typeDefinitionMap.get(childTypeHash);
String childTypeName = "ty" + (childTypeIndex + 1);
typeDef.put("child", childTypeName);
}

int newTypeIndex = typeDefinitions.size();
typeDefinitions.add(typeDef);
typeDefinitionMap.put(typeHash, newTypeIndex);
Expand Down

0 comments on commit 1567f6c

Please sign in to comment.