当前位置: 首页>>代码示例>>Java>>正文


Java EventBean.get方法代码示例

本文整理汇总了Java中com.espertech.esper.client.EventBean.get方法的典型用法代码示例。如果您正苦于以下问题:Java EventBean.get方法的具体用法?Java EventBean.get怎么用?Java EventBean.get使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.espertech.esper.client.EventBean的用法示例。


在下文中一共展示了EventBean.get方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getProperties

import com.espertech.esper.client.EventBean; //导入方法依赖的package包/类
private String getProperties(EventBean theEvent) {
    StringBuilder buf = new StringBuilder();

    for (String name : theEvent.getEventType().getPropertyNames()) {
        Object value = theEvent.get(name);
        buf.append(name);
        buf.append("=");

        if (name.contains("timestamp")) {
            buf.append(new Date((Long) value));
        } else {
            buf.append(value);
        }
        buf.append(" ");
    }
    return buf.toString();
}
 
开发者ID:espertechinc,项目名称:esper,代码行数:18,代码来源:OHLCUpdateListener.java

示例2: run

import com.espertech.esper.client.EventBean; //导入方法依赖的package包/类
public void run() {
    log.info("Started event send for read");

    try {
        String[] fields = "c0,c1,c2,c3,c4,c5".split(",");
        Object[] expected = new Object[]{1, 1, 1, 1, 1, 1};
        while (!shutdown) {
            epService.getEPRuntime().sendEvent(new SupportBean_S0(0));
            EventBean event = listener.assertOneGetNewAndReset();
            if (event.get("c0") == null) {
                notFoundCount++;
            } else {
                foundCount++;
                EPAssertionUtil.assertProps(event, fields, expected);
            }
            numQueries++;
        }
    } catch (RuntimeException ex) {
        log.error("Exception encountered: " + ex.getMessage(), ex);
        exception = ex;
    }

    log.info("Completed event send for read");
}
 
开发者ID:espertechinc,项目名称:esper,代码行数:25,代码来源:ExecTableMTAccessReadMergeWriteInsertDeleteRowVisible.java

示例3: tryAssertionTypableNewOperatorDocSample

import com.espertech.esper.client.EventBean; //导入方法依赖的package包/类
private void tryAssertionTypableNewOperatorDocSample(EPServiceProvider epService, String typeType) {
    epService.getEPAdministrator().createEPL("create " + typeType + " schema Item(name string, price double)");
    epService.getEPAdministrator().createEPL("create " + typeType + " schema PurchaseOrder(orderId string, items Item[])");
    epService.getEPAdministrator().createEPL("create schema TriggerEvent()");
    EPStatement stmt = epService.getEPAdministrator().createEPL("insert into PurchaseOrder select '001' as orderId, new {name= 'i1', price=10} as items from TriggerEvent");
    SupportUpdateListener listener = new SupportUpdateListener();
    stmt.addListener(listener);

    epService.getEPRuntime().sendEvent(Collections.emptyMap(), "TriggerEvent");
    EventBean event = listener.assertOneGetNewAndReset();
    EPAssertionUtil.assertProps(event, "orderId,items[0].name,items[0].price".split(","), new Object[]{"001", "i1", 10d});
    EventBean[] underlying = (EventBean[]) event.get("items");
    assertEquals(1, underlying.length);
    assertEquals("i1", underlying[0].get("name"));
    assertEquals(10d, underlying[0].get("price"));

    epService.getEPAdministrator().destroyAllStatements();
    epService.getEPAdministrator().getConfiguration().removeEventType("Item", true);
    epService.getEPAdministrator().getConfiguration().removeEventType("PurchaseOrder", true);
}
 
开发者ID:espertechinc,项目名称:esper,代码行数:21,代码来源:ExecInsertIntoPopulateEventTypeColumn.java

示例4: fetchMapEventBean

