Refine search
@Override public void removeByEndpointKeyHashAndConfigurationVersion(byte[] endpointKeyHash, Integer confSchemaVersion) { LOG.debug("Remove endpoint specific configuration by endpointKeyHash {} and confSchemaVersion {}", endpointKeyHash, confSchemaVersion); Delete.Where deleteQuery = delete().from(getColumnFamilyName()) .where(eq(EPS_CONFIGURATION_KEY_HASH_PROPERTY, getByteBuffer(endpointKeyHash))) .and(eq(EP_CONFIGURATION_VERSION_PROPERTY, confSchemaVersion)); LOG.trace("Remove endpoint specific configuration by endpointKeyHash and confSchemaVersion query {}", deleteQuery); execute(deleteQuery); }
/** * @return cql query statement to delete a workflow from the "workflows" table */ public String getDeleteWorkflowStatement() { return QueryBuilder.delete() .from(keyspace, TABLE_WORKFLOWS) .where(eq(WORKFLOW_ID_KEY, bindMarker())) .and(eq(SHARD_ID_KEY, bindMarker())) .getQueryString(); }
@Override public void removeTransferLog( String queueName, String source, String dest, UUID messageId ) throws QakkaException { Statement query = QueryBuilder.select().all().from(TABLE_TRANSFER_LOG) .where( QueryBuilder.eq( COLUMN_QUEUE_NAME, queueName )) .and( QueryBuilder.eq( COLUMN_DEST_REGION, dest )) .and( QueryBuilder.eq( COLUMN_MESSAGE_ID, messageId )); ResultSet rs = cassandraClient.getApplicationSession().execute( query ); if ( rs.getAvailableWithoutFetching() == 0 ) { StringBuilder sb = new StringBuilder(); sb.append( "Transfer log entry not found for queueName=" ).append( queueName ); sb.append( " dest=" ).append( dest ); sb.append( " messageId=" ).append( messageId ); throw new QakkaException( sb.toString() ); } Statement deleteQuery = QueryBuilder.delete().from(TABLE_TRANSFER_LOG) .where( QueryBuilder.eq( COLUMN_QUEUE_NAME, queueName )) .and( QueryBuilder.eq( COLUMN_DEST_REGION, dest )) .and( QueryBuilder.eq( COLUMN_MESSAGE_ID, messageId )); cassandraClient.getApplicationSession().execute( deleteQuery ); }
@Override public void removeNotificationsByTopicId(String topicId) { LOG.debug("Remove notifications by topic id {}", topicId); Delete.Where query = delete().from(getColumnFamilyName()) .where(eq(NF_TOPIC_ID_PROPERTY, topicId)) .and(QueryBuilder.in( NF_NOTIFICATION_TYPE_PROPERTY, getStringTypes(NotificationTypeDto.values()))); execute(query); LOG.trace("Execute query {}", query); }
/** * Generate an ... <strong>IF value = ?</strong> */ @SuppressWarnings("static-access") public final EntityWithCustomConstructor_Delete.E Eq(final double value) { boundValues.add(value); encodedValues.add(meta.value.encodeFromJava(value, Optional.of(cassandraOptions))); where.onlyIf(QueryBuilder.eq("value", QueryBuilder.bindMarker("value"))); return EntityWithCustomConstructor_Delete.E.this; }
delete = delete("a", "b", "c").from("foo").using(timestamp(0)).where(eq("k", 1)); assertEquals(delete.toString(), query); delete = delete().listElt("a", 3).mapElt("b", "foo").column("c").from("foo").where(eq("k", 1)); assertEquals(delete.toString(), query); .column("c") .from("foo") .where(eq("k", 1)); assertEquals(delete.toString(), query); .from("foo", "bar") .where() .and(eq("k", 1)) .using(timestamp(1240003134L)); assertEquals(delete.toString(), query); delete = delete().from("foo", "bar").where(eq("k1", "foo")).and(eq("k2", 1)); assertEquals(delete.toString(), query); delete = delete().from("foo", "bar").where(eq("k1", "foo")).ifExists(); assertEquals(delete.toString(), query); delete = delete().from("foo", "bar").where(eq("k1", "foo")).onlyIf(eq("a", 1)).and(eq("b", 2)); assertEquals(delete.toString(), query);
/** * Generate an ... <strong>IF set <= ?</strong> */ @SuppressWarnings("static-access") public final EntityWithCaseSensitivePK_Delete.E Lte(final Set<String> set) { boundValues.add(set); encodedValues.add(meta.set.encodeFromJava(set, Optional.of(cassandraOptions))); where.onlyIf(QueryBuilder.lte("\"setString\"", QueryBuilder.bindMarker("\"setString\""))); return EntityWithCaseSensitivePK_Delete.E.this; }
/** * Generate an ... <strong>IF name < ?</strong> */ @SuppressWarnings("static-access") public final EntityWithCustomConstructor_Delete.E Lt(final String name) { boundValues.add(name); encodedValues.add(meta.name.encodeFromJava(name, Optional.of(cassandraOptions))); where.onlyIf(QueryBuilder.lt("name", QueryBuilder.bindMarker("name"))); return EntityWithCustomConstructor_Delete.E.this; }
/** * Generate an ... <strong>IF list > ?</strong> */ @SuppressWarnings("static-access") public final EntityWithCaseSensitivePK_Delete.E Gt(final List<String> list) { boundValues.add(list); encodedValues.add(meta.list.encodeFromJava(list, Optional.of(cassandraOptions))); where.onlyIf(QueryBuilder.gt("\"listString\"", QueryBuilder.bindMarker("\"listString\""))); return EntityWithCaseSensitivePK_Delete.E.this; }
/** * Generate an ... <strong>IF value >= ?</strong> */ @SuppressWarnings("static-access") public final EntityWithCustomConstructor_Delete.E Gte(final double value) { boundValues.add(value); encodedValues.add(meta.value.encodeFromJava(value, Optional.of(cassandraOptions))); where.onlyIf(QueryBuilder.gte("value", QueryBuilder.bindMarker("value"))); return EntityWithCustomConstructor_Delete.E.this; }
/** * Generate an ... <strong>IF name != ?</strong> */ @SuppressWarnings("static-access") public final EntityWithCustomConstructor_Delete.E NotEq(final String name) { boundValues.add(name); encodedValues.add(meta.name.encodeFromJava(name, Optional.of(cassandraOptions))); where.onlyIf(NotEq.of("name", QueryBuilder.bindMarker("name"))); return EntityWithCustomConstructor_Delete.E.this; } }
/** * Adds the provided clause to this WHERE clause. * * @param clause the clause to add. * @return this WHERE clause. */ public Where and(Clause clause) { clauses.add(clause); statement.maybeAddRoutingKey(clause.name(), clause.firstValue()); if (!hasNonIdempotentOps() && !Utils.isIdempotent(clause)) { statement.setNonIdempotentOps(); } checkForBindMarkers(clause); return this; }
Delete( String keyspace, String table, List<Object> routingKeyValues, List<ColumnMetadata> partitionKey, List<Selector> columns) { super(keyspace, partitionKey, routingKeyValues); this.table = table; this.columns = columns; this.where = new Where(this); this.usings = new Options(this); this.conditions = new Conditions(this); // This is for JAVA-1089, if the query deletes an element in a list, the statement should be // non-idempotent. if (!areIdempotent(columns)) { setNonIdempotentOps(); } }
/** * Adds the provided clause to this WHERE clause. * * @param clause the clause to add. * @return this WHERE clause. */ public Where and(Clause clause) { clauses.add(clause); statement.maybeAddRoutingKey(clause.name(), clause.firstValue()); checkForBindMarkers(clause); return this; }
/** * Adds a WHERE clause to this statement. * * <p>This is a shorter/more readable version for {@code where().and(clause)}. * * @param clause the clause to add. * @return the where clause of this query to which more clause can be added. */ public Where where(Clause clause) { return where.and(clause); }
Delete(String keyspace, String table, List<Object> columnNames) { super(keyspace); this.table = table; this.columnNames = columnNames; this.where = new Where(this); this.usings = new Options(this); }
/** * @return cql query statement to delete a task from the "workflows" table */ public String getDeleteTaskStatement() { return QueryBuilder.delete() .from(keyspace, TABLE_WORKFLOWS) .where(eq(WORKFLOW_ID_KEY, bindMarker())) .and(eq(SHARD_ID_KEY, bindMarker())) .and(eq(ENTITY_KEY, ENTITY_TYPE_TASK)) .and(eq(TASK_ID_KEY, bindMarker())) .getQueryString(); } }
@Override public void delete( final MapScope scope, final String key ) { Statement deleteMapEntry; Clause equalsEntryKey = QueryBuilder.eq("key", getMapEntryPartitionKey(scope, key)); deleteMapEntry = QueryBuilder.delete().from(MAP_ENTRIES_TABLE) .where(equalsEntryKey); session.execute(deleteMapEntry); // not sure which bucket the value is in, execute a delete against them all final int[] buckets = BUCKET_LOCATOR.getAllBuckets( scope.getName() ); List<ByteBuffer> mapKeys = new ArrayList<>(); for( int bucket : buckets){ mapKeys.add( getMapKeyPartitionKey(scope, bucket)); } Statement deleteMapKey; Clause inKey = QueryBuilder.in("key", mapKeys); Clause column1Equals = QueryBuilder.eq("column1", DataType.text().serialize(key, ProtocolVersion.NEWEST_SUPPORTED)); deleteMapKey = QueryBuilder.delete().from(MAP_KEYS_TABLE) .where(inKey).and(column1Equals); session.execute(deleteMapKey); }
/** * Generate an ... <strong>IF list = ?</strong> */ @SuppressWarnings("static-access") public final EntityWithCaseSensitivePK_Delete.E Eq(final List<String> list) { boundValues.add(list); encodedValues.add(meta.list.encodeFromJava(list, Optional.of(cassandraOptions))); where.onlyIf(QueryBuilder.eq("\"listString\"", QueryBuilder.bindMarker("\"listString\""))); return EntityWithCaseSensitivePK_Delete.E.this; }