Java Code Examples for org.apache.flink.types.CharValue

The following examples show how to use org.apache.flink.types.CharValue. These examples are extracted from open source projects. 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 Project: flink   Source File: ValueArrayFactory.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Produce a {@code ValueArray} for the given {@code Value} type with the
 * given bounded size.
 *
 * @param cls {@code Value} class
 * @param bytes limit the array to the given number of bytes
 * @return {@code ValueArray} for given {@code Value} class
 */
@SuppressWarnings("unchecked")
public static <T> ValueArray<T> createValueArray(Class<? extends Value> cls, int bytes) {
	if (ByteValue.class.isAssignableFrom(cls)) {
		return (ValueArray<T>) new ByteValueArray(bytes);
	} else if (CharValue.class.isAssignableFrom(cls)) {
		return (ValueArray<T>) new CharValueArray(bytes);
	} else if (DoubleValue.class.isAssignableFrom(cls)) {
		return (ValueArray<T>) new DoubleValueArray(bytes);
	} else if (FloatValue.class.isAssignableFrom(cls)) {
		return (ValueArray<T>) new FloatValueArray(bytes);
	} else if (IntValue.class.isAssignableFrom(cls)) {
		return (ValueArray<T>) new IntValueArray(bytes);
	} else if (LongValue.class.isAssignableFrom(cls)) {
		return (ValueArray<T>) new LongValueArray(bytes);
	} else if (NullValue.class.isAssignableFrom(cls)) {
		return (ValueArray<T>) new NullValueArray(bytes);
	} else if (ShortValue.class.isAssignableFrom(cls)) {
		return (ValueArray<T>) new ShortValueArray(bytes);
	} else if (StringValue.class.isAssignableFrom(cls)) {
		return (ValueArray<T>) new StringValueArray(bytes);
	} else {
		throw new IllegalArgumentException("Unable to create bounded ValueArray for type " + cls);
	}
}
 
Example 2
Source Project: flink   Source File: ValueArrayFactory.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Produce a {@code ValueArray} for the given {@code Value} type.
 *
 * @param cls {@code Value} class
 * @return {@code ValueArray} for given {@code Value} class
 */
@SuppressWarnings("unchecked")
public static <T> ValueArray<T> createValueArray(Class<? extends Value> cls) {
	if (ByteValue.class.isAssignableFrom(cls)) {
		return (ValueArray<T>) new ByteValueArray();
	} else if (CharValue.class.isAssignableFrom(cls)) {
		return (ValueArray<T>) new CharValueArray();
	} else if (DoubleValue.class.isAssignableFrom(cls)) {
		return (ValueArray<T>) new DoubleValueArray();
	} else if (FloatValue.class.isAssignableFrom(cls)) {
		return (ValueArray<T>) new FloatValueArray();
	} else if (IntValue.class.isAssignableFrom(cls)) {
		return (ValueArray<T>) new IntValueArray();
	} else if (LongValue.class.isAssignableFrom(cls)) {
		return (ValueArray<T>) new LongValueArray();
	} else if (NullValue.class.isAssignableFrom(cls)) {
		return (ValueArray<T>) new NullValueArray();
	} else if (ShortValue.class.isAssignableFrom(cls)) {
		return (ValueArray<T>) new ShortValueArray();
	} else if (StringValue.class.isAssignableFrom(cls)) {
		return (ValueArray<T>) new StringValueArray();
	} else {
		throw new IllegalArgumentException("Unable to create unbounded ValueArray for type " + cls);
	}
}
 
Example 3
Source Project: Flink-CEPplus   Source File: CharValueArray.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public boolean add(CharValue value) {
	int newPosition = position + 1;

	if (newPosition > data.length) {
		if (isBounded) {
			return false;
		} else {
			ensureCapacity(newPosition);
		}
	}

	data[position] = value.getValue();
	position = newPosition;

	return true;
}
 