import com.espertech.esper.client.EventBean; //导入方法依赖的package包/类
public static Map fetchMapEventBean(EventBean eventBean, String propOne, String propTwo) {
    String theString = (String) eventBean.get(propOne);
    int id = (Integer) eventBean.get(propTwo);

    if (id < 0) {
        return null;
    }

    Map<String, Object> values = new HashMap<String, Object>();
    if (id == 0) {
        return values;
    }

    values.put("mapstring", "|" + theString + "|");
    values.put("mapint", id + 1);
    return values;
}
 
开发者ID:espertechinc,项目名称:esper,代码行数:18,代码来源:SupportStaticMethodLib.java

示例5: handleGetAllEventsProperty

import com.espertech.esper.client.EventBean; //导入方法依赖的package包/类
protected List<Object> handleGetAllEventsProperty(String strategyName, String ruleName, String property) throws Exception {

		EPStatement statement = getServiceProvider(strategyName).getEPAdministrator().getStatement(ruleName);
		List<Object> list = new ArrayList<Object>();
		if (statement != null && statement.isStarted()) {
			SafeIterator<EventBean> it = statement.safeIterator();
			try {
				while (it.hasNext()) {
					EventBean bean = it.next();
					Object underlaying = bean.get(property);
					list.add(underlaying);
				}
			} finally {
				it.close();
			}
		}
		return list;
	}
 
开发者ID:curtiszimmerman,项目名称:AlgoTrader,代码行数:19,代码来源:RuleServiceImpl.java

示例6: tryMT

import com.espertech.esper.client.EventBean; //导入方法依赖的package包/类
private void tryMT(EPServiceProvider epService, int numThreads, int numEvents) throws Exception {
    String eplCreateVariable = "create table varagg (theEvents window(*) @type(SupportBean))";
    epService.getEPAdministrator().createEPL(eplCreateVariable);

    Thread[] threads = new Thread[numThreads];
    WriteRunnable[] runnables = new WriteRunnable[numThreads];
    for (int i = 0; i < threads.length; i++) {
        runnables[i] = new WriteRunnable(epService, numEvents, i);
        threads[i] = new Thread(runnables[i]);
        threads[i].start();
    }

    // join
    log.info("Waiting for completion");
    for (int i = 0; i < threads.length; i++) {
        threads[i].join();
        assertNull(runnables[i].getException());
    }

    // verify
    SupportUpdateListener listener = new SupportUpdateListener();
    epService.getEPAdministrator().createEPL("select varagg.theEvents as c0 from SupportBean_S0").addListener(listener);
    epService.getEPRuntime().sendEvent(new SupportBean_S0(0));
    EventBean event = listener.assertOneGetNewAndReset();
    SupportBean[] window = (SupportBean[]) event.get("c0");
    assertEquals(numThreads * 3, window.length);
}
 
开发者ID:espertechinc,项目名称:esper,代码行数:28,代码来源:ExecTableMTUngroupedIntoTableWriteMultiWriterAgg.java

示例7: assertProps

import com.espertech.esper.client.EventBean; //导入方法依赖的package包/类
/**
 * Assert that the property values of a single event match the expected values.
 *
 * @param received      provides events
 * @param propertyNames array of property names
 * @param expected      expected values
 */
public static void assertProps(EventBean received, String[] propertyNames, Object[] expected) {
    if (compareArraySize(expected, propertyNames)) {
        return;
    }

    for (int j = 0; j < expected.length; j++) {
        String name = propertyNames[j].trim();
        Object value = expected[j];
        Object eventProp = received.get(name);
        assertEqualsAllowArray("Failed to assert property '" + name + "'", value, eventProp);
    }
}
 
开发者ID:espertechinc,项目名称:esper,代码行数:20,代码来源:EPAssertionUtil.java

示例8: getNumericFieldValues

import com.espertech.esper.client.EventBean; //导入方法依赖的package包/类
/**
 * This method is used to query field values from a CEP Query. 
 * @param StatementName
 * @param fieldName
 * @return Object[]
 */
