io.netty.util.collection.IntObjectHashMap Java Examples
The following examples show how to use
io.netty.util.collection.IntObjectHashMap.
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: HashInnerJoinBatchIterator.java From crate with Apache License 2.0 | 6 votes |
public HashInnerJoinBatchIterator(BatchIterator<Row> left, BatchIterator<Row> right, RowAccounting<Object[]> leftRowAccounting, CombinedRow combiner, Predicate<Row> joinCondition, ToIntFunction<Row> hashBuilderForLeft, ToIntFunction<Row> hashBuilderForRight, IntSupplier calculateBlockSize) { super(left, right, combiner); this.leftRowAccounting = leftRowAccounting; this.joinCondition = joinCondition; this.hashBuilderForLeft = hashBuilderForLeft; this.hashBuilderForRight = hashBuilderForRight; this.calculateBlockSize = calculateBlockSize; // resized upon block size calculation this.buffer = new IntObjectHashMap<>(); resetBuffer(); // initially 1 page/batch is loaded numberOfLeftBatchesLoadedForBlock = 1; this.activeIt = left; }
Example #2
Source File: GroupByMaps.java From crate with Apache License 2.0 | 6 votes |
public static <K, V> Supplier<Map<K, V>> mapForType(DataType<K> type) { switch (type.id()) { case ByteType.ID: return () -> (Map) new PrimitiveMapWithNulls<>(new ByteObjectHashMap<>()); case ShortType.ID: return () -> (Map) new PrimitiveMapWithNulls<>(new ShortObjectHashMap<>()); case IntegerType.ID: return () -> (Map) new PrimitiveMapWithNulls<>(new IntObjectHashMap<>()); case LongType.ID: case TimestampType.ID_WITH_TZ: case TimestampType.ID_WITHOUT_TZ: return () -> (Map) new PrimitiveMapWithNulls<>(new LongObjectHashMap<>()); default: return HashMap::new; } }
Example #3
Source File: UniformStreamByteDistributorTest.java From netty-4.1.22 with Apache License 2.0 | 6 votes |
@Before public void setup() throws Http2Exception { MockitoAnnotations.initMocks(this); stateMap = new IntObjectHashMap<TestStreamByteDistributorStreamState>(); connection = new DefaultHttp2Connection(false); distributor = new UniformStreamByteDistributor(connection); // Assume we always write all the allocated bytes. resetWriter(); connection.local().createStream(STREAM_A, false); connection.local().createStream(STREAM_B, false); Http2Stream streamC = connection.local().createStream(STREAM_C, false); Http2Stream streamD = connection.local().createStream(STREAM_D, false); setPriority(streamC.id(), STREAM_A, DEFAULT_PRIORITY_WEIGHT, false); setPriority(streamD.id(), STREAM_A, DEFAULT_PRIORITY_WEIGHT, false); }
Example #4
Source File: CumulativePageBucketReceiver.java From crate with Apache License 2.0 | 5 votes |
public CumulativePageBucketReceiver(String nodeName, int phaseId, Executor executor, Streamer<?>[] streamers, RowConsumer rowConsumer, PagingIterator<Integer, Row> pagingIterator, int numBuckets) { this.nodeName = nodeName; this.phaseId = phaseId; this.executor = executor; this.streamers = streamers; this.consumer = rowConsumer; this.pagingIterator = pagingIterator; this.numBuckets = numBuckets; this.exhausted = Collections.newSetFromMap(new IntObjectHashMap<>(numBuckets)); this.bucketsByIdx = new IntObjectHashMap<>(numBuckets); this.listenersByBucketIdx = new IntObjectHashMap<>(numBuckets); processingFuture.whenComplete((result, ex) -> { synchronized (listenersByBucketIdx) { for (PageResultListener resultListener : listenersByBucketIdx.values()) { resultListener.needMore(false); } listenersByBucketIdx.clear(); } }); batchPagingIterator = new BatchPagingIterator<>( pagingIterator, this::fetchMore, this::allUpstreamsExhausted, throwable -> { if (throwable == null) { processingFuture.complete(null); } else { processingFuture.completeExceptionally(throwable); } } ); traceEnabled = LOGGER.isTraceEnabled(); }
Example #5
Source File: IntObjectHashMapBenchmark.java From netty-4.1.22 with Apache License 2.0 | 5 votes |
@Override void put(Blackhole bh) { IntObjectHashMap<Long> map = new IntObjectHashMap<Long>(); for (int key : keys) { bh.consume(map.put(key, VALUE)); } }
Example #6
Source File: IntObjectHashMapBenchmark.java From netty-4.1.22 with Apache License 2.0 | 5 votes |
@Override void remove(Blackhole bh) { IntObjectHashMap<Long> copy = new IntObjectHashMap<Long>(); copy.putAll(map); for (int key : keys) { bh.consume(copy.remove(key)); } }
Example #7
Source File: DnsQueryContextManager.java From netty-4.1.22 with Apache License 2.0 | 5 votes |
private IntObjectMap<DnsQueryContext> getOrCreateContextMap(InetSocketAddress nameServerAddr) { synchronized (map) { final IntObjectMap<DnsQueryContext> contexts = map.get(nameServerAddr); if (contexts != null) { return contexts; } final IntObjectMap<DnsQueryContext> newContexts = new IntObjectHashMap<DnsQueryContext>(); final InetAddress a = nameServerAddr.getAddress(); final int port = nameServerAddr.getPort(); map.put(nameServerAddr, newContexts); if (a instanceof Inet4Address) { // Also add the mapping for the IPv4-compatible IPv6 address. final Inet4Address a4 = (Inet4Address) a; if (a4.isLoopbackAddress()) { map.put(new InetSocketAddress(NetUtil.LOCALHOST6, port), newContexts); } else { map.put(new InetSocketAddress(toCompactAddress(a4), port), newContexts); } } else if (a instanceof Inet6Address) { // Also add the mapping for the IPv4 address if this IPv6 address is compatible. final Inet6Address a6 = (Inet6Address) a; if (a6.isLoopbackAddress()) { map.put(new InetSocketAddress(NetUtil.LOCALHOST4, port), newContexts); } else if (a6.isIPv4CompatibleAddress()) { map.put(new InetSocketAddress(toIPv4Address(a6), port), newContexts); } } return newContexts; } }
Example #8
Source File: TileCraftingPlateRenderer.java From Wizardry with GNU Lesser General Public License v3.0 | 5 votes |
public TileCraftingPlateRenderer(@Nonnull TileCraftingPlate tile) { super(tile); animator.setUseWorldTicks(true); hoveringStacks = new IntObjectHashMap<>(tile.realInventory.getHandler().getSlots()); for (int i = 0; i < tile.realInventory.getHandler().getSlots(); i++) { update(i, tile.realInventory.getHandler().getStackInSlot(i)); } }
Example #9
Source File: RoundRobinProxyHandler.java From xio with Apache License 2.0 | 5 votes |
@Override public Optional<ClientConfig> getClientConfig(ChannelHandlerContext ctx, Request request) { // get/create the cachedClientConfig that is instanced per server channel IntObjectMap<Optional<ClientConfig>> cachedClientConfig = ctx.channel().attr(ROUND_ROBIN_KEY).get(); if (cachedClientConfig == null) { cachedClientConfig = new IntObjectHashMap<>(); ctx.channel().attr(ROUND_ROBIN_KEY).set(cachedClientConfig); } return getClientConfig(cachedClientConfig, request); }
Example #10
Source File: RoundRobinProxyHandlerTest.java From xio with Apache License 2.0 | 5 votes |
@Test public void testFullRequestsStandard() { when(config.clientConfigs()).thenReturn(clientConfigs); subject = RoundRobinProxyHandler.createStandardRoundRobinHandler(null, config, null); Request request1 = mock(Request.class); Request request2 = mock(Request.class); Request request3 = mock(Request.class); Request request4 = mock(Request.class); // since we are doing all full requests we actually don't care what the request path is when(request1.isFullMessage()).thenReturn(true); when(request1.path()).thenReturn("dontcare"); when(request1.streamId()).thenReturn(Message.H1_STREAM_ID_NONE); when(request2.isFullMessage()).thenReturn(true); when(request2.path()).thenReturn("dontcare"); when(request2.streamId()).thenReturn(Message.H1_STREAM_ID_NONE); when(request3.isFullMessage()).thenReturn(true); when(request3.path()).thenReturn("dontcare"); when(request3.streamId()).thenReturn(Message.H1_STREAM_ID_NONE); when(request4.isFullMessage()).thenReturn(true); when(request4.path()).thenReturn("dontcare"); when(request4.streamId()).thenReturn(Message.H1_STREAM_ID_NONE); IntObjectMap<Optional<ClientConfig>> cacheMap = new IntObjectHashMap<>(); ClientConfig result1 = subject.getClientConfig(cacheMap, request1).orElse(null); assertEquals(clientConfig1, result1); ClientConfig result2 = subject.getClientConfig(cacheMap, request2).orElse(null); assertEquals(clientConfig2, result2); ClientConfig result3 = subject.getClientConfig(cacheMap, request3).orElse(null); assertEquals(clientConfig3, result3); ClientConfig result4 = subject.getClientConfig(cacheMap, request3).orElse(null); assertEquals(clientConfig1, result4); assertTrue(cacheMap.isEmpty()); }
Example #11
Source File: FrameReassembler.java From rsocket-java with Apache License 2.0 | 4 votes |
public FrameReassembler(ByteBufAllocator allocator) { this.allocator = allocator; this.headers = new IntObjectHashMap<>(); this.metadata = new IntObjectHashMap<>(); this.data = new IntObjectHashMap<>(); }
Example #12
Source File: RoundRobinProxyHandlerTest.java From xio with Apache License 2.0 | 4 votes |
@Test public void testChunkedRequestsHttp2Statistical() { when(config.clientConfigs()).thenReturn(clientConfigs); Random mockRandom = mock(Random.class); subject = new RoundRobinProxyHandler(null, config, null, () -> mockRandom); int streamId1 = 1; int streamId2 = 3; Request request1a = mock(Request.class); Request request2a = mock(Request.class); Request request3a = mock(Request.class); Request request1b = mock(Request.class); Request request2b = mock(Request.class); Request request3b = mock(Request.class); // lets interleave requests between a and b // first part of a chunked message #1 when(request1a.isFullMessage()).thenReturn(false); when(request1a.startOfMessage()).thenReturn(true); when(request1a.endOfMessage()).thenReturn(false); when(request1a.path()).thenReturn("/foo"); when(request1a.streamId()).thenReturn(streamId1); // first part of a chunked message #2 when(request1b.isFullMessage()).thenReturn(false); when(request1b.startOfMessage()).thenReturn(true); when(request1b.endOfMessage()).thenReturn(false); when(request1b.path()).thenReturn("/foo"); when(request1b.streamId()).thenReturn(streamId2); // middle part of a chunked message #1 when(request2a.isFullMessage()).thenReturn(false); when(request2a.startOfMessage()).thenReturn(false); when(request2a.endOfMessage()).thenReturn(false); when(request2a.path()).thenReturn("/foo"); when(request2a.streamId()).thenReturn(streamId1); // middle part of a chunked message #2 when(request2b.isFullMessage()).thenReturn(false); when(request2b.startOfMessage()).thenReturn(false); when(request2b.endOfMessage()).thenReturn(false); when(request2b.path()).thenReturn("/foo"); when(request2b.streamId()).thenReturn(streamId2); // last part of a chunked message #1 when(request3a.isFullMessage()).thenReturn(false); when(request3a.startOfMessage()).thenReturn(false); when(request3a.endOfMessage()).thenReturn(true); when(request3a.path()).thenReturn("/foo"); when(request3a.streamId()).thenReturn(streamId1); // last part of a chunked message #2 when(request3b.isFullMessage()).thenReturn(false); when(request3b.startOfMessage()).thenReturn(false); when(request3b.endOfMessage()).thenReturn(true); when(request3b.path()).thenReturn("/foo"); when(request3b.streamId()).thenReturn(streamId2); IntObjectMap<Optional<ClientConfig>> cacheMap = new IntObjectHashMap<>(); when(mockRandom.nextInt(eq(config.clientConfigs().size()))).thenReturn(0); ClientConfig result1a = subject.getClientConfig(cacheMap, request1a).orElse(null); assertEquals(clientConfig1, result1a); when(mockRandom.nextInt(eq(config.clientConfigs().size()))).thenReturn(1); ClientConfig result1b = subject.getClientConfig(cacheMap, request1b).orElse(null); assertEquals(clientConfig2, result1b); ClientConfig result2a = subject.getClientConfig(cacheMap, request2a).orElse(null); assertEquals(clientConfig1, result2a); ClientConfig result2b = subject.getClientConfig(cacheMap, request2b).orElse(null); assertEquals(clientConfig2, result2b); ClientConfig result3a = subject.getClientConfig(cacheMap, request3a).orElse(null); assertEquals(clientConfig1, result3a); ClientConfig result3b = subject.getClientConfig(cacheMap, request3b).orElse(null); assertEquals(clientConfig2, result3b); assertTrue(cacheMap.isEmpty()); }
Example #13
Source File: RoundRobinProxyHandlerTest.java From xio with Apache License 2.0 | 4 votes |
@Test public void testChunkedRequestsHttp2Standard() { when(config.clientConfigs()).thenReturn(clientConfigs); subject = RoundRobinProxyHandler.createStandardRoundRobinHandler(null, config, null); int streamId1 = 1; int streamId2 = 3; Request request1a = mock(Request.class); Request request2a = mock(Request.class); Request request3a = mock(Request.class); Request request1b = mock(Request.class); Request request2b = mock(Request.class); Request request3b = mock(Request.class); // lets interleave requests between a and b // first part of a chunked message #1 when(request1a.isFullMessage()).thenReturn(false); when(request1a.startOfMessage()).thenReturn(true); when(request1a.endOfMessage()).thenReturn(false); when(request1a.path()).thenReturn("/foo"); when(request1a.streamId()).thenReturn(streamId1); // first part of a chunked message #2 when(request1b.isFullMessage()).thenReturn(false); when(request1b.startOfMessage()).thenReturn(true); when(request1b.endOfMessage()).thenReturn(false); when(request1b.path()).thenReturn("/foo"); when(request1b.streamId()).thenReturn(streamId2); // middle part of a chunked message #1 when(request2a.isFullMessage()).thenReturn(false); when(request2a.startOfMessage()).thenReturn(false); when(request2a.endOfMessage()).thenReturn(false); when(request2a.path()).thenReturn("/foo"); when(request2a.streamId()).thenReturn(streamId1); // middle part of a chunked message #2 when(request2b.isFullMessage()).thenReturn(false); when(request2b.startOfMessage()).thenReturn(false); when(request2b.endOfMessage()).thenReturn(false); when(request2b.path()).thenReturn("/foo"); when(request2b.streamId()).thenReturn(streamId2); // last part of a chunked message #1 when(request3a.isFullMessage()).thenReturn(false); when(request3a.startOfMessage()).thenReturn(false); when(request3a.endOfMessage()).thenReturn(true); when(request3a.path()).thenReturn("/foo"); when(request3a.streamId()).thenReturn(streamId1); // last part of a chunked message #2 when(request3b.isFullMessage()).thenReturn(false); when(request3b.startOfMessage()).thenReturn(false); when(request3b.endOfMessage()).thenReturn(true); when(request3b.path()).thenReturn("/foo"); when(request3b.streamId()).thenReturn(streamId2); IntObjectMap<Optional<ClientConfig>> cacheMap = new IntObjectHashMap<>(); ClientConfig result1a = subject.getClientConfig(cacheMap, request1a).orElse(null); assertEquals(clientConfig1, result1a); ClientConfig result1b = subject.getClientConfig(cacheMap, request1b).orElse(null); assertEquals(clientConfig2, result1b); ClientConfig result2a = subject.getClientConfig(cacheMap, request2a).orElse(null); assertEquals(clientConfig1, result2a); ClientConfig result2b = subject.getClientConfig(cacheMap, request2b).orElse(null); assertEquals(clientConfig2, result2b); ClientConfig result3a = subject.getClientConfig(cacheMap, request3a).orElse(null); assertEquals(clientConfig1, result3a); ClientConfig result3b = subject.getClientConfig(cacheMap, request3b).orElse(null); assertEquals(clientConfig2, result3b); assertTrue(cacheMap.isEmpty()); }
Example #14
Source File: RoundRobinProxyHandlerTest.java From xio with Apache License 2.0 | 4 votes |
@Test public void testChunkedRequestsHttp1Statistical() { when(config.clientConfigs()).thenReturn(clientConfigs); Random mockRandom = mock(Random.class); subject = new RoundRobinProxyHandler(null, config, null, () -> mockRandom); Request request1 = mock(Request.class); Request request2 = mock(Request.class); Request request3 = mock(Request.class); // first part of a chunked message when(request1.isFullMessage()).thenReturn(false); when(request1.startOfMessage()).thenReturn(true); when(request1.endOfMessage()).thenReturn(false); when(request1.path()).thenReturn("/foo"); when(request1.streamId()).thenReturn(Message.H1_STREAM_ID_NONE); // middle part of a chunked message when(request2.isFullMessage()).thenReturn(false); when(request2.startOfMessage()).thenReturn(false); when(request2.endOfMessage()).thenReturn(false); when(request2.path()).thenReturn("/foo"); when(request2.streamId()).thenReturn(Message.H1_STREAM_ID_NONE); // last part of a chunked message when(request3.isFullMessage()).thenReturn(false); when(request3.startOfMessage()).thenReturn(false); when(request3.endOfMessage()).thenReturn(true); when(request3.path()).thenReturn("/foo"); when(request3.streamId()).thenReturn(Message.H1_STREAM_ID_NONE); IntObjectMap<Optional<ClientConfig>> cacheMap = new IntObjectHashMap<>(); when(mockRandom.nextInt(eq(config.clientConfigs().size()))).thenReturn(0); ClientConfig result1 = subject.getClientConfig(cacheMap, request1).orElse(null); assertEquals(clientConfig1, result1); when(mockRandom.nextInt(eq(config.clientConfigs().size()))).thenReturn(1); ClientConfig result2 = subject.getClientConfig(cacheMap, request2).orElse(null); assertEquals(clientConfig1, result2); when(mockRandom.nextInt(eq(config.clientConfigs().size()))).thenReturn(2); ClientConfig result3 = subject.getClientConfig(cacheMap, request3).orElse(null); assertEquals(clientConfig1, result3); assertTrue(cacheMap.isEmpty()); }
Example #15
Source File: RoundRobinProxyHandlerTest.java From xio with Apache License 2.0 | 4 votes |
@Test public void testChunkedRequestsHttp1Standard() { when(config.clientConfigs()).thenReturn(clientConfigs); subject = RoundRobinProxyHandler.createStandardRoundRobinHandler(null, config, null); Request request1 = mock(Request.class); Request request2 = mock(Request.class); Request request3 = mock(Request.class); // first part of a chunked message when(request1.isFullMessage()).thenReturn(false); when(request1.startOfMessage()).thenReturn(true); when(request1.endOfMessage()).thenReturn(false); when(request1.path()).thenReturn("/foo"); when(request1.streamId()).thenReturn(Message.H1_STREAM_ID_NONE); // middle part of a chunked message when(request2.isFullMessage()).thenReturn(false); when(request2.startOfMessage()).thenReturn(false); when(request2.endOfMessage()).thenReturn(false); when(request2.path()).thenReturn("/foo"); when(request2.streamId()).thenReturn(Message.H1_STREAM_ID_NONE); // last part of a chunked message when(request3.isFullMessage()).thenReturn(false); when(request3.startOfMessage()).thenReturn(false); when(request3.endOfMessage()).thenReturn(true); when(request3.path()).thenReturn("/foo"); when(request3.streamId()).thenReturn(Message.H1_STREAM_ID_NONE); IntObjectMap<Optional<ClientConfig>> cacheMap = new IntObjectHashMap<>(); ClientConfig result1 = subject.getClientConfig(cacheMap, request1).orElse(null); assertEquals(clientConfig1, result1); ClientConfig result2 = subject.getClientConfig(cacheMap, request2).orElse(null); assertEquals(clientConfig1, result2); ClientConfig result3 = subject.getClientConfig(cacheMap, request3).orElse(null); assertEquals(clientConfig1, result3); assertTrue(cacheMap.isEmpty()); }
Example #16
Source File: RoundRobinProxyHandlerTest.java From xio with Apache License 2.0 | 4 votes |
@Test public void testFullRequestsStatistical() { when(config.clientConfigs()).thenReturn(clientConfigs); Random mockRandom = mock(Random.class); subject = new RoundRobinProxyHandler(null, config, null, () -> mockRandom); Request request1 = mock(Request.class); Request request2 = mock(Request.class); Request request3 = mock(Request.class); Request request4 = mock(Request.class); // since we are doing all full requests we actually don't care what the request path is when(request1.isFullMessage()).thenReturn(true); when(request1.path()).thenReturn("dontcare"); when(request1.streamId()).thenReturn(Message.H1_STREAM_ID_NONE); when(request2.isFullMessage()).thenReturn(true); when(request2.path()).thenReturn("dontcare"); when(request2.streamId()).thenReturn(Message.H1_STREAM_ID_NONE); when(request3.isFullMessage()).thenReturn(true); when(request3.path()).thenReturn("dontcare"); when(request3.streamId()).thenReturn(Message.H1_STREAM_ID_NONE); when(request4.isFullMessage()).thenReturn(true); when(request4.path()).thenReturn("dontcare"); when(request4.streamId()).thenReturn(Message.H1_STREAM_ID_NONE); IntObjectMap<Optional<ClientConfig>> cacheMap = new IntObjectHashMap<>(); when(mockRandom.nextInt(eq(config.clientConfigs().size()))).thenReturn(0); ClientConfig result1 = subject.getClientConfig(cacheMap, request1).orElse(null); assertEquals(clientConfig1, result1); when(mockRandom.nextInt(eq(config.clientConfigs().size()))).thenReturn(1); ClientConfig result2 = subject.getClientConfig(cacheMap, request2).orElse(null); assertEquals(clientConfig2, result2); when(mockRandom.nextInt(eq(config.clientConfigs().size()))).thenReturn(2); ClientConfig result3 = subject.getClientConfig(cacheMap, request3).orElse(null); assertEquals(clientConfig3, result3); when(mockRandom.nextInt(eq(config.clientConfigs().size()))).thenReturn(0); ClientConfig result4 = subject.getClientConfig(cacheMap, request3).orElse(null); assertEquals(clientConfig1, result4); assertTrue(cacheMap.isEmpty()); }
Example #17
Source File: MqttClientImpl.java From smartacus-mqtt-broker with Apache License 2.0 | 4 votes |
public IntObjectHashMap<MqttPendingSubscription> getPendingSubscriptions() { return pendingSubscriptions; }
Example #18
Source File: WeightedFairQueueByteDistributor.java From netty-4.1.22 with Apache License 2.0 | 4 votes |
private void initChildren() { children = new IntObjectHashMap<State>(INITIAL_CHILDREN_MAP_SIZE); }
Example #19
Source File: MqttClientImpl.java From smartacus-mqtt-broker with Apache License 2.0 | 4 votes |
public IntObjectHashMap<MqttIncomingQos2Publish> getQos2PendingIncomingPublishes() { return qos2PendingIncomingPublishes; }
Example #20
Source File: MqttClientImpl.java From smartacus-mqtt-broker with Apache License 2.0 | 4 votes |
public IntObjectHashMap<MqttPendingPublish> getPendingPublishes() { return pendingPublishes; }
Example #21
Source File: MqttClientImpl.java From smartacus-mqtt-broker with Apache License 2.0 | 4 votes |
public IntObjectHashMap<MqttPendingUnsubscription> getPendingServerUnsubscribes() { return pendingServerUnsubscribes; }