Example 4
Source Project: Flink-CEPplus   Source File: CharValueArray.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public boolean addAll(ValueArray<CharValue> other) {
	CharValueArray source = (CharValueArray) other;

	int sourceSize = source.position;
	int newPosition = position + sourceSize;

	if (newPosition > data.length) {
		if (isBounded) {
			return false;
		} else {
			ensureCapacity(newPosition);
		}
	}

	System.arraycopy(source.data, 0, data, position, sourceSize);
	position = newPosition;

	return true;
}
 
Example 5
Source Project: Flink-CEPplus   Source File: ValueArrayFactory.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Produce a {@code ValueArray} for the given {@code Value} type.
 *
 * @param cls {@code Value} class
 * @return {@code ValueArray} for given {@code Value} class
 */
@SuppressWarnings("unchecked")
public static <T> ValueArray<T> createValueArray(Class<? extends Value> cls) {
	if (ByteValue.class.isAssignableFrom(cls)) {
		return (ValueArray<T>) new ByteValueArray();
	} else if (CharValue.class.isAssignableFrom(cls)) {
		return (ValueArray<T>) new CharValueArray();
	} else if (DoubleValue.class.isAssignableFrom(cls)) {
		return (ValueArray<T>) new DoubleValueArray();
	} else if (FloatValue.class.isAssignableFrom(cls)) {
		return (ValueArray<T>) new FloatValueArray();
	} else if (IntValue.class.isAssignableFrom(cls)) {
		return (ValueArray<T>) new IntValueArray();
	} else if (LongValue.class.isAssignableFrom(cls)) {
		return (ValueArray<T>) new LongValueArray();
	} else if (NullValue.class.isAssignableFrom(cls)) {
		return (ValueArray<T>) new NullValueArray();
	} else if (ShortValue.class.isAssignableFrom(cls)) {
		return (ValueArray<T>) new ShortValueArray();
	} else if (StringValue.class.isAssignableFrom(cls)) {
		return (ValueArray<T>) new StringValueArray();
	} else {
		throw new IllegalArgumentException("Unable to create unbounded ValueArray for type " + cls);
	}
}
 
Example 6
Source Project: Flink-CEPplus   Source File: ValueArrayFactory.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Produce a {@code ValueArray} for the given {@code Value} type with the
 * given bounded size.
 *
 * @param cls {@code Value} class
 * @param bytes limit the array to the given number of bytes
 * @return {@code ValueArray} for given {@code Value} class
 */
@SuppressWarnings("unchecked")
public static <T> ValueArray<T> createValueArray(Class<? extends Value> cls, int bytes) {
	if (ByteValue.class.isAssignableFrom(cls)) {
		return (ValueArray<T>) new ByteValueArray(bytes);
	} else if (CharValue.class.isAssignableFrom(cls)) {
		return (ValueArray<T>) new CharValueArray(bytes);
	} else if (DoubleValue.class.isAssignableFrom(cls)) {
		return (ValueArray<T>) new DoubleValueArray(bytes);
	} else if (FloatValue.class.isAssignableFrom(cls)) {
		return (ValueArray<T>) new FloatValueArray(bytes);
	} else if (IntValue.class.isAssignableFrom(cls)) {
		return (ValueArray<T>) new IntValueArray(bytes);
	} else if (LongValue.class.isAssignableFrom(cls)) {
		return (ValueArray<T>) new LongValueArray(bytes);
	} else if (NullValue.class.isAssignableFrom(cls)) {
		return (ValueArray<T>) new NullValueArray(bytes);
	} else if (ShortValue.class.isAssignableFrom(cls)) {
		return (ValueArray<T>) new ShortValueArray(bytes);
	} else if (StringValue.class.isAssignableFrom(cls)) {
		return (ValueArray<T>) new StringValueArray(bytes);
	} else {
		throw new IllegalArgumentException("Unable to create bounded ValueArray for type " + cls);
	}
}
 
