Search in sources :

Example 46 with HoodieIOException

use of org.apache.hudi.exception.HoodieIOException in project hudi by apache.

the class HoodieHFileReader method getRecordIterator.

public ClosableIterator<R> getRecordIterator(List<String> keys, Schema schema) throws IOException {
    this.schema = schema;
    reader.loadFileInfo();
    Iterator<String> iterator = keys.iterator();
    return new ClosableIterator<R>() {

        private R next;

        @Override
        public void close() {
        }

        @Override
        public boolean hasNext() {
            try {
                while (iterator.hasNext()) {
                    Option<R> value = getRecordByKey(iterator.next(), schema);
                    if (value.isPresent()) {
                        next = value.get();
                        return true;
                    }
                }
                return false;
            } catch (IOException e) {
                throw new HoodieIOException("unable to read next record from hfile ", e);
            }
        }

        @Override
        public R next() {
            return next;
        }
    };
}
Also used : HoodieIOException(org.apache.hudi.exception.HoodieIOException) ClosableIterator(org.apache.hudi.common.util.ClosableIterator) IOException(java.io.IOException) HoodieIOException(org.apache.hudi.exception.HoodieIOException)

Example 47 with HoodieIOException

use of org.apache.hudi.exception.HoodieIOException in project hudi by apache.

the class HashID method getMD5Hash.

private static byte[] getMD5Hash(final byte[] message) throws HoodieIOException {
    try {
        MessageDigest messageDigest = MessageDigest.getInstance(MD5_ALGORITHM_NAME);
        messageDigest.update(message);
        return messageDigest.digest();
    } catch (NoSuchAlgorithmException e) {
        throw new HoodieIOException("Failed to create MD5 Hash: " + e);
    }
}
Also used : HoodieIOException(org.apache.hudi.exception.HoodieIOException) NoSuchAlgorithmException(java.security.NoSuchAlgorithmException) MessageDigest(java.security.MessageDigest)

Example 48 with HoodieIOException

use of org.apache.hudi.exception.HoodieIOException in project hudi by apache.

the class HoodieCopyOnWriteTableInputFormat method makeExternalFileSplit.

private BootstrapBaseFileSplit makeExternalFileSplit(PathWithBootstrapFileStatus file, FileSplit split) {
    try {
        LOG.info("Making external data split for " + file);
        FileStatus externalFileStatus = file.getBootstrapFileStatus();
        FileSplit externalFileSplit = makeSplit(externalFileStatus.getPath(), 0, externalFileStatus.getLen(), new String[0], new String[0]);
        return new BootstrapBaseFileSplit(split, externalFileSplit);
    } catch (IOException e) {
        throw new HoodieIOException(e.getMessage(), e);
    }
}
Also used : FileStatus(org.apache.hadoop.fs.FileStatus) HoodieIOException(org.apache.hudi.exception.HoodieIOException) IOException(java.io.IOException) HoodieIOException(org.apache.hudi.exception.HoodieIOException) FileSplit(org.apache.hadoop.mapred.FileSplit)

Example 49 with HoodieIOException

use of org.apache.hudi.exception.HoodieIOException in project hudi by apache.

the class TestHoodieRepairTool method cleanUpDanglingDataFilesInFS.

private void cleanUpDanglingDataFilesInFS() {
    FileSystem fs = metaClient.getFs();
    DANGLING_DATA_FILE_LIST.forEach(relativeFilePath -> {
        Path path = new Path(basePath, relativeFilePath);
        try {
            if (fs.exists(path)) {
                fs.delete(path, false);
            }
        } catch (IOException e) {
            throw new HoodieIOException("Unable to delete file: " + path);
        }
    });
}
Also used : Path(org.apache.hadoop.fs.Path) HoodieIOException(org.apache.hudi.exception.HoodieIOException) FileSystem(org.apache.hadoop.fs.FileSystem) IOException(java.io.IOException) HoodieIOException(org.apache.hudi.exception.HoodieIOException)

Example 50 with HoodieIOException

use of org.apache.hudi.exception.HoodieIOException in project hudi by apache.

the class AbstractBaseTestSource method initDataGen.

public static void initDataGen(TypedProperties props, int partition) {
    try {
        boolean useRocksForTestDataGenKeys = props.getBoolean(SourceConfigs.USE_ROCKSDB_FOR_TEST_DATAGEN_KEYS, SourceConfigs.DEFAULT_USE_ROCKSDB_FOR_TEST_DATAGEN_KEYS);
        String baseStoreDir = props.getString(SourceConfigs.ROCKSDB_BASE_DIR_FOR_TEST_DATAGEN_KEYS, File.createTempFile("test_data_gen", ".keys").getParent()) + "/" + partition;
        LOG.info("useRocksForTestDataGenKeys=" + useRocksForTestDataGenKeys + ", BaseStoreDir=" + baseStoreDir);
        dataGeneratorMap.put(partition, new HoodieTestDataGenerator(HoodieTestDataGenerator.DEFAULT_PARTITION_PATHS, useRocksForTestDataGenKeys ? new RocksDBBasedMap<>(baseStoreDir) : new HashMap<>()));
    } catch (IOException e) {
        throw new HoodieIOException(e.getMessage(), e);
    }
}
Also used : HoodieIOException(org.apache.hudi.exception.HoodieIOException) IOException(java.io.IOException) HoodieIOException(org.apache.hudi.exception.HoodieIOException) HoodieTestDataGenerator(org.apache.hudi.common.testutils.HoodieTestDataGenerator)

Aggregations

HoodieIOException (org.apache.hudi.exception.HoodieIOException)139 IOException (java.io.IOException)127 Path (org.apache.hadoop.fs.Path)45 List (java.util.List)31 ArrayList (java.util.ArrayList)30 Option (org.apache.hudi.common.util.Option)27 Collectors (java.util.stream.Collectors)26 HoodieInstant (org.apache.hudi.common.table.timeline.HoodieInstant)26 Pair (org.apache.hudi.common.util.collection.Pair)25 LogManager (org.apache.log4j.LogManager)25 Logger (org.apache.log4j.Logger)25 Map (java.util.Map)21 FileSystem (org.apache.hadoop.fs.FileSystem)20 GenericRecord (org.apache.avro.generic.GenericRecord)19 HashSet (java.util.HashSet)18 HoodieRecord (org.apache.hudi.common.model.HoodieRecord)18 HoodieTableMetaClient (org.apache.hudi.common.table.HoodieTableMetaClient)18 Set (java.util.Set)17 HoodieTimeline (org.apache.hudi.common.table.timeline.HoodieTimeline)17 HoodieException (org.apache.hudi.exception.HoodieException)17