org.apache.flink.types.CharValue Java Examples

The following examples show how to use org.apache.flink.types.CharValue. 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: ValueArrayFactory.java    From flink with 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 File: ValueArrayFactory.java    From flink with 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 File: CharValueArray.java    From Flink-CEPplus with 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 File: CharValueArray.java    From Flink-CEPplus with 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 File: ValueArrayFactory.java    From Flink-CEPplus with 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 File: ValueArrayFactory.java    From Flink-CEPplus with 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 File: ValueArrayFactory.java    From flink with 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 #8
Source File: CharValueArray.java    From flink with 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 File: CharValueArray.java    From flink with 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 #10
Source File: ValueArrayFactory.java    From flink with 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 #11
Source File: GraphKeyTypeTransformTest.java    From flink with 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 #12
Source File: CharValueArrayComparatorTest.java    From flink with 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 File: GraphKeyTypeTransformTest.java    From flink with 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 #14
Source File: CharValueSerializerTest.java    From flink with 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 #15
Source File: ValueArrayTypeInfo.java    From flink with 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 #16
Source File: CharValueSerializerTest.java    From Flink-CEPplus with 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 #17
Source File: GraphKeyTypeTransformTest.java    From Flink-CEPplus with 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 #18
Source File: ValueArrayTypeInfo.java    From Flink-CEPplus with 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 #19
Source File: ValueArrayTypeInfo.java    From Flink-CEPplus with 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 #20
Source File: ValueArraySerializerUpgradeTest.java    From flink with 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 #21
Source File: CharValueArray.java    From Flink-CEPplus with 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 #22
Source File: CharValueArrayComparatorTest.java    From Flink-CEPplus with 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 #23
Source File: CharValueArray.java    From flink with 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 #24
Source File: CharValueArrayComparatorTest.java    From flink with 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 #25
Source File: ValueArrayTypeInfo.java    From flink with 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 File: CharValueArray.java    From flink with 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 #27
Source File: CharValueSerializerTest.java    From flink with 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 #28
Source File: CharValueComparator.java    From Flink-CEPplus with Apache License 2.0 4 votes vote down vote up
@Override
public boolean supportsNormalizedKey() {
	return NormalizableKey.class.isAssignableFrom(CharValue.class);
}
 
Example #29
Source File: CharValueComparator.java    From flink with Apache License 2.0 4 votes vote down vote up
@Override
public void writeWithKeyNormalization(CharValue record, DataOutputView target) throws IOException {
	throw new UnsupportedOperationException();
}
 
Example #30
Source File: ValueTypeInfo.java    From flink with Apache License 2.0 4 votes vote down vote up
@Override
@SuppressWarnings("unchecked")
@PublicEvolving
public TypeSerializer<T> createSerializer(ExecutionConfig executionConfig) {
	if (BooleanValue.class.isAssignableFrom(type)) {
		return (TypeSerializer<T>) BooleanValueSerializer.INSTANCE;
	}
	else if (ByteValue.class.isAssignableFrom(type)) {
		return (TypeSerializer<T>) ByteValueSerializer.INSTANCE;
	}
	else if (CharValue.class.isAssignableFrom(type)) {
		return (TypeSerializer<T>) CharValueSerializer.INSTANCE;
	}
	else if (DoubleValue.class.isAssignableFrom(type)) {
		return (TypeSerializer<T>) DoubleValueSerializer.INSTANCE;
	}
	else if (FloatValue.class.isAssignableFrom(type)) {
		return (TypeSerializer<T>) FloatValueSerializer.INSTANCE;
	}
	else if (IntValue.class.isAssignableFrom(type)) {
		return (TypeSerializer<T>) IntValueSerializer.INSTANCE;
	}
	else if (LongValue.class.isAssignableFrom(type)) {
		return (TypeSerializer<T>) LongValueSerializer.INSTANCE;
	}
	else if (NullValue.class.isAssignableFrom(type)) {
		return (TypeSerializer<T>) NullValueSerializer.INSTANCE;
	}
	else if (ShortValue.class.isAssignableFrom(type)) {
		return (TypeSerializer<T>) ShortValueSerializer.INSTANCE;
	}
	else if (StringValue.class.isAssignableFrom(type)) {
		return (TypeSerializer<T>) StringValueSerializer.INSTANCE;
	}
	else if (CopyableValue.class.isAssignableFrom(type)) {
		return (TypeSerializer<T>) createCopyableValueSerializer(type.asSubclass(CopyableValue.class));
	}
	else {
		return new ValueSerializer<T>(type);
	}
}