com.microsoft.azure.storage.table.TableQuery Java Examples
The following examples show how to use
com.microsoft.azure.storage.table.TableQuery.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: FilterExpressionTable.java From components with Apache License 2.0 | 6 votes |
public String generateCombinedFilterConditions() { String filter = ""; if (isValidFilterExpession()) { for (int idx = 0; idx < column.getValue().size(); idx++) { String c = column.getValue().get(idx); String cfn = function.getValue().get(idx); String cop = predicate.getValue().get(idx); String typ = fieldType.getValue().get(idx); String f = Comparison.getQueryComparisons(cfn); String v = operand.getValue().get(idx); String p = Predicate.getOperator(cop); EdmType t = SupportedFieldType.getEdmType(typ); String flt = TableQuery.generateFilterCondition(c, f, v, t); if (!filter.isEmpty()) { filter = TableQuery.combineFilters(filter, p, flt); } else { filter = flt; } } } return filter; }
Example #2
Source File: AzureStorageTableSourceOrSink.java From components with Apache License 2.0 | 6 votes |
@Override public Schema getEndpointSchema(RuntimeContainer container, String schemaName) throws IOException { try { AzureStorageTableService tableService = new AzureStorageTableService(getAzureConnection(container)); TableQuery<DynamicTableEntity> partitionQuery; partitionQuery = TableQuery.from(DynamicTableEntity.class).take(1); Iterable<DynamicTableEntity> entities = tableService.executeQuery(schemaName, partitionQuery); if (entities.iterator().hasNext()) { DynamicTableEntity result = entities.iterator().next(); return AzureStorageAvroRegistry.get().inferSchema(result); } else { return null; } } catch (InvalidKeyException | URISyntaxException | StorageException e) { LOGGER.error(e.getLocalizedMessage()); throw new ComponentException(e); } }
Example #3
Source File: AzureUserAccess.java From timbuctoo with GNU General Public License v3.0 | 6 votes |
@Override public Optional<User> getUserForTimLocalId(String userId) throws AuthenticationUnavailableException { String query = "(PartitionKey eq 'users') and (id eq '" + userId + "')"; Iterator<DynamicTableEntity> users = table.execute(TableQuery.from(DynamicTableEntity.class) .where(query) .take(2)).iterator(); if (users.hasNext()) { Optional<User> result = Optional.of(propsToObject(users.next())); if (users.hasNext()) { LOG.error("Multiple items found for query " + query); } return result; } else { return Optional.empty(); } }
Example #4
Source File: AzureVreAuthorizationAccess.java From timbuctoo with GNU General Public License v3.0 | 6 votes |
@Override public void deleteVreAuthorizations(String vreId) throws AuthorizationUnavailableException { String condition = TableQuery.generateFilterCondition( "PartitionKey", TableQuery.QueryComparisons.EQUAL, vreId ); TableBatchOperation deletes = new TableBatchOperation(); for (DynamicTableEntity entity : table.execute(TableQuery.from(DynamicTableEntity.class).where(condition))) { deletes.delete(entity); } try { table.execute(deletes); } catch (StorageException e) { LOG.error("deleteVreAuthorizations failed", e); throw new AuthorizationUnavailableException("Could not delete authorizations"); } }
Example #5
Source File: AzureTableStore.java From data-transfer-project with Apache License 2.0 | 5 votes |
@Override public UUID findFirst(JobAuthorization.State jobState) { try { String partitionFilter = generateFilterCondition( "PartitionKey", TableQuery.QueryComparisons.EQUAL, configuration.getPartitionKey()); String stateFilter = generateFilterCondition( "State", TableQuery.QueryComparisons.EQUAL, jobState.name()); // properties are converted to capitalized by the storage API String combinedFilter = TableQuery.combineFilters(partitionFilter, TableQuery.Operators.AND, stateFilter); TableQuery<DataWrapper> query = TableQuery.from(DataWrapper.class).where(combinedFilter).take(1); CloudTable table = tableClient.getTableReference(JOB_TABLE); Iterator<DataWrapper> iter = table.execute(query).iterator(); if (!iter.hasNext()) { return null; } return UUID.fromString(iter.next().getRowKey()); } catch (StorageException | URISyntaxException e) { throw new MicrosoftStorageException("Error finding first job", e); } }
Example #6
Source File: AzureStorageTableReader.java From components with Apache License 2.0 | 5 votes |
@Override public boolean start() throws IOException { String tableName = properties.tableName.getValue(); String filter = ""; if (properties.useFilterExpression.getValue()) { filter = properties.filterExpression.generateCombinedFilterConditions(); LOGGER.debug(i18nMessages.getMessage("debug.FilterApplied", filter)); } try { TableQuery<DynamicTableEntity> partitionQuery; if (filter.isEmpty()) { partitionQuery = TableQuery.from(DynamicTableEntity.class); } else { partitionQuery = TableQuery.from(DynamicTableEntity.class).where(filter); } // Using execute will automatically and lazily follow the continuation tokens from page to page of results. // So, we bypass the 1000 entities limit. Iterable<DynamicTableEntity> entities = tableService.executeQuery(tableName, partitionQuery); recordsIterator = entities.iterator(); if (recordsIterator.hasNext()) { started = true; result.totalCount++; current = recordsIterator.next(); } } catch (InvalidKeyException | URISyntaxException | StorageException e) { LOGGER.error(e.getLocalizedMessage()); if (properties.dieOnError.getValue()) { throw new ComponentException(e); } } return started; }
Example #7
Source File: AzureStore.java From breakerbox with Apache License 2.0 | 5 votes |
@Override public Collection<DependencyModel> allDependenciesFor(DependencyId dependencyId, ServiceId serviceId) { try (Timer.Context timerContext = dependencyConfigs.time()) { return Entities.toDependencyModelList(tableClient.search( TableId.DEPENDENCY, TableQuery .from(DependencyEntity.class) .where(TableQuery.combineFilters( partitionEquals(dependencyId), TableQuery.Operators.AND, serviceIdEquals(serviceId))))); } }
Example #8
Source File: AzureStore.java From breakerbox with Apache License 2.0 | 5 votes |
private ImmutableList<ServiceEntity> allServiceEntities(ServiceId serviceId) { try (Timer.Context timerContext = listService.time()) { return tableClient.search(TableId.SERVICE, TableQuery .from(ServiceEntity.class) .where(partitionKeyEquals(serviceId))); } }
Example #9
Source File: AzureStore.java From breakerbox with Apache License 2.0 | 5 votes |
private static String partitionKeyEquals(ServiceId serviceId) { return TableQuery .generateFilterCondition( PARTITION_KEY, TableQuery.QueryComparisons.EQUAL, serviceId.getId()); }
Example #10
Source File: AzureStore.java From breakerbox with Apache License 2.0 | 5 votes |
private ImmutableList<DependencyEntity> getConfiguration(DependencyId dependencyId, long targetTimeStamp) { try (Timer.Context timerContext = dependencyConfigs.time()) { return tableClient.search(TableId.DEPENDENCY, TableQuery .from(DependencyEntity.class) .where(TableQuery.combineFilters( partitionEquals(dependencyId), TableQuery.Operators.AND, timestampEquals(targetTimeStamp)))); } }
Example #11
Source File: AzureStore.java From breakerbox with Apache License 2.0 | 5 votes |
private static String timestampEquals(long timestamp) { return TableQuery.generateFilterCondition( ROW_KEY, TableQuery.QueryComparisons.EQUAL, String.valueOf(timestamp) ); }
Example #12
Source File: TableUtils.java From samza with Apache License 2.0 | 4 votes |
/** * Retrieve all rows in a table with the given partition key. * @param partitionKey Job model version of the processors to be retrieved. * @return Iterable list of processor entities. */ public Iterable<ProcessorEntity> getEntitiesWithPartition(String partitionKey) { String partitionFilter = TableQuery.generateFilterCondition(PARTITION_KEY, TableQuery.QueryComparisons.EQUAL, partitionKey); TableQuery<ProcessorEntity> partitionQuery = TableQuery.from(ProcessorEntity.class).where(partitionFilter); return table.execute(partitionQuery); }
Example #13
Source File: AzureStorageTableService.java From components with Apache License 2.0 | 4 votes |
public Iterable<DynamicTableEntity> executeQuery(String tableName, TableQuery<DynamicTableEntity> partitionQuery) throws InvalidKeyException, URISyntaxException, StorageException { CloudTable cloudTable = connection.getCloudStorageAccount().createCloudTableClient().getTableReference(tableName); return cloudTable.execute(partitionQuery, null, AzureStorageUtils.getTalendOperationContext()); }
Example #14
Source File: AzureStore.java From breakerbox with Apache License 2.0 | 4 votes |
private ImmutableList<ServiceEntity> allServiceEntities() { try (Timer.Context timerContext = listService.time()) { return tableClient.search(TableId.SERVICE, TableQuery .from(ServiceEntity.class)); } }
Example #15
Source File: AzureStore.java From breakerbox with Apache License 2.0 | 4 votes |
private static String serviceIdEquals(ServiceId serviceId) { return TableQuery.generateFilterCondition( "ServiceName", TableQuery.QueryComparisons.EQUAL, serviceId.getId()); }
Example #16
Source File: AzureStore.java From breakerbox with Apache License 2.0 | 4 votes |
private static String partitionEquals(DependencyId dependencyId) { return TableQuery.generateFilterCondition( PARTITION_KEY, TableQuery.QueryComparisons.EQUAL, dependencyId.getId()); }