本文整理汇总了Java中org.h2.util.IntArray.add方法的典型用法代码示例。如果您正苦于以下问题:Java IntArray.add方法的具体用法?Java IntArray.add怎么用?Java IntArray.add使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.h2.util.IntArray
的用法示例。
在下文中一共展示了IntArray.add方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: narrowForQuery
import org.h2.util.IntArray; //导入方法依赖的package包/类
/** */
private Map<ClusterNode, IntArray> narrowForQuery(Map<ClusterNode, IntArray> partsMap, int[] parts) {
if (parts == null)
return partsMap;
Map<ClusterNode, IntArray> cp = U.newHashMap(partsMap.size());
for (Map.Entry<ClusterNode, IntArray> entry : partsMap.entrySet()) {
IntArray filtered = new IntArray(parts.length);
IntArray orig = entry.getValue();
for (int i = 0; i < orig.size(); i++) {
int p = orig.get(i);
if (Arrays.binarySearch(parts, p) >= 0)
filtered.add(p);
}
if (filtered.size() > 0)
cp.put(entry.getKey(), filtered);
}
return cp.isEmpty() ? null : cp;
}
示例2: removeUntil
import org.h2.util.IntArray; //导入方法依赖的package包/类
/**
* Remove all pages until the given data page.
*
* @param trunkPage the first trunk page
* @param firstDataPageToKeep the first data page to keep
* @return the trunk page of the data page to keep
*/
private int removeUntil(int trunkPage, int firstDataPageToKeep) {
trace.debug("log.removeUntil " + trunkPage + " " + firstDataPageToKeep);
int last = trunkPage;
while (true) {
Page p = store.getPage(trunkPage);
PageStreamTrunk t = (PageStreamTrunk) p;
if (t == null) {
throw DbException.throwInternalError(
"log.removeUntil not found: " + firstDataPageToKeep + " last " + last);
}
logKey = t.getLogKey();
last = t.getPos();
if (t.contains(firstDataPageToKeep)) {
return last;
}
trunkPage = t.getNextTrunk();
IntArray list = new IntArray();
list.add(t.getPos());
for (int i = 0;; i++) {
int next = t.getPageData(i);
if (next == -1) {
break;
}
list.add(next);
}
freeLogPages(list);
pageOut.free(t);
}
}
示例3: allocatePages
import org.h2.util.IntArray; //导入方法依赖的package包/类
/**
* Allocate a number of pages.
*
* @param list the list where to add the allocated pages
* @param pagesToAllocate the number of pages to allocate
* @param exclude the exclude list
* @param after all allocated pages are higher than this page
*/
void allocatePages(IntArray list, int pagesToAllocate, BitField exclude,
int after) {
list.ensureCapacity(list.size() + pagesToAllocate);
for (int i = 0; i < pagesToAllocate; i++) {
int page = allocatePage(exclude, after);
after = page;
list.add(page);
}
}
示例4: testRandom
import org.h2.util.IntArray; //导入方法依赖的package包/类
private void testRandom() {
IntArray array = new IntArray();
int[] test = {};
Random random = new Random(1);
for (int i = 0; i < 10000; i++) {
int idx = test.length == 0 ? 0 : random.nextInt(test.length);
int v = random.nextInt(100);
int op = random.nextInt(4);
switch (op) {
case 0:
array.add(v);
test = add(test, v);
break;
case 1:
if (test.length > idx) {
assertEquals(get(test, idx), array.get(idx));
}
break;
case 2:
if (test.length > 0) {
array.remove(idx);
test = remove(test, idx);
}
break;
case 3:
assertEquals(test.length, array.size());
break;
default:
}
assertEquals(test.length, array.size());
for (int j = 0; j < test.length; j++) {
assertEquals(test[j], array.get(j));
}
}
}
示例5: findParams
import org.h2.util.IntArray; //导入方法依赖的package包/类
/**
* @param el Element.
* @param params Parameters.
* @param target Extracted parameters.
* @param paramIdxs Parameter indexes.
*/
private static void findParams(@Nullable GridSqlElement el, Object[] params, ArrayList<Object> target,
IntArray paramIdxs) {
if (el == null)
return;
if (el instanceof GridSqlParameter) {
// H2 Supports queries like "select ?5" but first 4 non-existing parameters are need to be set to any value.
// Here we will set them to NULL.
final int idx = ((GridSqlParameter)el).index();
while (target.size() < idx)
target.add(null);
if (params.length <= idx)
throw new IgniteException("Invalid number of query parameters. " +
"Cannot find " + idx + " parameter.");
Object param = params[idx];
if (idx == target.size())
target.add(param);
else
target.set(idx, param);
paramIdxs.add(idx);
}
else if (el instanceof GridSqlSubquery)
findParams(((GridSqlSubquery)el).subquery(), params, target, paramIdxs);
else
for (int i = 0; i < el.size(); i++)
findParams((GridSqlElement)el.child(i), params, target, paramIdxs);
}
示例6: testInit
import org.h2.util.IntArray; //导入方法依赖的package包/类
private static void testInit() {
IntArray array = new IntArray(new int[0]);
array.add(10);
}