Exemplo n.º 1
0
  public void testVariantTwoJoin() {
    String stmtText =
        "insert into Event_1 "
            + "select intPrimitive - intBoxed as delta, intPrimitive * intBoxed as product "
            + "from "
            + SupportBean.class.getName()
            + ".win:length(100) as s0,"
            + SupportBean_A.class.getName()
            + ".win:length(100) as s1 "
            + " where s0.theString = s1.id";

    runAsserts(stmtText, null);

    // assert type metadata
    EventTypeSPI type =
        (EventTypeSPI)
            ((EPServiceProviderSPI) epService)
                .getEventAdapterService()
                .getExistsTypeByName("Event_1");
    assertEquals(null, type.getMetadata().getOptionalApplicationType());
    assertEquals(null, type.getMetadata().getOptionalSecondaryNames());
    assertEquals("Event_1", type.getMetadata().getPrimaryName());
    assertEquals("Event_1", type.getMetadata().getPublicName());
    assertEquals("Event_1", type.getName());
    assertEquals(EventTypeMetadata.TypeClass.STREAM, type.getMetadata().getTypeClass());
    assertEquals(false, type.getMetadata().isApplicationConfigured());
    assertEquals(false, type.getMetadata().isApplicationPreConfigured());
    assertEquals(false, type.getMetadata().isApplicationPreConfiguredStatic());
  }
Exemplo n.º 2
0
  public void setUp() {
    Configuration config = SupportConfigFactory.getConfiguration();
    ConfigurationVariantStream variant = new ConfigurationVariantStream();
    variant.setTypeVariance(ConfigurationVariantStream.TypeVariance.ANY);
    config.addVariantStream("MyVariantStream", variant);
    assertTrue(config.isVariantStreamExists("MyVariantStream"));

    epService = EPServiceProviderManager.getDefaultProvider(config);
    epService.initialize();
    listener = new SupportUpdateListener();

    // assert type metadata
    EventTypeSPI type =
        (EventTypeSPI)
            ((EPServiceProviderSPI) epService)
                .getValueAddEventService()
                .getValueAddProcessor("MyVariantStream")
                .getValueAddEventType();
    assertEquals(null, type.getMetadata().getOptionalApplicationType());
    assertEquals(null, type.getMetadata().getOptionalSecondaryNames());
    assertEquals("MyVariantStream", type.getMetadata().getPrimaryName());
    assertEquals("MyVariantStream", type.getMetadata().getPublicName());
    assertEquals("MyVariantStream", type.getName());
    assertEquals(EventTypeMetadata.TypeClass.VARIANT, type.getMetadata().getTypeClass());
    assertEquals(true, type.getMetadata().isApplicationConfigured());
    assertEquals(true, type.getMetadata().isApplicationPreConfigured());
    assertEquals(true, type.getMetadata().isApplicationPreConfiguredStatic());

    EventType[] valueAddTypes =
        ((EPServiceProviderSPI) epService).getValueAddEventService().getValueAddedTypes();
    assertEquals(1, valueAddTypes.length);
    assertSame(type, valueAddTypes[0]);

    assertEquals(0, type.getPropertyNames().length);
    assertEquals(0, type.getPropertyDescriptors().length);
  }
  private NamedWindowOnMergeActionIns setupInsert(
      String namedWindowName,
      InternalEventRouter internalEventRouter,
      EventTypeSPI eventTypeNamedWindow,
      int selectClauseNumber,
      OnTriggerMergeActionInsert desc,
      EventType triggeringEventType,
      String triggeringStreamName,
      StatementContext statementContext)
      throws ExprValidationException {

    // Compile insert-into info
    String streamName =
        desc.getOptionalStreamName() != null
            ? desc.getOptionalStreamName()
            : eventTypeNamedWindow.getName();
    InsertIntoDesc insertIntoDesc = InsertIntoDesc.fromColumns(streamName, desc.getColumns());

    // rewrite any wildcards to use "stream.wildcard"
    if (triggeringStreamName == null) {
      triggeringStreamName = UuidGenerator.generate();
    }
    List<SelectClauseElementCompiled> selectNoWildcard =
        compileSelectNoWildcard(triggeringStreamName, desc.getSelectClauseCompiled());

    // Set up event types for select-clause evaluation: The first type does not contain anything as
    // its the named window row which is not present for insert
    EventType dummyTypeNoProperties =
        new MapEventType(
            EventTypeMetadata.createAnonymous("merge_named_window_insert"),
            "merge_named_window_insert",
            0,
            null,
            Collections.<String, Object>emptyMap(),
            null,
            null,
            null);
    EventType[] eventTypes = new EventType[] {dummyTypeNoProperties, triggeringEventType};
    String[] streamNames = new String[] {UuidGenerator.generate(), triggeringStreamName};
    StreamTypeService streamTypeService =
        new StreamTypeServiceImpl(
            eventTypes, streamNames, new boolean[1], statementContext.getEngineURI(), false);

    // Get select expr processor
    SelectExprEventTypeRegistry selectExprEventTypeRegistry =
        new SelectExprEventTypeRegistry(
            statementContext.getStatementName(), statementContext.getStatementEventTypeRef());
    ExprEvaluatorContextStatement exprEvaluatorContext =
        new ExprEvaluatorContextStatement(statementContext, false);
    SelectExprProcessor insertHelper =
        SelectExprProcessorFactory.getProcessor(
            Collections.singleton(selectClauseNumber),
            selectNoWildcard.toArray(new SelectClauseElementCompiled[selectNoWildcard.size()]),
            false,
            insertIntoDesc,
            null,
            null,
            streamTypeService,
            statementContext.getEventAdapterService(),
            statementContext.getStatementResultService(),
            statementContext.getValueAddEventService(),
            selectExprEventTypeRegistry,
            statementContext.getMethodResolutionService(),
            exprEvaluatorContext,
            statementContext.getVariableService(),
            statementContext.getTableService(),
            statementContext.getTimeProvider(),
            statementContext.getEngineURI(),
            statementContext.getStatementId(),
            statementContext.getStatementName(),
            statementContext.getAnnotations(),
            statementContext.getContextDescriptor(),
            statementContext.getConfigSnapshot(),
            null,
            statementContext.getNamedWindowService(),
            null);
    ExprEvaluator filterEval =
        desc.getOptionalWhereClause() == null
            ? null
            : desc.getOptionalWhereClause().getExprEvaluator();

    InternalEventRouter routerToUser =
        streamName.equals(namedWindowName) ? null : internalEventRouter;
    boolean audit = AuditEnum.INSERT.getAudit(statementContext.getAnnotations()) != null;

    String insertIntoTableName = null;
    if (statementContext.getTableService().getTableMetadata(insertIntoDesc.getEventTypeName())
        != null) {
      insertIntoTableName = insertIntoDesc.getEventTypeName();
    }

    return new NamedWindowOnMergeActionIns(
        filterEval,
        insertHelper,
        routerToUser,
        insertIntoTableName,
        statementContext.getTableService(),
        statementContext.getEpStatementHandle(),
        statementContext.getInternalEventEngineRouteDest(),
        audit);
  }
