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


Java Type类代码示例

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


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

示例1: testSimple

import com.ibm.streams.operator.Type; //导入依赖的package包/类
@Test
public void testSimple() throws Exception {

    Topology topology = new Topology("testSimple");

    TStream<String> hw = topology.strings("Hello", "World!", "Test!!");
    SPLStream hws = SPLStreams.stringToSPLStream(hw);

    Tester tester = topology.getTester();
    StreamCounter<Tuple> counter = tester.splHandler(hws,
            new StreamCounter<Tuple>());
    StreamCollector<LinkedList<Tuple>, Tuple> collector = tester
            .splHandler(hws, StreamCollector.newLinkedListCollector());

    StreamsContextFactory
            .getStreamsContext(StreamsContext.Type.EMBEDDED_TESTER)
            .submit(topology).get();

    assertEquals(3, counter.getTupleCount());
    assertEquals("Hello", collector.getTuples().get(0).getString(0));
    assertEquals("World!", collector.getTuples().get(1).getString(0));
    assertEquals("Test!!", collector.getTuples().get(2).getString(0));
}
 
开发者ID:IBMStreams,项目名称:streamsx.topology,代码行数:24,代码来源:SimpleEmbeddedTest.java

示例2: testSimpleWithConditions

import com.ibm.streams.operator.Type; //导入依赖的package包/类
@Test
public void testSimpleWithConditions() throws Exception {

    Topology topology = new Topology("testSimpleConditions");

    TStream<String> hw = topology.strings("Hello", "World!", "Test!!");

    Tester tester = topology.getTester();
    Condition<Long> expectedCount = tester.tupleCount(hw, 3);
    Condition<List<String>> expectedContents = tester.stringContents(hw,
            "Hello", "World!", "Test!!");

    StreamsContextFactory
            .getStreamsContext(StreamsContext.Type.EMBEDDED_TESTER)
            .submit(topology).get();

    assertTrue(expectedCount.valid());
    assertTrue(expectedContents.valid());
}
 
开发者ID:IBMStreams,项目名称:streamsx.topology,代码行数:20,代码来源:SimpleEmbeddedTest.java

示例3: testIsSupported

import com.ibm.streams.operator.Type; //导入依赖的package包/类
@Test
public void testIsSupported() throws Exception {

    Topology topology = new Topology("test");

    TStream<String> hw = topology.strings("Hello", "World!", "Test!!");
    TStream<String> hw2 = hw.transform(new AppendXform("(stream-2)"));
    // make sure "marker" ops are ok: union,parallel,unparallel
    hw
        .union(hw2)
        .parallel(2)
            .filter(nilFilter)
            .filter(nilFilter)
        .endParallel()
    .print();

    StreamsContext<?> sc = StreamsContextFactory
            .getStreamsContext(StreamsContext.Type.EMBEDDED);
    assertTrue(sc.isSupported(topology));

    sc = StreamsContextFactory
            .getStreamsContext(StreamsContext.Type.EMBEDDED_TESTER);
    assertTrue(sc.isSupported(topology));
}
 
开发者ID:IBMStreams,项目名称:streamsx.topology,代码行数:25,代码来源:SimpleEmbeddedTest.java

示例4: testTupleStream

import com.ibm.streams.operator.Type; //导入依赖的package包/类
public static SPLStream testTupleStream(Topology topology, boolean withSets) {
    TStream<Long> beacon = BeaconStreams.longBeacon(topology, TUPLE_COUNT);

    SPLStream tuples = SPLStreams.convertStream(beacon, new BiFunction<Long, OutputTuple, OutputTuple>() {
        private static final long serialVersionUID = 1L;
        
        private transient TupleType type;
        private transient Random rand;

        @Override
        public OutputTuple apply(Long v1, OutputTuple v2) {
        	if (type == null) {
        		type = Type.Factory.getTupleType(getPythonTypesSchema(withSets).getLanguageType());
        		rand = new Random();
        	}
        	Tuple randTuple = (Tuple) type.randomValue(rand);
        	v2.assign(randTuple);
            return v2;
        }
    }, getPythonTypesSchema(withSets));

    return tuples;
}
 
开发者ID:IBMStreams,项目名称:streamsx.topology,代码行数:24,代码来源:PythonFunctionalOperatorsTest.java

示例5: testConsistentPeriodic

import com.ibm.streams.operator.Type; //导入依赖的package包/类
@Test
public void testConsistentPeriodic() throws Exception {
    Topology topology = new Topology("testConsistentPeriodic");
    
    StreamSchema schema = Type.Factory.getStreamSchema("tuple<uint64 id>");
    Map<String,Object> params = new HashMap<>();
    params.put("iterations", 200);
    params.put("period", 0.05);
    
    SPLStream b = SPL.invokeSource(topology, "spl.utility::Beacon", params, schema);
    
    ConsistentRegionConfig config = periodic(2);
    assertSame(b, b.setConsistent(config));
    
    Condition<Long> atLeast = topology.getTester().atLeastTupleCount(b, 200);
    complete(topology.getTester(), atLeast, 80, TimeUnit.SECONDS);
}
 