Example 7
Source Project: flink   Source File: CharValueArray.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public boolean add(CharValue value) {
	int newPosition = position + 1;

	if (newPosition > data.length) {
		if (isBounded) {
			return false;
		} else {
			ensureCapacity(newPosition);
		}
	}

	data[position] = value.getValue();
	position = newPosition;

	return true;
}
 
Example 8
Source Project: flink   Source File: CharValueArray.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public boolean add(CharValue value) {
	int newPosition = position + 1;

	if (newPosition > data.length) {
		if (isBounded) {
			return false;
		} else {
			ensureCapacity(newPosition);
		}
	}

	data[position] = value.getValue();
	position = newPosition;

	return true;
}
 
Example 9
Source Project: flink   Source File: ValueArrayFactory.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Produce a {@code ValueArray} for the given {@code Value} type.
 *
 * @param cls {@code Value} class
 * @return {@code ValueArray} for given {@code Value} class
 */
@SuppressWarnings("unchecked")
public static <T> ValueArray<T> createValueArray(Class<? extends Value> cls) {
	if (ByteValue.class.isAssignableFrom(cls)) {
		return (ValueArray<T>) new ByteValueArray();
	} else if (CharValue.class.isAssignableFrom(cls)) {
		return (ValueArray<T>) new CharValueArray();
	} else if (DoubleValue.class.isAssignableFrom(cls)) {
		return (ValueArray<T>) new DoubleValueArray();
	} else if (FloatValue.class.isAssignableFrom(cls)) {
		return (ValueArray<T>) new FloatValueArray();
	} else if (IntValue.class.isAssignableFrom(cls)) {
		return (ValueArray<T>) new IntValueArray();
	} else if (LongValue.class.isAssignableFrom(cls)) {
		return (ValueArray<T>) new LongValueArray();
	} else if (NullValue.class.isAssignableFrom(cls)) {
		return (ValueArray<T>) new NullValueArray();
	} else if (ShortValue.class.isAssignableFrom(cls)) {
		return (ValueArray<T>) new ShortValueArray();
	} else if (StringValue.class.isAssignableFrom(cls)) {
		return (ValueArray<T>) new StringValueArray();
	} else {
		throw new IllegalArgumentException("Unable to create unbounded ValueArray for type " + cls);
	}
}
 
Example 10
Source Project: flink   Source File: ValueArrayFactory.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Produce a {@code ValueArray} for the given {@code Value} type with the
 * given bounded size.
 *
 * @param cls {@code Value} class
 * @param bytes limit the array to the given number of bytes
 * @return {@code ValueArray} for given {@code Value} class
 */
@SuppressWarnings("unchecked")
public static <T> ValueArray<T> createValueArray(Class<? extends Value> cls, int bytes) {
	if (ByteValue.class.isAssignableFrom(cls)) {
		return (ValueArray<T>) new ByteValueArray(bytes);
	} else if (CharValue.class.isAssignableFrom(cls)) {
		return (ValueArray<T>) new CharValueArray(bytes);
	} else if (DoubleValue.class.isAssignableFrom(cls)) {
		return (ValueArray<T>) new DoubleValueArray(bytes);
	} else if (FloatValue.class.isAssignableFrom(cls)) {
		return (ValueArray<T>) new FloatValueArray(bytes);
	} else if (IntValue.class.isAssignableFrom(cls)) {
		return (ValueArray<T>) new IntValueArray(bytes);
	} else if (LongValue.class.isAssignableFrom(cls)) {
		return (ValueArray<T>) new LongValueArray(bytes);
	} else if (NullValue.class.isAssignableFrom(cls)) {
		return (ValueArray<T>) new NullValueArray(bytes);
	} else if (ShortValue.class.isAssignableFrom(cls)) {
		return (ValueArray<T>) new ShortValueArray(bytes);
	} else if (StringValue.class.isAssignableFrom(cls)) {
		return (ValueArray<T>) new StringValueArray(bytes);
	} else {
		throw new IllegalArgumentException("Unable to create bounded ValueArray for type " + cls);
	}
}
 
