Java Code Examples for com.carrotsearch.hppc.IntHashSet#size()

The following examples show how to use com.carrotsearch.hppc.IntHashSet#size() . 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: ExpandComponent.java    From lucene-solr with Apache License 2.0 6 votes vote down vote up
public GroupExpandCollector(SortedDocValues docValues, FixedBitSet groupBits, IntHashSet collapsedSet, int limit, Sort sort) throws IOException {
  int numGroups = collapsedSet.size();
  groups = new LongObjectHashMap<>(numGroups);
  DocIdSetIterator iterator = new BitSetIterator(groupBits, 0); // cost is not useful here
  int group;
  while ((group = iterator.nextDoc()) != DocIdSetIterator.NO_MORE_DOCS) {
    groups.put(group, getCollector(limit, sort));
  }

  this.collapsedSet = collapsedSet;
  this.groupBits = groupBits;
  this.docValues = docValues;
  if(docValues instanceof MultiDocValues.MultiSortedDocValues) {
    this.multiSortedDocValues = (MultiDocValues.MultiSortedDocValues)docValues;
    this.ordinalMap = multiSortedDocValues.mapping;
  }
}
 
Example 2
Source File: BaseWriteConfiguration.java    From spliceengine with GNU Affero General Public License v3.0 6 votes vote down vote up
@Override
public WriteResponse processGlobalResult(BulkWriteResult bulkWriteResult) throws Throwable {
    WriteResult writeResult = bulkWriteResult.getGlobalResult();
    if (writeResult.isSuccess())
        return WriteResponse.SUCCESS;
    else if (writeResult.isPartial()) {
        IntObjectHashMap<WriteResult> failedRows = bulkWriteResult.getFailedRows();
        if (failedRows != null && failedRows.size() > 0) {
            return WriteResponse.PARTIAL;
        }
        IntHashSet notRun = bulkWriteResult.getNotRunRows();
        if(notRun!=null && notRun.size()>0)
            return WriteResponse.PARTIAL;
        /*
         * We got a partial result, but didn't specify which rows needed behavior.
         * That's weird, but since we weren't told there would be a problem, we may
         * as well ignore
         */
        return WriteResponse.IGNORE;
    } else if (!writeResult.canRetry())
        throw exceptionFactory.processErrorResult(writeResult);
    else
        return WriteResponse.RETRY;
}
 
Example 3
Source File: ExpandComponent.java    From lucene-solr with Apache License 2.0 5 votes vote down vote up
public NumericGroupExpandCollector(String field, long nullValue, LongHashSet groupSet, IntHashSet collapsedSet, int limit, Sort sort) throws IOException {
  int numGroups = collapsedSet.size();
  this.nullValue = nullValue;
  groups = new LongObjectHashMap<>(numGroups);
  for (LongCursor cursor : groupSet) {
    groups.put(cursor.value, getCollector(limit, sort));
  }

  this.field = field;
  this.collapsedSet = collapsedSet;
}
 
Example 4
Source File: AddAllTest.java    From hashmapTest with The Unlicense 5 votes vote down vote up
public static void main(String[] args) {
    final long start = System.currentTimeMillis();

    final IntHashSet a = new com.carrotsearch.hppc.IntHashSet();
    for( int i = 10000000; i-- != 0; ) a.add(i);
    IntHashSet b = new com.carrotsearch.hppc.IntHashSet(a.size());
    b.addAll(a);
    b = new com.carrotsearch.hppc.IntHashSet();
    b.addAll(a);

    final long time = System.currentTimeMillis() - start;
    System.out.println( time / 1000.0 );
    System.out.println( b.size() );
}
 
Example 5
Source File: PipelineUtils.java    From spliceengine with GNU Affero General Public License v3.0 5 votes vote down vote up
public static Collection<KVPair> doPartialRetry(BulkWrite bulkWrite,BulkWriteResult response,long id) throws Exception{
    IntHashSet notRunRows=response.getNotRunRows();
    IntObjectHashMap<WriteResult> failedRows=response.getFailedRows();
    Collection<KVPair> toRetry=new ArrayList<>(failedRows.size()+notRunRows.size());
    List<String> errorMsgs= Lists.newArrayListWithCapacity(failedRows.size());
    int i=0;
    Collection<KVPair> allWrites=bulkWrite.getMutations();
    for(KVPair kvPair : allWrites){
        if(notRunRows.contains(i))
            toRetry.add(kvPair);
        else{
            WriteResult writeResult=failedRows.get(i);
            if(writeResult!=null){
                errorMsgs.add(writeResult.getErrorMessage());
                if(writeResult.canRetry())
                    toRetry.add(kvPair);
            }
        }
        i++;
    }
    if(LOG.isTraceEnabled()){
        int[] errorCounts=new int[11];
        for(IntObjectCursor<WriteResult> failedCursor : failedRows){
            errorCounts[failedCursor.value.getCode().ordinal()]++;
        }
        SpliceLogUtils.trace(LOG,"[%d] %d failures with types: %s",id,failedRows.size(),Arrays.toString(errorCounts));
    }

    return toRetry;
}