Jackie-Jiang commented on a change in pull request #7297:
URL: https://github.com/apache/pinot/pull/7297#discussion_r688729542
##########
File path:
pinot-segment-local/src/main/java/org/apache/pinot/segment/local/segment/store/FilePerIndexDirectory.java
##########
@@ -88,26 +91,42 @@ public boolean hasIndexFor(String column, ColumnIndexType
type) {
@Override
public void close()
throws IOException {
- for (PinotDataBuffer dataBuffer : indexBuffers.values()) {
+ for (PinotDataBuffer dataBuffer : _indexBuffers.values()) {
dataBuffer.close();
}
}
@Override
public void removeIndex(String columnName, ColumnIndexType indexType) {
File indexFile = getFileFor(columnName, indexType);
- indexFile.delete();
+ if (indexFile.delete()) {
+ _indexBuffers.remove(new IndexKey(columnName, indexType));
+ }
}
@Override
public boolean isIndexRemovalSupported() {
return true;
}
+ @Override
+ public Set<String> getColumnsWithIndex(ColumnIndexType type) {
+ if (_indexBuffers.isEmpty()) {
+ return Collections.emptySet();
+ }
+ Set<String> columns = new HashSet<>();
+ for (IndexKey entry : _indexBuffers.keySet()) {
Review comment:
(nit)
```suggestion
for (IndexKey indexKey : _indexBuffers.keySet()) {
```
##########
File path:
pinot-segment-local/src/main/java/org/apache/pinot/segment/local/segment/store/FilePerIndexDirectory.java
##########
@@ -88,26 +91,42 @@ public boolean hasIndexFor(String column, ColumnIndexType
type) {
@Override
public void close()
throws IOException {
- for (PinotDataBuffer dataBuffer : indexBuffers.values()) {
+ for (PinotDataBuffer dataBuffer : _indexBuffers.values()) {
dataBuffer.close();
}
}
@Override
public void removeIndex(String columnName, ColumnIndexType indexType) {
File indexFile = getFileFor(columnName, indexType);
- indexFile.delete();
+ if (indexFile.delete()) {
+ _indexBuffers.remove(new IndexKey(columnName, indexType));
+ }
}
@Override
public boolean isIndexRemovalSupported() {
return true;
}
+ @Override
+ public Set<String> getColumnsWithIndex(ColumnIndexType type) {
+ if (_indexBuffers.isEmpty()) {
+ return Collections.emptySet();
+ }
Review comment:
I don't think this check is required as it should be super rare that
there is no index in the segment
##########
File path:
pinot-segment-local/src/main/java/org/apache/pinot/segment/local/segment/store/SingleFileIndexDirectory.java
##########
@@ -370,6 +373,20 @@ public boolean isIndexRemovalSupported() {
return false;
}
+ @Override
+ public Set<String> getColumnsWithIndex(ColumnIndexType type) {
+ if (_columnEntries.isEmpty()) {
Review comment:
Same here
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]