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


Java CSVInputAdapter类代码示例

本文整理汇总了Java中com.espertech.esperio.csv.CSVInputAdapter的典型用法代码示例。如果您正苦于以下问题:Java CSVInputAdapter类的具体用法?Java CSVInputAdapter怎么用?Java CSVInputAdapter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: testNotUsingEngineThread

import com.espertech.esperio.csv.CSVInputAdapter; //导入依赖的package包/类
public void testNotUsingEngineThread() {
    coordinator = new AdapterCoordinatorImpl(epService, false);
    coordinator.coordinate(new CSVInputAdapter(epService, noTimestampsNotLooping));
    coordinator.coordinate(new CSVInputAdapter(epService, timestampsNotLooping));

    long startTime = System.currentTimeMillis();
    coordinator.start();
    long endTime = System.currentTimeMillis();

    // The last event should be sent after 500 ms
    assertTrue(endTime - startTime > 500);

    assertEquals(6, listener.getNewDataList().size());
    assertEvent(0, 1, 1.1, "noTimestampOne.one");
    assertEvent(1, 1, 1.1, "timestampOne.one");
    assertEvent(2, 2, 2.2, "noTimestampOne.two");
    assertEvent(3, 3, 3.3, "noTimestampOne.three");
    assertEvent(4, 3, 3.3, "timestampOne.three");
    assertEvent(5, 5, 5.5, "timestampOne.five");
}
 
开发者ID:espertechinc,项目名称:esper,代码行数:21,代码来源:TestAdapterCoordinator.java

示例2: testExternalTimer

import com.espertech.esperio.csv.CSVInputAdapter; //导入依赖的package包/类
public void testExternalTimer() {
    coordinator = new AdapterCoordinatorImpl(epService, false, true, false);
    coordinator.coordinate(new CSVInputAdapter(epService, noTimestampsNotLooping));
    coordinator.coordinate(new CSVInputAdapter(epService, timestampsNotLooping));

    long startTime = System.currentTimeMillis();
    coordinator.start();
    long endTime = System.currentTimeMillis();

    // Check that we haven't been kept waiting
    assertTrue(endTime - startTime < 50);

    assertEquals(6, listener.getNewDataList().size());
    assertEvent(0, 1, 1.1, "noTimestampOne.one");
    assertEvent(1, 1, 1.1, "timestampOne.one");
    assertEvent(2, 2, 2.2, "noTimestampOne.two");
    assertEvent(3, 3, 3.3, "noTimestampOne.three");
    assertEvent(4, 3, 3.3, "timestampOne.three");
    assertEvent(5, 5, 5.5, "timestampOne.five");
}
 
开发者ID:espertechinc,项目名称:esper,代码行数:21,代码来源:TestAdapterCoordinator.java

示例3: testExistingTypeNoOptions

import com.espertech.esperio.csv.CSVInputAdapter; //导入依赖的package包/类
/**
 * Play a CSV file using an existing event type definition (no timestamps).
 * <p>
 * Should not require a timestamp column, should block thread until played in.
 */
public void testExistingTypeNoOptions() {
    epService = EPServiceProviderManager.getProvider("testExistingTypeNoOptions", makeConfig("TypeA", useBean));
    epService.initialize();

    EPStatement stmt = epService.getEPAdministrator().createEPL("select symbol, price, volume from TypeA#length(100)");
    SupportUpdateListener listener = new SupportUpdateListener();
    stmt.addListener(listener);

    (new CSVInputAdapter(epService, new AdapterInputSource(CSV_FILENAME_ONELINE_TRADE), "TypeA")).start();

    assertEquals(1, listener.getNewDataList().size());

    // test graph
    String graph = "create dataflow ReadCSV " +
            "FileSource -> mystream<TypeA> { file: '" + CSV_FILENAME_ONELINE_TRADE + "', hasTitleLine: true, classpathFile: true }" +
            "DefaultSupportCaptureOp(mystream) {}";
    epService.getEPAdministrator().createEPL(graph);

    DefaultSupportCaptureOp<Object> outputOp = new DefaultSupportCaptureOp<Object>();
    EPDataFlowInstance instance = epService.getEPRuntime().getDataFlowRuntime().instantiate("ReadCSV", new EPDataFlowInstantiationOptions().operatorProvider(new DefaultSupportGraphOpProvider(outputOp)));
    instance.run();
    List<List<Object>> received = outputOp.getAndReset();
    Object[] receivedArr = received.get(0).toArray();
    assertEquals(1, receivedArr.length);
}
 