Example 11
Source Project: flink   Source File: ValueArrayTypeInfo.java    License: Apache License 2.0 5 votes vote down vote up
@Override
@SuppressWarnings("unchecked")
public TypeSerializer<ValueArray<T>> createSerializer(ExecutionConfig executionConfig) {
	Preconditions.checkNotNull(type, "TypeInformation type class is required");

	if (ByteValue.class.isAssignableFrom(type)) {
		return (TypeSerializer<ValueArray<T>>) (TypeSerializer<?>) new ByteValueArraySerializer();
	} else if (CharValue.class.isAssignableFrom(type)) {
		return (TypeSerializer<ValueArray<T>>) (TypeSerializer<?>) new CharValueArraySerializer();
	} else if (DoubleValue.class.isAssignableFrom(type)) {
		return (TypeSerializer<ValueArray<T>>) (TypeSerializer<?>) new DoubleValueArraySerializer();
	} else if (FloatValue.class.isAssignableFrom(type)) {
		return (TypeSerializer<ValueArray<T>>) (TypeSerializer<?>) new FloatValueArraySerializer();
	} else if (IntValue.class.isAssignableFrom(type)) {
		return (TypeSerializer<ValueArray<T>>) (TypeSerializer<?>) new IntValueArraySerializer();
	} else if (LongValue.class.isAssignableFrom(type)) {
		return (TypeSerializer<ValueArray<T>>) (TypeSerializer<?>) new LongValueArraySerializer();
	} else if (NullValue.class.isAssignableFrom(type)) {
		return (TypeSerializer<ValueArray<T>>) (TypeSerializer<?>) new NullValueArraySerializer();
	} else if (ShortValue.class.isAssignableFrom(type)) {
		return (TypeSerializer<ValueArray<T>>) (TypeSerializer<?>) new ShortValueArraySerializer();
	} else if (StringValue.class.isAssignableFrom(type)) {
		return (TypeSerializer<ValueArray<T>>) (TypeSerializer<?>) new StringValueArraySerializer();
	} else {
		throw new InvalidTypesException("No ValueArray class exists for " + type);
	}
}
 
Example 12
Source Project: flink   Source File: CharValueArrayComparatorTest.java    License: Apache License 2.0 5 votes vote down vote up
@Override
protected CharValueArray[] getSortedTestData() {
	CharValueArray lva0 = new CharValueArray();

	CharValueArray lva1 = new CharValueArray();
	lva1.add(new CharValue((char) 5));

	CharValueArray lva2 = new CharValueArray();
	lva2.add(new CharValue((char) 5));
	lva2.add(new CharValue((char) 10));

	return new CharValueArray[]{ lva0, lva1 };
}
 
Example 13
Source Project: flink   Source File: CharValueSerializerTest.java    License: Apache License 2.0 5 votes vote down vote up
@Override
protected CharValue[] getTestData() {
	Random rnd = new Random(874597969123412341L);
	int rndInt = rnd.nextInt((int) Character.MAX_VALUE);
	
	return new CharValue[] {new CharValue('a'), new CharValue('@'), new CharValue('ä'),
							new CharValue('1'), new CharValue((char) rndInt),
							new CharValue(Character.MAX_VALUE), new CharValue(Character.MIN_VALUE)};
}
 
Example 14
Source Project: flink   Source File: GraphKeyTypeTransformTest.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void testToCharValue() throws Exception {
	TranslateFunction<LongValue, CharValue> translator = new LongValueToCharValue();

	Assert.assertEquals(new CharValue((char) 0),
		translator.translate(new LongValue(0L), charValue));

	Assert.assertEquals(new CharValue(Character.MAX_VALUE),
		translator.translate(new LongValue(LongValueToCharValue.MAX_VERTEX_COUNT - 1), charValue));
}
 
