kikocis/java-driver public
Changesets · Branches · Tags · Compare
| Changeset | 52598c92fd080ea7eef274f50c828456cec2bfde8098af2742668f9eb9ee1b27 |
|---|---|
| Author | Alexandre Dutra <alexdut@gmail.com> · 2015-10-28 11:51 +01:00 |
| Committer | Alexandre Dutra <alexdut@gmail.com> · 2015-10-28 11:51 +01:00 |
| Parents | f5b832a93d1e, 646c6986220f |
8 files changed
modified changelog/README.md +5 −0
| @@ -1,5 +1,10 @@ | ||
| 1 | 1 | ## Changelog |
| 2 | 2 | |
| 3 | +### 3.0.0-beta1 (in progress) | |
| 4 | + | |
| 5 | + - [improvement] JAVA-958: Make TableOrView.Order visible. | |
| 6 | + - [improvement] JAVA-968: Update metrics to the latest version. | |
| 7 | + | |
| 3 | 8 | ### 3.0.0-alpha4 |
| 4 | 9 | |
| 5 | 10 | - [improvement] Change default consistency level to LOCAL_QUORUM (JAVA-926) |
added driver-core/src/main/java/com/datastax/driver/core/ClusteringOrder.java +28 −0
| @@ -0,0 +1,28 @@ | ||
| 1 | +/* | |
| 2 | + * Copyright (C) 2012-2015 DataStax Inc. | |
| 3 | + * | |
| 4 | + * Licensed under the Apache License, Version 2.0 (the "License"); | |
| 5 | + * you may not use this file except in compliance with the License. | |
| 6 | + * You may obtain a copy of the License at | |
| 7 | + * | |
| 8 | + * http://www.apache.org/licenses/LICENSE-2.0 | |
| 9 | + * | |
| 10 | + * Unless required by applicable law or agreed to in writing, software | |
| 11 | + * distributed under the License is distributed on an "AS IS" BASIS, | |
| 12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
| 13 | + * See the License for the specific language governing permissions and | |
| 14 | + * limitations under the License. | |
| 15 | + */ | |
| 16 | +package com.datastax.driver.core; | |
| 17 | + | |
| 18 | +/** | |
| 19 | + * Clustering orders. | |
| 20 | + * <p> | |
| 21 | + * This is used by metadata classes to indicate the clustering | |
| 22 | + * order of a clustering column in a table or materialized view. | |
| 23 | + */ | |
| 24 | +public enum ClusteringOrder { | |
| 25 | + | |
| 26 | + ASC, DESC; | |
| 27 | + | |
| 28 | +} |
modified driver-core/src/main/java/com/datastax/driver/core/MaterializedViewMetadata.java +3 −3
| @@ -48,7 +48,7 @@ | ||
| 48 | 48 | boolean includeAllColumns, |
| 49 | 49 | String whereClause, |
| 50 | 50 | TableOptionsMetadata options, |
| 51 | - List<Order> clusteringOrder, | |
| 51 | + List<ClusteringOrder> clusteringOrder, | |
| 52 | 52 | VersionNumber cassandraVersion) { |
| 53 | 53 | super(keyspace, name, id, partitionKey, clusteringColumns, columns, options, clusteringOrder, cassandraVersion); |
| 54 | 54 | this.baseTable = baseTable; |
| @@ -77,7 +77,7 @@ | ||
| 77 | 77 | |
| 78 | 78 | List<ColumnMetadata> partitionKey = new ArrayList<ColumnMetadata>(Collections.<ColumnMetadata>nCopies(partitionKeySize, null)); |
| 79 | 79 | List<ColumnMetadata> clusteringColumns = new ArrayList<ColumnMetadata>(Collections.<ColumnMetadata>nCopies(clusteringSize, null)); |
| 80 | - List<Order> clusteringOrder = new ArrayList<Order>(Collections.<Order>nCopies(clusteringSize, null)); | |
| 80 | + List<ClusteringOrder> clusteringOrder = new ArrayList<ClusteringOrder>(Collections.<ClusteringOrder>nCopies(clusteringSize, null)); | |
| 81 | 81 | |
| 82 | 82 | // We use a linked hashmap because we will keep this in the order of a 'SELECT * FROM ...'. |
| 83 | 83 | LinkedHashMap<String, ColumnMetadata> columns = new LinkedHashMap<String, ColumnMetadata>(); |
| @@ -108,7 +108,7 @@ | ||
| 108 | 108 | break; |
| 109 | 109 | case CLUSTERING_COLUMN: |
| 110 | 110 | clusteringColumns.set(rawCol.position, col); |
| 111 | - clusteringOrder.set(rawCol.position, rawCol.isReversed ? Order.DESC : Order.ASC); | |
| 111 | + clusteringOrder.set(rawCol.position, rawCol.isReversed ? ClusteringOrder.DESC : ClusteringOrder.ASC); | |
| 112 | 112 | break; |
| 113 | 113 | default: |
| 114 | 114 | otherColumns.add(col); |
modified driver-core/src/main/java/com/datastax/driver/core/TableMetadata.java +4 −4
| @@ -62,7 +62,7 @@ | ||
| 62 | 62 | Map<String, ColumnMetadata> columns, |
| 63 | 63 | Map<String, IndexMetadata> indexes, |
| 64 | 64 | TableOptionsMetadata options, |
| 65 | - List<Order> clusteringOrder, | |
| 65 | + List<ClusteringOrder> clusteringOrder, | |
| 66 | 66 | VersionNumber cassandraVersion) { |
| 67 | 67 | super(keyspace, name, id, partitionKey, clusteringColumns, columns, options, clusteringOrder, cassandraVersion); |
| 68 | 68 | this.indexes = indexes; |
| @@ -123,7 +123,7 @@ | ||
| 123 | 123 | |
| 124 | 124 | List<ColumnMetadata> partitionKey = new ArrayList<ColumnMetadata>(Collections.<ColumnMetadata>nCopies(partitionKeySize, null)); |
| 125 | 125 | List<ColumnMetadata> clusteringColumns = new ArrayList<ColumnMetadata>(Collections.<ColumnMetadata>nCopies(clusteringSize, null)); |
| 126 | - List<Order> clusteringOrder = new ArrayList<Order>(Collections.<Order>nCopies(clusteringSize, null)); | |
| 126 | + List<ClusteringOrder> clusteringOrder = new ArrayList<ClusteringOrder>(Collections.<ClusteringOrder>nCopies(clusteringSize, null)); | |
| 127 | 127 | |
| 128 | 128 | // We use a linked hashmap because we will keep this in the order of a 'SELECT * FROM ...'. |
| 129 | 129 | LinkedHashMap<String, ColumnMetadata> columns = new LinkedHashMap<String, ColumnMetadata>(); |
| @@ -165,7 +165,7 @@ | ||
| 165 | 165 | for (int i = 0; i < clusteringSize; i++) { |
| 166 | 166 | String alias = columnAliases.size() > i ? columnAliases.get(i) : DEFAULT_COLUMN_ALIAS + (i + 1); |
| 167 | 167 | clusteringColumns.set(i, ColumnMetadata.forAlias(tm, alias, comparator.types.get(i))); |
| 168 | - clusteringOrder.set(i, comparator.reversed.get(i) ? Order.DESC : Order.ASC); | |
| 168 | + clusteringOrder.set(i, comparator.reversed.get(i) ? ClusteringOrder.DESC : ClusteringOrder.ASC); | |
| 169 | 169 | } |
| 170 | 170 | |
| 171 | 171 | // if we're dense, chances are that we have a single regular "value" column with an alias |
| @@ -187,7 +187,7 @@ | ||
| 187 | 187 | break; |
| 188 | 188 | case CLUSTERING_COLUMN: |
| 189 | 189 | clusteringColumns.set(rawCol.position, col); |
| 190 | - clusteringOrder.set(rawCol.position, rawCol.isReversed ? Order.DESC : Order.ASC); | |
| 190 | + clusteringOrder.set(rawCol.position, rawCol.isReversed ? ClusteringOrder.DESC : ClusteringOrder.ASC); | |
| 191 | 191 | break; |
| 192 | 192 | default: |
| 193 | 193 | otherColumns.add(col); |
modified driver-core/src/main/java/com/datastax/driver/core/TableOrView.java +11 −21
| @@ -32,6 +32,12 @@ | ||
| 32 | 32 | } |
| 33 | 33 | }; |
| 34 | 34 | |
| 35 | + static final Predicate<ClusteringOrder> isAscending = new Predicate<ClusteringOrder>() { | |
| 36 | + public boolean apply(ClusteringOrder o) { | |
| 37 | + return o == ClusteringOrder.ASC; | |
| 38 | + } | |
| 39 | + }; | |
| 40 | + | |
| 35 | 41 | protected final KeyspaceMetadata keyspace; |
| 36 | 42 | protected final String name; |
| 37 | 43 | protected final UUID id; |
| @@ -39,25 +45,9 @@ | ||
| 39 | 45 | protected final List<ColumnMetadata> clusteringColumns; |
| 40 | 46 | protected final Map<String, ColumnMetadata> columns; |
| 41 | 47 | protected final TableOptionsMetadata options; |
| 42 | - protected final List<Order> clusteringOrder; | |
| 48 | + protected final List<ClusteringOrder> clusteringOrder; | |
| 43 | 49 | protected final VersionNumber cassandraVersion; |
| 44 | 50 | |
| 45 | - /** | |
| 46 | - * Clustering orders. | |
| 47 | - * <p> | |
| 48 | - * This is used by {@link #getClusteringOrder} to indicate the clustering | |
| 49 | - * order of a table. | |
| 50 | - */ | |
| 51 | - public enum Order { | |
| 52 | - ASC, DESC; | |
| 53 | - | |
| 54 | - static final Predicate<Order> isAscending = new Predicate<Order>() { | |
| 55 | - public boolean apply(Order o) { | |
| 56 | - return o == ASC; | |
| 57 | - } | |
| 58 | - }; | |
| 59 | - } | |
| 60 | - | |
| 61 | 51 | TableOrView(KeyspaceMetadata keyspace, |
| 62 | 52 | String name, |
| 63 | 53 | UUID id, |
| @@ -65,7 +55,7 @@ | ||
| 65 | 55 | List<ColumnMetadata> clusteringColumns, |
| 66 | 56 | Map<String, ColumnMetadata> columns, |
| 67 | 57 | TableOptionsMetadata options, |
| 68 | - List<Order> clusteringOrder, | |
| 58 | + List<ClusteringOrder> clusteringOrder, | |
| 69 | 59 | VersionNumber cassandraVersion) { |
| 70 | 60 | this.keyspace = keyspace; |
| 71 | 61 | this.name = name; |
| @@ -182,11 +172,11 @@ | ||
| 182 | 172 | * descending) of the {@code i}th clustering column (see |
| 183 | 173 | * {@link #getClusteringColumns}). Note that a table defined without any |
| 184 | 174 | * particular clustering order is equivalent to one for which all the |
| 185 | - * clustering key are in ascending order. | |
| 175 | + * clustering keys are in ascending order. | |
| 186 | 176 | * |
| 187 | 177 | * @return a list with the clustering order for each clustering column. |
| 188 | 178 | */ |
| 189 | - public List<Order> getClusteringOrder() { | |
| 179 | + public List<ClusteringOrder> getClusteringOrder() { | |
| 190 | 180 | return clusteringOrder; |
| 191 | 181 | } |
| 192 | 182 | |
| @@ -248,7 +238,7 @@ | ||
| 248 | 238 | sb.append(" WITH "); |
| 249 | 239 | if (options.isCompactStorage()) |
| 250 | 240 | and(sb.append("COMPACT STORAGE"), formatted); |
| 251 | - if (!Iterables.all(clusteringOrder, Order.isAscending)) | |
| 241 | + if (!Iterables.all(clusteringOrder, isAscending)) | |
| 252 | 242 | and(appendClusteringOrder(sb), formatted); |
| 253 | 243 | sb.append("read_repair_chance = ").append(options.getReadRepairChance()); |
| 254 | 244 | and(sb, formatted).append("dclocal_read_repair_chance = ").append(options.getLocalReadRepairChance()); |
modified driver-core/src/test/java/com/datastax/driver/core/ColumnMetadataAssert.java +2 −2
| @@ -55,8 +55,8 @@ | ||
| 55 | 55 | return this; |
| 56 | 56 | } |
| 57 | 57 | |
| 58 | - public ColumnMetadataAssert hasClusteringOrder(TableOrView.Order order) { | |
| 59 | - assertThat(actual.getParent().getClusteringOrder().get(actual.getParent().getClusteringColumns().indexOf(actual))).isEqualTo(order); | |
| 58 | + public ColumnMetadataAssert hasClusteringOrder(ClusteringOrder clusteringOrder) { | |
| 59 | + assertThat(actual.getParent().getClusteringOrder().get(actual.getParent().getClusteringColumns().indexOf(actual))).isEqualTo(clusteringOrder); | |
| 60 | 60 | return this; |
| 61 | 61 | } |
| 62 | 62 |
modified driver-core/src/test/java/com/datastax/driver/core/MaterializedViewMetadataTest.java +1 −1
| @@ -24,7 +24,7 @@ | ||
| 24 | 24 | |
| 25 | 25 | import static com.datastax.driver.core.Assertions.assertThat; |
| 26 | 26 | import static com.datastax.driver.core.DataType.*; |
| 27 | -import static com.datastax.driver.core.TableOrView.Order.DESC; | |
| 27 | +import static com.datastax.driver.core.ClusteringOrder.DESC; | |
| 28 | 28 | |
| 29 | 29 | @CassandraVersion(major = 3) |
| 30 | 30 | public class MaterializedViewMetadataTest extends CCMBridge.PerClassSingleNodeCluster { |
modified driver-core/src/test/java/com/datastax/driver/core/TableMetadataTest.java +2 −2
| @@ -28,8 +28,8 @@ | ||
| 28 | 28 | |
| 29 | 29 | import static com.datastax.driver.core.Assertions.assertThat; |
| 30 | 30 | import static com.datastax.driver.core.DataType.*; |
| 31 | -import static com.datastax.driver.core.TableOrView.Order.ASC; | |
| 32 | -import static com.datastax.driver.core.TableOrView.Order.DESC; | |
| 31 | +import static com.datastax.driver.core.ClusteringOrder.ASC; | |
| 32 | +import static com.datastax.driver.core.ClusteringOrder.DESC; | |
| 33 | 33 | |
| 34 | 34 | public class TableMetadataTest extends CCMBridge.PerClassSingleNodeCluster { |
| 35 | 35 | @Override |