NovaBryan/EVE_Dump
Log | Files | 📦 下载最新源码 (.zip) | Refs | README

igsUtil.py (2523B)


      1 #Embedded file name: C:\BuildAgent\work\20d73f1b24eed06e\eve\release\V24.01\carbon\common\script\util\igsUtil.py
      2 import types
      3 import log
      4 MAXEVENTS = 250
      5 IDX_DATETIME = 0
      6 IDX_ITEMID = 1
      7 IDX_ITEMID2 = 2
      8 IDX_INT1 = 3
      9 IDX_INT2 = 4
     10 IDX_INT3 = 5
     11 IDX_CHAR1 = 6
     12 IDX_CHAR2 = 7
     13 IDX_CHAR3 = 8
     14 IDX_FLOAT1 = 9
     15 IDX_FLOAT2 = 10
     16 IDX_FLOAT3 = 11
     17 LISTINDEXDICT = {'infoDate': IDX_DATETIME,
     18  'itemID': IDX_ITEMID,
     19  'itemID2': IDX_ITEMID2,
     20  'int_1': IDX_INT1,
     21  'int_2': IDX_INT2,
     22  'int_3': IDX_INT3,
     23  'char_1': IDX_CHAR1,
     24  'char_2': IDX_CHAR2,
     25  'char_3': IDX_CHAR3,
     26  'float_1': IDX_FLOAT1,
     27  'float_2': IDX_FLOAT2,
     28  'float_3': IDX_FLOAT3}
     29 
     30 def AggregateEvent(eventTypeID, event, storage, aggregatePath, aggregateKeys, valueIx):
     31     prevPath = None
     32     prevKey = None
     33     for key in aggregateKeys:
     34         prevPath = aggregatePath
     35         if event[key] not in aggregatePath:
     36             aggregatePath[event[key]] = {}
     37         aggregatePath = aggregatePath[event[key]]
     38         prevKey = event[key]
     39 
     40     if not len(aggregatePath):
     41         log.LogInfo('IGS has no record for the current aggregate event. IGS will create a new record for aggregation.')
     42         prevPath[prevKey] = event
     43         storage[eventTypeID].append(prevPath[prevKey])
     44     else:
     45         log.LogInfo('IGS already has a record for the current aggregate event. IGS will aggregate on non grouping columns.')
     46         for ix in valueIx.difference([IDX_DATETIME]):
     47             if type(event[ix]) == types.IntType:
     48                 log.LogInfo('IGS Treating aggregate event parameter at idx=', ix, 'as an Integer')
     49                 if prevPath[prevKey][ix] + event[ix] <= const.maxInt:
     50                     prevPath[prevKey][ix] += event[ix]
     51                 else:
     52                     log.LogException('Integer Overflow error on event! Event discarded: Consider using float!')
     53             elif type(event[ix]) == types.LongType:
     54                 log.LogInfo('IGS Treating aggregate event parameter at idx=', ix, 'as Bigint')
     55                 if prevPath[prevKey][ix] + event[ix] <= const.maxBigint:
     56                     prevPath[prevKey][ix] += event[ix]
     57                 else:
     58                     log.LogException('Integer Overflow error on event! Event discared: Consider using float!')
     59             elif type(event[ix]) == types.FloatType:
     60                 log.LogInfo('IGS Treating aggregate event parameter at idx=', ix, 'as an Float')
     61                 prevPath[prevKey][ix] += event[ix]
     62             elif ix > 0:
     63                 log.LogException('IGS received data of unhandled datatype!')