private void checkBlock(IDBlock block, LongSet ids) { assertEquals(blockSize,block.numIds()); for (int i=0;i<blockSize;i++) { long id = block.getId(i); assertEquals(id,block.getId(i)); assertFalse(ids.contains(id)); assertTrue(id<idUpperBound); assertTrue(id>0); ids.add(id); } if (hasEmptyUid) { assertEquals(blockSize-1,block.getId(block.numIds()-1)-block.getId(0)); } try { block.getId(blockSize); fail(); } catch (ArrayIndexOutOfBoundsException e) {} }
private IntLongMap getEdgeIdToOsmWayIdMap() { if (edgeIdToOsmWayIdMap == null) edgeIdToOsmWayIdMap = new GHIntLongHashMap(getOsmWayIdSet().size(), 0.5f); return edgeIdToOsmWayIdMap; }
/** * Stores only osmWayIds which are required for relations */ protected void storeOsmWayID(int edgeId, long osmWayId) { if (getOsmWayIdSet().contains(osmWayId)) { getEdgeIdToOsmWayIdMap().put(edgeId, osmWayId); } }
long item = resultRow.getNumber("item").longValue(); long id = resultRow.getNumber("category").longValue(); ids.add(id); double weight = resultRow.getNumber("weight").doubleValue(); map.compute(item, (key, agg) -> { int idx = 0; long[] idsArray = ids.toArray(); for (Map.Entry<Long, LongDoubleMap> entry : map.entrySet()) { Long item = entry.getKey(); List<Number> weightsList = new ArrayList<>(ids.size()); for (long id : idsArray) { weightsList.add(sparseWeights.getOrDefault(id, skipValue));
protected LeafEntry createEntry(final long tok, final LongSet offsets) { int offsetCount = offsets.size(); switch (offsetCount) { case 0: throw new AssertionError("no offsets for token " + tok); case 1: long offset = offsets.toArray()[0]; if (offset > MAX_OFFSET) throw new AssertionError("offset " + offset + " cannot be greater than " + MAX_OFFSET); else if (offset <= Integer.MAX_VALUE) return new SimpleLeafEntry(tok, offset); else return new FactoredOffsetLeafEntry(tok, offset); case 2: long[] rawOffsets = offsets.toArray(); if (rawOffsets[0] <= Integer.MAX_VALUE && rawOffsets[1] <= Integer.MAX_VALUE && (rawOffsets[0] <= Short.MAX_VALUE || rawOffsets[1] <= Short.MAX_VALUE)) return new PackedCollisionLeafEntry(tok, rawOffsets); else return createOverflowEntry(tok, offsetCount, offsets); default: return createOverflowEntry(tok, offsetCount, offsets); } }
protected LeafEntry createEntry(final long tok, final LongSet offsets) { int offsetCount = offsets.size(); switch (offsetCount) { case 0: throw new AssertionError("no offsets for token " + tok); case 1: long offset = offsets.toArray()[0]; if (offset > MAX_OFFSET) throw new AssertionError("offset " + offset + " cannot be greater than " + MAX_OFFSET); else if (offset <= Integer.MAX_VALUE) return new SimpleLeafEntry(tok, offset); else return new FactoredOffsetLeafEntry(tok, offset); case 2: long[] rawOffsets = offsets.toArray(); if (rawOffsets[0] <= Integer.MAX_VALUE && rawOffsets[1] <= Integer.MAX_VALUE && (rawOffsets[0] <= Short.MAX_VALUE || rawOffsets[1] <= Short.MAX_VALUE)) return new PackedCollisionLeafEntry(tok, rawOffsets); else return createOverflowEntry(tok, offsetCount, offsets); default: return createOverflowEntry(tok, offsetCount, offsets); } }
private void addReject(long val) { invalids.add(val); } }
private void checkBlock(IDBlock block, LongSet ids) { assertEquals(blockSize,block.numIds()); for (int i=0;i<blockSize;i++) { long id = block.getId(i); assertEquals(id,block.getId(i)); assertFalse(ids.contains(id)); assertTrue(id<idUpperBound); assertTrue(id>0); ids.add(id); } if (hasEmptyUid) { assertEquals(blockSize-1,block.getId(block.numIds()-1)-block.getId(0)); } try { block.getId(blockSize); fail(); } catch (ArrayIndexOutOfBoundsException ignored) {} }
protected LeafEntry createEntry(final long tok, final LongSet offsets) { int offsetCount = offsets.size(); switch (offsetCount) { case 0: throw new AssertionError("no offsets for token " + tok); case 1: long offset = offsets.toArray()[0]; if (offset > MAX_OFFSET) throw new AssertionError("offset " + offset + " cannot be greater than " + MAX_OFFSET); else if (offset <= Integer.MAX_VALUE) return new SimpleLeafEntry(tok, offset); else return new FactoredOffsetLeafEntry(tok, offset); case 2: long[] rawOffsets = offsets.toArray(); if (rawOffsets[0] <= Integer.MAX_VALUE && rawOffsets[1] <= Integer.MAX_VALUE && (rawOffsets[0] <= Short.MAX_VALUE || rawOffsets[1] <= Short.MAX_VALUE)) return new PackedCollisionLeafEntry(tok, rawOffsets); else return createOverflowEntry(tok, offsetCount, offsets); default: return createOverflowEntry(tok, offsetCount, offsets); } }
/** * Return true if all keys of some other container exist in this container. */ private boolean sameKeys(LongSet other) { if (other.size() != size()) { return false; } for (LongCursor c : other) { if (!contains( c.value)) { return false; } } return true; }
private void addAccept(long val) { valids.add(val); }
private IntLongMap getEdgeIdToOsmWayIdMap() { if (edgeIdToOsmWayIdMap == null) edgeIdToOsmWayIdMap = new GHIntLongHashMap(getOsmWayIdSet().size(), 0.5f); return edgeIdToOsmWayIdMap; }
private void addReject(long val) { invalids.add(val); } }