@Override protected JsonDatastore createDatastore(final String name, final Resource resource) { return new JsonDatastore(name, resource); }
/** * Extrnalizes a Json datastore * * @param datastore * @param filename * @return */ public Element toElement(final JsonDatastore datastore, final String filename) { final Element datastoreElement = getDocument().createElement("json-datastore"); datastoreElement.setAttribute("name", datastore.getName()); final String description = datastore.getDescription(); if (!Strings.isNullOrEmpty(description)) { datastoreElement.setAttribute("description", description); } appendElement(datastoreElement, "filename", filename); return datastoreElement; }
/** * Creates a {@link Datastore} replacement to use for configured properties * * @param cb * @param datastore * @param replacementResource * @return a replacement datastore, or null if it shouldn't be replaced */ private ResourceDatastore createReplacementDatastore(final ComponentBuilder cb, final ResourceDatastore datastore, final Resource replacementResource) { final String name = datastore.getName(); if (datastore instanceof CsvDatastore) { final CsvConfiguration csvConfiguration = ((CsvDatastore) datastore).getCsvConfiguration(); return new CsvDatastore(name, replacementResource, csvConfiguration); } if (datastore instanceof JsonDatastore) { return new JsonDatastore(name, replacementResource, ((JsonDatastore) datastore).getSchemaBuilder()); } logger.warn("Could not replace datastore '{}' because it is of an unsupported type: ", name, datastore.getClass().getSimpleName()); return datastore; }
public static boolean isHdfsResourcedDatastore(final Datastore datastore) { if (datastore instanceof CsvDatastore) { final CsvDatastore csvDatastore = (CsvDatastore) datastore; final Resource resource = csvDatastore.getResource(); if (!isHdfsResource(resource)) { return false; } } else if (datastore instanceof JsonDatastore) { final JsonDatastore jsonDatastore = (JsonDatastore) datastore; final Resource resource = jsonDatastore.getResource(); if (!isHdfsResource(resource)) { return false; } } else if (datastore instanceof FixedWidthDatastore) { final FixedWidthDatastore fixedWidthDatastore = (FixedWidthDatastore) datastore; final Resource resource = fixedWidthDatastore.getResource(); if (!isHdfsResource(resource)) { return false; } } else { // other type of datastore return false; } return true; }
public List<Column> getColumns() { if (_columns == null) { try (DatastoreConnection openConnection = _jsonDatastore.openConnection()) { _columns = openConnection.getDataContext().getDefaultSchema().getTable(0).getColumns(); } } return _columns; } }
elem = toElement((SalesforceDatastore) datastore); } else if (datastore instanceof JsonDatastore) { final Resource resource = ((JsonDatastore) datastore).getResource(); final String filename = toFilename(resource); elem = toElement((JsonDatastore) datastore, filename);
private Datastore createDatastore(final String name, final JsonDatastoreType datastoreType, final DataCleanerConfiguration configuration) { final String filename = getStringVariable("filename", datastoreType.getFilename()); final Resource resource = _interceptor.createResource(filename, configuration); return new JsonDatastore(name, resource); }
} else if (datastore instanceof JsonDatastore) { final JsonDatastore jsonDatastore = (JsonDatastore) datastore; final String datastorePath = jsonDatastore.getResource().getQualifiedPath(); final JavaRDD<String> rawInput; if (_minPartitions != null) {
return new DbaseDatastore(datastoreName, resource.getQualifiedPath()); case JSON: return new JsonDatastore(datastoreName, resource); case OPENOFFICE: return new OdbDatastore(datastoreName, resource.getQualifiedPath());