/** * Load a Solr core/collection from a Avro or JSON file. * * @param collection Collection name * @param path Path to the file to load * @throws VariantSearchException VariantSearchException * @throws IOException IOException */ public void load(String collection, Path path) throws VariantSearchException, IOException { // TODO: can we use VariantReaderUtils as implemented in the function load00 below ? // TODO: VarriantReaderUtils supports JSON, AVRO and VCF file formats. // Check path is not null and exists. FileUtils.checkFile(path); File file = path.toFile(); if (file.getName().endsWith("json") || file.getName().endsWith("json.gz")) { try { loadJson(collection, path); } catch (SolrServerException e) { throw new VariantSearchException("Error loading variants from JSON file.", e); } } else if (file.getName().endsWith("avro") || file.getName().endsWith("avro.gz")) { try { loadAvro(collection, path); } catch (StorageEngineException | SolrServerException e) { throw new VariantSearchException("Error loading variants from AVRO file.", e); } } else { throw new VariantSearchException("File format " + path + " not supported. Please, use Avro or JSON file formats."); } }