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


Java KeyGroupRange类代码示例

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


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

示例1: createStateInternals

import org.apache.flink.runtime.state.KeyGroupRange; //导入依赖的package包/类
@Override
protected StateInternals createStateInternals() {
  MemoryStateBackend backend = new MemoryStateBackend();
  try {
    AbstractKeyedStateBackend<ByteBuffer> keyedStateBackend = backend.createKeyedStateBackend(
        new DummyEnvironment("test", 1, 0),
        new JobID(),
        "test_op",
        new GenericTypeInfo<>(ByteBuffer.class).createSerializer(new ExecutionConfig()),
        1,
        new KeyGroupRange(0, 0),
        new KvStateRegistry().createTaskRegistry(new JobID(), new JobVertexID()));

    keyedStateBackend.setCurrentKey(
        ByteBuffer.wrap(CoderUtils.encodeToByteArray(StringUtf8Coder.of(), "Hello")));

    return new FlinkStateInternals<>(keyedStateBackend, StringUtf8Coder.of());
  } catch (Exception e) {
    throw new RuntimeException(e);
  }
}
 
开发者ID:apache,项目名称:beam,代码行数:22,代码来源:FlinkStateInternalsTest.java

示例2: getKeyedStateBackend

import org.apache.flink.runtime.state.KeyGroupRange; //导入依赖的package包/类
private static KeyedStateBackend<ByteBuffer> getKeyedStateBackend(int numberOfKeyGroups,
                                                 KeyGroupRange keyGroupRange) {
  MemoryStateBackend backend = new MemoryStateBackend();
  try {
    AbstractKeyedStateBackend<ByteBuffer> keyedStateBackend = backend.createKeyedStateBackend(
        new DummyEnvironment("test", 1, 0),
        new JobID(),
        "test_op",
        new GenericTypeInfo<>(ByteBuffer.class).createSerializer(new ExecutionConfig()),
        numberOfKeyGroups,
        keyGroupRange,
        new KvStateRegistry().createTaskRegistry(new JobID(), new JobVertexID()));
    keyedStateBackend.setCurrentKey(ByteBuffer.wrap(
        CoderUtils.encodeToByteArray(StringUtf8Coder.of(), "1")));
    return keyedStateBackend;
  } catch (Exception e) {
    throw new RuntimeException(e);
  }
}
 
开发者ID:apache,项目名称:beam,代码行数:20,代码来源:FlinkKeyGroupStateInternalsTest.java

示例3: RocksDBIncrementalKeyedStateHandle

