Preallocate a certain number of T Objects. Useful for services so that
the first transactions don't get hit with all the Object creation costs

@param lt
@param prime
@throws APIException
198030
public void prime(LogTarget lt, int prime) throws APIException {
		for (int i = 0; i < prime; ++i) {
			Pooled<T> pt = new Pooled<T>(creator.create(), this, lt);
			synchronized (list) {
				list.addFirst(pt);
				++count;
			}
		}

	}
425449
public void setApi(String api) {
        api = api.trim();
        if ("liberty".equalsIgnoreCase(api)) {
            this.api = "liberty";
        } else if ("websphere".equalsIgnoreCase(api)) {
            this.api = "tr";
        } else if ("tr".equalsIgnoreCase(api)) {
            this.api = "tr";
        } else if ("jsr47".equalsIgnoreCase(api)) {
            this.api = "java-logging";
        } else if ("java".equalsIgnoreCase(api)) {
            this.api = "java-logging";
        } else if ("java.logging".equalsIgnoreCase(api)) {
            this.api = "java-logging";
        } else if ("java-logging".equalsIgnoreCase(api)) {
            this.api = "java-logging";
        } else {
            log("Invalid trace type " + api, Project.MSG_ERR);
        }
    }
45613
@Override
    public <E extends Exception> void add(Iteration<? extends Statement, E> statements, Resource... contexts) throws RepositoryException, E {
        while(statements.hasNext()){
            Statement st = statements.next();
            add(st.getSubject(), st.getPredicate(), st.getObject(), mergeResource(st.getContext(), contexts));
        }
    }
1099368
protected static TransmissionDataIterator allocateFromPool(Connection connection,
                                                              JFapByteBuffer buffer,
                                                              int priority,
                                                              boolean isPooled,
                                                              boolean isExchange,
                                                              int segmentType,
                                                              int conversationId,
                                                              int requestNumber,
                                                              Conversation conversation,
                                                              SendListener sendListener,
                                                              boolean isTerminal,
                                                              int size)
   {
      if (tc.isEntryEnabled()) SibTr.entry(tc, "allocateFromPool");
      TransmissionDataIterator retValue = (TransmissionDataIterator)pool.remove();
      if (retValue == null)
         retValue = new TransmissionDataIterator();
      retValue.reset(connection, buffer, priority, isPooled, isExchange, segmentType, conversationId, requestNumber, conversation, sendListener, isTerminal, size);
      if (tc.isEntryEnabled()) SibTr.exit(tc, "allocateFromPool", retValue);
      return retValue;
   }
306351
synchronized public void set(Element value) {
    int bind = ((int)value.getIndex() & Integer.MAX_VALUE) % buckets.length;
    Element[] bucket = buckets[bind];
    int count = counts[bind];
    if (bucket == null)
      buckets[bind] = bucket = new Element[initBucketSize];
    else if (bucket.length == count) {
      bucket = new Element[count * 2];
      System.arraycopy(buckets[bind], 0, bucket, 0, count);
      buckets[bind] = bucket;
    }
    bucket[count] = value;
    counts[bind] = count + 1;
    totalSize += 1;
  }
456334
public static <T> List<T> setOrAppend(List<T> list, int index, T element) {
		if (index < list.size()) {
			list.set(index, element);
		} else {
			list.add(element);
		}
		return list;
	}
833982
public<T> Put<T> put(Class<T> cls) throws APIException {
		return new Put<T>(this,getDF(cls));
	}
422481
@Override
    public void preProcess(@NonNull MultiDataSet toPreProcess) {
        int numFeatures = toPreProcess.numFeatureArrays();
        int numLabels = toPreProcess.numLabelsArrays();

        for (int i = 0; i < numFeatures; i++) {
            strategy.preProcess(toPreProcess.getFeatures(i), toPreProcess.getFeaturesMaskArray(i), getFeatureStats(i));
        }
        if (isFitLabel()) {
            for (int i = 0; i < numLabels; i++) {
                strategy.preProcess(toPreProcess.getLabels(i), toPreProcess.getLabelsMaskArray(i), getLabelStats(i));
            }
        }
    }
