-
Notifications
You must be signed in to change notification settings - Fork 3.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Opt](multi-catalog)Improve performance by introducing cache of list …
…directory files when getting split for each query.
- Loading branch information
1 parent
00e5ab8
commit 65ef2e1
Showing
17 changed files
with
813 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
fe/fe-core/src/main/java/org/apache/doris/fs/DirectoryLister.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
// Licensed to the Apache Software Foundation (ASF) under one | ||
// or more contributor license agreements. See the NOTICE file | ||
// distributed with this work for additional information | ||
// regarding copyright ownership. The ASF licenses this file | ||
// to you under the Apache License, Version 2.0 (the | ||
// "License"); you may not use this file except in compliance | ||
// with the License. You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, | ||
// software distributed under the License is distributed on an | ||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
// KIND, either express or implied. See the License for the | ||
// specific language governing permissions and limitations | ||
// under the License. | ||
// This file is copied from | ||
// https://github.com/trinodb/trino/blob/438/plugin/trino-hive/src/main/java/io/trino/plugin/hive/fs/DirectoryLister.java | ||
// and modified by Doris | ||
|
||
package org.apache.doris.fs; | ||
|
||
import org.apache.doris.catalog.TableIf; | ||
import org.apache.doris.fs.remote.RemoteFile; | ||
|
||
import java.io.IOException; | ||
|
||
public interface DirectoryLister { | ||
RemoteIterator<RemoteFile> listFilesRecursively(FileSystem fs, TableIf table, String location) | ||
throws IOException; | ||
} |
38 changes: 38 additions & 0 deletions
38
fe/fe-core/src/main/java/org/apache/doris/fs/FileSystemDirectoryLister.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
// Licensed to the Apache Software Foundation (ASF) under one | ||
// or more contributor license agreements. See the NOTICE file | ||
// distributed with this work for additional information | ||
// regarding copyright ownership. The ASF licenses this file | ||
// to you under the Apache License, Version 2.0 (the | ||
// "License"); you may not use this file except in compliance | ||
// with the License. You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, | ||
// software distributed under the License is distributed on an | ||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
// KIND, either express or implied. See the License for the | ||
// specific language governing permissions and limitations | ||
// under the License. | ||
|
||
package org.apache.doris.fs; | ||
|
||
import org.apache.doris.backup.Status; | ||
import org.apache.doris.catalog.TableIf; | ||
import org.apache.doris.fs.remote.RemoteFile; | ||
|
||
import java.io.IOException; | ||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
public class FileSystemDirectoryLister implements DirectoryLister { | ||
public RemoteIterator<RemoteFile> listFilesRecursively(FileSystem fs, TableIf table, String location) | ||
throws IOException { | ||
List<RemoteFile> result = new ArrayList<>(); | ||
Status status = fs.listFiles(location, true, result); | ||
if (!status.ok()) { | ||
throw new IOException(status.getErrMsg()); | ||
} | ||
return new RemoteFileRemoteIterator(result); | ||
} | ||
} |
48 changes: 48 additions & 0 deletions
48
fe/fe-core/src/main/java/org/apache/doris/fs/RemoteFileRemoteIterator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
// Licensed to the Apache Software Foundation (ASF) under one | ||
// or more contributor license agreements. See the NOTICE file | ||
// distributed with this work for additional information | ||
// regarding copyright ownership. The ASF licenses this file | ||
// to you under the Apache License, Version 2.0 (the | ||
// "License"); you may not use this file except in compliance | ||
// with the License. You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, | ||
// software distributed under the License is distributed on an | ||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
// KIND, either express or implied. See the License for the | ||
// specific language governing permissions and limitations | ||
// under the License. | ||
|
||
package org.apache.doris.fs; | ||
|
||
import org.apache.doris.fs.remote.RemoteFile; | ||
|
||
import java.io.IOException; | ||
import java.util.List; | ||
import java.util.NoSuchElementException; | ||
import java.util.Objects; | ||
|
||
public class RemoteFileRemoteIterator | ||
implements RemoteIterator<RemoteFile> { | ||
private final List<RemoteFile> remoteFileList; | ||
private int currentIndex = 0; | ||
|
||
public RemoteFileRemoteIterator(List<RemoteFile> remoteFileList) { | ||
this.remoteFileList = Objects.requireNonNull(remoteFileList, "iterator is null"); | ||
} | ||
|
||
@Override | ||
public boolean hasNext() throws IOException { | ||
return currentIndex < remoteFileList.size(); | ||
} | ||
|
||
@Override | ||
public RemoteFile next() throws IOException { | ||
if (!hasNext()) { | ||
throw new NoSuchElementException("No more elements in RemoteFileRemoteIterator"); | ||
} | ||
return remoteFileList.get(currentIndex++); | ||
} | ||
} |
Oops, something went wrong.