Example usage for java.util HashMap size

List of usage examples for java.util HashMap size

Introduction

In this page you can find the example usage for java.util HashMap size.

Prototype

int size

To view the source code for java.util HashMap size.

Click Source Link

Document

The number of key-value mappings contained in this map.

Usage

From source file:edu.lternet.pasta.portal.statistics.GrowthStats.java

private Long[] buildSortedList(HashMap<String, Long> map) {

    Long[] list = new Long[map.size()];

    int i = 0;/*from ww w .  j a  v a  2s.co m*/
    for (Map.Entry<String, Long> entry : map.entrySet()) {
        list[i++] = entry.getValue();
    }

    Arrays.sort(list);

    return list;

}

From source file:org.kitodo.data.index.elasticsearch.type.ProcessTypeTest.java

@Test
public void shouldCreateDocuments() throws Exception {
    ProcessType processType = new ProcessType();

    List<Process> processes = prepareData();
    HashMap<Integer, HttpEntity> documents = processType.createDocuments(processes);
    assertEquals("HashMap of documents doesn't contain given amount of elements!", 3, documents.size());
}

From source file:org.kitodo.data.elasticsearch.index.type.ProcessTypeTest.java

@Test
public void shouldCreateDocuments() {
    ProcessType processType = new ProcessType();

    List<Process> processes = prepareData();
    HashMap<Integer, HttpEntity> documents = processType.createDocuments(processes);
    assertEquals("HashMap of documents doesn't contain given amount of elements!", 3, documents.size());
}

From source file:org.openmidaas.library.common.network.AndroidNetworkTransport.java

@Override
public void doPostRequest(boolean withSSL, String url, HashMap<String, String> headers, JSONObject data,
        AsyncHttpResponseHandler responseHandler) {
    try {/*w w  w  . jav  a2 s  .  co  m*/
        AsyncHttpClient client = new AsyncHttpClient();
        if (headers != null) {
            if (headers.size() > 0) {
                MIDaaS.logDebug(TAG, "Headers: ");
                MIDaaS.logDebug(TAG, "Key: Value");
                for (String key : headers.keySet()) {
                    client.addHeader(key, headers.get(key));
                    MIDaaS.logDebug(TAG, "" + key + " : " + headers.get(key));
                }
            }
        }
        MIDaaS.logDebug(TAG, "Data: " + data.toString());
        client.post(null, mHostUrl + url, new StringEntity(data.toString()), "application/json",
                responseHandler);
    } catch (UnsupportedEncodingException e) {
        MIDaaS.logError(TAG, e.getMessage());
        responseHandler.onFailure(e, e.getMessage());
    }
}

From source file:org.kitodo.data.index.elasticsearch.type.UserTypeTest.java

@Test
public void shouldCreateDocuments() throws Exception {
    UserType userType = new UserType();

    List<User> users = prepareData();
    HashMap<Integer, HttpEntity> documents = userType.createDocuments(users);
    assertEquals("HashMap of documents doesn't contain given amount of elements!", 3, documents.size());
}

From source file:org.kitodo.data.elasticsearch.index.type.TaskTypeTest.java

@Test
public void shouldCreateDocuments() {
    TaskType taskType = new TaskType();

    List<Task> tasks = prepareData();
    HashMap<Integer, HttpEntity> documents = taskType.createDocuments(tasks);
    assertEquals("HashMap of documents doesn't contain given amount of elements!", 3, documents.size());
}

From source file:org.kitodo.data.index.elasticsearch.RestClientImplementation.java

/**
 * Add list of documents to the index. This method will be used for add whole table to the index.
 * It performs asynchronous request./*from  w  ww . java2s  .  c  o m*/
 *
 * @param documentsToIndex list of json documents to the index
 */
public String addType(HashMap<Integer, HttpEntity> documentsToIndex) throws InterruptedException {
    final CountDownLatch latch = new CountDownLatch(documentsToIndex.size());
    final StringBuilder output = new StringBuilder();

    for (HashMap.Entry<Integer, HttpEntity> entry : documentsToIndex.entrySet()) {
        restClient.performRequestAsync("PUT",
                "/" + this.getIndex() + "/" + this.getType() + "/" + entry.getKey(),
                Collections.<String, String>emptyMap(), entry.getValue(), new ResponseListener() {
                    @Override
                    //problem with return type - it should be String
                    //dirty hack private variable ArrayResult
                    public void onSuccess(Response response) {
                        output.append(response.toString());
                        latch.countDown();
                    }

                    @Override
                    public void onFailure(Exception exception) {
                        latch.countDown();
                    }
                });
    }
    latch.await();

    return output.toString();
}

From source file:org.kitodo.data.index.elasticsearch.type.TaskTypeTest.java

@Test
public void shouldCreateDocuments() throws Exception {
    TaskType taskType = new TaskType();

    List<Task> tasks = prepareData();
    HashMap<Integer, HttpEntity> documents = taskType.createDocuments(tasks);
    assertEquals("HashMap of documents doesn't contain given amount of elements!", 3, documents.size());
}

From source file:com.linkedin.pinot.util.DataTableCustomSerDeTest.java

/**
 * Test for ser/de of HashMap&lt;String, Double&gt;
 *///from w w  w .  j  a va2  s.co  m
@Test
public void testStringDoubleHashMap() {
    for (int i = 0; i < NUM_ITERATIONS; i++) {
        Map<String, Double> expected = new HashMap<>();

        int size = random.nextInt(100);
        for (int j = 0; j < size; j++) {
            expected.put(RandomStringUtils.random(random.nextInt(20), true, true), random.nextDouble());
        }

        byte[] bytes = serde.serialize(expected);
        HashMap<String, Double> actual = serde.deserialize(bytes, DataTableSerDe.DataType.HashMap);

        Assert.assertEquals(actual.size(), expected.size(), "Random seed: " + randomSeed);
        for (Map.Entry<String, Double> entry : expected.entrySet()) {
            String key = entry.getKey();
            Assert.assertTrue(actual.containsKey(key), "Random seed: " + randomSeed);
            Assert.assertEquals(actual.get(key), entry.getValue(), "Random seed: " + randomSeed);
        }
    }
}

From source file:Evaluator.StatCalculator.java

public double correlationCalc(HashMap<String, Double> kderunQidMap, HashMap<String, Double> aprunQidMap) {
    double xArray[], yArray[];
    int count = 0;

    xArray = new double[kderunQidMap.size()];
    yArray = new double[kderunQidMap.size()];

    Iterator it = kderunQidMap.keySet().iterator();
    while (it.hasNext()) {
        String run = (String) it.next();
        xArray[count] = kderunQidMap.get(run);
        yArray[count++] = aprunQidMap.get(run);
    }//from   w w  w . j  a  v  a 2s . c om

    PearsonsCorrelation prc = new PearsonsCorrelation();
    return prc.correlation(xArray, yArray);

}