Skip to content

Commit 9257b2a

Browse files
committed
tablets: remove keyspace and table name
Keyspace and table name are not used. It only occupie memory and CPU on hash calculation. At not point tablet from one table/keyspace is compared to a tablet from another table/keyspace.
1 parent 513d7ff commit 9257b2a

File tree

1 file changed

+5
-30
lines changed

1 file changed

+5
-30
lines changed

driver-core/src/main/java/com/datastax/driver/core/TabletMap.java

Lines changed: 5 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ void processTabletsRoutingV1Payload(String keyspace, String table, ByteBuffer pa
141141
HostShardPair hostShardPair = new HostShardPair(tuple.getUUID(0), tuple.getInt(1));
142142
replicas.add(hostShardPair);
143143
}
144-
Tablet newTablet = new Tablet(keyspace, table, firstToken, lastToken, replicas);
144+
Tablet newTablet = new Tablet(firstToken, lastToken, replicas);
145145

146146
TabletSet tabletSet = mapping.computeIfAbsent(ktPair, k -> new TabletSet());
147147
Lock writeLock = tabletSet.lock.writeLock();
@@ -315,20 +315,11 @@ public TabletSet() {
315315
* for quick lookup on sorted Collections based just on the token value.
316316
*/
317317
public static class Tablet implements Comparable<Tablet> {
318-
private final String keyspaceName;
319-
private final String tableName;
320318
private final long firstToken;
321319
private final long lastToken;
322320
private final List<HostShardPair> replicas;
323321

324-
private Tablet(
325-
String keyspaceName,
326-
String tableName,
327-
long firstToken,
328-
long lastToken,
329-
List<HostShardPair> replicas) {
330-
this.keyspaceName = keyspaceName;
331-
this.tableName = tableName;
322+
private Tablet(long firstToken, long lastToken, List<HostShardPair> replicas) {
332323
this.firstToken = firstToken;
333324
this.lastToken = lastToken;
334325
this.replicas = replicas;
@@ -342,15 +333,7 @@ private Tablet(
342333
* @return New {@link Tablet} object
343334
*/
344335
public static Tablet malformedTablet(long lastToken) {
345-
return new Tablet(null, null, lastToken, lastToken, null);
346-
}
347-
348-
public String getKeyspaceName() {
349-
return keyspaceName;
350-
}
351-
352-
public String getTableName() {
353-
return tableName;
336+
return new Tablet(lastToken, lastToken, null);
354337
}
355338

356339
public long getFirstToken() {
@@ -368,13 +351,7 @@ public List<HostShardPair> getReplicas() {
368351
@Override
369352
public String toString() {
370353
return "LazyTablet{"
371-
+ "keyspaceName='"
372-
+ keyspaceName
373-
+ '\''
374-
+ ", tableName='"
375-
+ tableName
376-
+ '\''
377-
+ ", firstToken="
354+
+ "firstToken="
378355
+ firstToken
379356
+ ", lastToken="
380357
+ lastToken
@@ -390,14 +367,12 @@ public boolean equals(Object o) {
390367
Tablet that = (Tablet) o;
391368
return firstToken == that.firstToken
392369
&& lastToken == that.lastToken
393-
&& keyspaceName.equals(that.keyspaceName)
394-
&& tableName.equals(that.tableName)
395370
&& Objects.equals(replicas, that.replicas);
396371
}
397372

398373
@Override
399374
public int hashCode() {
400-
return Objects.hash(keyspaceName, tableName, firstToken, lastToken, replicas);
375+
return Objects.hash(firstToken, lastToken, replicas);
401376
}
402377

403378
@Override

0 commit comments

Comments
 (0)