name
stringlengths
12
178
code_snippet
stringlengths
8
36.5k
score
float64
3.26
3.68
hudi_HoodieLogFileReader_prev_rdh
/** * This is a reverse iterator Note: At any point, an instance of HoodieLogFileReader should either iterate reverse * (prev) or forward (next). Doing both in the same instance is not supported WARNING : Every call to prev() should be * preceded with hasPrev() */ @Override public HoodieLogBlock prev() throws IOExc...
3.26
hudi_Types_isTighterThan_rdh
/** * Returns whether this DecimalType is tighter than `other`. If yes, it means `this` * can be casted into `other` safely without losing any precision or range. */ public boolean isTighterThan(PrimitiveType other) { if (other instanceof DecimalType) { DecimalType dt = ((DecimalType) (other)); r...
3.26
hudi_Types_get_rdh
// Experimental method to support defaultValue public static Field get(int id, boolean isOptional, String name, Type type, String doc, Object defaultValue) { return new Field(isOptional, id, name, type, doc, defaultValue); }
3.26
hudi_Types_fieldByName_rdh
/** * Case-sensitive get field by name */ public Field fieldByName(String name) { if (nameToFields == null) { nameToFields = Arrays.stream(fields).collect(Collectors.toMap(Field::name, field -> field)); } return nameToFields.get(name); }
3.26
hudi_Types_isWiderThan_rdh
/** * Returns whether this DecimalType is wider than `other`. If yes, it means `other` * can be casted into `this` safely without losing any precision or range. */ public boolean isWiderThan(PrimitiveType other) { if (other instanceof DecimalType) { DecimalType dt = ((DecimalType) (other)); retur...
3.26
hudi_SqlQueryPreCommitValidator_validateRecordsBeforeAndAfter_rdh
/** * Takes input datasets 1) before commit started and 2) with inflight commit. Perform required validation * and throw error if validation fails */ @Override public void validateRecordsBeforeAndAfter(Dataset<Row> before, Dataset<Row> after, final Set<String> partitionsAffected) { String hoodieTableName = "sta...
3.26
hudi_SafeParquetRecordReaderWrapper_createValue_rdh
/** * We could be in concurrent fetch and read env. We need to ensure new ArrayWritable as ParquetReader implementation * reuses same ArrayWritable for all reads which will cause corruption when buffering. So, we create a new * ArrayWritable here with Value class from parquetReader's value and an empty array. */ @O...
3.26
hudi_HoodieSimpleBucketLayout_determinesNumFileGroups_rdh
/** * Bucketing controls the number of file groups directly. */ @Override public boolean determinesNumFileGroups() { return true; }
3.26
hudi_ByteBufferBackedInputStream_getPosition_rdh
/** * Returns current position of the stream */ public int getPosition() { return buffer.position() - bufferOffset; }
3.26
hudi_ByteBufferBackedInputStream_m0_rdh
/** * Copies at most {@code length} bytes starting from position {@code pos} into the target * buffer with provided {@code offset}. Returns number of bytes copied from the backing buffer * * NOTE: This does not change the current position of the stream and is thread-safe * * @param pos * absolute position w/in...
3.26
hudi_ByteBufferBackedInputStream_seek_rdh
/** * Seeks to a position w/in the stream * * NOTE: Position is relative to the start of the stream (ie its absolute w/in this stream), * with following invariant being assumed: * <p>0 <= pos <= length (of the stream)</p> * * This method is NOT thread-safe * * @param pos * target position to seek to w/in th...
3.26
hudi_HoodieConsistentBucketLayout_determinesNumFileGroups_rdh
/** * Bucketing controls the number of file groups directly. */ @Override public boolean determinesNumFileGroups() { return true; }
3.26
hudi_HoodieConsistentBucketLayout_layoutPartitionerClass_rdh
/** * Consistent hashing will tag all incoming records, so we could go ahead reusing an existing Partitioner */ @Override public Option<String> layoutPartitionerClass() { return Option.empty(); }
3.26
hudi_TypeUtils_getValueToEnumMap_rdh
/** * Maps values from the provided Enum's {@link Class} into corresponding values, * extracted by provided {@code valueMapper} */ public static <EnumT extends Enum<EnumT>> Map<String, EnumT> getValueToEnumMap(@Nonnull Class<EnumT> klass, @Nonnull Function<EnumT, String> valueMapper) { return Arrays.stream(klas...
3.26
hudi_TypeUtils_unsafeCast_rdh
/** * This utility abstracts unsafe type-casting in a way that allows to * <ul> * <li>Search for such type-casts more easily (just searching for usages of this method)</li> * <li>Avoid type-cast warnings from the compiler</li> * </ul> */ @SuppressWarnings("unchecked") public static <T> T unsafeCast(Object o) ...
3.26
hudi_QuickstartConfigurations_sql_rdh
/** * Creates the tool to build hoodie table DDL. */ public static Sql sql(String tableName) { return new Sql(tableName); }
3.26
hudi_ConfigProperty_key_rdh
/** * Create a OptionBuilder with key. * * @param key * The key of the option * @return Return a OptionBuilder. */ public static PropertyBuilder key(String key) { Objects.requireNonNull(key); return new PropertyBuilder(key); }
3.26
hudi_ConfigProperty_markAdvanced_rdh
/** * Marks the config as an advanced config. */ public ConfigProperty<T> markAdvanced() { return new ConfigProperty<>(key, defaultValue, docOnDefaultValue, doc, sinceVersion, deprecatedVersion, inferFunction, validValues, true, alternatives); }
3.26
hudi_HoodieSparkKeyGeneratorFactory_getKeyGeneratorClassNameFromType_rdh
/** * * @param type * {@link KeyGeneratorType} enum. * @return The key generator class name for Spark based on the {@link KeyGeneratorType}. */ public static String getKeyGeneratorClassNameFromType(KeyGeneratorType type) { switch (type) { case SIMPLE : return SimpleKeyGenerator.class....
3.26
hudi_HoodieSparkKeyGeneratorFactory_getKeyGenerator_rdh
/** * Instantiate {@link BuiltinKeyGenerator}. * * @param properties * properties map. * @return the key generator thus instantiated. */ public static Option<BuiltinKeyGenerator> getKeyGenerator(Properties properties) { TypedProperties typedProperties = new TypedProperties(); typedProperties.putAll(pr...
3.26
hudi_HoodieSparkKeyGeneratorFactory_inferKeyGeneratorTypeFromWriteConfig_rdh
/** * Infers the key generator type based on the record key and partition fields. * If neither of the record key and partition fields are set, the default type is returned. * * @param props * Properties from the write config. * @return Inferred key generator type. */ public static KeyGeneratorType inferKeyGene...
3.26
hudi_HoodieSparkKeyGeneratorFactory_convertToSparkKeyGenerator_rdh
/** * Convert hoodie-common KeyGenerator to SparkKeyGeneratorInterface implement. */ public static String convertToSparkKeyGenerator(String keyGeneratorClassName) { return COMMON_TO_SPARK_KEYGENERATOR.getOrDefault(keyGeneratorClassName, keyGeneratorClassName); }
3.26
hudi_BucketStreamWriteFunction_m0_rdh
/** * Determine whether the current fileID belongs to the current task. * (partition + curBucket) % numPartitions == this taskID belongs to this task. */ public boolean m0(int bucketNumber, String partition) { final int partitionIndex = (partition.hashCode() & Integer.MAX_VALUE) % parallelism; int globalInd...
3.26
hudi_BucketStreamWriteFunction_bootstrapIndexIfNeed_rdh
/** * Get partition_bucket -> fileID mapping from the existing hudi table. * This is a required operation for each restart to avoid having duplicate file ids for one bucket. */ private void bootstrapIndexIfNeed(String partition) { if (OptionsResolver.isInsertOverwr...
3.26
hudi_ExpressionEvaluators_getInLiteralVals_rdh
// ------------------------------------------------------------------------- // Utilities // ------------------------------------------------------------------------- /** * Returns the IN expression literal values. */ private static Object[] getInLiteralVals(List<Expression> childExprs) { List<Object> vals = new ...
3.26
hudi_ExpressionEvaluators_fromExpression_rdh
/** * Converts specific call expression to the evaluator. * <p>Two steps to bind the call: * 1. map the evaluator instance; * 2. bind the field reference; * * <p>Normalize the expression to simplify the subsequent decision logic: * always put the literal expression in the RHS. */ public static Evaluator fromExp...
3.26
hudi_RollbackUtils_getRollbackPlan_rdh
/** * Get Latest version of Rollback plan corresponding to a clean instant. * * @param metaClient * Hoodie Table Meta Client * @param rollbackInstant * Instant referring to rollback action * @return Rollback plan corresponding to rollback instant * @throws IOException */ public static HoodieRollbackPlan ge...
3.26
hudi_TransactionUtils_getInflightAndRequestedInstants_rdh
/** * Get InflightAndRequest instants. * * @param metaClient * @return */ public static Set<String> getInflightAndRequestedInstants(HoodieTableMetaClient metaClient) { // collect InflightAndRequest instants for deltaCommit/commit/compaction/clustering Set<String> timelineActions = CollectionUtils.createImm...
3.26
hudi_TransactionUtils_resolveWriteConflictIfAny_rdh
/** * Resolve any write conflicts when committing data. * * @param table * @param currentTxnOwnerInstant * @param thisCommitMetadata * @param config * @param lastCompletedTxnOwnerInstant * @param pendingInstants * @return * @throws HoodieWriteConflictException */public static Option<HoodieCommitMetadata> res...
3.26
hudi_TransactionUtils_getLastCompletedTxnInstantAndMetadata_rdh
/** * Get the last completed transaction hoodie instant and {@link HoodieCommitMetadata#getExtraMetadata()}. * * @param metaClient * @return */ public static Option<Pair<HoodieInstant, Map<String, String>>> getLastCompletedTxnInstantAndMetadata(HoodieTableMetaClient metaClient) { Optio...
3.26
hudi_HoodieRecordPayload_preCombine_rdh
/** * When more than one HoodieRecord have the same HoodieKey in the incoming batch, this function combines them before attempting to insert/upsert by taking in a schema. * Implementation can leverage the schema to decide their business logic to do preCombine. * * @param oldValue * instance of the old {@link Hoo...
3.26
hudi_HoodieRecordPayload_combineAndGetUpdateValue_rdh
/** * This methods lets you write custom merging/combining logic to produce new values as a function of current value on storage and whats contained * in this object. Implementations can leverage properties if required. * <p> * eg: * 1) You are updating counters, you may want to add counts to currentValue and writ...
3.26
hudi_HoodieRecordPayload_getOrderingValue_rdh
/** * This method can be used to extract the ordering value of the payload for combining/merging, * or 0 if no value is specified which means natural order(arrival time is used). * * @return the ordering value */ @PublicAPIMethod(maturity = ApiMaturityLevel.STABLE) default Comparable<?> getOrderingValue() { //...
3.26
hudi_HoodieRecordPayload_getInsertValue_rdh
/** * Generates an avro record out of the given HoodieRecordPayload, to be written out to storage. Called when writing a new value for the given * HoodieKey, wherein there is no existing record in storage to be combined against. (i.e insert) Return EMPTY to skip writing this record. * Implementations can leverage pr...
3.26
hudi_RocksDBDAO_init_rdh
/** * Initialized Rocks DB instance. */ private void init() { try { LOG.info("DELETING RocksDB persisted at " + rocksDBBasePath); FileIOUtils.deleteDirectory(new File(rocksDBBasePath)); managedHandlesMap = new ConcurrentHashMap<>(); managedDesc...
3.26
hudi_RocksDBDAO_put_rdh
/** * Perform single PUT on a column-family. * * @param columnFamilyName * Column family name * @param key * Key * @param value * Payload * @param <T> * Type of Payload */ public <K extends Serializable, T extends Serializable> void put(String columnFamilyName, K key, T value) { try { byt...
3.26
hudi_RocksDBDAO_prefixSearch_rdh
/** * Perform a prefix search and return stream of key-value pairs retrieved. * * @param columnFamilyName * Column Family Name * @param prefix * Prefix Key * @param <T> * Type of value stored */ public <T extends Serializable> Stream<Pair<String, T>> prefixSearch(String columnFamilyName, String prefix) {...
3.26
hudi_RocksDBDAO_deleteInBatch_rdh
/** * Helper to add delete operation in batch. * * @param batch * Batch Handle * @param columnFamilyName * Column Family * @param key * Key */ public <K extends Serializable> void deleteInBatch(WriteBatch batch, String columnFamilyName, K key) { try { batch.delete(managedHandlesMap.get(colu...
3.26
hudi_RocksDBDAO_writeBatch_rdh
/** * Perform a batch write operation. */ public void writeBatch(BatchHandler handler) { try (WriteBatch batch = new WriteBatch()) { handler.apply(batch); getRocksDB().write(new WriteOptions(), batch); } catch (RocksDBException re) { throw new HoodieException(re); } }
3.26
hudi_RocksDBDAO_close_rdh
/** * Close the DAO object. */ public synchronized void close() { if (!closed) { closed = true; managedHandlesMap.values().forEach(AbstractImmutableNativeReference::close); managedHandlesMap.clear(); managedDescriptorMap.clear(); getRocksDB().close(); try { Fil...
3.26
hudi_RocksDBDAO_dropColumnFamily_rdh
/** * Note : Does not delete from underlying DB. Just closes the handle. * * @param columnFamilyName * Column Family Name */ public void dropColumnFamily(String columnFamilyName) { ValidationUtils.checkArgument(!closed); managedDescriptorMap.computeIfPresent(columnFamilyName, (colFamilyName, descriptor) -> { ...
3.26
hudi_RocksDBDAO_getRocksDB_rdh
/** * Create RocksDB if not initialized. */ private RocksDB getRocksDB() {return rocksDB;}
3.26
hudi_RocksDBDAO_addColumnFamily_rdh
/** * Add a new column family to store. * * @param columnFamilyName * Column family name */ public void addColumnFamily(String columnFamilyName) { ValidationUtils.checkArgument(!closed); managedDescriptorMap.computeIfAbsent(columnFamilyName, colFamilyName -> { try {ColumnFamilyDescriptor descriptor = getCol...
3.26
hudi_RocksDBDAO_get_rdh
/** * Retrieve a value for a given key in a column family. * * @param columnFamilyName * Column Family Name * @param key * Key to be retrieved * @param <T> * Type of object stored. */ public <K extends Serializable, T extends Serializable> T get(String columnFamilyName, K key) { ValidationUtils.chec...
3.26
hudi_RocksDBDAO_iterator_rdh
/** * Return Iterator of key-value pairs from RocksIterator. * * @param columnFamilyName * Column Family Name * @param <T> * Type of value stored */ public <T extends Serializable> Iterator<T> iterator(String columnFamilyName) { return new IteratorWrapper<>(getRocksDB().newIterator(managedHandlesMap.get(...
3.26
hudi_RocksDBDAO_prefixDelete_rdh
/** * Perform a prefix delete and return stream of key-value pairs retrieved. * * @param columnFamilyName * Column Family Name * @param prefix * Prefix Key * @param <T> * Type of value stored */ public <T extends Serializable> void prefixDelete(String columnFamilyName, String prefix) { ValidationUtil...
3.26
hudi_RocksDBDAO_loadManagedColumnFamilies_rdh
/** * Helper to load managed column family descriptors. */ private List<ColumnFamilyDescriptor> loadManagedColumnFamilies(DBOptions dbOptions) throws RocksDBException { final List<ColumnFamilyDescriptor> managedColumnFamilies = new ArrayList<>();final Options options = new Options(dbOptions, new ColumnFamilyOptio...
3.26
hudi_RocksDBDAO_delete_rdh
/** * Perform a single Delete operation. * * @param columnFamilyName * Column Family name * @param key * Key to be deleted */ public <K extends Serializable> void delete(String columnFamilyName, K key) { try { getRocksDB().delete(managedHandlesMap.get(columnFamilyName), SerializationUtils.serial...
3.26
hudi_RocksDBDAO_putInBatch_rdh
/** * Helper to add put operation in batch. * * @param batch * Batch Handle * @param columnFamilyName * Column Family * @param key * Key * @param value * Payload * @param <T> * Type of payload */ public <K extends Serializable, T extends Serializable> void putInBatch(WriteBatch batch, String c...
3.26
hudi_ImmutableTriple_getMiddle_rdh
/** * {@inheritDoc } */ @Override public M getMiddle() { return middle; }
3.26
hudi_ImmutableTriple_getLeft_rdh
// ----------------------------------------------------------------------- /** * {@inheritDoc } */ @Override public L getLeft() { return left; }
3.26
hudi_ImmutableTriple_of_rdh
/** * <p> * Obtains an immutable triple of from three objects inferring the generic types. * </p> * * <p> * This factory allows the triple to be created using inference to obtain the generic types. * </p> * * @param <L> * the left element type * @param <M> * the middle element type * @param <R> * th...
3.26
hudi_ImmutableTriple_getRight_rdh
/** * {@inheritDoc } */ @Override public R getRight() { return right; }
3.26
hudi_HoodieEmptyRecord_readRecordPayload_rdh
/** * NOTE: This method is declared final to make sure there's no polymorphism and therefore * JIT compiler could perform more aggressive optimizations */ @Override protected final T readRecordPayload(Kryo kryo, Input input) { this.type = kryo.readObject(input, HoodieRecordType.class); this.orderingVal = ((Com...
3.26
hudi_HoodieEmptyRecord_writeRecordPayload_rdh
/** * NOTE: This method is declared final to make sure there's no polymorphism and therefore * JIT compiler could perform more aggressive optimizations */ @Override protected final void writeRecordPayload(T payload, Kryo kryo, Output output) { kryo.writeObject(output, type); // NOTE: Since [[orderingVal]] is...
3.26
hudi_Pipelines_compact_rdh
/** * The compaction tasks pipeline. * * <p>The compaction plan operator monitors the new compaction plan on the timeline * then distributes the sub-plans to the compaction tasks. The compaction task then * handle over the metadata to commit task for compaction transaction commit. * The whole pipeline looks like ...
3.26
hudi_Pipelines_boundedBootstrap_rdh
/** * Constructs bootstrap pipeline for batch execution mode. * The indexing data set is loaded before the actual data write * in order to support batch UPSERT. */ private static DataStream<HoodieRecord> boundedBootstrap(Configuration conf, RowType rowType, DataStream<RowData> dataStream) { final RowDataKeyGen ...
3.26
hudi_Pipelines_bootstrap_rdh
/** * Constructs bootstrap pipeline. * The bootstrap operator loads the existing data index (primary key to file id mapping), * then send the indexing data set to subsequent operator(usually the bucket assign operator). * * @param conf * The configuration * @param rowType * The row type * @param dataStream...
3.26
hudi_Pipelines_bulkInsert_rdh
/** * Bulk insert the input dataset at once. * * <p>By default, the input dataset would shuffle by the partition path first then * sort by the partition path before passing around to the write function. * The whole pipeline looks like the following: * * <pre> * | input1 | ===\ /=== |sorter| === | task1...
3.26
hudi_Pipelines_rowDataToHoodieRecord_rdh
/** * Transforms the row data to hoodie records. */ public static DataStream<HoodieRecord> rowDataToHoodieRecord(Configuration conf, RowType rowType, DataStream<RowData> dataStream) { return dataStream.map(RowDataToHoodieFunctions.create(rowType, conf), TypeInformation.of(HoodieRecord.class)).setParallelism(dat...
3.26
hudi_Pipelines_hoodieStreamWrite_rdh
/** * The streaming write pipeline. * * <p>The input dataset shuffles by the primary key first then * shuffles by the file group ID before passing around to the write function. * The whole pipeline looks like the following: * * <pre> * | input1 | ===\ /=== | bucket assigner | ===\ /=== | task1 | *...
3.26
hudi_Pipelines_cluster_rdh
/** * The clustering tasks pipeline. * * <p>The clustering plan operator monitors the new clustering plan on the timeline * then distributes the sub-plans to the clustering tasks. The clustering task then * handle over the metadata to commit task for clustering transaction commit. * The whole pipeline looks like ...
3.26
hudi_HoodieIngestionService_startIngestion_rdh
/** * Entrypoint to start ingestion. * <p> * Depends on the ingestion mode, this method will * <li>either start a loop as implemented in {@link #startService()} for continuous mode * <li>or do one-time ingestion as implemented in {@link #ingestOnce()} for non-continuous mode */ pub...
3.26
hudi_HoodieIngestionService_onIngestionCompletes_rdh
/** * A callback method to be invoked after ingestion completes. * <p> * For continuous mode, this is invoked once after exiting the ingestion loop. */ protected boolean onIngestionCompletes(boolean hasError) { return true; }
3.26
hudi_HoodieIngestionService_requestShutdownIfNeeded_rdh
/** * To determine if shutdown should be requested to allow gracefully terminate the ingestion in continuous mode. * <p> * Subclasses should implement the logic to make the decision. If the shutdown condition is met, the implementation * should call {@link #shutdown(boolean)} to indicate the request. * * @see Pos...
3.26
hudi_HoodieIngestionService_startService_rdh
/** * The main loop for running ingestion in continuous mode. */ @Overrideprotected Pair<CompletableFuture, ExecutorService> startService() { ExecutorService executor = Executors.newFixedThreadPool(1); return Pair.of(CompletableFuture.supplyAsync(() -> { try { while (!isShutdownRequested(...
3.26
hudi_WriteMetadataEvent_builder_rdh
/** * Returns the builder for {@link WriteMetadataEvent}. */ public static Builder builder() { return new Builder();}
3.26
hudi_WriteMetadataEvent_mergeWith_rdh
/** * Merges this event with given {@link WriteMetadataEvent} {@code other}. * * @param other * The event to be merged */ public void mergeWith(WriteMetadataEvent other) { ValidationUtils.checkArgument(this.taskID == other.taskID); // the instant time could be monotonically increasing this.instantTime = other.in...
3.26
hudi_WriteMetadataEvent_isReady_rdh
/** * Returns whether the event is ready to commit. */ public boolean isReady(String currentInstant) { return lastBatch && this.instantTime.equals(currentInstant); }
3.26
hudi_WriteMetadataEvent_emptyBootstrap_rdh
// ------------------------------------------------------------------------- // Utilities // ------------------------------------------------------------------------- /** * Creates empty bootstrap event for task {@code taskId}. * * <p>The event indicates that the new instant can start directly, * there is no old in...
3.26
hudi_HoodieAvroUtils_needsRewriteToString_rdh
/** * Helper for recordNeedsRewriteForExtendedAvroSchemaEvolution. Returns true if schema type is * int, long, float, double, or bytes because avro doesn't support evolution from those types to * string so some intervention is needed */ private static boolean needsRewriteToString(Schema schema) { switch (schema.get...
3.26
hudi_HoodieAvroUtils_getRecordKeyPartitionPathSchema_rdh
/** * Fetch schema for record key and partition path. */ public static Schema getRecordKeyPartitionPathSchema() { List<Schema.Field> toBeAddedFields = new ArrayList<>(); Schema recordSchema = Schema.createRecord("HoodieRecordKey", "", "", false); Schema.Field recordKeyField = new Schema.Field(HoodieRecord...
3.26
hudi_HoodieAvroUtils_wrapValueIntoAvro_rdh
/** * Wraps a value into Avro type wrapper. * * @param value * Java value. * @return A wrapped value with Avro type wrapper. */ public static Object wrapValueIntoAvro(Comparable<?> value) { if (value == null) { return null;} else if ((value instanceof Date) || (value instanceof LocalDate)) { // NOTE: Du...
3.26
hudi_HoodieAvroUtils_jsonBytesToAvro_rdh
/** * Convert json bytes back into avro record. */ public static GenericRecord jsonBytesToAvro(byte[] bytes, Schema schema) throws IOException {ByteArrayInputStream bio = new ByteArrayInputStream(bytes); JsonDecoder jsonDecoder = DecoderFactory.get().jsonDecoder(schema, bio); GenericDatumReader<GenericReco...
3.26
hudi_HoodieAvroUtils_getNestedFieldValAsString_rdh
/** * Obtain value of the provided field as string, denoted by dot notation. e.g: a.b.c */ public static String getNestedFieldValAsString(GenericRecord record, String fieldName, boolean returnNullIfNotFound, boolean consistentLogicalTimestampEnabled) { Object obj = getNestedFieldVal(record, fieldName, returnN...
3.26
hudi_HoodieAvroUtils_generateProjectionSchema_rdh
/** * Generate a reader schema off the provided writeSchema, to just project out the provided columns. */ public static Schema generateProjectionSchema(Schema originalSchema, List<String> fieldNames) { Map<String, Field> schemaFieldsMap = originalSchema.getFields().stream().map(r -> Pair.of(r.name().toLowerCase(...
3.26
hudi_HoodieAvroUtils_toJavaDate_rdh
/** * convert days to Date * <p> * NOTE: This method could only be used in tests * * @VisibleForTesting */ public static Date toJavaDate(int days) { LocalDate date = LocalDate.ofEpochDay(days); ZoneId defaultZoneId = ZoneId.systemDefault(); ZonedDateTime zonedDateTime = date.atStartOfDay(defaultZoneId); return ...
3.26
hudi_HoodieAvroUtils_convertValueForSpecificDataTypes_rdh
/** * This method converts values for fields with certain Avro/Parquet data types that require special handling. * * @param fieldSchema * avro field schema * @param fieldValue * avro field value * @return field value either converted (for certain data types) or as it is. */ public static Object convertValue...
3.26
hudi_HoodieAvroUtils_rewriteRecord_rdh
/** * Given an Avro record with a given schema, rewrites it into the new schema while setting fields only from the new * schema. * <p> * NOTE: This method is rewriting every record's field that is record itself recu...
3.26
hudi_HoodieAvroUtils_recordToBytes_rdh
/** * TODO serialize other type of record. */ public static Option<byte[]> recordToBytes(HoodieRecord record, Schema schema) throws IOException {return Option.of(HoodieAvroUtils.indexedRecordToBytes(record.toIndexedRecord(schema, new Properties()).get().getData())); }
3.26
hudi_HoodieAvroUtils_avroToJson_rdh
/** * Convert a given avro record to json and return the encoded bytes. * * @param record * The GenericRecord to convert * @param pretty * Whether to pretty-print the json output */ public static byte[] avroToJson(GenericRecord record, boolean pretty) throws IOException { DatumWriter<Object> writer =...
3.26
hudi_HoodieAvroUtils_avroToBytes_rdh
/** * Convert a given avro record to bytes. */ public static byte[] avroToBytes(GenericRecord record) { return indexedRecordToBytes(record); }
3.26
hudi_HoodieAvroUtils_rewriteEvolutionRecordWithMetadata_rdh
// TODO Unify the logical of rewriteRecordWithMetadata and rewriteEvolutionRecordWithMetadata, and delete this function. public static GenericRecord rewriteEvolutionRecordWithMetadata(GenericRecord genericRecord, Schema newSchema, String fileName) { GenericRecord newRecord = HoodieAvroUtils.rewriteRecordWithNewSche...
3.26
hudi_HoodieAvroUtils_bytesToAvro_rdh
/** * Convert serialized bytes back into avro record. */ public static GenericRecord bytesToAvro(byte[] bytes, Schema writerSchema, Schema readerSchema) throws IOException { BinaryDecoder decoder = DecoderFactory.get().binaryDecoder(bytes, BINARY_DECODER.get()); BINARY_DECODER.set(decoder); GenericDatumRe...
3.26
hudi_HoodieAvroUtils_fromJavaDate_rdh
/** * convert Date to days * <p> * NOTE: This method could only be used in tests * * @VisibleForTesting */ public static int fromJavaDate(Date date) { long millisUtc = date.getTime(); long millisLocal = millisUtc + TimeZone.getDefault().getOffset(millisUtc); int julianDays = Math.toIntExact(Math.floorDiv(millisLo...
3.26
hudi_HoodieAvroUtils_addMetadataFields_rdh
/** * Adds the Hoodie metadata fields to the given schema. * * @param schema * The schema * @param withOperationField * Whether to include the '_hoodie_operation' field */ public static Schema addMetadataFields(Schema schema, boolean withOperationField) { int newFieldsSize = HoodieRecord.HOODIE_META_COL...
3.26
hudi_HoodieAvroUtils_getNestedFieldVal_rdh
/** * Obtain value of the provided field, denoted by dot notation. e.g: a.b.c */ public static Object getNestedFieldVal(GenericRecord record, String fieldName, boolean returnNullIfNotFound, boolean consistentLogicalTimestampEnabled) { ...
3.26
hudi_HoodieAvroUtils_recordNeedsRewriteForExtendedAvroTypePromotion_rdh
/** * Avro does not support type promotion from numbers to string. This function returns true if * it will be necessary to rewrite the record to support this promotion. * NOTE: this does not determine whether the writerSchema and readerSchema are compatible. * It is just trying to find if the reader expects a numbe...
3.26
hudi_HoodieAvroUtils_getNestedFieldSchemaFromRecord_rdh
/** * Get schema for the given field and record. Field can be nested, denoted by dot notation. e.g: a.b.c * * @param record * - record containing the value of the given field * @param fieldName * - name of the field * @return */ public static Schema getNestedFieldSchemaFromRecord(GenericRecord record, Strin...
3.26
hudi_HoodieAvroUtils_getNestedFieldSchemaFromWriteSchema_rdh
/** * Get schema for the given field and write schema. Field can be nested, denoted by dot notation. e.g: a.b.c * Use this method when record is not available. Otherwise, prefer to use {@link #getNestedFieldSchemaFromRecord(GenericRecord, String)} * * @param writeSchema * - write schema of the record * @param f...
3.26
hudi_HoodieAvroUtils_getRootLevelFieldName_rdh
/** * Obtain the root-level field name of a full field name, possibly a nested field. * For example, given "a.b.c", the output is "a"; given "a", the output is "a". * * @param fieldName * The field name. * @return Root-level field name */ public static String getRootLevelFieldName(String fieldName) { retur...
3.26
hudi_HoodieAvroUtils_addCommitMetadataToRecord_rdh
/** * Adds the Hoodie commit metadata into the provided Generic Record. */ public static GenericRecord addCommitMetadataToRecord(GenericRecord record, String instantTime, String commitSeqno) { record.put(HoodieRecord.COMMIT_TIME_METADATA_FIELD, instantTime); record.put(HoodieRecord.COMMIT_SEQNO_METADATA_FIELD...
3.26
hudi_HoodieAvroUtils_rewriteRecords_rdh
/** * Converts list of {@link GenericRecord} provided into the {@link GenericRecord} adhering to the * provided {@code newSchema}. * <p> * To better understand conversion rules please check {@link #rewriteRecord(GenericRecord, Schema)} */ public static List<GenericRecord> rewriteRecords(List<GenericRecord> records...
3.26
hudi_HoodieAvroUtils_getRecordColumnValues_rdh
/** * Gets record column values into one object. * * @param record * Hoodie record. * @param columns * Names of the columns to get values. * @param schema * {@link SerializableSchema} instance. * @return Column value if a single column, or concatenated String values by comma. */ public static Object get...
3.26
hudi_HoodieAvroUtils_getFieldVal_rdh
/** * Obtain value of the provided key, when set returnNullIfNotFound false, * it is consistent with avro after 1.10 */ public static Object getFieldVal(GenericRecord record, String key, boolean returnNullIfNotFound) { S...
3.26
hudi_HoodieAvroUtils_unwrapAvroValueWrapper_rdh
/** * Unwraps Avro value wrapper into Java value. * * @param avroValueWrapper * A wrapped value with Avro type wrapper. * @return Java value. */public static Comparable<?> unwrapAvroValueWrapper(Object avroValueWrapper) { if (avroValueWrapper == null) { return null; } else if (avroValueWrapper instanceof DateWr...
3.26
hudi_HoodieAvroUtils_removeFields_rdh
/** * Given an Avro record and list of columns to remove, this method removes the list of columns from * the given avro record using rewriteRecord method. * <p> * To better understand how it removes please check {@li...
3.26
hudi_HoodieAvroUtils_rewriteRecordWithNewSchema_rdh
/** * Given avro records, rewrites them with new schema. * * @param oldRecords * oldRecords to be rewritten * @param newSchema * newSchema used to rewrite oldRecord * @param renameCols * a map store all rename cols, (k, v)-> (colNameFromNewSchema, colNameFromOldSchema) * @return a iterator of rewritten G...
3.26
hudi_HoodieAvroUtils_convertValueForAvroLogicalTypes_rdh
/** * This method converts values for fields with certain Avro Logical data types that require special handling. * <p> * Logical Date Type is converted to actual Date value instead of Epoch Integer which is how it is * represented/stored in parquet. * <p> * Decimal Data Type is converted to actual decimal value i...
3.26
hudi_HoodieAvroUtils_sanitizeName_rdh
/** * Sanitizes Name according to Avro rule for names. * Removes characters other than the ones mentioned in https://avro.apache.org/docs/current/spec.html#names . * * @param name * input name * @param invalidCharMask * replacement for invalid characters. * @return sanitized name */ public static String sa...
3.26