org.apache.flink.types.BooleanValue Java Examples
The following examples show how to use
org.apache.flink.types.BooleanValue.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SummaryAggregatorFactoryTest.java From Flink-CEPplus with Apache License 2.0 | 6 votes |
@Test public void testCreate() throws Exception { // supported primitive types Assert.assertEquals(StringSummaryAggregator.class, SummaryAggregatorFactory.create(String.class).getClass()); Assert.assertEquals(ShortSummaryAggregator.class, SummaryAggregatorFactory.create(Short.class).getClass()); Assert.assertEquals(IntegerSummaryAggregator.class, SummaryAggregatorFactory.create(Integer.class).getClass()); Assert.assertEquals(LongSummaryAggregator.class, SummaryAggregatorFactory.create(Long.class).getClass()); Assert.assertEquals(FloatSummaryAggregator.class, SummaryAggregatorFactory.create(Float.class).getClass()); Assert.assertEquals(DoubleSummaryAggregator.class, SummaryAggregatorFactory.create(Double.class).getClass()); Assert.assertEquals(BooleanSummaryAggregator.class, SummaryAggregatorFactory.create(Boolean.class).getClass()); // supported value types Assert.assertEquals(ValueSummaryAggregator.StringValueSummaryAggregator.class, SummaryAggregatorFactory.create(StringValue.class).getClass()); Assert.assertEquals(ValueSummaryAggregator.ShortValueSummaryAggregator.class, SummaryAggregatorFactory.create(ShortValue.class).getClass()); Assert.assertEquals(ValueSummaryAggregator.IntegerValueSummaryAggregator.class, SummaryAggregatorFactory.create(IntValue.class).getClass()); Assert.assertEquals(ValueSummaryAggregator.LongValueSummaryAggregator.class, SummaryAggregatorFactory.create(LongValue.class).getClass()); Assert.assertEquals(ValueSummaryAggregator.FloatValueSummaryAggregator.class, SummaryAggregatorFactory.create(FloatValue.class).getClass()); Assert.assertEquals(ValueSummaryAggregator.DoubleValueSummaryAggregator.class, SummaryAggregatorFactory.create(DoubleValue.class).getClass()); Assert.assertEquals(ValueSummaryAggregator.BooleanValueSummaryAggregator.class, SummaryAggregatorFactory.create(BooleanValue.class).getClass()); // some not well supported types - these fallback to ObjectSummaryAggregator Assert.assertEquals(ObjectSummaryAggregator.class, SummaryAggregatorFactory.create(Object.class).getClass()); Assert.assertEquals(ObjectSummaryAggregator.class, SummaryAggregatorFactory.create(List.class).getClass()); }
Example #2
Source File: BooleanValueSummaryAggregatorTest.java From flink with Apache License 2.0 | 6 votes |
/** * Helper method for summarizing a list of values. * * <p>This method breaks the rule of "testing only one thing" by aggregating and combining * a bunch of different ways. */ protected BooleanColumnSummary summarize(Boolean... values) { BooleanValue[] booleanValues = new BooleanValue[values.length]; for (int i = 0; i < values.length; i++) { if (values[i] != null) { booleanValues[i] = new BooleanValue(values[i]); } } return new AggregateCombineHarness<BooleanValue, BooleanColumnSummary, ValueSummaryAggregator.BooleanValueSummaryAggregator>() { @Override protected void compareResults(BooleanColumnSummary result1, BooleanColumnSummary result2) { Assert.assertEquals(result1.getNullCount(), result2.getNullCount()); Assert.assertEquals(result1.getNonNullCount(), result2.getNonNullCount()); Assert.assertEquals(result1.getTrueCount(), result2.getTrueCount()); Assert.assertEquals(result1.getFalseCount(), result2.getFalseCount()); } }.summarize(booleanValues); }
Example #3
Source File: BooleanValueParserTest.java From Flink-CEPplus with Apache License 2.0 | 5 votes |
@Override public BooleanValue[] getValidTestResults() { return new BooleanValue[] { new BooleanValue(true), new BooleanValue(false), new BooleanValue(false), new BooleanValue(true), new BooleanValue(true), new BooleanValue(false), new BooleanValue(true), new BooleanValue(false) }; }
Example #4
Source File: BooleanValueParser.java From flink with Apache License 2.0 | 5 votes |
@Override public int parseField(byte[] bytes, int startPos, int limit, byte[] delim, BooleanValue reuse) { int returnValue = parser.parseField(bytes, startPos, limit, delim, reuse.getValue()); setErrorState(parser.getErrorState()); reuse.setValue(parser.getLastResult()); result = reuse; return returnValue; }
Example #5
Source File: BooleanValueParser.java From Flink-CEPplus with Apache License 2.0 | 5 votes |
@Override public int parseField(byte[] bytes, int startPos, int limit, byte[] delim, BooleanValue reuse) { int returnValue = parser.parseField(bytes, startPos, limit, delim, reuse.getValue()); setErrorState(parser.getErrorState()); reuse.setValue(parser.getLastResult()); result = reuse; return returnValue; }
Example #6
Source File: BooleanValueParserTest.java From flink with Apache License 2.0 | 5 votes |
@Override public BooleanValue[] getValidTestResults() { return new BooleanValue[] { new BooleanValue(true), new BooleanValue(false), new BooleanValue(false), new BooleanValue(true), new BooleanValue(true), new BooleanValue(false), new BooleanValue(true), new BooleanValue(false) }; }
Example #7
Source File: CsvReaderITCase.java From Flink-CEPplus with Apache License 2.0 | 5 votes |
@Test public void testValueTypes() throws Exception { final String inputData = "ABC,true,1,2,3,4,5.0,6.0\nBCD,false,1,2,3,4,5.0,6.0"; final String dataPath = createInputData(inputData); final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment(); DataSet<Tuple8<StringValue, BooleanValue, ByteValue, ShortValue, IntValue, LongValue, FloatValue, DoubleValue>> data = env.readCsvFile(dataPath).types(StringValue.class, BooleanValue.class, ByteValue.class, ShortValue.class, IntValue.class, LongValue.class, FloatValue.class, DoubleValue.class); List<Tuple8<StringValue, BooleanValue, ByteValue, ShortValue, IntValue, LongValue, FloatValue, DoubleValue>> result = data.collect(); expected = inputData; compareResultAsTuples(result, expected); }
Example #8
Source File: BooleanValueSerializerTest.java From flink with Apache License 2.0 | 5 votes |
@Override protected BooleanValue[] getTestData() { Random rnd = new Random(874597969123412341L); return new BooleanValue[] {new BooleanValue(true), new BooleanValue(false), new BooleanValue(rnd.nextBoolean()), new BooleanValue(rnd.nextBoolean()), new BooleanValue(rnd.nextBoolean())}; }
Example #9
Source File: BooleanValueParserTest.java From flink with Apache License 2.0 | 5 votes |
@Override public BooleanValue[] getValidTestResults() { return new BooleanValue[] { new BooleanValue(true), new BooleanValue(false), new BooleanValue(false), new BooleanValue(true), new BooleanValue(true), new BooleanValue(false), new BooleanValue(true), new BooleanValue(false) }; }
Example #10
Source File: BooleanValueSerializerTest.java From flink with Apache License 2.0 | 5 votes |
@Override protected BooleanValue[] getTestData() { Random rnd = new Random(874597969123412341L); return new BooleanValue[] {new BooleanValue(true), new BooleanValue(false), new BooleanValue(rnd.nextBoolean()), new BooleanValue(rnd.nextBoolean()), new BooleanValue(rnd.nextBoolean())}; }
Example #11
Source File: BooleanValueParser.java From flink with Apache License 2.0 | 5 votes |
@Override public int parseField(byte[] bytes, int startPos, int limit, byte[] delim, BooleanValue reuse) { int returnValue = parser.parseField(bytes, startPos, limit, delim, reuse.getValue()); setErrorState(parser.getErrorState()); reuse.setValue(parser.getLastResult()); result = reuse; return returnValue; }
Example #12
Source File: CSVReaderTest.java From Flink-CEPplus with Apache License 2.0 | 5 votes |
@Test public void testWithValueType() throws Exception { CsvReader reader = getCsvReader(); DataSource<Tuple8<StringValue, BooleanValue, ByteValue, ShortValue, IntValue, LongValue, FloatValue, DoubleValue>> items = reader.types(StringValue.class, BooleanValue.class, ByteValue.class, ShortValue.class, IntValue.class, LongValue.class, FloatValue.class, DoubleValue.class); TypeInformation<?> info = items.getType(); Assert.assertEquals(true, info.isTupleType()); Assert.assertEquals(Tuple8.class, info.getTypeClass()); }
Example #13
Source File: CSVReaderTest.java From flink with Apache License 2.0 | 5 votes |
@Test public void testWithValueType() throws Exception { CsvReader reader = getCsvReader(); DataSource<Tuple8<StringValue, BooleanValue, ByteValue, ShortValue, IntValue, LongValue, FloatValue, DoubleValue>> items = reader.types(StringValue.class, BooleanValue.class, ByteValue.class, ShortValue.class, IntValue.class, LongValue.class, FloatValue.class, DoubleValue.class); TypeInformation<?> info = items.getType(); Assert.assertEquals(true, info.isTupleType()); Assert.assertEquals(Tuple8.class, info.getTypeClass()); }
Example #14
Source File: CSVReaderTest.java From flink with Apache License 2.0 | 5 votes |
@Test public void testWithValueType() throws Exception { CsvReader reader = getCsvReader(); DataSource<Tuple8<StringValue, BooleanValue, ByteValue, ShortValue, IntValue, LongValue, FloatValue, DoubleValue>> items = reader.types(StringValue.class, BooleanValue.class, ByteValue.class, ShortValue.class, IntValue.class, LongValue.class, FloatValue.class, DoubleValue.class); TypeInformation<?> info = items.getType(); Assert.assertEquals(true, info.isTupleType()); Assert.assertEquals(Tuple8.class, info.getTypeClass()); }
Example #15
Source File: BooleanValueSerializer.java From flink with Apache License 2.0 | 4 votes |
@Override public BooleanValue createInstance() { return new BooleanValue(); }
Example #16
Source File: BasicTypeSerializerUpgradeTestSpecifications.java From flink with Apache License 2.0 | 4 votes |
@Override public BooleanValue createTestData() { return BooleanValue.TRUE; }
Example #17
Source File: BooleanValueComparator.java From flink with Apache License 2.0 | 4 votes |
@Override public boolean supportsNormalizedKey() { return NormalizableKey.class.isAssignableFrom(BooleanValue.class); }
Example #18
Source File: BooleanValueComparator.java From flink with Apache License 2.0 | 4 votes |
@Override public TypeComparator<BooleanValue> duplicate() { return new BooleanValueComparator(ascendingComparison); }
Example #19
Source File: BooleanValueComparator.java From flink with Apache License 2.0 | 4 votes |
@Override public void writeWithKeyNormalization(BooleanValue record, DataOutputView target) throws IOException { throw new UnsupportedOperationException(); }
Example #20
Source File: BooleanValueParser.java From flink with Apache License 2.0 | 4 votes |
@Override public BooleanValue getLastResult() { return result; }
Example #21
Source File: BooleanValueParserTest.java From flink with Apache License 2.0 | 4 votes |
@Override public FieldParser<BooleanValue> getParser() { return new BooleanValueParser(); }
Example #22
Source File: BooleanValueSerializerTest.java From flink with Apache License 2.0 | 4 votes |
@Override protected Class<BooleanValue> getTypeClass() { return BooleanValue.class; }
Example #23
Source File: BooleanValueComparator.java From flink with Apache License 2.0 | 4 votes |
@Override public int compare(BooleanValue first, BooleanValue second) { int comp = first.compareTo(second); return ascendingComparison ? comp : -comp; }
Example #24
Source File: BasicTypeSerializerUpgradeTestSpecifications.java From flink with Apache License 2.0 | 4 votes |
@Override public TypeSerializer<BooleanValue> createUpgradedSerializer() { return BooleanValueSerializer.INSTANCE; }
Example #25
Source File: BooleanValueParserTest.java From flink with Apache License 2.0 | 4 votes |
@Override public Class<BooleanValue> getTypeClass() { return BooleanValue.class; }
Example #26
Source File: BooleanValueComparator.java From flink with Apache License 2.0 | 4 votes |
@Override public void writeWithKeyNormalization(BooleanValue record, DataOutputView target) throws IOException { throw new UnsupportedOperationException(); }
Example #27
Source File: BooleanValueComparator.java From flink with Apache License 2.0 | 4 votes |
@Override public int hash(BooleanValue record) { return record.hashCode(); }
Example #28
Source File: ValueTypeInfo.java From flink with Apache License 2.0 | 4 votes |
@SuppressWarnings({ "unchecked", "rawtypes" }) @Override @PublicEvolving public TypeComparator<T> createComparator(boolean sortOrderAscending, ExecutionConfig executionConfig) { if (!isKeyType()) { throw new RuntimeException("The type " + type.getName() + " is not Comparable."); } if (BooleanValue.class.isAssignableFrom(type)) { return (TypeComparator<T>) new BooleanValueComparator(sortOrderAscending); } else if (ByteValue.class.isAssignableFrom(type)) { return (TypeComparator<T>) new ByteValueComparator(sortOrderAscending); } else if (CharValue.class.isAssignableFrom(type)) { return (TypeComparator<T>) new CharValueComparator(sortOrderAscending); } else if (DoubleValue.class.isAssignableFrom(type)) { return (TypeComparator<T>) new DoubleValueComparator(sortOrderAscending); } else if (FloatValue.class.isAssignableFrom(type)) { return (TypeComparator<T>) new FloatValueComparator(sortOrderAscending); } else if (IntValue.class.isAssignableFrom(type)) { return (TypeComparator<T>) new IntValueComparator(sortOrderAscending); } else if (LongValue.class.isAssignableFrom(type)) { return (TypeComparator<T>) new LongValueComparator(sortOrderAscending); } else if (NullValue.class.isAssignableFrom(type)) { return (TypeComparator<T>) NullValueComparator.getInstance(); } else if (ShortValue.class.isAssignableFrom(type)) { return (TypeComparator<T>) new ShortValueComparator(sortOrderAscending); } else if (StringValue.class.isAssignableFrom(type)) { return (TypeComparator<T>) new StringValueComparator(sortOrderAscending); } else if (CopyableValue.class.isAssignableFrom(type)) { return (TypeComparator<T>) new CopyableValueComparator(sortOrderAscending, type); } else { return (TypeComparator<T>) new ValueComparator(sortOrderAscending, type); } }
Example #29
Source File: BooleanValueComparator.java From flink with Apache License 2.0 | 4 votes |
@Override public int hash(BooleanValue record) { return record.hashCode(); }
Example #30
Source File: ValueTypeInfo.java From flink with Apache License 2.0 | 4 votes |
@PublicEvolving public boolean isBasicValueType() { return type.equals(StringValue.class) || type.equals(ByteValue.class) || type.equals(ShortValue.class) || type.equals(CharValue.class) || type.equals(DoubleValue.class) || type.equals(FloatValue.class) || type.equals(IntValue.class) || type.equals(LongValue.class) || type.equals(NullValue.class) || type.equals(BooleanValue.class); }