Package it.unimi.dsi.fastutil.longs

Examples of it.unimi.dsi.fastutil.longs.LongArrayList


    final ValueSpecification spec2 = createValueSpec(2);
    final ValueSpecification spec3 = createValueSpec(3);
    final Long2ObjectMap<ValueSpecification> spec1And2 = new Long2ObjectOpenHashMap<ValueSpecification>(new long[] {1L, 2L }, new ValueSpecification[] {spec1, spec2 });
    final IdentifierMap underlying = Mockito.mock(IdentifierMap.class);
    final CachingIdentifierMap cache = new CachingIdentifierMap(underlying);
    Mockito.when(underlying.getValueSpecifications(new LongArrayList(new long[] {1L, 2L }))).thenReturn(spec1And2);
    Mockito.when(underlying.getValueSpecification(3L)).thenReturn(spec3);
    Long2ObjectMap<ValueSpecification> result = cache.getValueSpecifications(new LongArrayList(new long[] {1L, 2L }));
    assertEquals(result.size(), 2);
    assertEquals(result.get(1L), spec1);
    assertEquals(result.get(2L), spec2);
    result = cache.getValueSpecifications(new LongArrayList(new long[] {1L, 2L }));
    assertEquals(result.size(), 2);
    assertEquals(result.get(1L), spec1);
    assertEquals(result.get(2L), spec2);
    Mockito.verify(underlying, Mockito.times(1)).getValueSpecifications(new LongArrayList(new long[] {1L, 2L }));
    result = cache.getValueSpecifications(new LongArrayList(new long[] {2L, 3L }));
    assertEquals(result.size(), 2);
    assertEquals(result.get(2L), spec2);
    assertEquals(result.get(3L), spec3);
    result = cache.getValueSpecifications(new LongArrayList(new long[] {2L, 3L }));
    assertEquals(result.size(), 2);
    assertEquals(result.get(2L), spec2);
    assertEquals(result.get(3L), spec3);
    Mockito.verify(underlying, Mockito.times(1)).getValueSpecification(3L);
    result = cache.getValueSpecifications(new LongArrayList(new long[] {1L, 2L, 3L }));
    assertEquals(result.size(), 3);
    assertEquals(result.get(1L), spec1);
    assertEquals(result.get(2L), spec2);
    assertEquals(result.get(3L), spec3);
    result = cache.getValueSpecifications(new LongArrayList(new long[] {1L, 2L, 3L }));
    assertEquals(result.size(), 3);
    assertEquals(result.get(1L), spec1);
    assertEquals(result.get(2L), spec2);
    assertEquals(result.get(3L), spec3);
    Mockito.verifyNoMoreInteractions(underlying);
View Full Code Here


    _rand = new Random(System.currentTimeMillis());

    BufferedReader reader = null;

    LongArrayList idList = new LongArrayList(_numIds);
    try {
      reader = new BufferedReader(new InputStreamReader(new FileInputStream(dataFile),
          Charset.forName("UTF-8")));
      while (true) {
        String line = reader.readLine();
        if (line == null) break;
        try {
          JSONObject json = new JSONObject(line);
          long id = Long.parseLong(json.getString("id_str"));
          idList.add(id);
        } catch (Exception e) {
          // ignore
        }
        if (idList.size() >= _numIds) break;
      }
    } finally {
      if (reader != null) {
        reader.close();
      }
    }
    _idArray = idList.toLongArray();
  }
View Full Code Here

    private Type type;

    public ChannelIndex(int expectedPositions, TupleInfo tupleInfo)
    {
        this.tupleInfo = tupleInfo;
        valueAddresses = new LongArrayList(expectedPositions);
        slices = ObjectArrayList.wrap(new Slice[1024], 0);
        type = tupleInfo.getType();
    }
View Full Code Here

                       new TransactionManager.InProgressTx(startPointer - 1, currentTime + 300000L));
      }
    }

    // make 100 random invalid IDs
    LongArrayList invalid = new LongArrayList();
    for (int i = 0; i < 100; i++) {
      invalid.add(Math.abs(random.nextLong()) % 1000000L);
    }

    // make 100 committing entries, 10 keys each
    Map<Long, Set<ChangeId>> committing = Maps.newHashMap();
    for (int i = 0; i < 100; i++) {
View Full Code Here

TOP

Related Classes of it.unimi.dsi.fastutil.longs.LongArrayList

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.