开发者ID:IBMStreams,项目名称:streamsx.topology,代码行数:18,代码来源:ConsistentRegionTest.java

示例6: testConsistentOperatorDriven

import com.ibm.streams.operator.Type; //导入依赖的package包/类
@Test
public void testConsistentOperatorDriven() throws Exception {
    Topology topology = new Topology("testConsistentOperatorDriven");
    
    StreamSchema schema = Type.Factory.getStreamSchema("tuple<uint64 id>");
    Map<String,Object> params = new HashMap<>();
    params.put("iterations", 300);
    params.put("triggerCount", SPL.createValue(37, Type.MetaType.UINT32));
    
    SPLStream b = SPL.invokeSource(topology, "spl.utility::Beacon", params, schema);
    
    ConsistentRegionConfig config = ConsistentRegionConfig.operatorDriven();
    assertSame(b, b.setConsistent(config));
    
    Condition<Long> atLeast = topology.getTester().atLeastTupleCount(b, 300);
    complete(topology.getTester(), atLeast, 40, TimeUnit.SECONDS);
}
 
开发者ID:IBMStreams,项目名称:streamsx.topology,代码行数:18,代码来源:ConsistentRegionTest.java

示例7: isList

import com.ibm.streams.operator.Type; //导入依赖的package包/类
protected static boolean isList(Attribute attr,
		Class<?> clz) {
	Type type = attr.getType();
	if(type.getMetaType() == MetaType.LIST) {
		CollectionType cType = (CollectionType)type;
		if(cType.getElementType().getObjectType() == clz) {
			return true;
		}
	}
	return false;
}
 
开发者ID:IBMStreams,项目名称:streamsx.sparkMLLib,代码行数:12,代码来源:AbstractSparkMLlibOperator.java

示例8: listRStringParam

import com.ibm.streams.operator.Type; //导入依赖的package包/类
private static Object listRStringParam(String[] values) {
    List<String> literals = new ArrayList<>(values.length);
    for (String v : values)
        literals.add("\"" + v + "\""); //$NON-NLS-1$ //$NON-NLS-2$

    return new Attribute() {

        @Override
        public int getIndex() {
            // TODO Auto-generated method stub
            return 0;
        }

        @Override
        public String getName() {
            return literals.toString();
        }

        @Override
        public Type getType() {
            // TODO Auto-generated method stub
            return null;
        }

        @Override
        public boolean same(Attribute arg0) {
            return false;
        }

    };
}
 
开发者ID:IBMStreams,项目名称:streamsx.iot,代码行数:32,代码来源:IotSPLStreams.java

示例9: notSupported

import com.ibm.streams.operator.Type; //导入依赖的package包/类
private IllegalStateException notSupported(JsonObject op) {
    
    String namespace = jstring(builder._json(), NAMESPACE);
    String name = jstring(builder._json(), NAME);
    
    return new IllegalStateException(
            "Topology '"+namespace+"."+name+"'"
            + " does not support "+StreamsContext.Type.EMBEDDED+" mode:"
            + " the topology contains non-Java operator:" +
            jstring(op, KIND));
}
 
开发者ID:IBMStreams,项目名称:streamsx.topology,代码行数:12,代码来源:EmbeddedGraph.java

示例10: testTwoStreams

import com.ibm.streams.operator.Type; //导入依赖的package包/类
@Test
public void testTwoStreams() throws Exception {

    Topology topology = new Topology("testTwoStreams");

    TStream<String> hw = topology.strings("Hello", "World!", "Test!!");
    SPLStream hws = SPLStreams.stringToSPLStream(hw);

    TStream<String> hw2 = StringStreams.contains(hw, "e");
    SPLStream hw2s = SPLStreams.stringToSPLStream(hw2);

    Tester tester = topology.getTester();
    StreamCounter<Tuple> counter = tester.splHandler(hws,
            new StreamCounter<Tuple>());
    StreamCollector<LinkedList<Tuple>, Tuple> collector = tester
            .splHandler(hws, StreamCollector.newLinkedListCollector());

    StreamCounter<Tuple> counter2 = tester.splHandler(hw2s,
            new StreamCounter<Tuple>());
    StreamCollector<LinkedList<Tuple>, Tuple> collector2 = tester
            .splHandler(hw2s, StreamCollector.newLinkedListCollector());

    StreamsContextFactory
            .getStreamsContext(StreamsContext.Type.EMBEDDED_TESTER)
            .submit(topology).get();

    assertEquals(3, counter.getTupleCount());
    assertEquals("Hello", collector.getTuples().get(0).getString(0));
    assertEquals("World!", collector.getTuples().get(1).getString(0));
    assertEquals("Test!!", collector.getTuples().get(2).getString(0));

    assertEquals(2, counter2.getTupleCount());
    assertEquals("Hello", collector2.getTuples().get(0).getString(0));
    assertEquals("Test!!", collector2.getTuples().get(1).getString(0));
}
 
开发者ID:IBMStreams,项目名称:streamsx.topology,代码行数:36,代码来源:SimpleEmbeddedTest.java

示例11: runSpl

