private String getDatastoreName() { if (_datastore != null) { return _datastore.getName(); } return "<null>"; }
public AnalysisJobBuilder setDatastore(final Datastore datastore) { _datastore = datastore; final DatastoreConnection datastoreConnection; if (datastore == null) { datastoreConnection = null; } else { datastoreConnection = datastore.openConnection(); } return setDatastoreConnection(datastoreConnection); }
/** * @return the description */ public String getDescription() { return _datastore.getDescription(); }
final int maxRowsToQuery) { final PojoDatastoreType datastoreType = new PojoDatastoreType(); datastoreType.setName(datastore.getName()); datastoreType.setDescription(datastore.getDescription()); try (DatastoreConnection con = datastore.openConnection()) { final DataContext dataContext = con.getDataContext();
if (datastore != null && datastore.getName() != null) { try (DatastoreConnection con = datastore.openConnection()) { con.getSchemaNavigator().refreshSchemas(); final Table previewTable = result.getPreviewTable(datastore); panel.add(Box.createHorizontalStrut(4)); final Datastore ds = _datastoreCatalog.getDatastore(datastore.getName()); if (!datastore.equals(ds)) { final JButton addDatastoreButton =
public static String getDescription(final Datastore datastore) { if (datastore.getDescription() != null) { return datastore.getDescription(); sb.append(", "); sb.append(ds.getName());
ds.setDescription(datastoreDescription); for (final CustomElementType customElementType : customDatastores) { final Datastore ds = createCustomElement(customElementType, Datastore.class, temporaryConfiguration, true); final String name = ds.getName(); checkName(name, Datastore.class, datastores); datastores.put(name, ds);
@Override public PerformanceCharacteristics getPerformanceCharacteristics() { boolean queryOptimizationPreferred = true; boolean naturalRecordOrderConsistent = true; for (final Datastore datastore : _datastores) { final PerformanceCharacteristics performanceCharacteristics = datastore.getPerformanceCharacteristics(); queryOptimizationPreferred = queryOptimizationPreferred && performanceCharacteristics.isQueryOptimizationPreferred(); naturalRecordOrderConsistent = naturalRecordOrderConsistent && performanceCharacteristics.isNaturalRecordOrderConsistent(); } return new PerformanceCharacteristicsImpl(queryOptimizationPreferred, naturalRecordOrderConsistent); }
try (final DatastoreConnection connection = datastore.openConnection()) { final DataContext dataContext = connection.getDataContext(); final JaxbPojoDatastoreAdaptor adaptor = new JaxbPojoDatastoreAdaptor(configuration); final AbstractDatastoreType pojoDatastoreType = adaptor.createPojoDatastore(datastore.getName(), schemaName, pojoTables); pojoDatastoreType.setDescription(datastore.getDescription());
throw new NoSuchDatastoreException(ref); datastoreConnection = datastore.openConnection(); } else { datastore = sourceColumnMapping.getDatastore(); datastoreConnection = datastore.openConnection(); metadata.getJobDescription(), metadata.getAuthor(), convertToDate(metadata.getCreatedDate()), convertToDate(metadata.getUpdatedDate()), datastore.getName(), getSourceColumnPaths(job), getSourceColumnTypes(job), variables, getMetadataProperties(metadata)); analysisJobBuilder.setAnalysisJobMetadata(immutableAnalysisJobMetadata);
if (!_datastore.getPerformanceCharacteristics().isQueryOptimizationPreferred()) {
@Override protected UsageAwareDatastoreConnection<DataContext> createDatastoreConnection() { final List<DataContext> dataContexts = new ArrayList<>(_datastores.size()); final List<Closeable> closeables = new ArrayList<>(_datastores.size()); for (final Datastore datastore : _datastores) { final DatastoreConnection con = datastore.openConnection(); final DataContext dc = con.getDataContext(); closeables.add(con); dataContexts.add(dc); } final Closeable[] closeablesArray = closeables.toArray(new Closeable[closeables.size()]); return new DatastoreConnectionImpl<>(DataContextFactory.createCompositeDataContext(dataContexts), this, closeablesArray); }
public WriteDataResultImpl(final int writtenRowCount, final int updatesCount, final Datastore datastore, final String schemaName, final String tableName, final int errorRowCount, final FileDatastore errorDatastore) { _writtenRowCount = writtenRowCount; _updatesCount = updatesCount; _schemaName = schemaName; _tableName = tableName; _datastoreName = (datastore == null ? null : datastore.getName()); _datastoreFunc = catalog -> datastore; _errorRowCount = errorRowCount; _errorDatastore = errorDatastore; }
@RequestMapping(method = RequestMethod.GET, produces = "application/json") @ResponseBody public List<Map<String, String>> datastoresFolderJson(@PathVariable("tenant") String tenant) { final TenantContext context = _contextFactory.getContext(tenant); final DatastoreCatalog datastoreCatalog = context.getConfiguration().getDatastoreCatalog(); final String[] names = datastoreCatalog.getDatastoreNames(); final List<Map<String, String>> result = new ArrayList<Map<String, String>>(); for (String name : names) { final Datastore datastore = datastoreCatalog.getDatastore(name); final Map<String, String> map = new LinkedHashMap<String, String>(); map.put("name", name); map.put("description", datastore.getDescription()); map.put("type", datastore.getClass().getSimpleName()); result.add(map); } return result; }
public SimpleDictionary loadIntoMemory(final DatastoreConnection datastoreConnection) { final DataContext dataContext = datastoreConnection.getDataContext(); final Column column = getColumn(datastoreConnection); final Query query = dataContext.query().from(column.getTable()).select(column).toQuery(); if (datastoreConnection.getDatastore().getPerformanceCharacteristics().isQueryOptimizationPreferred()) { query.getSelectClause().setDistinct(true); } final Set<String> values = new HashSet<>(); try (DataSet dataSet = dataContext.executeQuery(query)) { while (dataSet.next()) { final Object value = dataSet.getRow().getValue(0); if (value != null) { values.add(value.toString()); } } } return new SimpleDictionary(getName(), values); }
@Override public Table getPreviewTable(final Datastore datastore) { try (DatastoreConnection con = datastore.openConnection()) { return con.getSchemaNavigator().convertToTable(_schemaName, _tableName); } }
/** * @return the name */ public String getName() { return _datastore.getName(); }
/** * Creates a slave job by copying the original job and adding a * {@link MaxRowsFilter} as a default requirement. * * @param job * @param firstRow * @param maxRows * @return */ private AnalysisJob buildSlaveJob(final AnalysisJob job, final int slaveJobIndex, final int firstRow, final int maxRows) { logger.info("Building slave job {} with firstRow={} and maxRow={}", slaveJobIndex + 1, firstRow, maxRows); try (AnalysisJobBuilder jobBuilder = new AnalysisJobBuilder(_configuration, job)) { final FilterComponentBuilder<MaxRowsFilter, Category> maxRowsFilter = jobBuilder.addFilter(MaxRowsFilter.class); maxRowsFilter.getComponentInstance().setFirstRow(firstRow); maxRowsFilter.getComponentInstance().setMaxRows(maxRows); final boolean naturalRecordOrderConsistent = jobBuilder.getDatastore().getPerformanceCharacteristics().isNaturalRecordOrderConsistent(); if (!naturalRecordOrderConsistent) { final InputColumn<?> orderColumn = findOrderByColumn(jobBuilder); maxRowsFilter.getComponentInstance().setOrderColumn(orderColumn); } jobBuilder.setDefaultRequirement(maxRowsFilter, MaxRowsFilter.Category.VALID); // in assertion/test mode do an early validation assert jobBuilder.isConfigured(true); return jobBuilder.toAnalysisJob(); } }
private void openConnection(final Datastore datastore) { if (_connection != null && _connection.getDatastore() == datastore) { return; } if (_connection != null) { _connection.close(); _connection = null; } if (datastore != null) { try { _connection = datastore.openConnection(); } catch (final Exception e) { logger.warn("Could not open connection to datastore: {}", datastore); } } }
@Override public String getWindowTitle() { return "Query " + _datastore.getName(); }