(self, events, session_num, start_events)
Iterate over the event stream, checking the event ID to find the
        type of event. Add session ID attribute to the start / end events. Add
        a view for each session.

        Args:
            events: The event stream to process.
            session_num: The number of sessions created so far.
            start_events: A dictionary representing the current start events -
                with the keys as login IDs, and values as the corresponding
                session IDs.

        Returns:
            Tuple containing the timestamp of the last start event, the number
            of sessions created so far, a dictionary representing the current
            start events, and whether all events have been processed.
Iterate over the event stream, checking the event ID to find the
        type of event. Add session ID attribute to the start / end events. Add
        a view for each session.
Iterate over the event stream checking the event ID to find the type of event . Add session ID attribute to the start / end events . Add a view for each session .
def processSessions(self, events, session_num, start_events):
        """Iterate over the event stream, checking the event ID to find the
        type of event. Add session ID attribute to the start / end events. Add
        a view for each session.

        Args:
            events: The event stream to process.
            session_num: The number of sessions created so far.
            start_events: A dictionary representing the current start events -
                with the keys as login IDs, and values as the corresponding
                session IDs.

        Returns:
            Tuple containing the timestamp of the last start event, the number
            of sessions created so far, a dictionary representing the current
            start events, and whether all events have been processed.
        """
        try:
            start_time = 0
            prev_record_ids = []

            for event in events:
                curr_record_id = event.source.get('record_number')
                if (curr_record_id is not None and curr_record_id in
                        prev_record_ids):
                    #skip if duplicate event
                    continue
                prev_record_ids.append(curr_record_id)
                prev_record_ids = prev_record_ids[(EVENT_HISTORY_LENGTH * -1):]

                event_id = event.source.get('event_identifier')
                start_time = event.source.get('timestamp')

                if event_id in self.start_events:
                    logon_id = self.getLogonId(event, event_id)
                    session_id = self.getSessionId(event, session_num)
                    self.annotateEvent(event, [session_id])
                    start_events[logon_id] = session_id

                    view_query = 'session_id.{0:s}:"{1:s}"'.format(
                        self.session_type, session_id)
                    self.sketch.add_view(
                        session_id, self.NAME, query_string=view_query)
                    session_num += 1

                elif event_id in self.end_events:
                    logon_id = self.getLogonId(event, event_id)
                    session_id = start_events.get(logon_id)
                    if session_id:
                        self.annotateEvent(event, [session_id])
                        del start_events[logon_id]

                elif start_events:
                    # startup event clears current sessions
                    self.annotateEvent(event, start_events.values())
                    start_events = {}

            return (start_time, session_num, start_events, True)

        except (opensearchpy.exceptions.NotFoundError,
                opensearchpy.exceptions.ConnectionTimeout) as _:
            return (start_time, session_num, start_events, False)
def processSessions ( self , events , session_num , start_events ) : try : start_time = 0 prev_record_ids = [ ] for event in events : curr_record_id = event . source . get ( 'record_number' ) if ( curr_record_id is not None and curr_record_id in prev_record_ids ) : #skip if duplicate event continue prev_record_ids . append ( curr_record_id ) prev_record_ids = prev_record_ids [ ( EVENT_HISTORY_LENGTH * - 1 ) : ] event_id = event . source . get ( 'event_identifier' ) start_time = event . source . get ( 'timestamp' ) if event_id in self . start_events : logon_id = self . getLogonId ( event , event_id ) session_id = self . getSessionId ( event , session_num ) self . annotateEvent ( event , [ session_id ] ) start_events [ logon_id ] = session_id view_query = 'session_id.{0:s}:"{1:s}"' . format ( self . session_type , session_id ) self . sketch . add_view ( session_id , self . NAME , query_string = view_query ) session_num += 1 elif event_id in self . end_events : logon_id = self . getLogonId ( event , event_id ) session_id = start_events . get ( logon_id ) if session_id : self . annotateEvent ( event , [ session_id ] ) del start_events [ logon_id ] elif start_events : # startup event clears current sessions self . annotateEvent ( event , start_events . values ( ) ) start_events = { } return ( start_time , session_num , start_events , True ) except ( opensearchpy . exceptions . NotFoundError , opensearchpy . exceptions . ConnectionTimeout ) as _ : return ( start_time , session_num , start_events , False )