Esempio n. 1
0
 /**
  * Creates the event type for this view
  *
  * @param statementContext is the event adapter service
  * @return event type for view
  */
 public static EventType createEventType(
     StatementContext statementContext, StatViewAdditionalProps additionalProps) {
   Map<String, Object> schemaMap = new HashMap<String, Object>();
   schemaMap.put(ViewFieldEnum.SIZE_VIEW__SIZE.getName(), long.class);
   StatViewAdditionalProps.addCheckDupProperties(
       schemaMap, additionalProps, ViewFieldEnum.SIZE_VIEW__SIZE);
   return statementContext.getEventAdapterService().createAnonymousMapType(schemaMap);
 }
Esempio n. 2
0
  public final void update(EventBean[] newData, EventBean[] oldData) {
    long priorSize = size;

    // add data points to the window
    if (newData != null) {
      size += newData.length;

      if ((additionalProps != null) && (newData.length != 0)) {
        if (lastValuesEventNew == null) {
          lastValuesEventNew = new Object[additionalProps.getAdditionalExpr().length];
        }
        for (int val = 0; val < additionalProps.getAdditionalExpr().length; val++) {
          lastValuesEventNew[val] =
              additionalProps.getAdditionalExpr()[val].evaluate(
                  new EventBean[] {newData[newData.length - 1]}, true, statementContext);
        }
      }
    }

    if (oldData != null) {
      size -= oldData.length;
    }

    // If there are child views, fireStatementStopped update method
    if ((this.hasViews()) && (priorSize != size)) {
      Map<String, Object> postNewData = new HashMap<String, Object>();
      postNewData.put(ViewFieldEnum.SIZE_VIEW__SIZE.getName(), size);
      addProperties(postNewData);
      EventBean newEvent =
          statementContext.getEventAdapterService().adaptorForTypedMap(postNewData, eventType);

      if (lastSizeEvent != null) {
        updateChildren(new EventBean[] {newEvent}, new EventBean[] {lastSizeEvent});
      } else {
        Map<String, Object> postOldData = new HashMap<String, Object>();
        postOldData.put(ViewFieldEnum.SIZE_VIEW__SIZE.getName(), priorSize);
        EventBean oldEvent =
            statementContext.getEventAdapterService().adaptorForTypedMap(postOldData, eventType);

        updateChildren(new EventBean[] {newEvent}, new EventBean[] {oldEvent});
      }

      lastSizeEvent = newEvent;
    }
  }
Esempio n. 3
0
 public void attach(
     EventType parentEventType,
     StatementContext statementContext,
     ViewFactory optionalParentFactory,
     List<ViewFactory> parentViewFactories)
     throws ViewParameterException {
   ExprNode[] validated =
       ViewFactorySupport.validate(
           getViewName(), parentEventType, statementContext, viewParameters, true);
   additionalProps = StatViewAdditionalProps.make(validated, 0, parentEventType);
   eventType = SizeView.createEventType(statementContext, additionalProps, streamNumber);
 }
Esempio n. 4
0
 private void addProperties(Map<String, Object> newDataMap) {
   if (additionalProps == null) {
     return;
   }
   additionalProps.addProperties(newDataMap, lastValuesEventNew);
 }