Example 15
Source Project: Flink-CEPplus   Source File: CharValueSerializerTest.java    License: Apache License 2.0 5 votes vote down vote up
@Override
protected CharValue[] getTestData() {
	Random rnd = new Random(874597969123412341L);
	int rndInt = rnd.nextInt((int) Character.MAX_VALUE);
	
	return new CharValue[] {new CharValue('a'), new CharValue('@'), new CharValue('ä'),
							new CharValue('1'), new CharValue((char) rndInt),
							new CharValue(Character.MAX_VALUE), new CharValue(Character.MIN_VALUE)};
}
 
Example 16
Source Project: Flink-CEPplus   Source File: GraphKeyTypeTransformTest.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void testToCharValue() throws Exception {
	TranslateFunction<LongValue, CharValue> translator = new LongValueToCharValue();

	Assert.assertEquals(new CharValue((char) 0),
		translator.translate(new LongValue(0L), charValue));

	Assert.assertEquals(new CharValue(Character.MAX_VALUE),
		translator.translate(new LongValue(LongValueToCharValue.MAX_VERTEX_COUNT - 1), charValue));
}
 
Example 17
Source Project: Flink-CEPplus   Source File: ValueArrayTypeInfo.java    License: Apache License 2.0 5 votes vote down vote up
@Override
@SuppressWarnings("unchecked")
public TypeSerializer<ValueArray<T>> createSerializer(ExecutionConfig executionConfig) {
	Preconditions.checkNotNull(type, "TypeInformation type class is required");

	if (ByteValue.class.isAssignableFrom(type)) {
		return (TypeSerializer<ValueArray<T>>) (TypeSerializer<?>) new ByteValueArraySerializer();
	} else if (CharValue.class.isAssignableFrom(type)) {
		return (TypeSerializer<ValueArray<T>>) (TypeSerializer<?>) new CharValueArraySerializer();
	} else if (DoubleValue.class.isAssignableFrom(type)) {
		return (TypeSerializer<ValueArray<T>>) (TypeSerializer<?>) new DoubleValueArraySerializer();
	} else if (FloatValue.class.isAssignableFrom(type)) {
		return (TypeSerializer<ValueArray<T>>) (TypeSerializer<?>) new FloatValueArraySerializer();
	} else if (IntValue.class.isAssignableFrom(type)) {
		return (TypeSerializer<ValueArray<T>>) (TypeSerializer<?>) new IntValueArraySerializer();
	} else if (LongValue.class.isAssignableFrom(type)) {
		return (TypeSerializer<ValueArray<T>>) (TypeSerializer<?>) new LongValueArraySerializer();
	} else if (NullValue.class.isAssignableFrom(type)) {
		return (TypeSerializer<ValueArray<T>>) (TypeSerializer<?>) new NullValueArraySerializer();
	} else if (ShortValue.class.isAssignableFrom(type)) {
		return (TypeSerializer<ValueArray<T>>) (TypeSerializer<?>) new ShortValueArraySerializer();
	} else if (StringValue.class.isAssignableFrom(type)) {
		return (TypeSerializer<ValueArray<T>>) (TypeSerializer<?>) new StringValueArraySerializer();
	} else {
		throw new InvalidTypesException("No ValueArray class exists for " + type);
	}
}
 