开发者ID:espertechinc,项目名称:esper,代码行数:31,代码来源:TestCSVAdapterUseCases.java

示例4: testEngineThread1000PerSec

import com.espertech.esperio.csv.CSVInputAdapter; //导入依赖的package包/类
/**
 * Play a CSV file using an engine thread
 */
public void testEngineThread1000PerSec() throws Exception {
    epService = EPServiceProviderManager.getProvider("testExistingTypeNoOptions", makeConfig("TypeA"));
    epService.initialize();

    EPStatement stmt = epService.getEPAdministrator().createEPL("select symbol, price, volume from TypeA#length(100)");
    SupportUpdateListener listener = new SupportUpdateListener();
    stmt.addListener(listener);

    CSVInputAdapterSpec spec = new CSVInputAdapterSpec(new AdapterInputSource(CSV_FILENAME_ONELINE_TRADE), "TypeA");
    spec.setEventsPerSec(1000);
    spec.setUsingEngineThread(true);

    InputAdapter inputAdapter = new CSVInputAdapter(epService, spec);
    inputAdapter.start();
    Thread.sleep(1000);

    assertEquals(1, listener.getNewDataList().size());
}
 
开发者ID:espertechinc,项目名称:esper,代码行数:22,代码来源:TestCSVAdapterUseCases.java

示例5: testEngineThread1PerSec

import com.espertech.esperio.csv.CSVInputAdapter; //导入依赖的package包/类
/**
 * Play a CSV file using an engine thread.
 */
public void testEngineThread1PerSec() throws Exception {
    epService = EPServiceProviderManager.getProvider("testExistingTypeNoOptions", makeConfig("TypeA"));
    epService.initialize();

    EPStatement stmt = epService.getEPAdministrator().createEPL("select symbol, price, volume from TypeA#length(100)");
    SupportUpdateListener listener = new SupportUpdateListener();
    stmt.addListener(listener);

    CSVInputAdapterSpec spec = new CSVInputAdapterSpec(new AdapterInputSource(CSV_FILENAME_ONELINE_TRADE_MULTIPLE), "TypeA");
    spec.setEventsPerSec(1);
    spec.setUsingEngineThread(true);

    InputAdapter inputAdapter = new CSVInputAdapter(epService, spec);
    inputAdapter.start();

    Thread.sleep(1500);
    assertEquals(1, listener.getNewDataList().size());
    listener.reset();
    Thread.sleep(300);
    assertEquals(0, listener.getNewDataList().size());

    Thread.sleep(2000);
    assertTrue(listener.getNewDataList().size() >= 2);
}
 
开发者ID:espertechinc,项目名称:esper,代码行数:28,代码来源:TestCSVAdapterUseCases.java

示例6: testAppThread

import com.espertech.esperio.csv.CSVInputAdapter; //导入依赖的package包/类
/**
 * Play a CSV file using the application thread
 */
public void testAppThread() throws Exception {
    epService = EPServiceProviderManager.getProvider("testExistingTypeNoOptions", makeConfig("TypeA"));
    epService.initialize();

    EPStatement stmt = epService.getEPAdministrator().createEPL("select symbol, price, volume from TypeA#length(100)");
    SupportUpdateListener listener = new SupportUpdateListener();
    stmt.addListener(listener);

    CSVInputAdapterSpec spec = new CSVInputAdapterSpec(new AdapterInputSource(CSV_FILENAME_ONELINE_TRADE), "TypeA");
    spec.setEventsPerSec(1000);

    InputAdapter inputAdapter = new CSVInputAdapter(epService, spec);
    inputAdapter.start();

    assertEquals(1, listener.getNewDataList().size());
}
 
开发者ID:espertechinc,项目名称:esper,代码行数:20,代码来源:TestCSVAdapterUseCases.java

示例7: testDynamicType

import com.espertech.esperio.csv.CSVInputAdapter; //导入依赖的package包/类
/**
 * Play a CSV file using no existing (dynamic) event type (no timestamp)
 */
