Skip to content

Commit d006860

Browse files
dataroaringclaude
andcommitted
[opt](memory) Move schemaHash from Replica to LocalReplica
schemaHash in the base Replica class wastes 4 bytes per CloudReplica. Cloud storage paths don't use schema_hash, and callers like MetadataViewer already guard with getSchemaHash() != -1. This follows the same pattern as dbId removal in #62079. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 4c421c0 commit d006860

2 files changed

Lines changed: 15 additions & 5 deletions

File tree

fe/fe-core/src/main/java/org/apache/doris/catalog/LocalReplica.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ public class LocalReplica extends Replica {
3030

3131
@SerializedName(value = "bid", alternate = {"backendId"})
3232
private long backendId;
33+
private int schemaHash = -1;
3334

3435
@SerializedName(value = "rds", alternate = {"remoteDataSize"})
3536
private volatile long remoteDataSize = 0;
@@ -129,6 +130,7 @@ public LocalReplica(long replicaId, long backendId, long version, int schemaHash
129130
super(replicaId, backendId, version, schemaHash, dataSize, remoteDataSize, rowCount, state, lastFailedVersion,
130131
lastSuccessVersion);
131132
this.backendId = backendId;
133+
this.schemaHash = schemaHash;
132134
this.lastFailedVersion = lastFailedVersion;
133135
if (this.lastFailedVersion > 0) {
134136
this.lastFailedTimestamp = System.currentTimeMillis();
@@ -157,6 +159,16 @@ public void setBackendId(long backendId) {
157159
this.backendId = backendId;
158160
}
159161

162+
@Override
163+
public int getSchemaHash() {
164+
return schemaHash;
165+
}
166+
167+
@Override
168+
public void setSchemaHash(int schemaHash) {
169+
this.schemaHash = schemaHash;
170+
}
171+
160172
@Override
161173
public long getLastFailedVersion() {
162174
return lastFailedVersion;

fe/fe-core/src/main/java/org/apache/doris/catalog/Replica.java

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,6 @@ public static class ReplicaContext {
8888
// the version could be queried
8989
@SerializedName(value = "v", alternate = {"version"})
9090
protected volatile long version;
91-
private int schemaHash = -1;
9291
@SerializedName(value = "ds", alternate = {"dataSize"})
9392
private volatile long dataSize = 0;
9493
@SerializedName(value = "rc", alternate = {"rowCount"})
@@ -129,7 +128,6 @@ public Replica(long replicaId, long backendId, long version, int schemaHash,
129128
long lastSuccessVersion) {
130129
this.id = replicaId;
131130
this.version = version;
132-
this.schemaHash = schemaHash;
133131

134132
this.dataSize = dataSize;
135133
this.rowCount = rowCount;
@@ -144,12 +142,12 @@ public long getVersion() {
144142
}
145143

146144
public int getSchemaHash() {
147-
return schemaHash;
145+
return -1;
148146
}
149147

150148
// for compatibility
151149
public void setSchemaHash(int schemaHash) {
152-
this.schemaHash = schemaHash;
150+
// no-op in base class; overridden in LocalReplica
153151
}
154152

155153
public long getId() {
@@ -428,7 +426,7 @@ public String toString() {
428426
strBuffer.append(", lastFailedTimestamp=");
429427
strBuffer.append(getLastFailedTimestamp());
430428
strBuffer.append(", schemaHash=");
431-
strBuffer.append(schemaHash);
429+
strBuffer.append(getSchemaHash());
432430
strBuffer.append(", state=");
433431
strBuffer.append(state.name());
434432
strBuffer.append(", isBad=");

0 commit comments

Comments
 (0)