public Number[] getNumericFieldValues(String StatementName, String fieldName ) {
	
	Boolean exists = this.checkIfStatementNameExists(StatementName);
	
	if (exists) {
		// Get ArrayList of Event Beans
		ArrayList<EventBean> list = queryStatement(StatementName);
		
		logger.trace("Getting Numeric Values for Statement: " + StatementName +" - Field: " + fieldName);
		
		// Loop over array and add the requested field to the output list
		//ArrayList<Number> resultList = new ArrayList<Number>();
		Number[] resultList = new Number[list.size()];
		
		for (int i = 0; i < list.size(); i++) {
			EventBean event = list.get(i);
			
			resultList[i] = (Number) event.get(fieldName);
		}
		
		//logger.trace("Returning list with " + resultList.length + " objects " + resultList.toString());
		
		// Convert back to an Array!
		return resultList;
	} else {
		return null;
	}

}
 
开发者ID:sgrotz,项目名称:myopentrader,代码行数:36,代码来源:EsperFactory.java

示例9: getScores

import com.espertech.esper.client.EventBean; //导入方法依赖的package包/类
public static Map<String, Integer> getScores(EPServiceProvider engine) {
    EPStatement stmt = engine.getEPAdministrator().getStatement("Score window");
    Map<String, Integer> result = new LinkedHashMap<String, Integer>();
    for (Iterator<EventBean> it = stmt.iterator(); it.hasNext(); ) {
        EventBean next = it.next();
        String playerId = (String) next.get("playerId");
        Integer score = (Integer) next.get("score");
        result.put(playerId, score);
    }
    return result;
}
 
开发者ID:espertechinc,项目名称:esper,代码行数:12,代码来源:TriviaHelper.java

示例10: getDoubleFieldValues

import com.espertech.esper.client.EventBean; //导入方法依赖的package包/类
/**
 * @param StatementName
 * @param fieldName
 * @return
 */
public Double[] getDoubleFieldValues(String StatementName, String fieldName ) {
	
	if (this.checkIfStatementNameExists(StatementName)) {
		// Get ArrayList of Event Beans
		ArrayList<EventBean> list = queryStatement(StatementName);
		
		logger.trace("Getting Numeric Values for Statement: " + StatementName +" - Field: " + fieldName);
		
		// Loop over array and add the requested field to the output list
		//ArrayList<Number> resultList = new ArrayList<Number>();
		Double[] resultList = new Double[list.size()];
		
		for (int i = 0; i < list.size(); i++) {
			EventBean event = list.get(i);
			
			resultList[i] = (Double) event.get(fieldName);
			//System.out.println(resultList[i]);
		}
		
		//logger.trace("Returning list with " + resultList.length + " objects " + resultList.toString());
		return resultList;
	} else {
		return null;
	}
	
}
 
开发者ID:sgrotz,项目名称:myopentrader,代码行数:32,代码来源:EsperFactory.java

示例11: runAssertion2PatternJoinWildcard

import com.espertech.esper.client.EventBean; //导入方法依赖的package包/类
private void runAssertion2PatternJoinWildcard(EPServiceProvider epService) {
    String stmtText = "select * " +
            " from " +
            " pattern [every (es0=" + SupportBean_S0.class.getName() +
            " and es1=" + SupportBean_S1.class.getName() + ")]#length(5) as s0," +
            " pattern [every (es2=" + SupportBean_S2.class.getName() +
            " and es3=" + SupportBean_S3.class.getName() + ")]#length(5) as s1" +
            " where s0.es0.id = s1.es2.id";
    EPStatement statement = epService.getEPAdministrator().createEPL(stmtText);

    SupportUpdateListener updateListener = new SupportUpdateListener();
    statement.addListener(updateListener);

    SupportBean_S0 s0 = sendEventS0(epService, 100, "");
    SupportBean_S1 s1 = sendEventS1(epService, 1, "");
    SupportBean_S2 s2 = sendEventS2(epService, 100, "");
    SupportBean_S3 s3 = sendEventS3(epService, 2, "");

    EventBean theEvent = updateListener.assertOneGetNewAndReset();

    Map<String, EventBean> result = (Map<String, EventBean>) theEvent.get("s0");
    assertSame(s0, result.get("es0").getUnderlying());
    assertSame(s1, result.get("es1").getUnderlying());

    result = (Map<String, EventBean>) theEvent.get("s1");
    assertSame(s2, result.get("es2").getUnderlying());
    assertSame(s3, result.get("es3").getUnderlying());

    statement.destroy();
}
 
