org.apache.flink.annotation.Internal Java Examples
The following examples show how to use
org.apache.flink.annotation.Internal.
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: GroupReduceOperator.java From Flink-CEPplus with Apache License 2.0 | 6 votes |
@Override @Internal public SingleInputSemanticProperties getSemanticProperties() { SingleInputSemanticProperties props = super.getSemanticProperties(); // offset semantic information by extracted key fields if (props != null && this.grouper != null && this.grouper.keys instanceof SelectorFunctionKeys) { int offset = ((SelectorFunctionKeys<?, ?>) this.grouper.keys).getKeyType().getTotalFields(); if (this.grouper instanceof SortedGrouping) { offset += ((SortedGrouping<?>) this.grouper).getSortSelectionFunctionKey().getKeyType().getTotalFields(); } props = SemanticPropUtil.addSourceFieldOffset(props, this.getInputType().getTotalFields(), offset); } return props; }
Example #2
Source File: ReduceOperator.java From Flink-CEPplus with Apache License 2.0 | 6 votes |
@Override @Internal public SingleInputSemanticProperties getSemanticProperties() { SingleInputSemanticProperties props = super.getSemanticProperties(); // offset semantic information by extracted key fields if (props != null && this.grouper != null && this.grouper.keys instanceof SelectorFunctionKeys) { int offset = ((SelectorFunctionKeys<?, ?>) this.grouper.keys).getKeyType().getTotalFields(); if (this.grouper instanceof SortedGrouping) { offset += ((SortedGrouping<?>) this.grouper).getSortSelectionFunctionKey().getKeyType().getTotalFields(); } props = SemanticPropUtil.addSourceFieldOffset(props, this.getInputType().getTotalFields(), offset); } return props; }
Example #3
Source File: ReduceOperator.java From flink with Apache License 2.0 | 6 votes |
@Override @Internal public SingleInputSemanticProperties getSemanticProperties() { SingleInputSemanticProperties props = super.getSemanticProperties(); // offset semantic information by extracted key fields if (props != null && this.grouper != null && this.grouper.keys instanceof SelectorFunctionKeys) { int offset = ((SelectorFunctionKeys<?, ?>) this.grouper.keys).getKeyType().getTotalFields(); if (this.grouper instanceof SortedGrouping) { offset += ((SortedGrouping<?>) this.grouper).getSortSelectionFunctionKey().getKeyType().getTotalFields(); } props = SemanticPropUtil.addSourceFieldOffset(props, this.getInputType().getTotalFields(), offset); } return props; }
Example #4
Source File: GroupCombineOperator.java From Flink-CEPplus with Apache License 2.0 | 6 votes |
@Override @Internal public SingleInputSemanticProperties getSemanticProperties() { SingleInputSemanticProperties props = super.getSemanticProperties(); // offset semantic information by extracted key fields if (props != null && this.grouper != null && this.grouper.keys instanceof SelectorFunctionKeys) { int offset = ((SelectorFunctionKeys<?, ?>) this.grouper.keys).getKeyType().getTotalFields(); if (this.grouper instanceof SortedGrouping) { offset += ((SortedGrouping<?>) this.grouper).getSortSelectionFunctionKey().getKeyType().getTotalFields(); } props = SemanticPropUtil.addSourceFieldOffset(props, this.getInputType().getTotalFields(), offset); } return props; }
Example #5
Source File: FunctionAnnotation.java From Flink-CEPplus with Apache License 2.0 | 6 votes |
/** * Reads the annotations of a user defined function with one input and returns semantic properties according to the forwarded fields annotated. * * @param udfClass The user defined function, represented by its class. * @return The DualInputSemanticProperties containing the forwarded fields. */ @Internal public static Set<Annotation> readSingleForwardAnnotations(Class<?> udfClass) { ForwardedFields forwardedFields = udfClass.getAnnotation(ForwardedFields.class); NonForwardedFields nonForwardedFields = udfClass.getAnnotation(NonForwardedFields.class); ReadFields readSet = udfClass.getAnnotation(ReadFields.class); Set<Annotation> annotations = new HashSet<Annotation>(); if (forwardedFields != null) { annotations.add(forwardedFields); } if (nonForwardedFields != null) { if (!annotations.isEmpty()) { throw new InvalidProgramException("Either " + ForwardedFields.class.getSimpleName() + " or " + NonForwardedFields.class.getSimpleName() + " can be annotated to a function, not both."); } annotations.add(nonForwardedFields); } if (readSet != null) { annotations.add(readSet); } return !annotations.isEmpty() ? annotations : null; }
Example #6
Source File: TypeExtractor.java From Flink-CEPplus with Apache License 2.0 | 6 votes |
/** * Returns the type information factory for a type using the factory registry or annotations. */ @Internal public static <OUT> TypeInfoFactory<OUT> getTypeInfoFactory(Type t) { final Class<?> factoryClass; if (registeredTypeInfoFactories.containsKey(t)) { factoryClass = registeredTypeInfoFactories.get(t); } else { if (!isClassType(t) || !typeToClass(t).isAnnotationPresent(TypeInfo.class)) { return null; } final TypeInfo typeInfoAnnotation = typeToClass(t).getAnnotation(TypeInfo.class); factoryClass = typeInfoAnnotation.value(); // check for valid factory class if (!TypeInfoFactory.class.isAssignableFrom(factoryClass)) { throw new InvalidTypesException("TypeInfo annotation does not specify a valid TypeInfoFactory."); } } // instantiate return (TypeInfoFactory<OUT>) InstantiationUtil.instantiate(factoryClass); }
Example #7
Source File: TypeExtractor.java From flink with Apache License 2.0 | 6 votes |
/** * Returns the type information factory for a type using the factory registry or annotations. */ @Internal public static <OUT> TypeInfoFactory<OUT> getTypeInfoFactory(Type t) { final Class<?> factoryClass; if (registeredTypeInfoFactories.containsKey(t)) { factoryClass = registeredTypeInfoFactories.get(t); } else { if (!isClassType(t) || !typeToClass(t).isAnnotationPresent(TypeInfo.class)) { return null; } final TypeInfo typeInfoAnnotation = typeToClass(t).getAnnotation(TypeInfo.class); factoryClass = typeInfoAnnotation.value(); // check for valid factory class if (!TypeInfoFactory.class.isAssignableFrom(factoryClass)) { throw new InvalidTypesException("TypeInfo annotation does not specify a valid TypeInfoFactory."); } } // instantiate return (TypeInfoFactory<OUT>) InstantiationUtil.instantiate(factoryClass); }
Example #8
Source File: FunctionAnnotation.java From flink with Apache License 2.0 | 6 votes |
/** * Reads the annotations of a user defined function with one input and returns semantic properties according to the forwarded fields annotated. * * @param udfClass The user defined function, represented by its class. * @return The DualInputSemanticProperties containing the forwarded fields. */ @Internal public static Set<Annotation> readSingleForwardAnnotations(Class<?> udfClass) { ForwardedFields forwardedFields = udfClass.getAnnotation(ForwardedFields.class); NonForwardedFields nonForwardedFields = udfClass.getAnnotation(NonForwardedFields.class); ReadFields readSet = udfClass.getAnnotation(ReadFields.class); Set<Annotation> annotations = new HashSet<Annotation>(); if (forwardedFields != null) { annotations.add(forwardedFields); } if (nonForwardedFields != null) { if (!annotations.isEmpty()) { throw new InvalidProgramException("Either " + ForwardedFields.class.getSimpleName() + " or " + NonForwardedFields.class.getSimpleName() + " can be annotated to a function, not both."); } annotations.add(nonForwardedFields); } if (readSet != null) { annotations.add(readSet); } return !annotations.isEmpty() ? annotations : null; }
Example #9
Source File: AvroSerializer.java From Flink-CEPplus with Apache License 2.0 | 5 votes |
/** * Creates a new AvroSerializer for the type indicated by the given class. */ @Internal AvroSerializer(Class<T> type, SerializableAvroSchema newSchema, SerializableAvroSchema previousSchema) { this.type = checkNotNull(type); this.schema = checkNotNull(newSchema); this.previousSchema = checkNotNull(previousSchema); }
Example #10
Source File: SingleInputUdfOperator.java From flink with Apache License 2.0 | 5 votes |
@Override @Internal public Map<String, DataSet<?>> getBroadcastSets() { return this.broadcastVariables == null ? Collections.<String, DataSet<?>>emptyMap() : Collections.unmodifiableMap(this.broadcastVariables); }
Example #11
Source File: SingleInputUdfOperator.java From Flink-CEPplus with Apache License 2.0 | 5 votes |
@Override @Internal public SingleInputSemanticProperties getSemanticProperties() { if (this.udfSemantics == null || analyzedUdfSemantics) { SingleInputSemanticProperties props = extractSemanticAnnotations(getFunction().getClass()); if (props != null) { setSemanticProperties(props); } } if (this.udfSemantics == null) { setSemanticProperties(new SingleInputSemanticProperties()); } return this.udfSemantics; }
Example #12
Source File: TwoInputUdfOperator.java From Flink-CEPplus with Apache License 2.0 | 5 votes |
@Override @Internal public Map<String, DataSet<?>> getBroadcastSets() { return this.broadcastVariables == null ? Collections.<String, DataSet<?>>emptyMap() : Collections.unmodifiableMap(this.broadcastVariables); }
Example #13
Source File: AvroSerializer.java From flink with Apache License 2.0 | 5 votes |
/** * Creates a new AvroSerializer for the type indicated by the given class. */ @Internal AvroSerializer(Class<T> type, SerializableAvroSchema newSchema, SerializableAvroSchema previousSchema) { this.type = checkNotNull(type); this.schema = checkNotNull(newSchema); this.previousSchema = checkNotNull(previousSchema); }
Example #14
Source File: FileSystemSafetyNet.java From Flink-CEPplus with Apache License 2.0 | 5 votes |
/** * Activates the safety net for a thread. {@link FileSystem} instances obtained by the thread * that called this method will be guarded, meaning that their created streams are tracked and can * be closed via the safety net closing hook. * * <p>This method should be called at the beginning of a thread that should be guarded. * * @throws IllegalStateException Thrown, if a safety net was already registered for the thread. */ @Internal public static void initializeSafetyNetForThread() { SafetyNetCloseableRegistry oldRegistry = REGISTRIES.get(); checkState(null == oldRegistry, "Found an existing FileSystem safety net for this thread: %s " + "This may indicate an accidental repeated initialization, or a leak of the" + "(Inheritable)ThreadLocal through a ThreadPool.", oldRegistry); SafetyNetCloseableRegistry newRegistry = new SafetyNetCloseableRegistry(); REGISTRIES.set(newRegistry); }
Example #15
Source File: FileSystemSafetyNet.java From Flink-CEPplus with Apache License 2.0 | 5 votes |
/** * Closes the safety net for a thread. This closes all remaining unclosed streams that were opened * by safety-net-guarded file systems. After this method was called, no streams can be opened any more * from any FileSystem instance that was obtained while the thread was guarded by the safety net. * * <p>This method should be called at the very end of a guarded thread. */ @Internal public static void closeSafetyNetAndGuardedResourcesForThread() { SafetyNetCloseableRegistry registry = REGISTRIES.get(); if (null != registry) { REGISTRIES.remove(); IOUtils.closeQuietly(registry); } }
Example #16
Source File: TwoInputUdfOperator.java From flink with Apache License 2.0 | 5 votes |
@Override @Internal public DualInputSemanticProperties getSemanticProperties() { if (this.udfSemantics == null || analyzedUdfSemantics) { DualInputSemanticProperties props = extractSemanticAnnotationsFromUdf(getFunction().getClass()); if (props != null) { setSemanticProperties(props); } } if (this.udfSemantics == null) { setSemanticProperties(new DualInputSemanticProperties()); } return this.udfSemantics; }
Example #17
Source File: FileSystemSafetyNet.java From flink with Apache License 2.0 | 5 votes |
/** * Closes the safety net for a thread. This closes all remaining unclosed streams that were opened * by safety-net-guarded file systems. After this method was called, no streams can be opened any more * from any FileSystem instance that was obtained while the thread was guarded by the safety net. * * <p>This method should be called at the very end of a guarded thread. */ @Internal public static void closeSafetyNetAndGuardedResourcesForThread() { SafetyNetCloseableRegistry registry = REGISTRIES.get(); if (null != registry) { REGISTRIES.remove(); IOUtils.closeQuietly(registry); } }
Example #18
Source File: StreamExecutionEnvironment.java From Flink-CEPplus with Apache License 2.0 | 5 votes |
/** * Getter of the {@link org.apache.flink.streaming.api.graph.StreamGraph} of the streaming job. * * @return The streamgraph representing the transformations */ @Internal public StreamGraph getStreamGraph() { if (transformations.size() <= 0) { throw new IllegalStateException("No operators defined in streaming topology. Cannot execute."); } return StreamGraphGenerator.generate(this, transformations); }
Example #19
Source File: StreamExecutionEnvironment.java From Flink-CEPplus with Apache License 2.0 | 5 votes |
/** * Returns a "closure-cleaned" version of the given function. Cleans only if closure cleaning * is not disabled in the {@link org.apache.flink.api.common.ExecutionConfig} */ @Internal public <F> F clean(F f) { if (getConfig().isClosureCleanerEnabled()) { ClosureCleaner.clean(f, getConfig().getClosureCleanerLevel(), true); } ClosureCleaner.ensureSerializable(f); return f; }
Example #20
Source File: ZonedTimestampType.java From flink with Apache License 2.0 | 5 votes |
/** * Internal constructor that allows attaching additional metadata about time attribute * properties. The additional metadata does not affect equality or serializability. * * <p>Use {@link #getKind()} for comparing this metadata. */ @Internal public ZonedTimestampType(boolean isNullable, TimestampKind kind, int precision) { super(isNullable, LogicalTypeRoot.TIMESTAMP_WITH_TIME_ZONE); if (precision < MIN_PRECISION || precision > MAX_PRECISION) { throw new ValidationException( String.format( "Timestamp with time zone precision must be between %d and %d (both inclusive).", MIN_PRECISION, MAX_PRECISION)); } this.kind = kind; this.precision = precision; }
Example #21
Source File: LocalZonedTimestampType.java From flink with Apache License 2.0 | 5 votes |
/** * Internal constructor that allows attaching additional metadata about time attribute * properties. The additional metadata does not affect equality or serializability. * * <p>Use {@link #getKind()} for comparing this metadata. */ @Internal public LocalZonedTimestampType(boolean isNullable, TimestampKind kind, int precision) { super(isNullable, LogicalTypeRoot.TIMESTAMP_WITH_LOCAL_TIME_ZONE); if (precision < MIN_PRECISION || precision > MAX_PRECISION) { throw new ValidationException( String.format( "Timestamp with local time zone precision must be between %d and %d (both inclusive).", MIN_PRECISION, MAX_PRECISION)); } this.kind = kind; this.precision = precision; }
Example #22
Source File: EnvironmentSettings.java From flink with Apache License 2.0 | 5 votes |
@Internal public Map<String, String> toPlannerProperties() { Map<String, String> properties = new HashMap<>(toCommonProperties()); if (plannerClass != null) { properties.put(CLASS_NAME, plannerClass); } return properties; }
Example #23
Source File: EnvironmentSettings.java From flink with Apache License 2.0 | 5 votes |
@Internal public Map<String, String> toExecutorProperties() { Map<String, String> properties = new HashMap<>(toCommonProperties()); if (executorClass != null) { properties.put(CLASS_NAME, executorClass); } return properties; }
Example #24
Source File: ExecutionConfig.java From flink with Apache License 2.0 | 4 votes |
@Override @Internal public ArchivedExecutionConfig archive() { return new ArchivedExecutionConfig(this); }
Example #25
Source File: TypeSerializerConfigSnapshot.java From flink with Apache License 2.0 | 4 votes |
/** * Set the originating serializer of this configuration snapshot. */ @Internal public final void setPriorSerializer(TypeSerializer<T> serializer) { this.serializer = Preconditions.checkNotNull(serializer); }
Example #26
Source File: Grouping.java From Flink-CEPplus with Apache License 2.0 | 4 votes |
@Internal public Keys<T> getKeys() { return this.keys; }
Example #27
Source File: GroupReduceOperator.java From Flink-CEPplus with Apache License 2.0 | 4 votes |
@Internal public boolean isCombinable() { return combinable; }
Example #28
Source File: StreamTableEnvironmentImpl.java From flink with Apache License 2.0 | 4 votes |
/** * This is a temporary workaround for Python API. Python API should not use StreamExecutionEnvironment at all. */ @Internal public StreamExecutionEnvironment execEnv() { return executionEnvironment; }
Example #29
Source File: CoGroupOperator.java From Flink-CEPplus with Apache License 2.0 | 4 votes |
@Internal protected Keys<I2> getKeys2() { return this.keys2; }
Example #30
Source File: DataSink.java From Flink-CEPplus with Apache License 2.0 | 4 votes |
@Internal public TypeInformation<T> getType() { return type; }