import com.ibm.streams.operator.Type; //导入依赖的package包/类
@Before
public void runSpl() {
    assumeSPLOk();
    
    assumeTrue(getTesterContext().getType() == StreamsContext.Type.STANDALONE_TESTER
    		|| getTesterContext().getType() == StreamsContext.Type.DISTRIBUTED_TESTER);
}
 
开发者ID:IBMStreams,项目名称:streamsx.topology,代码行数:8,代码来源:PythonFunctionalOperatorsTest.java

示例12: testSourceWithClass

import com.ibm.streams.operator.Type; //导入依赖的package包/类
@Test
public void testSourceWithClass() throws Exception {
    Topology topology = new Topology("testSourceWithClass");
    
    addTestToolkit(topology);
    
    StreamSchema outSchema = Type.Factory.getStreamSchema("tuple<int32 seq>");
    
    int count = new Random().nextInt(200) + 10;
    SPLStream pysrc = SPL.invokeSource(topology,
    		"com.ibm.streamsx.topology.pysamples.sources::Range",
    		Collections.singletonMap("count", count), outSchema);
    
    Tester tester = topology.getTester();
    Condition<Long> expectedCount = tester.tupleCount(pysrc, count);
    Condition<List<Tuple>> outTuples = tester.tupleContents(pysrc);
    
    // getConfig().put(ContextProperties.TRACING_LEVEL, TraceLevel.DEBUG);
            
    complete(tester, expectedCount, 20, TimeUnit.SECONDS);

    assertTrue(expectedCount.valid());
    
    List<Tuple> result = outTuples.getResult();
    
    assertEquals(count, result.size());
    for (int i = 0; i < count; i++)
        assertEquals(i, result.get(i).getInt("seq"));
}
 
开发者ID:IBMStreams,项目名称:streamsx.topology,代码行数:30,代码来源:PythonFunctionalOperatorsTest.java

示例13: convertListToSPL

import com.ibm.streams.operator.Type; //导入依赖的package包/类
@SuppressWarnings("serial")
private static SPLStream convertListToSPL(TStream<List<String>> s) {
    
    return SPLStreams.convertStream(s, new BiFunction<List<String>, OutputTuple, OutputTuple>() {

        @Override
        public OutputTuple apply(List<String> v1, OutputTuple v2) {
            v2.setList("lrs", v1);
            return v2;
        }
    }, Type.Factory.getStreamSchema("tuple<list<ustring> lrs>"));

}
 
开发者ID:IBMStreams,项目名称:streamsx.topology,代码行数:14,代码来源:SPLStreamsTest.java

示例14: testMissingOperatorDrivenConsistent

import com.ibm.streams.operator.Type; //导入依赖的package包/类
/**
 * Expected to raise an exception as triggerCount requires it
 * be in a operator driven consistent region. Somewhat
 * enforces that testConsistentOperatorDriven() is doing the correct thing.
 * @throws Exception
 */
@Test(expected=Exception.class)
public void testMissingOperatorDrivenConsistent() throws Exception {
    Topology topology = new Topology("testConsistentOperatorDriven");
    
    StreamSchema schema = Type.Factory.getStreamSchema("tuple<uint64 id>");
    Map<String,Object> params = new HashMap<>();
    params.put("iterations", 300);
    params.put("triggerCount", SPL.createValue(37, Type.MetaType.UINT32));
    
    SPLStream b = SPL.invokeSource(topology, "spl.utility::Beacon", params, schema);
    
    Condition<Long> atLeast = topology.getTester().atLeastTupleCount(b, 300);
    complete(topology.getTester(), atLeast, 40, TimeUnit.SECONDS);
}
 
开发者ID:IBMStreams,项目名称:streamsx.topology,代码行数:21,代码来源:ConsistentRegionTest.java

示例15: checkOutputPort

import com.ibm.streams.operator.Type; //导入依赖的package包/类
@ContextCheck(compile = true)
public static void checkOutputPort(OperatorContextChecker checker) {
	OperatorContext context = checker.getOperatorContext();
	if (context.getNumberOfStreamingOutputs() == 1) {
		StreamingOutput<OutputTuple> streamingOutputPort = context
				.getStreamingOutputs().get(0);
		if (streamingOutputPort.getStreamSchema().getAttributeCount() != 2) {
			checker.setInvalidContext(
					Messages.getString("HDFS_SINK_OUTPUT_PORT"), 
					null);

		} else {
			if (streamingOutputPort.getStreamSchema().getAttribute(0)
					.getType().getMetaType() != Type.MetaType.RSTRING) {
				checker.setInvalidContext(
						Messages.getString("HDFS_SINK_FIRST_OUTPUT_PORT"), 
						null);
			}
			if (streamingOutputPort.getStreamSchema().getAttribute(1)
					.getType().getMetaType() != Type.MetaType.UINT64) {
				checker.setInvalidContext(
						Messages.getString("HDFS_SINK_SECOND_OUTPUT_PORT"), 
						null);

			}

		}

	}
}
 
开发者ID:IBMStreams,项目名称:streamsx.hdfs,代码行数:31,代码来源:HDFS2FileSink.java


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