public void testDynamicType() {
    CSVInputAdapterSpec spec = new CSVInputAdapterSpec(new AdapterInputSource(CSV_FILENAME_ONELINE_TRADE), "TypeB");

    Configuration config = new Configuration();
    config.getEngineDefaults().getThreading().setInternalTimerEnabled(false);
    epService = EPServiceProviderManager.getDefaultProvider(config);
    epService.initialize();

    InputAdapter feed = new CSVInputAdapter(epService, spec);

    EPStatement stmt = epService.getEPAdministrator().createEPL("select symbol, price, volume from TypeB#length(100)");
    SupportUpdateListener listener = new SupportUpdateListener();
    stmt.addListener(listener);

    assertEquals(String.class, stmt.getEventType().getPropertyType("symbol"));
    assertEquals(String.class, stmt.getEventType().getPropertyType("price"));
    assertEquals(String.class, stmt.getEventType().getPropertyType("volume"));

    feed.start();
    assertEquals(1, listener.getNewDataList().size());
}
 
开发者ID:espertechinc,项目名称:esper,代码行数:25,代码来源:TestCSVAdapterUseCases.java

示例8: testConflictingPropertyOrder

import com.espertech.esperio.csv.CSVInputAdapter; //导入依赖的package包/类
public void testConflictingPropertyOrder() {
    CSVInputAdapterSpec adapterSpec = new CSVInputAdapterSpec(new AdapterInputSource("regression/intsTitleRow.csv"), "intsTitleRowEvent");
    adapterSpec.setEventsPerSec(10);
    adapterSpec.setPropertyOrder(new String[]{"intTwo", "intOne"});
    adapterSpec.setUsingEngineThread(true);
    adapter = new CSVInputAdapter(epService, adapterSpec);

    String statementText = "select * from intsTitleRowEvent#length(5)";
    EPStatement statement = epService.getEPAdministrator().createEPL(statementText);
    statement.addListener(listener);

    adapter.start();

    sendTimeEvent(100);

    assertTrue(listener.getAndClearIsInvoked());
    assertEquals(1, listener.getLastNewData().length);
    assertEquals("1", listener.getLastNewData()[0].get("intTwo"));
    assertEquals("0", listener.getLastNewData()[0].get("intOne"));
}
 
开发者ID:espertechinc,项目名称:esper,代码行数:21,代码来源:TestCSVAdapter.java

示例9: testNoPropertyTypes

import com.espertech.esperio.csv.CSVInputAdapter; //导入依赖的package包/类
public void testNoPropertyTypes() {
    CSVInputAdapterSpec adapterSpec = new CSVInputAdapterSpec(new AdapterInputSource("regression/noTimestampOne.csv"), "allStringEvent");
    adapterSpec.setEventsPerSec(10);
    adapterSpec.setPropertyOrder(new String[]{"myInt", "myDouble", "myString"});
    adapterSpec.setUsingEngineThread(true);
    adapter = new CSVInputAdapter(epService, adapterSpec);

    String statementText = "select * from allStringEvent#length(5)";
    EPStatement statement = epService.getEPAdministrator().createEPL(statementText);
    statement.addListener(listener);

    adapter.start();

    sendTimeEvent(100);
    assertEvent("1", "1.1", "noTimestampOne.one");

    sendTimeEvent(100);
    assertEvent("2", "2.2", "noTimestampOne.two");

    sendTimeEvent(100);
    assertEvent("3", "3.3", "noTimestampOne.three");
}
 
开发者ID:espertechinc,项目名称:esper,代码行数:23,代码来源:TestCSVAdapter.java

示例10: testRuntimePropertyTypes

import com.espertech.esperio.csv.CSVInputAdapter; //导入依赖的package包/类
public void testRuntimePropertyTypes() {
    CSVInputAdapterSpec adapterSpec = new CSVInputAdapterSpec(new AdapterInputSource("regression/noTimestampOne.csv"), "propertyTypeEvent");
    adapterSpec.setEventsPerSec(10);
    adapterSpec.setPropertyOrder(new String[]{"myInt", "myDouble", "myString"});
    adapterSpec.setPropertyTypes(propertyTypes);
    adapterSpec.setUsingEngineThread(true);
    adapter = new CSVInputAdapter(epService, adapterSpec);

    String statementText = "select * from propertyTypeEvent#length(5)";
    EPStatement statement = epService.getEPAdministrator().createEPL(statementText);
    statement.addListener(listener);

    adapter.start();

    sendTimeEvent(100);
    assertEvent(1, 1.1, "noTimestampOne.one");

    sendTimeEvent(100);
    assertEvent(2, 2.2, "noTimestampOne.two");

    sendTimeEvent(100);
    assertEvent(3, 3.3, "noTimestampOne.three");
}
 
