public void mReadRecordSet(RecordSetMD aInputRecordSetMD, RecordSet aInputRecordSet, PrintWriter pw) //throws WDSException { int ri = 0; try { if (aInputRecordSet.isEmpty()) { //Java aInputRecordSet.Records = new ArrayList<>(0); //C# aInputRecordSet.Records = new List <Map <FieldName, Object> >(0); //Java aInputRecordSet.Records_Orig = new ArrayList<>(0); //C# aInputRecordSet.Records_Orig = new List <Object []>(0); } int nColumns = aInputRecordSetMD.nColumns(); int i = -1; int j = -1; int jj = -1; DBB buf = aInputRecordSetMD.DBBMatter.RecordSet.Buffer; int nRows = (int)aInputRecordSetMD.DBBMatter.RecordSet.Buffer.nRecords; /* Java >>> * * Double lvd = 0.0; * Long lvl = 0L; * Integer lvi = 0; * Boolean lvbln = false; * /* <<< Java */ /* C# >>> */ double? lvd = 0.0; long? lvl = 0L; int? lvi = 0; Boolean?lvbln = false; /* <<< C# */ String lvs = ""; int bptr = 0; for (i = 0; i < nRows; i++, bptr += (int)aInputRecordSetMD.DBBMatter.RecordSet.Buffer.nRecordFLenBytes) { ri = i; buf.position(buf.ptr, bptr, buf.vlenptr); Object[] inputRow_orig = new Object[nColumns]; //Java Map<FieldName, Object> inputRow = new LinkedHashMap<>(); //C# Map <FieldName, Object> inputRow = new Map <FieldName, Object>(); for (jj = 0; jj < nColumns; jj++) { switch (aInputRecordSetMD.Column[jj].DTyp) { //case Dbl: case FieldMDEnums.eDTyp.Dbl: lvd = buf.GetLayerDouble(1); //Java if (lvd==null || lvd.isNaN() || Double.isInfinite(lvd) ) lvd=null; //C# if (lvd == null || Double.IsNaN(lvd.Value) || lvd == Double.MinValue || lvd == Double.MaxValue || Double.IsNegativeInfinity(lvd.Value) || Double.IsPositiveInfinity(lvd.Value)) { lvd = null; } inputRow_orig[jj] = lvd; if (aInputRecordSetMD.Column[jj].hasMapKey()) { inputRow.put(aInputRecordSetMD.Column[jj].MapKey, lvd); } break; //case Lng: case FieldMDEnums.eDTyp.Lng: lvl = buf.GetLayerLong(1); //Java if ( lvl == null || lvl.equals(Long.MIN_VALUE) || lvl.equals(Long.MAX_VALUE) ) lvl = null; //C# if (lvl == null || lvl == long.MinValue || lvl == long.MaxValue) { lvl = null; } inputRow_orig[jj] = lvl; if (aInputRecordSetMD.Column[jj].hasMapKey()) { inputRow.put(aInputRecordSetMD.Column[jj].MapKey, lvl); } break; //case Int: case FieldMDEnums.eDTyp.Int: lvi = buf.GetLayerInt(1); //Java if ( lvi == null || lvi.equals(Integer.MIN_VALUE) || lvi.equals(Integer.MAX_VALUE) ) lvi = null; //C# if (lvi == null || lvi == int.MinValue || lvi == int.MaxValue) { lvi = null; } inputRow_orig[jj] = lvi; if (aInputRecordSetMD.Column[jj].hasMapKey()) { inputRow.put(aInputRecordSetMD.Column[jj].MapKey, lvi); } break; //case Str: case FieldMDEnums.eDTyp.Str: lvs = buf.GetLayerFLenString(1, aInputRecordSetMD.Column[jj].ByteMaxLength); inputRow_orig[jj] = lvs; if (aInputRecordSetMD.Column[jj].hasMapKey()) { inputRow.put(aInputRecordSetMD.Column[jj].MapKey, lvs); } break; //case VLS: case FieldMDEnums.eDTyp.VLS: lvs = buf.GetLayerVLenString(1, aInputRecordSetMD.Column[jj].ByteMaxLength); inputRow_orig[jj] = lvs; if (aInputRecordSetMD.Column[jj].hasMapKey()) { inputRow.put(aInputRecordSetMD.Column[jj].MapKey, lvs); } break; //case Bln: case FieldMDEnums.eDTyp.Bln: lvi = buf.GetLayerInt(1); //Java if ( lvi == null || lvi.equals(Integer.MIN_VALUE) || lvi.equals(Integer.MAX_VALUE) ) lvi = null; //C$ if (lvi == null || lvi == int.MinValue || lvi == int.MaxValue) { lvi = null; } lvbln = null; if (lvi != null) { lvbln = (lvi != 0); } inputRow_orig[jj] = lvbln; if (aInputRecordSetMD.Column[jj].hasMapKey()) { inputRow.put(aInputRecordSetMD.Column[jj].MapKey, lvbln); } break; //case Byt: case FieldMDEnums.eDTyp.Byt: default: throw new com.WDataSci.WDS.WDSException("Error, column type not implemented"); } } aInputRecordSet.Records.add(inputRow); aInputRecordSet.Records_Orig.add(inputRow_orig); } } catch (Exception e) { throw new com.WDataSci.WDS.WDSException("Error reading from DBB, row " + ri + ":", e); } }
public void mReadMap(RecordSetMD aRecordSetMD, JniPMMLItem aJniPMML, PrintWriter pw, Boolean bFillDictionaryNames) //throws com.WDataSci.WDS.WDSException { try { int i = -1; int ii = -1; int j = -1; int jj = -1; int k = -1; int kk = -1; //Java Boolean bUsingPMML = (aJniPMML != null && aJniPMML.PMMLMatter.Doc != null); //C# Boolean bUsingPMML = false; String[] lFieldStringNames = null; int nDataFieldNames = 0; if (bUsingPMML) { lFieldStringNames = aJniPMML.PMMLDataFieldStringNames(); nDataFieldNames = lFieldStringNames.Length; } if (pw != null) { pw.printf("In RecordSetMD constructor\n"); } if (pw != null) { pw.flush(); } //point to file or memory DBB buffer = this.Header.Buffer; buffer.position(0, 0, 0); try { //get compound dataset information long nColumns = buffer.nRecords; long nBlockMaxStringByteLength = this.Header.MaxStringByteLength; int nBlockCoreColumnSize = (int)(buffer.nRecordFLenBytes); int nBlockAllocatedSize = (int)(buffer.nDBBRequiredBytes); if (nBlockAllocatedSize > this.Header.Buffer.Length) { throw new com.WDataSci.WDS.WDSException("Error, HeaderBuffer capacity, " + this.Header.Buffer.Length + ", is less then what should be BlockAllocatedSize, " + nBlockAllocatedSize ); } int nBlockCoreSize = (int)(buffer.nDBBLeadingBytes + buffer.nDBBFLenBytes); if (pw != null) { pw.printf("In RecordSetMD constructor, nColumns=%d\n", nColumns); } if (pw != null) { pw.flush(); } byte[] namebuffer = new byte[(int)(nBlockMaxStringByteLength)]; //iterate through columns (dataset members) aRecordSetMD.Column = new FieldMD[(int)(nColumns)]; int bptr = 0; for (ii = 0; ii < nColumns; ii++, bptr += (int)nBlockCoreColumnSize) { buffer.position(buffer.ptr, bptr, buffer.vlenptr); aRecordSetMD.Column[ii] = new FieldMD(); FieldMD col = aRecordSetMD.Column[ii]; //the first two fields are always names and taken to be variable length col.Name = buffer.GetLayerVLenString(1, nBlockMaxStringByteLength); //Check for PMML DataFieldName map //If not mapped externally, the next VLenString pointer will be 0 and will come back as empty String tmpname = buffer.GetLayerVLenString(1, nBlockMaxStringByteLength); //Search for PMML DataFieldName map, take input supplied map first, then the usual search /* Java >>> * * Boolean found = false; * if ( bUsingPMML && tmpname.length() > 0 ) { * for (j = 0; !found && j < nDataFieldNames; j++) { * if ( tmpname.equals(lFieldStringNames[j]) ) { * col.MapToMapKey(lFieldStringNames[j]); * found = true; * break; * } * } * } * if ( bUsingPMML && !found ) { * for (j = 0; !found && j < nDataFieldNames; j++) { * if ( col.Name.equals(lFieldStringNames[j]) ) { * col.MapToMapKey(lFieldNames[j]); * found = true; * break; * } * } * } * /* <<< Java */ if (!bUsingPMML && bFillDictionaryNames) { col.MapToMapKey(col.Name); } //Java col.DTyp = FieldMDEnums.eDTyp.FromInt(buffer.GetLayerInt(1)); //C# col.DTyp = FieldMDExt.eDTyp_FromInt((int)buffer.GetLayerInt(1)); //See notes above on Date and DateTime types //Since the header block is being passed in, Date and DateTime types are provided. col.ByteMemLength = (long)buffer.GetLayerLong(1); col.ByteMaxLength = (long)buffer.GetLayerLong(1); if (col.DTyp.bIn(FieldMDEnums.eDTyp.VLS, FieldMDEnums.eDTyp.Str)) { col.StringMaxLength = (int)(col.ByteMaxLength / 2); } //no longer using the last byte for bIsMappedToPMMLFieldName, so there is filler space at the end } } catch (Exception e) { throw new com.WDataSci.WDS.WDSException("Error in RecordSetMD processing of Header DBB:", e); } if (pw != null) { pw.printf("leaving RecordSetMD constructor\n"); } if (pw != null) { pw.flush(); } } catch (Exception e) { throw new com.WDataSci.WDS.WDSException("Error in ProcessInputMapFor", e); } }