-
Notifications
You must be signed in to change notification settings - Fork 874
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
use SMO service for class name and SHA1 queries.
- the remote index does not contain class name information anymore - sha1 queries are rarely used and contribute to index size, which makes them a good candidate for SMO too
- Loading branch information
Showing
5 changed files
with
212 additions
and
12 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
106 changes: 106 additions & 0 deletions
106
java/maven.indexer/src/org/netbeans/modules/maven/indexer/SMOResultImpl.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,106 @@ | ||
/* | ||
* 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.netbeans.modules.maven.indexer; | ||
|
||
import java.util.Collections; | ||
import java.util.List; | ||
import java.util.stream.Collectors; | ||
import org.apache.maven.search.backend.smo.SmoSearchResponse; | ||
import org.netbeans.modules.maven.indexer.api.NBVersionInfo; | ||
import org.netbeans.modules.maven.indexer.spi.ResultImplementation; | ||
|
||
/** | ||
* Wraps search-maven-org query results. | ||
* | ||
* @author mbien | ||
*/ | ||
final class SMOResultImpl implements ResultImplementation<NBVersionInfo> { | ||
|
||
private List<NBVersionInfo> list = null; | ||
private final String repoId; | ||
private final SmoSearchResponse response; | ||
|
||
public SMOResultImpl(String repoId, SmoSearchResponse response) { | ||
this.repoId = repoId; | ||
this.response = response; | ||
} | ||
|
||
@Override | ||
public List<NBVersionInfo> getResults() { | ||
if (list == null) { | ||
list = response.getPage().stream() | ||
.map(rec -> new NBVersionInfo( | ||
repoId, | ||
rec.getValue(org.apache.maven.search.MAVEN.GROUP_ID), | ||
rec.getValue(org.apache.maven.search.MAVEN.ARTIFACT_ID), | ||
rec.getValue(org.apache.maven.search.MAVEN.VERSION), | ||
rec.getValue(org.apache.maven.search.MAVEN.PACKAGING), // todo, type is used in the UI as packaging?? | ||
rec.getValue(org.apache.maven.search.MAVEN.PACKAGING), | ||
null, | ||
null, | ||
rec.getValue(org.apache.maven.search.MAVEN.CLASSIFIER))) | ||
.collect(Collectors.toList()); | ||
} | ||
return list; | ||
} | ||
|
||
@Override | ||
public boolean isPartial() { | ||
return false; | ||
} | ||
|
||
@Override | ||
public void waitForSkipped() { | ||
throw new UnsupportedOperationException(); | ||
} | ||
|
||
@Override | ||
public int getTotalResultCount() { | ||
return response.getTotalHits(); | ||
} | ||
|
||
@Override | ||
public int getReturnedResultCount() { | ||
return response.getCurrentHits(); | ||
} | ||
|
||
public static ResultImplementation<NBVersionInfo> empty() { | ||
return new ResultImplementation<NBVersionInfo>() { | ||
@Override | ||
public boolean isPartial() { | ||
return false; | ||
} | ||
@Override | ||
public List<NBVersionInfo> getResults() { | ||
return Collections.emptyList(); | ||
} | ||
@Override | ||
public int getTotalResultCount() { | ||
return 0; | ||
} | ||
@Override | ||
public int getReturnedResultCount() { | ||
return 0; | ||
} | ||
@Override | ||
public void waitForSkipped() {} | ||
}; | ||
} | ||
|
||
} |