Example 18
Source Project: Flink-CEPplus   Source File: ValueArrayTypeInfo.java    License: Apache License 2.0 5 votes vote down vote up
@SuppressWarnings({ "unchecked", "rawtypes" })
@Override
public TypeComparator<ValueArray<T>> createComparator(boolean sortOrderAscending, ExecutionConfig executionConfig) {
	Preconditions.checkNotNull(type, "TypeInformation type class is required");

	if (ByteValue.class.isAssignableFrom(type)) {
		return (TypeComparator<ValueArray<T>>) (TypeComparator<?>) new ByteValueArrayComparator(sortOrderAscending);
	} else if (CharValue.class.isAssignableFrom(type)) {
		return (TypeComparator<ValueArray<T>>) (TypeComparator<?>) new CharValueArrayComparator(sortOrderAscending);
	} else if (DoubleValue.class.isAssignableFrom(type)) {
		return (TypeComparator<ValueArray<T>>) (TypeComparator<?>) new DoubleValueArrayComparator(sortOrderAscending);
	} else if (FloatValue.class.isAssignableFrom(type)) {
		return (TypeComparator<ValueArray<T>>) (TypeComparator<?>) new FloatValueArrayComparator(sortOrderAscending);
	} else if (IntValue.class.isAssignableFrom(type)) {
		return (TypeComparator<ValueArray<T>>) (TypeComparator<?>) new IntValueArrayComparator(sortOrderAscending);
	} else if (LongValue.class.isAssignableFrom(type)) {
		return (TypeComparator<ValueArray<T>>) (TypeComparator<?>) new LongValueArrayComparator(sortOrderAscending);
	} else if (NullValue.class.isAssignableFrom(type)) {
		return (TypeComparator<ValueArray<T>>) (TypeComparator<?>) new NullValueArrayComparator(sortOrderAscending);
	} else if (ShortValue.class.isAssignableFrom(type)) {
		return (TypeComparator<ValueArray<T>>) (TypeComparator<?>) new ShortValueArrayComparator(sortOrderAscending);
	} else if (StringValue.class.isAssignableFrom(type)) {
		return (TypeComparator<ValueArray<T>>) (TypeComparator<?>) new StringValueArrayComparator(sortOrderAscending);
	} else {
		throw new InvalidTypesException("No ValueArray class exists for " + type);
	}
}
 
Example 19
Source Project: flink   Source File: ValueArraySerializerUpgradeTest.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public CharValueArray createTestData() {
	CharValueArray array = new CharValueArray(128);
	array.add(new CharValue((char) 23));
	array.add(new CharValue((char) 34));
	array.add(new CharValue((char) 45));
	return array;
}
 
Example 20
Source Project: Flink-CEPplus   Source File: CharValueArray.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public int compareTo(ValueArray<CharValue> o) {
	CharValueArray other = (CharValueArray) o;

	int min = Math.min(position, other.position);
	for (int i = 0; i < min; i++) {
		int cmp = Character.compare(data[i], other.data[i]);

		if (cmp != 0) {
			return cmp;
		}
	}

	return Integer.compare(position, other.position);
}
 
Example 21
@Override
protected CharValueArray[] getSortedTestData() {
	CharValueArray lva0 = new CharValueArray();

	CharValueArray lva1 = new CharValueArray();
	lva1.add(new CharValue((char) 5));

	CharValueArray lva2 = new CharValueArray();
	lva2.add(new CharValue((char) 5));
	lva2.add(new CharValue((char) 10));

	return new CharValueArray[]{ lva0, lva1 };
}
 
Example 22
Source Project: flink   Source File: CharValueArray.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public int compareTo(ValueArray<CharValue> o) {
	CharValueArray other = (CharValueArray) o;

	int min = Math.min(position, other.position);
	for (int i = 0; i < min; i++) {
		int cmp = Character.compare(data[i], other.data[i]);

		if (cmp != 0) {
			return cmp;
		}
	}

	return Integer.compare(position, other.position);
}
 
Example 23
Source Project: flink   Source File: CharValueSerializerTest.java    License: Apache License 2.0 5 votes vote down vote up
@Override
protected CharValue[] getTestData() {
	Random rnd = new Random(874597969123412341L);
	int rndInt = rnd.nextInt((int) Character.MAX_VALUE);
	
	return new CharValue[] {new CharValue('a'), new CharValue('@'), new CharValue('ä'),
							new CharValue('1'), new CharValue((char) rndInt),
							new CharValue(Character.MAX_VALUE), new CharValue(Character.MIN_VALUE)};
}
 
Example 24
Source Project: flink   Source File: GraphKeyTypeTransformTest.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void testToCharValue() throws Exception {
	TranslateFunction<LongValue, CharValue> translator = new LongValueToCharValue();

	Assert.assertEquals(new CharValue((char) 0),
		translator.translate(new LongValue(0L), charValue));

	Assert.assertEquals(new CharValue(Character.MAX_VALUE),
		translator.translate(new LongValue(LongValueToCharValue.MAX_VERTEX_COUNT - 1), charValue));
}
 