585756
public void putNext(Tuple t) throws IOException
    {
        if (t.size() < 1)
        {
            // simply nothing here, we can't even delete without a key
            logger.warn("Empty output skipped, filter empty tuples to suppress this warning");
            return;
        }

        if (t.getType(0) == DataType.TUPLE)
        {
            if (t.getType(1) == DataType.TUPLE)
            {
                Map<String, ByteBuffer> key = tupleToKeyMap((Tuple)t.get(0));
                cqlQueryFromTuple(key, t, 1);
            }
            else
                throw new IOException("Second argument in output must be a tuple");
        }
        else
            throw new IOException("First argument in output must be a tuple");
    }
52099
@Override
    public C.Sequence<T> prepend(C.Sequence<? extends T> seq) {
        if (seq instanceof C.List) {
            return prependList((C.List<T>) seq);
        }
        if (isLazy()) {
            return new CompositeSeq<T>(seq, this);
        }
        return unLazyPrepend(seq);
    }
322907
@Override
	public GenericContext<ElementType> lookup(final Predicate<ElementType> pPredicate) {

		return lookup(pPredicate, Integer.MAX_VALUE, new GenericContext<ElementType>());
	}
547339
public static <T> CompletableFuture<T> toCompletableFuture(ApiFuture<T> apiFuture) {
        return Java8FutureUtils.createCompletableFuture(ApiFutureUtils.createValueSourceFuture(apiFuture));
    }
1200151
protected void processLAandLI(File archive, RepositoryResourceWritable resource,
                                  ProvisioningFeatureDefinition feature) throws IOException, RepositoryException {
        String LAHeader = feature.getHeader(LA_HEADER_FEATURE);
        String LIHeader = feature.getHeader(LI_HEADER_FEATURE);
        processLAandLI(archive, resource, LAHeader, LIHeader);
    }
576520
private RunList<R> limit(final CountingPredicate<R> predicate) {
        size = null;
        first = null;
        final Iterable<R> nested = base;
        base = new Iterable<R>() {
            public Iterator<R> iterator() {
                return hudson.util.Iterators.limit(nested.iterator(),predicate);
            }

            @Override
            public String toString() {
                return Iterables.toString(this);
            }
        };
        return this;
    }
1028588
public void ensureSpareCapacity(int n)
        throws IOException
    {
        // Do we have space?
        if (n>spareCapacity())
        {
            // No, then try flushing what we do have
            if (_pos>_start )
                flush();

            ensureCapacity(n);
        }
    }
216944
@Override
	public <R extends OBDAResultSet> R execute(InputQuery<R> inputQuery) throws OntopConnectionException,
            OntopReformulationException, OntopQueryEvaluationException, OntopResultConversionException {
		if (inputQuery instanceof SelectQuery) {
			return (R) executeInThread((SelectQuery) inputQuery, this::executeSelectQuery);
		}
		else if (inputQuery instanceof AskQuery) {
			return (R) executeInThread((AskQuery) inputQuery, this::executeBooleanQuery);
		}
		else if (inputQuery instanceof ConstructQuery) {
			return (R) executeInThread((ConstructQuery) inputQuery, this::executeConstructQuery);
		}
		else if (inputQuery instanceof DescribeQuery) {
			return (R) executeDescribeQuery((DescribeQuery) inputQuery);
		}
		else {
			throw new OntopUnsupportedInputQueryException("Unsupported query type: " + inputQuery);
		}
	}
630097
public DataLoader<K, V> prime(K key, V value) {
        Object cacheKey = getCacheKey(key);
        synchronized (this) {
            if (!futureCache.containsKey(cacheKey)) {
                futureCache.set(cacheKey, CompletableFuture.completedFuture(value));
            }
        }
        return this;
    }