當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。