Java Code Examples for com.carrotsearch.hppc.IntArrayList#get()
The following examples show how to use
com.carrotsearch.hppc.IntArrayList#get() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ShardResponse.java From crate with Apache License 2.0 | 6 votes |
public void update(ShardResponse response) { IntArrayList itemIndices = response.itemIndices(); List<Failure> failures = response.failures(); for (int i = 0; i < itemIndices.size(); i++) { int location = itemIndices.get(i); ShardResponse.Failure failure = failures.get(i); if (failure == null) { successfulWrites.set(location, true); } else { failureLocations.set(location, true); } } List<Object[]> resultRows = response.getResultRows(); if (resultRows != null) { this.resultRows.addAll(resultRows); } }
Example 2
Source File: SolrInformationServer.java From SearchServices with GNU Lesser General Public License v3.0 | 5 votes |
@Override public Set<Long> getErrorDocIds() throws IOException { Set<Long> errorDocIds = new HashSet<>(); RefCounted<SolrIndexSearcher> refCounted = null; try { refCounted = this.core.getSearcher(); SolrIndexSearcher searcher = refCounted.get(); TermQuery errorQuery = new TermQuery(new Term(FIELD_DOC_TYPE, DOC_TYPE_ERROR_NODE)); DocListCollector docListCollector = new DocListCollector(); searcher.search(errorQuery, docListCollector); IntArrayList docList = docListCollector.getDocs(); int size = docList.size(); for (int i = 0; i < size; ++i) { int doc = docList.get(i); Document document = searcher.doc(doc, REQUEST_ONLY_ID_FIELD); IndexableField id = document.getField(FIELD_SOLR4_ID); String idString = id.stringValue(); if (idString.startsWith(PREFIX_ERROR)) { idString = idString.substring(PREFIX_ERROR.length()); } errorDocIds.add(Long.valueOf(idString)); } } finally { ofNullable(refCounted).ifPresent(RefCounted::decref); } return errorDocIds; }
Example 3
Source File: UpsertResultCollectors.java From crate with Apache License 2.0 | 5 votes |
void processShardResponse(UpsertResults upsertResults, ShardResponse shardResponse, List<RowSourceInfo> rowSourceInfos) { synchronized (lock) { List<ShardResponse.Failure> failures = shardResponse.failures(); IntArrayList locations = shardResponse.itemIndices(); for (int i = 0; i < failures.size(); i++) { ShardResponse.Failure failure = failures.get(i); int location = locations.get(i); RowSourceInfo rowSourceInfo = rowSourceInfos.get(location); String msg = failure == null ? null : failure.message(); upsertResults.addResult(rowSourceInfo.sourceUri, msg, rowSourceInfo.lineNumber); } } }
Example 4
Source File: SolrInformationServer.java From SearchServices with GNU Lesser General Public License v3.0 | 4 votes |
@Override public List<NodeMetaData> getCascadeNodes(List<Long> txnIds) throws IOException, JSONException { List<FieldInstance> list = dataModel.getIndexedFieldNamesForProperty(ContentModel.PROP_CASCADE_TX).getFields(); FieldInstance fieldInstance = list.get(0); RefCounted<SolrIndexSearcher> refCounted = null; IntArrayList docList; Set<Long> parentNodesId = new HashSet<>(); try { refCounted = core.getSearcher(); SolrIndexSearcher searcher = refCounted.get(); String field = fieldInstance.getField(); SchemaField schemaField = searcher.getSchema().getField(field); FieldType fieldType = schemaField.getType(); BooleanQuery.Builder builder = new BooleanQuery.Builder(); BooleanQuery booleanQuery; for(Long l : txnIds) { BytesRefBuilder bytesRefBuilder = new BytesRefBuilder(); fieldType.readableToIndexed(l.toString(), bytesRefBuilder); TermQuery termQuery = new TermQuery(new Term(field, bytesRefBuilder.toBytesRef())); BooleanClause booleanClause = new BooleanClause(termQuery, BooleanClause.Occur.SHOULD); builder.add(booleanClause); } booleanQuery = builder.build(); DocListCollector collector = new DocListCollector(); searcher.search(booleanQuery, collector); docList = collector.getDocs(); int size = docList.size(); for(int i=0; i<size; i++) { int docId = docList.get(i); Document document = searcher.doc(docId, REQUEST_ONLY_ID_FIELD); IndexableField indexableField = document.getField(FIELD_SOLR4_ID); String id = indexableField.stringValue(); TenantDbId ids = AlfrescoSolrDataModel.decodeNodeDocumentId(id); parentNodesId.add(ids.dbId); } } finally { ofNullable(refCounted).ifPresent(RefCounted::decref); } List<NodeMetaData> allNodeMetaDatas = new ArrayList<>(); for (Long parentNodeId : parentNodesId) { NodeMetaDataParameters nmdp = new NodeMetaDataParameters(); nmdp.setFromNodeId(parentNodeId); nmdp.setToNodeId(parentNodeId); nmdp.setIncludeAclId(true); nmdp.setIncludeChildAssociations(false); nmdp.setIncludeChildIds(true); nmdp.setIncludeOwner(false); nmdp.setIncludeParentAssociations(false); nmdp.setIncludePaths(true); nmdp.setIncludeProperties(false); nmdp.setIncludeTxnId(true); nmdp.setMaxResults(1); // Gets only one Optional<Collection<NodeMetaData>> nodeMetaDatas = getNodesMetaDataFromRepository(nmdp); allNodeMetaDatas.addAll(nodeMetaDatas.orElse(Collections.emptyList())); } return allNodeMetaDatas; }
Example 5
Source File: InsertFromValues.java From crate with Apache License 2.0 | 4 votes |
/** * Create bulk-response depending on number of bulk responses * <pre> * compressedResult * success: [1, 1, 1, 1] * failure: [] * * insert into t (x) values (?), (?) -- bulkParams: [[1, 2], [3, 4]] * Response: * [2, 2] * * insert into t (x) values (?) -- bulkParams: [[1], [2], [3], [4]] * Response: * [1, 1, 1, 1] * </pre> */ private static long[] createBulkResponse(ShardResponse.CompressedResult result, int bulkResponseSize, IntArrayList bulkIndices) { long[] resultRowCount = new long[bulkResponseSize]; Arrays.fill(resultRowCount, 0L); for (int i = 0; i < bulkIndices.size(); i++) { int resultIdx = bulkIndices.get(i); if (result.successfulWrites(i)) { resultRowCount[resultIdx]++; } else if (result.failed(i)) { resultRowCount[resultIdx] = Row1.ERROR; } } return resultRowCount; }