开发者ID:espertechinc,项目名称:esper,代码行数:31,代码来源:ExecJoinPatterns.java

示例12: assertWindowAggAndPrev

import com.espertech.esper.client.EventBean; //导入方法依赖的package包/类
private void assertWindowAggAndPrev(SupportUpdateListener listener, Object[][] expected) {
    String[] fields = "theString,intPrimitive,longPrimitive".split(",");
    EventBean event = listener.assertOneGetNewAndReset();
    EPAssertionUtil.assertPropsPerRow((Object[]) event.get("win"), fields, expected);
    for (int i = 0; i < 5; i++) {
        Object prevValue = event.get("prev" + i);
        if (prevValue == null && expected.length <= i) {
            continue;
        }
        EPAssertionUtil.assertProps(prevValue, fields, expected[i]);
    }
}
 
开发者ID:espertechinc,项目名称:esper,代码行数:13,代码来源:ExecViewRank.java

示例13: getDoubleValue

import com.espertech.esper.client.EventBean; //导入方法依赖的package包/类
private double getDoubleValue(ViewFieldEnum field, EventBean theEvent) {
    return (Double) theEvent.get(field.getName());
}
 
开发者ID:espertechinc,项目名称:esper,代码行数:4,代码来源:TestRegressionLinestView.java

示例14: logRate

import com.espertech.esper.client.EventBean; //导入方法依赖的package包/类
private void logRate(EventBean theEvent) {
    String sensorId = (String) theEvent.get("sensorId");
    double numTags = (Double) theEvent.get("numTagsPerSensor");

    log.info("Sensor " + sensorId + " totals " + numTags + " tags");
}
 
开发者ID:espertechinc,项目名称:esper,代码行数:7,代码来源:RFIDTagsPerSensorListener.java

示例15: call

import com.espertech.esper.client.EventBean; //导入方法依赖的package包/类
public Boolean call() throws Exception {
    try {
        SupportMTUpdateListener listener = new SupportMTUpdateListener();
        targetStatement.addListener(listener);

        for (int loop = 0; loop < numRepeats; loop++) {
            String generalKey = "Key";
            int valueExpected = threadNum * 1000000000 + loop + 1;

            // send insert event with string-value NOT specific to thread
            sendEvent(generalKey, valueExpected);

            // send subquery trigger event
            engine.getEPRuntime().sendEvent(new SupportBean(generalKey, -1));

            // assert trigger event received
            List<EventBean[]> events = listener.getNewDataListCopy();
            boolean found = false;
            for (EventBean[] arr : events) {
                for (EventBean item : arr) {
                    List<Integer> value = (List<Integer>) item.get("val");
                    for (Integer valueReceived : value) {
                        if (valueReceived == valueExpected) {
                            found = true;
                            break;
                        }
                    }
                    if (found) {
                        break;
                    }
                }
                if (found) {
                    break;
                }
            }
            listener.reset();

            if (!found) {
                return false;
            }

            // send delete event with string-value specific to thread
            sendEvent(generalKey, valueExpected);
        }
    } catch (Exception ex) {
        log.error("Error in thread " + Thread.currentThread().getId(), ex);
        return false;
    }
    return true;
}
 
开发者ID:espertechinc,项目名称:esper,代码行数:51,代码来源:StmtNamedWindowSubqueryAggCallable.java


注:本文中的com.espertech.esper.client.EventBean.get方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。