Java Code Examples for org.apache.flink.core.memory.DataInputView#readByte()
The following examples show how to use
org.apache.flink.core.memory.DataInputView#readByte() .
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: StateTableByKeyGroupReaders.java From flink with Apache License 2.0 | 6 votes |
@Override public void readMappingsInKeyGroup(@Nonnull DataInputView inView, @Nonnegative int keyGroupId) throws IOException { if (inView.readByte() == 0) { return; } final TypeSerializer<N> namespaceSerializer = stateTable.getNamespaceSerializer(); final TypeSerializer<S> stateSerializer = stateTable.getStateSerializer(); // V1 uses kind of namespace compressing format int numNamespaces = inView.readInt(); for (int k = 0; k < numNamespaces; k++) { N namespace = namespaceSerializer.deserialize(inView); int numEntries = inView.readInt(); for (int l = 0; l < numEntries; l++) { K key = keySerializer.deserialize(inView); S state = stateSerializer.deserialize(inView); stateTable.put(key, keyGroupId, namespace, state); } } }
Example 2
Source File: StringValueArrayComparator.java From flink with Apache License 2.0 | 6 votes |
/** * Read the next character from the serialized {@code StringValue}. * * @param source the input view containing the record * @return the next {@code char} of the current serialized {@code StringValue} * @throws IOException if the input view raised an exception when reading the length */ private static char readStringChar(DataInputView source) throws IOException { int c = source.readByte() & 0xFF; if (c >= HIGH_BIT) { int shift = 7; int curr; c = c & 0x7F; while ((curr = source.readByte() & 0xFF) >= HIGH_BIT) { c |= (curr & 0x7F) << shift; shift += 7; } c |= curr << shift; } return (char) c; }
Example 3
Source File: ExternalSortLargeRecordsITCase.java From Flink-CEPplus with Apache License 2.0 | 5 votes |
@Override public void read(DataInputView in) throws IOException { val = in.readInt(); isLong = in.readBoolean(); if (isLong) { for (int i = 0; i < BUFFER.length; i++) { byte b = in.readByte(); assertEquals(BUFFER[i], b); } } }
Example 4
Source File: ByteComparator.java From Flink-CEPplus with Apache License 2.0 | 5 votes |
@Override public int compareSerialized(DataInputView firstSource, DataInputView secondSource) throws IOException { byte b1 = firstSource.readByte(); byte b2 = secondSource.readByte(); int comp = (b1 < b2 ? -1 : (b1 == b2 ? 0 : 1)); return ascendingComparison ? comp : -comp; }
Example 5
Source File: LargeRecordHandlerITCase.java From Flink-CEPplus with Apache License 2.0 | 5 votes |
@Override public void read(DataInputView in) throws IOException { val = in.readInt(); for (byte bufferByte : BUFFER) { byte b = in.readByte(); assertEquals(bufferByte, b); } }
Example 6
Source File: LegacyStateMetaInfoReaders.java From flink with Apache License 2.0 | 5 votes |
@Nonnull @Override public StateMetaInfoSnapshot readStateMetaInfoSnapshot( @Nonnull DataInputView in, @Nonnull ClassLoader userCodeClassLoader) throws IOException { final String name = in.readUTF(); final OperatorStateHandle.Mode mode = OperatorStateHandle.Mode.values()[in.readByte()]; final Map<String, String> optionsMap = Collections.singletonMap( StateMetaInfoSnapshot.CommonOptionsKeys.OPERATOR_STATE_DISTRIBUTION_MODE.toString(), mode.toString()); DataInputViewStream dis = new DataInputViewStream(in); ClassLoader previousClassLoader = Thread.currentThread().getContextClassLoader(); try ( InstantiationUtil.FailureTolerantObjectInputStream ois = new InstantiationUtil.FailureTolerantObjectInputStream(dis, userCodeClassLoader)) { Thread.currentThread().setContextClassLoader(userCodeClassLoader); TypeSerializer<?> stateSerializer = (TypeSerializer<?>) ois.readObject(); return new StateMetaInfoSnapshot( name, StateMetaInfoSnapshot.BackendStateType.OPERATOR, optionsMap, Collections.singletonMap( StateMetaInfoSnapshot.CommonSerializerKeys.VALUE_SERIALIZER.toString(), new BackwardsCompatibleSerializerSnapshot<>(stateSerializer))); } catch (ClassNotFoundException exception) { throw new IOException(exception); } finally { Thread.currentThread().setContextClassLoader(previousClassLoader); } }
Example 7
Source File: ByteComparator.java From flink with Apache License 2.0 | 5 votes |
@Override public int compareSerialized(DataInputView firstSource, DataInputView secondSource) throws IOException { byte b1 = firstSource.readByte(); byte b2 = secondSource.readByte(); int comp = (b1 < b2 ? -1 : (b1 == b2 ? 0 : 1)); return ascendingComparison ? comp : -comp; }
Example 8
Source File: NodeId.java From flink with Apache License 2.0 | 5 votes |
@Override public NodeId deserialize(DataInputView source) throws IOException { byte b = source.readByte(); if (b == 0) { return null; } EventId eventId = eventIdSerializer.deserialize(source); String pageName = StringValue.readString(source); return new NodeId(eventId, pageName); }
Example 9
Source File: StateBackendMigrationTestBase.java From Flink-CEPplus with Apache License 2.0 | 4 votes |
@Override public VoidNamespace deserialize(DataInputView source) throws IOException { source.readByte(); return VoidNamespace.get(); }
Example 10
Source File: VoidNamespaceSerializer.java From Flink-CEPplus with Apache License 2.0 | 4 votes |
@Override public VoidNamespace deserialize(VoidNamespace reuse, DataInputView source) throws IOException { source.readByte(); return VoidNamespace.get(); }
Example 11
Source File: VoidNamespaceSerializer.java From flink with Apache License 2.0 | 4 votes |
@Override public VoidNamespace deserialize(VoidNamespace reuse, DataInputView source) throws IOException { source.readByte(); return VoidNamespace.get(); }
Example 12
Source File: VoidCoderTypeSerializer.java From flink-dataflow with Apache License 2.0 | 4 votes |
@Override public void copy(DataInputView source, DataOutputView target) throws IOException { source.readByte(); target.writeByte(1); }
Example 13
Source File: GlobalWindow.java From Flink-CEPplus with Apache License 2.0 | 4 votes |
@Override public GlobalWindow deserialize(GlobalWindow reuse, DataInputView source) throws IOException { source.readByte(); return GlobalWindow.INSTANCE; }
Example 14
Source File: Tuple0Serializer.java From Flink-CEPplus with Apache License 2.0 | 4 votes |
@Override public Tuple0 deserialize(DataInputView source) throws IOException { source.readByte(); return Tuple0.INSTANCE; }
Example 15
Source File: LegacyStateMetaInfoReaders.java From flink with Apache License 2.0 | 4 votes |
@Nonnull @Override public StateMetaInfoSnapshot readStateMetaInfoSnapshot( @Nonnull DataInputView in, @Nonnull ClassLoader userCodeClassLoader) throws IOException { final String name = in.readUTF(); final OperatorStateHandle.Mode mode = OperatorStateHandle.Mode.values()[in.readByte()]; Map<String, String> optionsMap = Collections.singletonMap( StateMetaInfoSnapshot.CommonOptionsKeys.OPERATOR_STATE_DISTRIBUTION_MODE.toString(), mode.toString()); List<Tuple2<TypeSerializer<?>, TypeSerializerSnapshot<?>>> stateSerializerAndConfigList = TypeSerializerSerializationUtil.readSerializersAndConfigsWithResilience(in, userCodeClassLoader); final int listSize = stateSerializerAndConfigList.size(); StateMetaInfoSnapshot.BackendStateType stateType = listSize == 1 ? StateMetaInfoSnapshot.BackendStateType.OPERATOR : StateMetaInfoSnapshot.BackendStateType.BROADCAST; Map<String, TypeSerializerSnapshot<?>> serializerConfigsMap = new HashMap<>(listSize); switch (stateType) { case OPERATOR: serializerConfigsMap.put( StateMetaInfoSnapshot.CommonSerializerKeys.VALUE_SERIALIZER.toString(), stateSerializerAndConfigList.get(0).f1); break; case BROADCAST: serializerConfigsMap.put( StateMetaInfoSnapshot.CommonSerializerKeys.KEY_SERIALIZER.toString(), stateSerializerAndConfigList.get(0).f1); serializerConfigsMap.put( StateMetaInfoSnapshot.CommonSerializerKeys.VALUE_SERIALIZER.toString(), stateSerializerAndConfigList.get(1).f1); break; default: throw new IllegalStateException("Unknown operator state type " + stateType); } return new StateMetaInfoSnapshot( name, stateType, optionsMap, serializerConfigsMap); }
Example 16
Source File: ByteValue.java From Flink-CEPplus with Apache License 2.0 | 4 votes |
@Override public void read(DataInputView in) throws IOException { this.value = in.readByte(); }
Example 17
Source File: VoidNamespaceSerializer.java From flink with Apache License 2.0 | 4 votes |
@Override public VoidNamespace deserialize(DataInputView source) throws IOException { source.readByte(); return VoidNamespace.get(); }
Example 18
Source File: LegacyStateMetaInfoReaders.java From flink with Apache License 2.0 | 4 votes |
@Nonnull @Override public StateMetaInfoSnapshot readStateMetaInfoSnapshot( @Nonnull DataInputView in, @Nonnull ClassLoader userCodeClassLoader) throws IOException { final String name = in.readUTF(); final OperatorStateHandle.Mode mode = OperatorStateHandle.Mode.values()[in.readByte()]; Map<String, String> optionsMap = Collections.singletonMap( StateMetaInfoSnapshot.CommonOptionsKeys.OPERATOR_STATE_DISTRIBUTION_MODE.toString(), mode.toString()); List<Tuple2<TypeSerializer<?>, TypeSerializerSnapshot<?>>> stateSerializerAndConfigList = TypeSerializerSerializationUtil.readSerializersAndConfigsWithResilience(in, userCodeClassLoader); final int listSize = stateSerializerAndConfigList.size(); StateMetaInfoSnapshot.BackendStateType stateType = listSize == 1 ? StateMetaInfoSnapshot.BackendStateType.OPERATOR : StateMetaInfoSnapshot.BackendStateType.BROADCAST; Map<String, TypeSerializerSnapshot<?>> serializerConfigsMap = new HashMap<>(listSize); switch (stateType) { case OPERATOR: serializerConfigsMap.put( StateMetaInfoSnapshot.CommonSerializerKeys.VALUE_SERIALIZER.toString(), stateSerializerAndConfigList.get(0).f1); break; case BROADCAST: serializerConfigsMap.put( StateMetaInfoSnapshot.CommonSerializerKeys.KEY_SERIALIZER.toString(), stateSerializerAndConfigList.get(0).f1); serializerConfigsMap.put( StateMetaInfoSnapshot.CommonSerializerKeys.VALUE_SERIALIZER.toString(), stateSerializerAndConfigList.get(1).f1); break; default: throw new IllegalStateException("Unknown operator state type " + stateType); } return new StateMetaInfoSnapshot( name, stateType, optionsMap, serializerConfigsMap); }
Example 19
Source File: StateBackendMigrationTestBase.java From Flink-CEPplus with Apache License 2.0 | 4 votes |
@Override public VoidNamespace deserialize(VoidNamespace reuse, DataInputView source) throws IOException { source.readByte(); return VoidNamespace.get(); }
Example 20
Source File: ByteType.java From flink with Apache License 2.0 | 4 votes |
@Override public void read(DataInputView in) throws IOException { this.value = in.readByte(); }