Example 25
Source Project: flink   Source File: ValueArrayTypeInfo.java    License: Apache License 2.0 5 votes vote down vote up
@Override
@SuppressWarnings("unchecked")
public TypeSerializer<ValueArray<T>> createSerializer(ExecutionConfig executionConfig) {
	Preconditions.checkNotNull(type, "TypeInformation type class is required");

	if (ByteValue.class.isAssignableFrom(type)) {
		return (TypeSerializer<ValueArray<T>>) (TypeSerializer<?>) new ByteValueArraySerializer();
	} else if (CharValue.class.isAssignableFrom(type)) {
		return (TypeSerializer<ValueArray<T>>) (TypeSerializer<?>) new CharValueArraySerializer();
	} else if (DoubleValue.class.isAssignableFrom(type)) {
		return (TypeSerializer<ValueArray<T>>) (TypeSerializer<?>) new DoubleValueArraySerializer();
	} else if (FloatValue.class.isAssignableFrom(type)) {
		return (TypeSerializer<ValueArray<T>>) (TypeSerializer<?>) new FloatValueArraySerializer();
	} else if (IntValue.class.isAssignableFrom(type)) {
		return (TypeSerializer<ValueArray<T>>) (TypeSerializer<?>) new IntValueArraySerializer();
	} else if (LongValue.class.isAssignableFrom(type)) {
		return (TypeSerializer<ValueArray<T>>) (TypeSerializer<?>) new LongValueArraySerializer();
	} else if (NullValue.class.isAssignableFrom(type)) {
		return (TypeSerializer<ValueArray<T>>) (TypeSerializer<?>) new NullValueArraySerializer();
	} else if (ShortValue.class.isAssignableFrom(type)) {
		return (TypeSerializer<ValueArray<T>>) (TypeSerializer<?>) new ShortValueArraySerializer();
	} else if (StringValue.class.isAssignableFrom(type)) {
		return (TypeSerializer<ValueArray<T>>) (TypeSerializer<?>) new StringValueArraySerializer();
	} else {
		throw new InvalidTypesException("No ValueArray class exists for " + type);
	}
}
 
Example 26
Source Project: flink   Source File: CharValueArrayComparatorTest.java    License: Apache License 2.0 5 votes vote down vote up
@Override
protected CharValueArray[] getSortedTestData() {
	CharValueArray lva0 = new CharValueArray();

	CharValueArray lva1 = new CharValueArray();
	lva1.add(new CharValue((char) 5));

	CharValueArray lva2 = new CharValueArray();
	lva2.add(new CharValue((char) 5));
	lva2.add(new CharValue((char) 10));

	return new CharValueArray[]{ lva0, lva1 };
}
 
Example 27
Source Project: flink   Source File: CharValueArray.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public int compareTo(ValueArray<CharValue> o) {
	CharValueArray other = (CharValueArray) o;

	int min = Math.min(position, other.position);
	for (int i = 0; i < min; i++) {
		int cmp = Character.compare(data[i], other.data[i]);

		if (cmp != 0) {
			return cmp;
		}
	}

	return Integer.compare(position, other.position);
}
 
Example 28
Source Project: Flink-CEPplus   Source File: CSVReaderTest.java    License: Apache License 2.0 4 votes vote down vote up
@Test(expected = IllegalArgumentException.class)
public void testWithInvalidValueType1() throws Exception {
	CsvReader reader = getCsvReader();
	// CsvReader doesn't support CharValue
	reader.types(CharValue.class);
}
 
Example 29
Source Project: flink   Source File: CharValueSerializer.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public void serialize(CharValue record, DataOutputView target) throws IOException {
	record.write(target);
}
 
Example 30
Source Project: Flink-CEPplus   Source File: ValueTypeInfo.java    License: Apache License 2.0 4 votes vote down vote up
@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);
	}
}