import org.apache.flink.runtime.state.KeyGroupRange; //导入依赖的package包/类
RocksDBIncrementalKeyedStateHandle(
		JobID jobId,
		String operatorIdentifier,
		KeyGroupRange keyGroupRange,
		long checkpointId,
		Map<String, StreamStateHandle> newSstFiles,
		Map<String, StreamStateHandle> oldSstFiles,
		Map<String, StreamStateHandle> miscFiles,
		StreamStateHandle metaStateHandle) {

	this.jobId = Preconditions.checkNotNull(jobId);
	this.operatorIdentifier = Preconditions.checkNotNull(operatorIdentifier);
	this.keyGroupRange = Preconditions.checkNotNull(keyGroupRange);
	this.checkpointId = checkpointId;
	this.newSstFiles = Preconditions.checkNotNull(newSstFiles);
	this.oldSstFiles = Preconditions.checkNotNull(oldSstFiles);
	this.miscFiles = Preconditions.checkNotNull(miscFiles);
	this.metaStateHandle = Preconditions.checkNotNull(metaStateHandle);
	this.registered = false;
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:21,代码来源:RocksDBIncrementalKeyedStateHandle.java

示例4: RocksDBKeyedStateBackend2

import org.apache.flink.runtime.state.KeyGroupRange; //导入依赖的package包/类
RocksDBKeyedStateBackend2(
		final String operatorIdentifier,
		final ClassLoader userCodeClassLoader,
		final File instanceBasePath,
		final DBOptions dbOptions,
		final ColumnFamilyOptions columnFamilyOptions,
		final TaskKvStateRegistry kvStateRegistry,
		final TypeSerializer<K> keySerializer,
		final int numberOfKeyGroups,
		final KeyGroupRange keyGroupRange,
		final ExecutionConfig executionConfig) throws Exception {

	super(operatorIdentifier, userCodeClassLoader,
		instanceBasePath,
		dbOptions, columnFamilyOptions, kvStateRegistry, keySerializer,
		numberOfKeyGroups, keyGroupRange, executionConfig, false);
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:18,代码来源:KVStateRequestSerializerRocksDBTest.java

示例5: deserializeKeyedStateHandle

import org.apache.flink.runtime.state.KeyGroupRange; //导入依赖的package包/类
@VisibleForTesting
public static KeyedStateHandle deserializeKeyedStateHandle(DataInputStream dis) throws IOException {
	final int type = dis.readByte();
	if (NULL_HANDLE == type) {
		return null;
	} else if (KEY_GROUPS_HANDLE == type) {
		int startKeyGroup = dis.readInt();
		int numKeyGroups = dis.readInt();
		KeyGroupRange keyGroupRange = KeyGroupRange.of(startKeyGroup, startKeyGroup + numKeyGroups - 1);
		long[] offsets = new long[numKeyGroups];
		for (int i = 0; i < numKeyGroups; ++i) {
			offsets[i] = dis.readLong();
		}
		KeyGroupRangeOffsets keyGroupRangeOffsets = new KeyGroupRangeOffsets(
			keyGroupRange, offsets);
		StreamStateHandle stateHandle = deserializeStreamStateHandle(dis);
		return new KeyGroupsStateHandle(keyGroupRangeOffsets, stateHandle);
	} else {
		throw new IllegalStateException("Reading invalid KeyedStateHandle, type: " + type);
	}
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:22,代码来源:SavepointV1Serializer.java

示例6: getRawKeyedStateHandles

import org.apache.flink.runtime.state.KeyGroupRange; //导入依赖的package包/类
/**
 * Collect {@link KeyGroupsStateHandle  rawKeyedStateHandles} which have intersection with given
 * {@link KeyGroupRange} from {@link TaskState operatorState}
 *
 * @param operatorState        all state handles of a operator
 * @param subtaskKeyGroupRange the KeyGroupRange of a subtask
 * @return all rawKeyedStateHandles which have intersection with given KeyGroupRange
 */
public static List<KeyedStateHandle> getRawKeyedStateHandles(
	OperatorState operatorState,
	KeyGroupRange subtaskKeyGroupRange) {

	List<KeyedStateHandle> extractedKeyedStateHandles = new ArrayList<>();

	for (int i = 0; i < operatorState.getParallelism(); i++) {
		if (operatorState.getState(i) != null) {
			Collection<KeyedStateHandle> rawKeyedState = operatorState.getState(i).getRawKeyedState();
			extractIntersectingState(
				rawKeyedState,
				subtaskKeyGroupRange,
				extractedKeyedStateHandles);
		}
	}

	return extractedKeyedStateHandles;
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:27,代码来源:StateAssignmentOperation.java

示例7: extractIntersectingState

import org.apache.flink.runtime.state.KeyGroupRange; //导入依赖的package包/类
/**
 * Extracts certain key group ranges from the given state handles and adds them to the collector.
 */
private static void extractIntersectingState(
	Collection<KeyedStateHandle> originalSubtaskStateHandles,
	KeyGroupRange rangeToExtract,
	List<KeyedStateHandle> extractedStateCollector) {

	for (KeyedStateHandle keyedStateHandle : originalSubtaskStateHandles) {

		if (keyedStateHandle != null) {

			KeyedStateHandle intersectedKeyedStateHandle = keyedStateHandle.getIntersection(rangeToExtract);

			if (intersectedKeyedStateHandle != null) {
				extractedStateCollector.add(intersectedKeyedStateHandle);
			}
		}
	}
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:21,代码来源:StateAssignmentOperation.java

示例8: getKeyedStateHandles

import org.apache.flink.runtime.state.KeyGroupRange; //导入依赖的package包/类
/**
 * Determine the subset of {@link KeyGroupsStateHandle KeyGroupsStateHandles} with correct
 * key group index for the given subtask {@link KeyGroupRange}.
 * <p>
 * <p>This is publicly visible to be used in tests.
 */
public static List<KeyedStateHandle> getKeyedStateHandles(
	Collection<? extends KeyedStateHandle> keyedStateHandles,
	KeyGroupRange subtaskKeyGroupRange) {

	List<KeyedStateHandle> subtaskKeyedStateHandles = new ArrayList<>();

	for (KeyedStateHandle keyedStateHandle : keyedStateHandles) {
		KeyedStateHandle intersectedKeyedStateHandle = keyedStateHandle.getIntersection(subtaskKeyGroupRange);

		if (intersectedKeyedStateHandle != null) {
			subtaskKeyedStateHandles.add(intersectedKeyedStateHandle);
		}
	}

	return subtaskKeyedStateHandles;
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:23,代码来源:StateAssignmentOperation.java

示例9: notifyKvStateRegistered

import org.apache.flink.runtime.state.KeyGroupRange; //导入依赖的package包/类
@Override
public void notifyKvStateRegistered(
	JobID jobId,
	JobVertexID jobVertexId,
	KeyGroupRange keyGroupRange,
	String registrationName,
	KvStateID kvStateId) {

	Object msg = new KvStateMessage.NotifyKvStateRegistered(
		jobId,
		jobVertexId,
		keyGroupRange,
		registrationName,
		kvStateId,
		kvStateServerAddress);

	jobManager.tell(msg);
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:19,代码来源:ActorGatewayKvStateRegistryListener.java

示例10: registerKvState

import org.apache.flink.runtime.state.KeyGroupRange; //导入依赖的package包/类
/**
 * Registers a KvState instance for the given key group index.
 *
 * @param keyGroupRange  Key group range to register
 * @param kvStateId      ID of the KvState instance at the key group index.
 * @param kvStateAddress Server address of the KvState instance at the key group index.
 * @throws IndexOutOfBoundsException If key group range start < 0 or key group range end >= Number of key groups
 */
public void registerKvState(KeyGroupRange keyGroupRange, KvStateID kvStateId, InetSocketAddress kvStateAddress) {

	if (keyGroupRange.getStartKeyGroup() < 0 || keyGroupRange.getEndKeyGroup() >= numKeyGroups) {
		throw new IndexOutOfBoundsException("Key group index");
	}

	for (int kgIdx = keyGroupRange.getStartKeyGroup(); kgIdx <= keyGroupRange.getEndKeyGroup(); ++kgIdx) {

		if (kvStateIds[kgIdx] == null && kvStateAddresses[kgIdx] == null) {
			numRegisteredKeyGroups++;
		}

		kvStateIds[kgIdx] = kvStateId;
		kvStateAddresses[kgIdx] = kvStateAddress;
	}
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:25,代码来源:KvStateLocation.java

示例11: unregisterKvState

import org.apache.flink.runtime.state.KeyGroupRange; //导入依赖的package包/类
/**
 * Registers a KvState instance for the given key group index.
 *
 * @param keyGroupRange Key group range to unregister.
 * @throws IndexOutOfBoundsException If key group range start < 0 or key group range end >= Number of key groups
 * @throws IllegalArgumentException  If no location information registered for a key group index in the range.
 */
void unregisterKvState(KeyGroupRange keyGroupRange) {
	if (keyGroupRange.getStartKeyGroup() < 0 || keyGroupRange.getEndKeyGroup() >= numKeyGroups) {
		throw new IndexOutOfBoundsException("Key group index");
	}

	for (int kgIdx = keyGroupRange.getStartKeyGroup(); kgIdx <= keyGroupRange.getEndKeyGroup(); ++kgIdx) {
		if (kvStateIds[kgIdx] == null || kvStateAddresses[kgIdx] == null) {
			throw new IllegalArgumentException("Not registered. Probably registration/unregistration race.");
		}

		numRegisteredKeyGroups--;

		kvStateIds[kgIdx] = null;
		kvStateAddresses[kgIdx] = null;
	}
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:24,代码来源:KvStateLocation.java

示例12: NotifyKvStateRegistered

import org.apache.flink.runtime.state.KeyGroupRange; //导入依赖的package包/类
/**
 * Notifies the JobManager about a registered {@link InternalKvState} instance.
 *
 * @param jobId                JobID the KvState instance belongs to
 * @param jobVertexId          JobVertexID the KvState instance belongs to
 * @param keyGroupRange        Key group range the KvState instance belongs to
 * @param registrationName     Name under which the KvState has been registered
 * @param kvStateId            ID of the registered KvState instance
 * @param kvStateServerAddress Server address where to find the KvState instance
 */
public NotifyKvStateRegistered(
		JobID jobId,
		JobVertexID jobVertexId,
		KeyGroupRange keyGroupRange,
		String registrationName,
		KvStateID kvStateId,
		InetSocketAddress kvStateServerAddress) {

	this.jobId = Preconditions.checkNotNull(jobId, "JobID");
	this.jobVertexId = Preconditions.checkNotNull(jobVertexId, "JobVertexID");
	Preconditions.checkArgument(keyGroupRange != KeyGroupRange.EMPTY_KEY_GROUP_RANGE);
	this.keyGroupRange = Preconditions.checkNotNull(keyGroupRange);
	this.registrationName = Preconditions.checkNotNull(registrationName, "Registration name");
	this.kvStateId = Preconditions.checkNotNull(kvStateId, "KvStateID");
	this.kvStateServerAddress = Preconditions.checkNotNull(kvStateServerAddress, "ServerAddress");
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:27,代码来源:KvStateMessage.java

示例13: unregisterKvState

import org.apache.flink.runtime.state.KeyGroupRange; //导入依赖的package包/类
/**
 * Unregisters the KvState instance identified by the given KvStateID.
 *
 * @param jobId     JobId the KvState instance belongs to
 * @param kvStateId KvStateID to identify the KvState instance
 * @param keyGroupRange    Key group range the KvState instance belongs to
 */
public void unregisterKvState(
		JobID jobId,
		JobVertexID jobVertexId,
		KeyGroupRange keyGroupRange,
		String registrationName,
		KvStateID kvStateId) {

	if (registeredKvStates.remove(kvStateId) != null) {
		final KvStateRegistryListener listener = listenerRef.get();
		if (listener != null) {
			listener.notifyKvStateUnregistered(
					jobId,
					jobVertexId,
					keyGroupRange,
					registrationName);
		}
	}
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:26,代码来源:KvStateRegistry.java

示例14: notifyKvStateUnregistered

import org.apache.flink.runtime.state.KeyGroupRange; //导入依赖的package包/类
/**
 * Notifies the registry about an unregistered KvState instance.
 *
 * @param jobVertexId JobVertexID the KvState instance belongs to
 * @param keyGroupRange Key group index the KvState instance belongs to
 * @param registrationName Name under which the KvState has been registered
 * @throws IllegalArgumentException If another operator registered the state instance
 * @throws IllegalArgumentException If the registration name is not known
 */
public void notifyKvStateUnregistered(
		JobVertexID jobVertexId,
		KeyGroupRange keyGroupRange,
		String registrationName) {

	KvStateLocation location = lookupTable.get(registrationName);

	if (location != null) {
		// Duplicate name if vertex IDs don't match
		if (!location.getJobVertexId().equals(jobVertexId)) {
			throw new IllegalArgumentException("Another operator (" +
					location.getJobVertexId() + ") registered the KvState " +
					"under '" + registrationName + "'.");
		}

		location.unregisterKvState(keyGroupRange);

		if (location.getNumRegisteredKeyGroups() == 0) {
			lookupTable.remove(registrationName);
		}
	} else {
		throw new IllegalArgumentException("Unknown registration name '" +
				registrationName + "'. " + "Probably registration/unregistration race.");
	}
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:35,代码来源:KvStateLocationRegistry.java

示例15: notifyKvStateRegistered

import org.apache.flink.runtime.state.KeyGroupRange; //导入依赖的package包/类
@Override
public void notifyKvStateRegistered(
		final JobVertexID jobVertexId,
		final KeyGroupRange keyGroupRange,
		final String registrationName,
		final KvStateID kvStateId,
		final InetSocketAddress kvStateServerAddress) {
	if (log.isDebugEnabled()) {
		log.debug("Key value state registered for job {} under name {}.",
				jobGraph.getJobID(), registrationName);
	}

	try {
		executionGraph.getKvStateLocationRegistry().notifyKvStateRegistered(
				jobVertexId, keyGroupRange, registrationName, kvStateId, kvStateServerAddress);
	} catch (Exception e) {
		log.error("Failed to notify KvStateRegistry about registration {}.", registrationName);
	}
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:20,代码来源:JobMaster.java


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