开发者ID:espertechinc,项目名称:esper,代码行数:24,代码来源:TestCSVAdapter.java

示例11: testUsingTimespan

import com.espertech.esperio.csv.CSVInputAdapter; //导入依赖的package包/类
public void testUsingTimespan() {
    epService.getEPAdministrator().destroyAllStatements();

    EPStatement stmt = epService.getEPAdministrator().createEPL("select current_timestamp as c0 from pattern[timer:interval(150 milliseconds)]");
    stmt.addListener(listener);

    CSVInputAdapterSpec adapterSpec = new CSVInputAdapterSpec(new AdapterInputSource("regression/timestampOne.csv"), eventTypeName);
    adapterSpec.setUsingTimeSpanEvents(true);
    adapterSpec.setTimestampColumn("timestamp");
    adapterSpec.setPropertyOrder(propertyOrderTimestamps);
    adapterSpec.setUsingExternalTimer(true);
    adapterSpec.setUsingEngineThread(true);
    adapter = new CSVInputAdapter(epService, adapterSpec);
    adapter.start();

    assertEquals(150L, listener.getNewDataListFlattened()[0].get("c0"));
}
 
开发者ID:espertechinc,项目名称:esper,代码行数:18,代码来源:TestCSVAdapter.java

示例12: testAutoTyped

import com.espertech.esperio.csv.CSVInputAdapter; //导入依赖的package包/类
public void testAutoTyped() throws EOFException {
    Configuration config = new Configuration();
    EPServiceProvider epService = EPServiceProviderManager.getDefaultProvider(config);
    CSVInputAdapter adapter = new CSVInputAdapter(
            epService,
            new AdapterInputSource(new StringReader("sym,price\nGOOG,22\nGOOG,33")),
            "MarketData"
    );
    try {
        epService.getEPAdministrator().createEPL("select sum(price) from MarketData#length(2)");
        fail("should fail due to type conversion");
    } catch (EPStatementException e) {
        assertTrue(e.getMessage().contains("Implicit conversion"));
    }

    CSVInputAdapter adapter2 = new CSVInputAdapter(
            epService,
            new AdapterInputSource(new StringReader("sym,long price\nGOOG,22\nGOOG,33")),
            "MarketData2"
    );
    epService.getEPAdministrator().createEPL("select sum(price) from MarketData2#length(2)");
}
 
开发者ID:espertechinc,项目名称:esper,代码行数:23,代码来源:TestCSVAdapter.java

示例13: testRunTillNull

import com.espertech.esperio.csv.CSVInputAdapter; //导入依赖的package包/类
public void testRunTillNull() {
    coordinator.coordinate(new CSVInputAdapter(epService, timestampsNotLooping));
    coordinator.start();

    // Time is 100
    sendTimeEvent(100);
    log.debug(".testRunTillNull time==100");
    assertEvent(0, 1, 1.1, "timestampOne.one");
    assertSizeAndReset(1);

    // Time is 300
    sendTimeEvent(200);
    log.debug(".testRunTillNull time==300");
    assertEvent(0, 3, 3.3, "timestampOne.three");
    assertSizeAndReset(1);

    // Time is 500
    sendTimeEvent(200);
    log.debug(".testRunTillNull time==500");
    assertEvent(0, 5, 5.5, "timestampOne.five");
    assertSizeAndReset(1);

    // Time is 600
    sendTimeEvent(100);
    log.debug(".testRunTillNull time==600");
    assertFalse(listener.getAndClearIsInvoked());

    // Time is 700
    sendTimeEvent(100);
    log.debug(".testRunTillNull time==700");
    assertFalse(listener.getAndClearIsInvoked());

    // Time is 800
    sendTimeEvent(100);
    log.debug(".testRunTillNull time==800");
}
 
