private ObjectMapper objectMapper() { if (this.objectMapper == null) { synchronized (this) { if (this.objectMapper == null) { this.objectMapper = newObjectMapperWith(RowJsonDeserializer.forSchema(this.schema)); } } } return this.objectMapper; } }
/** * Discovers all shards of this file. * * <p>Because of eventual consistency, reads may discover no files or fewer files than the shard * template implies. In this case, the read is considered to have failed. */ public List<String> readFilesWithRetries() throws IOException, InterruptedException { return readFilesWithRetries(Sleeper.DEFAULT, BACK_OFF_FACTORY.backoff()); }
/** * Discovers all shards of this file. * * <p>Because of eventual consistency, reads may discover no files or fewer files than the shard * template implies. In this case, the read is considered to have failed. */ public List<String> readFilesWithRetries() throws IOException, InterruptedException { return readFilesWithRetries(Sleeper.DEFAULT, BACK_OFF_FACTORY.backoff()); }
private static BackOff createBackOff() { return BackOffAdapter.toGcpBackOff(BACKOFF_FACTORY.backoff()); } /**
/** * Encodes the given value using the specified Coder, and returns the encoded bytes. * * <p>This function is not reentrant; it should not be called from methods of the provided {@link * Coder}. */ public static <T> byte[] encodeToByteArray(Coder<T> coder, T value) throws CoderException { return encodeToByteArray(coder, value, Coder.Context.OUTER); }
/** Discovers all shards of this file. */ public List<String> readFilesWithRetries() throws IOException, InterruptedException { return readFilesWithRetries(Sleeper.DEFAULT, BACK_OFF_FACTORY.backoff()); }
/** Decodes the given bytes using the specified Coder, and returns the resulting decoded value. */ public static <T> T decodeFromByteArray(Coder<T> coder, byte[] encodedValue) throws CoderException { return decodeFromByteArray(coder, encodedValue, Coder.Context.OUTER); }
public static <K, InputT, AccumT, OutputT> AppliedCombineFn<K, InputT, AccumT, OutputT> withAccumulatorCoder( GlobalCombineFn<? super InputT, AccumT, OutputT> fn, Coder<AccumT> accumCoder, Iterable<PCollectionView<?>> sideInputViews, KvCoder<K, InputT> kvCoder, WindowingStrategy<?, ?> windowingStrategy) { // Casting down the K and InputT is safe because they're only used as inputs. @SuppressWarnings("unchecked") GlobalCombineFn<InputT, AccumT, OutputT> clonedFn = (GlobalCombineFn<InputT, AccumT, OutputT>) SerializableUtils.clone(fn); return create(clonedFn, accumCoder, sideInputViews, kvCoder, windowingStrategy); }
/** * Returns the partial application of the {@link CombineFnWithContext} to a specific context to * produce a {@link CombineFn}. * * <p>The returned {@link CombineFn} cannot be serialized. */ public static <K, InputT, AccumT, OutputT> CombineFn<InputT, AccumT, OutputT> bindContext( CombineFnWithContext<InputT, AccumT, OutputT> combineFn, StateContext<?> stateContext) { Context context = CombineContextFactory.createFromStateContext(stateContext); return new NonSerializableBoundedCombineFn<>(combineFn, context); }
/** * Extracts string value from the JsonNode if it is within bounds. * * <p>Throws {@link UnsupportedRowJsonException} if value is out of bounds. */ static ValueExtractor<String> stringValueExtractor() { return ValidatingValueExtractor.<String>builder() .setExtractor(JsonNode::textValue) .setValidator(JsonNode::isTextual) .build(); }
/** * Causes the currently executing thread to sleep (temporarily cease execution) for the specified * number of milliseconds. The thread does not lose ownership of any monitors. */ public static void sleepMillis(long millis) throws InterruptedException { INSTANCE.sleep(millis); } }
@Override protected boolean matchesSafely( final ApiSurface apiSurface, final Description mismatchDescription) { final boolean noDisallowed = verifyNoDisallowed(apiSurface, classMatchers, mismatchDescription); final boolean noAbandoned = verifyNoAbandoned(apiSurface, classMatchers, mismatchDescription); return noDisallowed && noAbandoned; }
private BucketingFunction newFunc() { return new BucketingFunction( BUCKET_WIDTH, SIGNIFICANT_BUCKETS, SIGNIFICANT_SAMPLES, SUM); }
private static <K, InputT, AccumT, OutputT> AppliedCombineFn<K, InputT, AccumT, OutputT> create( GlobalCombineFn<InputT, AccumT, OutputT> fn, Coder<AccumT> accumulatorCoder, Iterable<PCollectionView<?>> sideInputViews, KvCoder<K, InputT> kvCoder, WindowingStrategy<?, ?> windowingStrategy) { return new AppliedCombineFn<>(fn, accumulatorCoder, sideInputViews, kvCoder, windowingStrategy); }
/** * Returns a {@code WindowedValue} with the given value in the {@link GlobalWindow} using the * default timestamp and the specified pane. */ public static <T> WindowedValue<T> valueInGlobalWindow(T value, PaneInfo pane) { return new ValueInGlobalWindow<>(value, pane); }
@Override public void verifyDeterministic() throws NonDeterministicException { verifyDeterministic( this, "FullWindowedValueCoder requires a deterministic valueCoder", valueCoder); verifyDeterministic( this, "FullWindowedValueCoder requires a deterministic windowCoder", windowCoder); }
public static UserCodeException wrap(Throwable t) { if (t instanceof UserCodeException) { return (UserCodeException) t; } return new UserCodeException(t); }
/** * Extracts boolean value from JsonNode if it is within bounds. * * <p>Throws {@link UnsupportedRowJsonException} if value is out of bounds. */ static ValueExtractor<Boolean> booleanValueExtractor() { return ValidatingValueExtractor.<Boolean>builder() .setExtractor(JsonNode::booleanValue) .setValidator(JsonNode::isBoolean) .build(); }