private static AbstractType[] getKeyTypes(CFMetaData cfm) { AbstractType[] types = new AbstractType[cfm.partitionKeyColumns().size()]; int i = 0; for (ColumnDefinition def : cfm.partitionKeyColumns()) types[i++] = def.type; return types; }
private static AbstractType[] getKeyTypes(CFMetaData cfm) { AbstractType[] types = new AbstractType[cfm.partitionKeyColumns().size()]; int i = 0; for (ColumnDefinition def : cfm.partitionKeyColumns()) types[i++] = def.type; return types; }
private static AbstractType[] getKeyTypes(CFMetaData cfm) { AbstractType[] types = new AbstractType[cfm.partitionKeyColumns().size()]; int i = 0; for (ColumnDefinition def : cfm.partitionKeyColumns()) types[i++] = def.type; return types; }
private static AbstractType[] getKeyTypes(CFMetaData cfm) { AbstractType[] types = new AbstractType[cfm.partitionKeyColumns().size()]; int i = 0; for (ColumnDefinition def : cfm.partitionKeyColumns()) types[i++] = def.type; return types; }
@Override public boolean hasUnrestrictedPartitionKeyComponents(CFMetaData cfm) { return size() < cfm.partitionKeyColumns().size(); }
@Override public boolean hasUnrestrictedPartitionKeyComponents(CFMetaData cfm) { return size() < cfm.partitionKeyColumns().size(); }
@Override public boolean hasUnrestrictedPartitionKeyComponents(CFMetaData cfm) { return size() < cfm.partitionKeyColumns().size(); }
/** * Returns the partition key components that are not restricted. * @return the partition key components that are not restricted. */ private Collection<ColumnIdentifier> getPartitionKeyUnrestrictedComponents() { List<ColumnDefinition> list = new ArrayList<>(cfm.partitionKeyColumns()); list.removeAll(partitionKeyRestrictions.getColumnDefs()); return ColumnDefinition.toIdentifiers(list); }
public SelectStatement(CFMetaData cfm, int boundTerms, Parameters parameters, Selection selection, Term limit) { this.cfm = cfm; this.boundTerms = boundTerms; this.selection = selection; this.keyRestrictions = new Restriction[cfm.partitionKeyColumns().size()]; this.columnRestrictions = new Restriction[cfm.clusteringColumns().size()]; this.parameters = parameters; this.limit = limit; // Now gather a few info on whether we should bother with static columns or not for this statement initStaticColumnsInfo(); }
/** * Returns the partition key components that are not restricted. * @return the partition key components that are not restricted. */ private Collection<ColumnIdentifier> getPartitionKeyUnrestrictedComponents() { List<ColumnDefinition> list = new ArrayList<>(cfm.partitionKeyColumns()); list.removeAll(partitionKeyRestrictions.getColumnDefs()); return ColumnDefinition.toIdentifiers(list); }
/** * Returns the partition key components that are not restricted. * @return the partition key components that are not restricted. */ private Collection<ColumnIdentifier> getPartitionKeyUnrestrictedComponents() { List<ColumnDefinition> list = new ArrayList<>(cfm.partitionKeyColumns()); list.removeAll(partitionKeyRestrictions.getColumnDefs()); return ColumnDefinition.toIdentifiers(list); }
private DecoratedKey makeCurrentPartitionKey() { ByteBuffer rawKey = viewMetadata.partitionKeyColumns().size() == 1 ? currentViewEntryPartitionKey[0] : CompositeType.build(currentViewEntryPartitionKey); return viewMetadata.decorateKey(rawKey); }
private DecoratedKey makeCurrentPartitionKey() { ByteBuffer rawKey = viewMetadata.partitionKeyColumns().size() == 1 ? currentViewEntryPartitionKey[0] : CompositeType.build(currentViewEntryPartitionKey); return viewMetadata.decorateKey(rawKey); }
private DecoratedKey makeCurrentPartitionKey() { ByteBuffer rawKey = viewMetadata.partitionKeyColumns().size() == 1 ? currentViewEntryPartitionKey[0] : CompositeType.build(currentViewEntryPartitionKey); return viewMetadata.decorateKey(rawKey); }
private void validateDistinctSelection() throws InvalidRequestException { Collection<ColumnDefinition> requestedColumns = selection.getColumns(); for (ColumnDefinition def : requestedColumns) if (def.kind != ColumnDefinition.Kind.PARTITION_KEY && def.kind != ColumnDefinition.Kind.STATIC) throw new InvalidRequestException(String.format("SELECT DISTINCT queries must only request partition key columns and/or static columns (not %s)", def.name)); // If it's a key range, we require that all partition key columns are selected so we don't have to bother with post-query grouping. if (!isKeyRange) return; for (ColumnDefinition def : cfm.partitionKeyColumns()) if (!requestedColumns.contains(def)) throw new InvalidRequestException(String.format("SELECT DISTINCT queries must request all the partition key columns (missing %s)", def.name)); }
private ByteBuffer getKeyBound(Bound b, QueryOptions options) throws InvalidRequestException { // Deal with unrestricted partition key components (special-casing is required to deal with 2i queries on the first // component of a composite partition key). for (int i = 0; i < keyRestrictions.length; i++) if (keyRestrictions[i] == null) return ByteBufferUtil.EMPTY_BYTE_BUFFER; // We deal with IN queries for keys in other places, so we know buildBound will return only one result return buildBound(b, cfm.partitionKeyColumns(), keyRestrictions, false, cfm.getKeyValidatorAsCType(), options).get(0).toByteBuffer(); }
public boolean isStaticDocument(final IndexService indexService, Uid uid) throws JsonParseException, JsonMappingException, IOException { CFMetaData metadata = getCFMetaData(indexService.keyspace(), typeToCfName(uid.type())); String id = uid.id(); if (id.startsWith("[") && id.endsWith("]")) { org.codehaus.jackson.map.ObjectMapper jsonMapper = new org.codehaus.jackson.map.ObjectMapper(); Object[] elements = jsonMapper.readValue(id, Object[].class); return metadata.clusteringColumns().size() > 0 && elements.length == metadata.partitionKeyColumns().size(); } else { return metadata.clusteringColumns().size() != 0; } }
protected void appendCQLWhereClause(StringBuilder sb) { sb.append(" WHERE "); sb.append(ColumnDefinition.toCQLString(metadata().partitionKeyColumns())).append(" = "); DataRange.appendKeyString(sb, metadata().getKeyValidator(), partitionKey().getKey()); // We put the row filter first because the clustering index filter can end by "ORDER BY" if (!rowFilter().isEmpty()) sb.append(" AND ").append(rowFilter()); String filterString = clusteringIndexFilter().toCQLString(metadata()); if (!filterString.isEmpty()) sb.append(" AND ").append(filterString); }
protected void appendCQLWhereClause(StringBuilder sb) { sb.append(" WHERE "); sb.append(ColumnDefinition.toCQLString(metadata().partitionKeyColumns())).append(" = "); DataRange.appendKeyString(sb, metadata().getKeyValidator(), partitionKey().getKey()); // We put the row filter first because the clustering index filter can end by "ORDER BY" if (!rowFilter().isEmpty()) sb.append(" AND ").append(rowFilter()); String filterString = clusteringIndexFilter().toCQLString(metadata()); if (!filterString.isEmpty()) sb.append(" AND ").append(filterString); }
protected void appendCQLWhereClause(StringBuilder sb) { sb.append(" WHERE "); sb.append(ColumnDefinition.toCQLString(metadata().partitionKeyColumns())).append(" = "); DataRange.appendKeyString(sb, metadata().getKeyValidator(), partitionKey().getKey()); // We put the row filter first because the clustering index filter can end by "ORDER BY" if (!rowFilter().isEmpty()) sb.append(" AND ").append(rowFilter()); String filterString = clusteringIndexFilter().toCQLString(metadata()); if (!filterString.isEmpty()) sb.append(" AND ").append(filterString); }