开发者ID:espertechinc,项目名称:esper,代码行数:37,代码来源:TestAdapterCoordinator.java

示例14: trySource

import com.espertech.esperio.csv.CSVInputAdapter; //导入依赖的package包/类
private void trySource(AdapterInputSource source) throws Exception {
    CSVInputAdapterSpec spec = new CSVInputAdapterSpec(source, "TypeC");

    epService = EPServiceProviderManager.getProvider("testPlayFromInputStream", makeConfig("TypeC"));
    epService.initialize();
    InputAdapter feed = new CSVInputAdapter(epService, spec);

    EPStatement stmt = epService.getEPAdministrator().createEPL("select * from TypeC#length(100)");
    SupportUpdateListener listener = new SupportUpdateListener();
    stmt.addListener(listener);

    feed.start();
    assertEquals(1, listener.getNewDataList().size());

    if (source.getAsReader() != null) {
        source.getAsReader().reset();
    } else {
        source.getAsStream().reset();
    }

    // test graph
    String graph = "create dataflow ReadCSV " +
            "FileSource -> mystream<TypeC> { hasTitleLine: true, classpathFile: true }" +
            "DefaultSupportCaptureOp(mystream) {}";
    epService.getEPAdministrator().createEPL(graph);

    DefaultSupportCaptureOp<Object> outputOp = new DefaultSupportCaptureOp<Object>();
    EPDataFlowInstantiationOptions options = new EPDataFlowInstantiationOptions();
    options.operatorProvider(new DefaultSupportGraphOpProvider(outputOp));
    options.parameterProvider(new DefaultSupportGraphParamProvider(Collections.<String, Object>singletonMap("adapterInputSource", source)));
    EPDataFlowInstance instance = epService.getEPRuntime().getDataFlowRuntime().instantiate("ReadCSV", options);
    instance.run();
    Object[] received = outputOp.getAndReset().get(0).toArray();
    assertEquals(1, received.length);
}
 
开发者ID:espertechinc,项目名称:esper,代码行数:36,代码来源:TestCSVAdapterUseCases.java

示例15: testReadWritePropsBean

import com.espertech.esperio.csv.CSVInputAdapter; //导入依赖的package包/类
public void testReadWritePropsBean() {
    Configuration configuration = new Configuration();
    configuration.addEventType("ReadWrite", ExampleMarketDataBeanReadWrite.class);
    configuration.addImport(FileSourceCSV.class.getPackage().getName() + ".*");

    epService = EPServiceProviderManager.getProvider("testExistingTypeNoOptions", configuration);
    epService.initialize();

    EPStatement stmt = epService.getEPAdministrator().createEPL("select * from ReadWrite#length(100)");
    SupportUpdateListener listener = new SupportUpdateListener();
    stmt.addListener(listener);

    (new CSVInputAdapter(epService, new AdapterInputSource(CSV_FILENAME_ONELINE_TRADE), "ReadWrite")).start();

    assertEquals(1, listener.getNewDataList().size());
    EventBean eb = listener.getNewDataList().get(0)[0];
    assertTrue(ExampleMarketDataBeanReadWrite.class == eb.getUnderlying().getClass());
    assertEquals(55.5 * 1000, eb.get("value"));

    // test graph
    String graph = "create dataflow ReadCSV " +
            "FileSource -> mystream<ReadWrite> { file: '" + CSV_FILENAME_ONELINE_TRADE + "', hasTitleLine: true, classpathFile: true }" +
            "DefaultSupportCaptureOp(mystream) {}";
    epService.getEPAdministrator().createEPL(graph);

    DefaultSupportCaptureOp<Object> outputOp = new DefaultSupportCaptureOp<Object>();
    EPDataFlowInstance instance = epService.getEPRuntime().getDataFlowRuntime().instantiate("ReadCSV", new EPDataFlowInstantiationOptions().operatorProvider(new DefaultSupportGraphOpProvider(outputOp)));
    instance.run();
    Object[] received = outputOp.getAndReset().get(0).toArray();
    assertEquals(1, received.length);
    assertEquals(55.5 * 1000, ((ExampleMarketDataBeanReadWrite) received[0]).getValue());
}
 
开发者ID:espertechinc,项目名称:esper,代码行数:33,代码来源:TestCSVAdapterUseCasesBean.java


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