Example usage for com.google.common.collect ImmutableListMultimap of

List of usage examples for com.google.common.collect ImmutableListMultimap of

Introduction

In this page you can find the example usage for com.google.common.collect ImmutableListMultimap of.

Prototype

public static <K, V> ImmutableListMultimap<K, V> of(K k1, V v1, K k2, V v2, K k3, V v3, K k4, V v4) 

Source Link

Document

Returns an immutable multimap containing the given entries, in order.

Usage

From source file:com.facebook.presto.operator.MockExchangeRequestProcessor.java

@Override
public Response apply(Request request) {
    if (request.getMethod().equalsIgnoreCase("DELETE")) {
        return new TestingResponse(HttpStatus.NO_CONTENT, ImmutableListMultimap.<String, String>of(),
                new byte[0]);
    }//  w w w  .j  a va  2s.  c  o  m

    // verify we got a data size and it parses correctly
    assertTrue(!request.getHeaders().get(PrestoHeaders.PRESTO_MAX_SIZE).isEmpty());
    DataSize maxSize = DataSize.valueOf(request.getHeader(PrestoHeaders.PRESTO_MAX_SIZE));
    assertEquals(maxSize, expectedMaxSize);

    RequestLocation requestLocation = new RequestLocation(request.getUri());
    URI location = requestLocation.getLocation();

    BufferResult result = buffers.getUnchecked(location).getPages(requestLocation.getSequenceId(), maxSize);
    List<Page> pages = result.getPages();

    byte[] bytes = new byte[0];
    HttpStatus status;
    if (!pages.isEmpty()) {
        DynamicSliceOutput sliceOutput = new DynamicSliceOutput(64);
        PagesSerde.writePages(new BlockEncodingManager(new TypeRegistry()), sliceOutput, pages);
        bytes = sliceOutput.slice().getBytes();
        status = HttpStatus.OK;
    } else {
        status = HttpStatus.NO_CONTENT;
    }

    return new TestingResponse(status, ImmutableListMultimap.of(CONTENT_TYPE, PRESTO_PAGES, PRESTO_PAGE_TOKEN,
            String.valueOf(result.getToken()), PRESTO_PAGE_NEXT_TOKEN, String.valueOf(result.getNextToken()),
            PRESTO_BUFFER_COMPLETE, String.valueOf(result.isBufferComplete())), bytes);
}