/// <summary> /// Fetches the index of the recordset. /// </summary> /// <param name="part">The part.</param> /// <param name="entry">The entry.</param> /// <param name="isFramed"></param> /// <returns></returns> public int FetchRecordsetIndex(IIntellisenseResult part, IBinaryDataListEntry entry, bool isFramed) { // figure out the index type ;) enRecordsetIndexType idxType = DataListUtil.GetRecordsetIndexTypeRaw(part.Option.RecordsetIndex); int result = 1; if (idxType == enRecordsetIndexType.Numeric) { // fix index insert ;) if (!Int32.TryParse(part.Option.RecordsetIndex, out result)) { result = -1; } } else if (idxType == enRecordsetIndexType.Blank) { // append mode if (!_recordsetAppendIndexs.TryGetValue(part.Option.Recordset, out result)) { if (entry != null) { result = entry.FetchAppendRecordsetIndex(); _recordsetAppendIndexs[part.Option.Recordset] = result; // stash in cache } } // Assign behavior ;) if (!isFramed) { // duplicate match ;) if (nonFramedTokens.Contains(part)) { // reset the framing ;) nonFramedTokens.Clear(); nonFramedTokens.Add(part); // inc this index ;) _recordsetAppendIndexs[part.Option.Recordset]++; result++; } else { // current append indexes are alright ;) nonFramedTokens.Add(part); } } } else if (idxType == enRecordsetIndexType.Star) { // overwrite mode from idx 1 if (!_recordsetOverwriteIndexs.TryGetValue(part.Option.Recordset, out result)) { result = 1; _recordsetOverwriteIndexs[part.Option.Recordset] = result; } } return(result); }
public void DataListUtil_GetRecordsetIndexTypeRaw_StarNotationDoesNotParseInt() { //------------Setup for test-------------------------- const string startingData = "**"; //------------Execute Test--------------------------- Assert.AreEqual(enRecordsetIndexType.Error, DataListUtil.GetRecordsetIndexTypeRaw(startingData)); }
public void DataListUtil_GetRecordsetIndexTypeRaw_IntParsesInt() { //------------Setup for test-------------------------- const string startingData = "1"; //------------Execute Test--------------------------- Assert.AreEqual(enRecordsetIndexType.Numeric, DataListUtil.GetRecordsetIndexTypeRaw(startingData)); }
// 2 seconds for 10k entries with 75 columns ;) public void FlushIterations(PayloadIterationFrame <string> scopedFrame, bool isFramed, bool isTerminalFlush) { string error; Dev2TokenConverter tc = new Dev2TokenConverter(); bool amendedData = false; // We do not care about data language in these cases, skip all the junk and get it done son ;) while (scopedFrame.HasData()) { DataListPayloadFrameTO <string> tmp = scopedFrame.FetchNextFrameItem(); string exp = tmp.Expression; //.Replace("(*)", "()"); // force conversion ;) string val = tmp.Value; // correction, we now need to support recursive evaluation ;( if (!DataListUtil.IsRootVariable(exp)) { ErrorResultTO errors; var tmpToken = _c.Evaluate(_bdl.UID, enActionType.User, exp, true, out errors); if (errors.HasErrors()) { throw new Exception(errors.MakeDisplayReady()); } var scalar = tmpToken.FetchScalar(); if (scalar == null) { // ReSharper disable RedundantAssignment exp = null; // ReSharper restore RedundantAssignment } exp = tmpToken.FetchScalar().TheValue; } IIntellisenseResult token = tc.ParseTokenForMatch(exp, _bdl.FetchIntellisenseParts()); if (token != null) { // Get rs and field string rs = token.Option.Recordset; string field = token.Option.Field; string idx = token.Option.RecordsetIndex; if (rs != _lastRs && !string.IsNullOrEmpty(rs)) { // Flush any existing row data for a different recordset ;) if (_rowData != null) { if (!token.Option.IsScalar) { DumpColAtATime(); } amendedData = false; } _bdl.TryGetEntry(rs, out _entry, out error); if (error != string.Empty || _entry == null) { throw new Exception("Upsert Exception : " + error); } // stash last rs _lastRs = rs; // build new row data int cnt = _entry.Columns.Count; _rowData = new List <IBinaryDataListItem>(cnt); InitRowBuffer(cnt); } if (!token.Option.IsScalar) { // set commit flag ;) amendedData = true; int colIdx = _entry.InternalFetchColumnIndex(field); IBinaryDataListItem itm = _rowData[colIdx]; enRecordsetIndexType idxType = DataListUtil.GetRecordsetIndexTypeRaw(idx); int tmpIdx = _dris.FetchRecordsetIndex(token, _entry, isFramed); if (tmpIdx != _upsertIdx) { // silly users making algorithms slow ;( // we need to dump data at this point... 1 fliping column at a time DumpColAtATime(); } _upsertIdx = tmpIdx; if (_upsertIdx == 0) { throw new Exception("Invalid recordset index of 0"); } // if numeric fetch the index if (idxType == enRecordsetIndexType.Numeric) { Int32.TryParse(idx, out _upsertIdx); } itm.UpdateIndex(_upsertIdx); itm.UpdateField(field); itm.UpdateValue(val); if (_rowData == null) { throw new Exception("Invalid Bulk Load Data"); } _rowData[colIdx] = itm; } else { IBinaryDataListItem itm = DataListConstants.baseItem.Clone(); // else scalar and we need to get the entry ;( IBinaryDataListEntry scalarEntry; _bdl.TryGetEntry(field, out scalarEntry, out error); itm.UpdateField(field); itm.UpdateValue(val); scalarEntry.TryPutScalar(itm, out error); if (error != string.Empty) { throw new Exception(error); } } } else { throw new Exception("Null token for [ " + exp + " ]"); } } // flush the rowData out ;) if (_entry != null && _entry.IsRecordset && amendedData) { _entry.TryPutRecordRowAt(_rowData, _upsertIdx, out error); if (error != string.Empty) { throw new Exception(error); } _dris.MoveIndexesToNextPosition(); } if (isTerminalFlush) { ErrorResultTO errors; _c.PushBinaryDataListInServerScope(_liveFlushingLocation, _bdl, out errors); } // clear out the buffer ClearRowBuffer(); }