Exemplo n.º 4
0
  public void setUp() {
    Configuration config = SupportConfigFactory.getConfiguration();

    config.addEventType("SupportBean", SupportBean.class);
    config.addEventType("FullEvent", SupportRevisionFull.class);
    config.addEventType("D1", SupportDeltaOne.class);
    config.addEventType("D2", SupportDeltaTwo.class);
    config.addEventType("D3", SupportDeltaThree.class);
    config.addEventType("D4", SupportDeltaFour.class);
    config.addEventType("D5", SupportDeltaFive.class);

    ConfigurationRevisionEventType configRev = new ConfigurationRevisionEventType();
    configRev.setKeyPropertyNames(new String[] {"k0"});
    configRev.addNameBaseEventType("FullEvent");
    configRev.addNameDeltaEventType("D1");
    configRev.addNameDeltaEventType("D2");
    configRev.addNameDeltaEventType("D3");
    configRev.addNameDeltaEventType("D4");
    configRev.addNameDeltaEventType("D5");
    config.addRevisionEventType("RevisableQuote", configRev);

    epService = EPServiceProviderManager.getDefaultProvider(config);
    epService.initialize();
    listenerOne = new SupportUpdateListener();
    listenerTwo = new SupportUpdateListener();
    listenerThree = new SupportUpdateListener();

    stmtCreateWin =
        epService
            .getEPAdministrator()
            .createEPL("create window RevQuote.win:keepall() as select * from RevisableQuote");
    epService.getEPAdministrator().createEPL("insert into RevQuote select * from FullEvent");
    epService.getEPAdministrator().createEPL("insert into RevQuote select * from D1");
    epService.getEPAdministrator().createEPL("insert into RevQuote select * from D2");
    epService.getEPAdministrator().createEPL("insert into RevQuote select * from D3");
    epService.getEPAdministrator().createEPL("insert into RevQuote select * from D4");
    epService.getEPAdministrator().createEPL("insert into RevQuote select * from D5");

    // assert type metadata
    EventTypeSPI type =
        (EventTypeSPI)
            ((EPServiceProviderSPI) epService)
                .getValueAddEventService()
                .getValueAddProcessor("RevQuote")
                .getValueAddEventType();
    assertEquals(null, type.getMetadata().getOptionalApplicationType());
    assertEquals(null, type.getMetadata().getOptionalSecondaryNames());
    assertEquals("RevisableQuote", type.getMetadata().getPrimaryName());
    assertEquals("RevisableQuote", type.getMetadata().getPublicName());
    assertEquals("RevisableQuote", type.getName());
    assertEquals(EventTypeMetadata.TypeClass.REVISION, type.getMetadata().getTypeClass());
    assertEquals(true, type.getMetadata().isApplicationConfigured());
    assertEquals(true, type.getMetadata().isApplicationPreConfigured());
    assertEquals(true, type.getMetadata().isApplicationPreConfiguredStatic());

    EventType[] valueAddTypes =
        ((EPServiceProviderSPI) epService).getValueAddEventService().getValueAddedTypes();
    assertEquals(1, valueAddTypes.length);
    assertSame(type, valueAddTypes[0]);

    ArrayAssertionUtil.assertEqualsAnyOrder(
        new Object[] {
          new EventPropertyDescriptor("k0", String.class, null, false, false, false, false, false),
          new EventPropertyDescriptor("p0", String.class, null, false, false, false, false, false),
          new EventPropertyDescriptor("p1", String.class, null, false, false, false, false, false),
          new EventPropertyDescriptor("p2", String.class, null, false, false, false, false, false),
          new EventPropertyDescriptor("p3", String.class, null, false, false, false, false, false),
          new EventPropertyDescriptor("p4", String.class, null, false, false, false, false, false),
          new EventPropertyDescriptor("p5", String.class, null, false, false, false, false, false)
        },
        type.getPropertyDescriptors());
  }