java.util.AbstractMap Java Examples

The following examples show how to use java.util.AbstractMap. 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: StellarProcessorUtils.java    From metron with Apache License 2.0 6 votes vote down vote up
public static void runWithArguments(String function, List<Object> arguments, Object expected) {
  Supplier<Stream<Map.Entry<String, Object>>> kvStream = () -> StreamSupport
          .stream(new XRange(arguments.size()), false)
          .map(i -> new AbstractMap.SimpleImmutableEntry<>("var" + i, arguments.get(i)));

  String args = kvStream.get().map(kv -> kv.getKey()).collect(Collectors.joining(","));
  Map<String, Object> variables = kvStream.get().collect(Collectors.toMap(kv -> kv.getKey(), kv -> kv.getValue()));
  String stellarStatement = function + "(" + args + ")";
  String reason = stellarStatement + " != " + expected + " with variables: " + variables;

  if (expected instanceof Double) {
    if(!(Math.abs((Double) expected - (Double) run(stellarStatement, variables)) < 1e-6)) {
      throw new AssertionError(reason);
    }
  } else {
    if(!expected.equals(run(stellarStatement, variables))) {
      throw new AssertionError(reason);
    }
  }
}
 
Example #2
Source File: Util.java    From Bats with Apache License 2.0 6 votes vote down vote up
/** Returns a map that is a view onto a collection of values, using the
 * provided function to convert a value to a key.
 *
 * <p>Unlike
 * {@link com.google.common.collect.Maps#uniqueIndex(Iterable, com.google.common.base.Function)},
 * returns a view whose contents change as the collection of values changes.
 *
 * @param values Collection of values
 * @param function Function to map value to key
 * @param <K> Key type
 * @param <V> Value type
 * @return Map that is a view onto the values
 */
public static <K, V> Map<K, V> asIndexMapJ(
    final Collection<V> values,
    final Function<V, K> function) {
  final Collection<Map.Entry<K, V>> entries =
      Collections2.transform(values, v -> Pair.of(function.apply(v), v));
  final Set<Map.Entry<K, V>> entrySet =
      new AbstractSet<Map.Entry<K, V>>() {
        public Iterator<Map.Entry<K, V>> iterator() {
          return entries.iterator();
        }

        public int size() {
          return entries.size();
        }
      };
  return new AbstractMap<K, V>() {
    public Set<Entry<K, V>> entrySet() {
      return entrySet;
    }
  };
}
 
Example #3
Source File: ConcurrentSkipListMap.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
public boolean tryAdvance(Consumer<? super Map.Entry<K,V>> action) {
    if (action == null) throw new NullPointerException();
    Comparator<? super K> cmp = comparator;
    K f = fence;
    Node<K,V> e = current;
    for (; e != null; e = e.next) {
        K k; Object v;
        if ((k = e.key) != null && f != null && cpr(cmp, f, k) <= 0) {
            e = null;
            break;
        }
        if ((v = e.value) != null && v != e) {
            current = e.next;
            @SuppressWarnings("unchecked") V vv = (V)v;
            action.accept
                (new AbstractMap.SimpleImmutableEntry<K,V>(k, vv));
            return true;
        }
    }
    current = e;
    return false;
}
 
Example #4
Source File: ConcurrentSkipListMap.java    From j2objc with Apache License 2.0 6 votes vote down vote up
public void forEachRemaining(Consumer<? super Map.Entry<K,V>> action) {
    if (action == null) throw new NullPointerException();
    Comparator<? super K> cmp = comparator;
    K f = fence;
    Node<K,V> e = current;
    current = null;
    for (; e != null; e = e.next) {
        K k; Object v;
        if ((k = e.key) != null && f != null && cpr(cmp, f, k) <= 0)
            break;
        if ((v = e.value) != null && v != sentinel()) {
            @SuppressWarnings("unchecked") V vv = (V)v;
            action.accept
                (new AbstractMap.SimpleImmutableEntry<K,V>(k, vv));
        }
    }
}
 
Example #5
Source File: KeyValueSplitter.java    From iow-hadoop-streaming with Apache License 2.0 6 votes vote down vote up
public Map.Entry<String, String> split(String s) {
	int idx = s.indexOf(delimiter);
	if (idx < 0) {
		return new AbstractMap.SimpleEntry<String, String>(s, "");
	}

       int k = 1;
       while (k < numKeys) {
           idx = s.indexOf(delimiter,idx + 1);
           if (idx < 0) break;
           k ++;
       }

       return new AbstractMap.SimpleEntry<String, String>(
                   s.substring(0, idx),
                   s.substring(idx+1)
       );
}
 
Example #6
Source File: IconUtils.java    From roboconf-platform with Apache License 2.0 6 votes vote down vote up
/**
 * Decodes an URL path to extract a name and a potential version.
 * @param path an URL path
 * @return a non-null map entry (key = name, value = version)
 */
public static Map.Entry<String,String> decodeIconUrl( String path ) {

	if( path.startsWith( "/" ))
		path = path.substring( 1 );

	String name = null, version = null;
	String[] parts = path.split( "/" );
	switch( parts.length ) {
	case 2:
		name = parts[ 0 ];
		break;

	case 3:
		name = parts[ 0 ];
		version = parts[ 1 ];
		break;

	default:
		break;
	}

	return new AbstractMap.SimpleEntry<>( name, version );
}
 
Example #7
Source File: DropWizardMetrics.java    From opencensus-java with Apache License 2.0 6 votes vote down vote up
/**
 * Returns a {@code Metric} collected from {@link io.dropwizard.metrics5.Meter}.
 *
 * @param dropwizardMetric the metric name.
 * @param meter the meter object to collect
 * @return a {@code Metric}.
 */
private Metric collectMeter(MetricName dropwizardMetric, Meter meter) {
  String metricName = DropWizardUtils.generateFullMetricName(dropwizardMetric.getKey(), "meter");
  String metricDescription =
      DropWizardUtils.generateFullMetricDescription(dropwizardMetric.getKey(), meter);
  final AbstractMap.SimpleImmutableEntry<List<LabelKey>, List<LabelValue>> labels =
      DropWizardUtils.generateLabels(dropwizardMetric);

  MetricDescriptor metricDescriptor =
      MetricDescriptor.create(
          metricName, metricDescription, DEFAULT_UNIT, Type.CUMULATIVE_INT64, labels.getKey());
  TimeSeries timeSeries =
      TimeSeries.createWithOnePoint(
          labels.getValue(),
          Point.create(Value.longValue(meter.getCount()), clock.now()),
          cumulativeStartTimestamp);

  return Metric.createWithOneTimeSeries(metricDescriptor, timeSeries);
}
 
Example #8
Source File: ConcurrentSkipListMap.java    From j2objc with Apache License 2.0 6 votes vote down vote up
/**
 * Submap version of ConcurrentSkipListMap.getNearEntry.
 */
Map.Entry<K,V> getNearEntry(K key, int rel) {
    Comparator<? super K> cmp = m.comparator;
    if (isDescending) { // adjust relation for direction
        if ((rel & LT) == 0)
            rel |= LT;
        else
            rel &= ~LT;
    }
    if (tooLow(key, cmp))
        return ((rel & LT) != 0) ? null : lowestEntry();
    if (tooHigh(key, cmp))
        return ((rel & LT) != 0) ? highestEntry() : null;
    for (;;) {
        Node<K,V> n = m.findNear(key, rel, cmp);
        if (n == null || !inBounds(n.key, cmp))
            return null;
        K k = n.key;
        V v = n.getValidValue();
        if (v != null)
            return new AbstractMap.SimpleImmutableEntry<K,V>(k, v);
    }
}
 
Example #9
Source File: ConcurrentSkipListMap.java    From JDKSourceCode1.8 with MIT License 6 votes vote down vote up
/**
 * Submap version of ConcurrentSkipListMap.getNearEntry
 */
Map.Entry<K,V> getNearEntry(K key, int rel) {
    Comparator<? super K> cmp = m.comparator;
    if (isDescending) { // adjust relation for direction
        if ((rel & LT) == 0)
            rel |= LT;
        else
            rel &= ~LT;
    }
    if (tooLow(key, cmp))
        return ((rel & LT) != 0) ? null : lowestEntry();
    if (tooHigh(key, cmp))
        return ((rel & LT) != 0) ? highestEntry() : null;
    for (;;) {
        Node<K,V> n = m.findNear(key, rel, cmp);
        if (n == null || !inBounds(n.key, cmp))
            return null;
        K k = n.key;
        V v = n.getValidValue();
        if (v != null)
            return new AbstractMap.SimpleImmutableEntry<K,V>(k, v);
    }
}
 
Example #10
Source File: RecordHelper.java    From pravega with Apache License 2.0 6 votes vote down vote up
/**
 * Method to validate supplied scale input. It performs a check that new ranges are identical to sealed ranges.
 *
 * @param segmentsToSeal segments to seal
 * @param newRanges      new ranges to create
 * @param currentEpoch   current epoch record
 * @return true if scale input is valid, false otherwise.
 */
public static boolean validateInputRange(final List<Long> segmentsToSeal,
                                         final List<Map.Entry<Double, Double>> newRanges,
                                         final EpochRecord currentEpoch) {
    boolean newRangesCheck = newRanges.stream().noneMatch(x -> x.getKey() >= x.getValue() && x.getValue() > 0);

    if (newRangesCheck) {
        List<Map.Entry<Double, Double>> oldRanges = segmentsToSeal.stream()
                .map(segmentId -> {
                    StreamSegmentRecord segment = currentEpoch.getSegment(segmentId);
                    if (segment != null) {
                        return new AbstractMap.SimpleEntry<>(segment.getKeyStart(), segment.getKeyEnd());
                    } else {
                        return null;
                    }
                }).filter(Objects::nonNull)
                .collect(Collectors.toList());
        return reduce(oldRanges).equals(reduce(newRanges));
    }
    
    return false;
}
 
Example #11
Source File: OperationLogTestBase.java    From pravega with Apache License 2.0 6 votes vote down vote up
void performReadIndexChecks(Collection<OperationWithCompletion> operations, ReadIndex readIndex) throws Exception {
    AbstractMap<Long, Integer> expectedLengths = getExpectedLengths(operations);
    AbstractMap<Long, InputStream> expectedData = getExpectedContents(operations);
    for (Map.Entry<Long, InputStream> e : expectedData.entrySet()) {
        int expectedLength = expectedLengths.getOrDefault(e.getKey(), -1);
        @Cleanup
        ReadResult readResult = readIndex.read(e.getKey(), 0, expectedLength, TIMEOUT);
        int readLength = 0;
        while (readResult.hasNext()) {
            BufferView entry = readResult.next().getContent().join();
            int length = entry.getLength();
            readLength += length;
            int streamSegmentOffset = expectedLengths.getOrDefault(e.getKey(), 0);
            expectedLengths.put(e.getKey(), streamSegmentOffset + length);
            AssertExtensions.assertStreamEquals(String.format("Unexpected data returned from ReadIndex. StreamSegmentId = %d, Offset = %d.",
                    e.getKey(), streamSegmentOffset), e.getValue(), entry.getReader(), length);
        }

        Assert.assertEquals("Not enough bytes were read from the ReadIndex for StreamSegment " + e.getKey(), expectedLength, readLength);
    }
}
 
Example #12
Source File: FileLedgerIterator.java    From julongchain with Apache License 2.0 6 votes vote down vote up
/**
 * @return Map.Entry<QueryResult, Common.Status>
 */
@Override
public QueryResult next() throws LedgerException {
    Map.Entry<QueryResult, Common.Status> map;
    QueryResult result;
    try {
        result = commonIterator.next();
    } catch (LedgerException e) {
        log.error(e.getMessage(), e);
        map = new AbstractMap.SimpleEntry<>(null, Common.Status.SERVICE_UNAVAILABLE);
        return new QueryResult(map);
    }
    map = new AbstractMap.SimpleEntry<>(result
            , result == null ? Common.Status.SERVICE_UNAVAILABLE : Common.Status.SUCCESS);
    return new QueryResult(map);
}
 
Example #13
Source File: VersionUniverseVersionSelector.java    From buck with Apache License 2.0 6 votes vote down vote up
@VisibleForTesting
protected Optional<Map.Entry<String, VersionUniverse>> getVersionUniverse(TargetNode<?> root) {
  Optional<String> universeName = getVersionUniverseName(root);
  if (!universeName.isPresent() && !universes.isEmpty()) {
    return Optional.of(Iterables.get(universes.entrySet(), 0));
  }
  if (!universeName.isPresent()) {
    return Optional.empty();
  }
  VersionUniverse universe = universes.get(universeName.get());
  if (universe == null) {
    throw new VerifyException(
        String.format(
            "%s: unknown version universe \"%s\"", root.getBuildTarget(), universeName.get()));
  }
  return Optional.of(new AbstractMap.SimpleEntry<>(universeName.get(), universe));
}
 
Example #14
Source File: TreeSpliterator.java    From streamex with Apache License 2.0 6 votes vote down vote up
@Override
public void accept(T t) {
    if (depth > MAX_RECURSION_DEPTH) {
        try (TreeSpliterator<T, Entry<Integer, T>> spliterator = new Depth<>(t, mapper, depth)) {
            do { // nothing
            } while (spliterator.tryAdvance(action));
        }
        return;
    }
    action.accept(new AbstractMap.SimpleImmutableEntry<>(depth, t));
    try (Stream<T> stream = mapper.apply(depth, t)) {
        if (stream != null) {
            depth++;
            stream.spliterator().forEachRemaining(this);
            depth--;
        }
    }
}
 
Example #15
Source File: StreamInputPacketIndexEntry.java    From tracecompass with Eclipse Public License 2.0 6 votes vote down vote up
private static @NonNull Map<String, Object> computeAttributeMap(StructDefinition streamPacketContextDef) {
    Builder<String, Object> attributeBuilder = ImmutableMap.<String, Object> builder();
    for (String field : streamPacketContextDef.getDeclaration().getFieldsList()) {
        IDefinition id = streamPacketContextDef.lookupDefinition(field);
        if (id instanceof IntegerDefinition) {
            attributeBuilder.put(field, ((IntegerDefinition) id).getValue());
        } else if (id instanceof FloatDefinition) {
            attributeBuilder.put(field, ((FloatDefinition) id).getValue());
        } else if (id instanceof EnumDefinition) {
            final EnumDefinition enumDec = (EnumDefinition) id;
            attributeBuilder.put(field, new AbstractMap.SimpleImmutableEntry<>(
                    NonNullUtils.checkNotNull(enumDec.getStringValue()),
                    NonNullUtils.checkNotNull(enumDec.getIntegerValue())));
        } else if (id instanceof StringDefinition) {
            attributeBuilder.put(field, ((StringDefinition) id).getValue());
        }
    }
    return attributeBuilder.build();
}
 
Example #16
Source File: ConcurrentSkipListMap.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
public boolean tryAdvance(Consumer<? super Map.Entry<K,V>> action) {
    if (action == null) throw new NullPointerException();
    Comparator<? super K> cmp = comparator;
    K f = fence;
    Node<K,V> e = current;
    for (; e != null; e = e.next) {
        K k; Object v;
        if ((k = e.key) != null && f != null && cpr(cmp, f, k) <= 0) {
            e = null;
            break;
        }
        if ((v = e.value) != null && v != e) {
            current = e.next;
            @SuppressWarnings("unchecked") V vv = (V)v;
            action.accept
                (new AbstractMap.SimpleImmutableEntry<K,V>(k, vv));
            return true;
        }
    }
    current = e;
    return false;
}
 
Example #17
Source File: SolidityElement.java    From ethdroid with MIT License 6 votes vote down vote up
protected List<AbstractMap.SimpleEntry<Type, SArray.Size>> getReturnsType() {
    Type[] returnTypes = extractReturnTypesFromElement();
    List<AbstractMap.SimpleEntry<Type, SArray.Size>> ret = new ArrayList<>();

    ReturnParameters annotations = method.getAnnotation(ReturnParameters.class);
    SArray.Size[] arraySizeAnnotations =
        annotations == null ? new SArray.Size[]{} : annotations.value();

    for (int i = 0; i < returnTypes.length; i++) {
        SArray.Size size = null;
        if (arraySizeAnnotations.length > i) {
            size = arraySizeAnnotations[i];
            if (size.value().length == 0) {
                size = null;
            }
        }
        ret.add(new AbstractMap.SimpleEntry<>(returnTypes[i], size));
    }
    return ret;
}
 
Example #18
Source File: TxPoolA0.java    From aion with MIT License 6 votes vote down vote up
@Override
public PooledTransaction getPoolTx(AionAddress from, BigInteger txNonce) {
    if (from == null || txNonce == null) {
        LOG.error("TxPoolA0.getPoolTx null args");
        return null;
    }

    sortTxn();

    lock.readLock().lock();
    try {
        AbstractMap.SimpleEntry<ByteArrayWrapper, BigInteger> entry =
                this.getAccView(from).getMap().get(txNonce);
        return (entry == null ? null : this.getMainMap().get(entry.getKey()).getTx());
    } finally {
        lock.readLock().unlock();
    }
}
 
Example #19
Source File: ConcurrentSkipListMap.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
public void forEachRemaining(Consumer<? super Map.Entry<K,V>> action) {
    if (action == null) throw new NullPointerException();
    Comparator<? super K> cmp = comparator;
    K f = fence;
    Node<K,V> e = current;
    current = null;
    for (; e != null; e = e.next) {
        K k; Object v;
        if ((k = e.key) != null && f != null && cpr(cmp, f, k) <= 0)
            break;
        if ((v = e.value) != null && v != e) {
            @SuppressWarnings("unchecked") V vv = (V)v;
            action.accept
                (new AbstractMap.SimpleImmutableEntry<K,V>(k, vv));
        }
    }
}
 
Example #20
Source File: AccumulatingEntriesSpliteratorTest.java    From streams-utils with Apache License 2.0 6 votes vote down vote up
@Test
public void should_correctly_count_the_elements_of_a_sized_stream() {
    // Given
    List<Map.Entry<Integer, String>> entries = Arrays.asList(
            new AbstractMap.SimpleEntry<>(1, "1"),
            new AbstractMap.SimpleEntry<>(2, "2"),
            new AbstractMap.SimpleEntry<>(3, "3"),
            new AbstractMap.SimpleEntry<>(4, "4")
    );
    Stream<Map.Entry<Integer, String>> accumulatingStream = StreamsUtils.accumulateEntries(entries.stream(), String::concat);

    // When
    long count = accumulatingStream.count();

    // Then
    assertThat(count).isEqualTo(4);
}
 
Example #21
Source File: ConcurrentSkipListMap.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Removes first entry; returns its snapshot.
 * @return null if empty, else snapshot of first entry
 */
private Map.Entry<K,V> doRemoveFirstEntry() {
    for (Node<K,V> b, n;;) {
        if ((n = (b = head.node).next) == null)
            return null;
        Node<K,V> f = n.next;
        if (n != b.next)
            continue;
        Object v = n.value;
        if (v == null) {
            n.helpDelete(b, f);
            continue;
        }
        if (!n.casValue(v, null))
            continue;
        if (!n.appendMarker(f) || !b.casNext(n, f))
            findFirst(); // retry
        clearIndexToFirst();
        @SuppressWarnings("unchecked") V vv = (V)v;
        return new AbstractMap.SimpleImmutableEntry<K,V>(n.key, vv);
    }
}
 
Example #22
Source File: SimpleConfigObject.java    From waterdrop with Apache License 2.0 5 votes vote down vote up
@Override
public Set<Map.Entry<String, ConfigValue>> entrySet() {
    // total bloat just to work around lack of type variance

    HashSet<Map.Entry<String, ConfigValue>> entries = new HashSet<Map.Entry<String, ConfigValue>>();
    for (Map.Entry<String, AbstractConfigValue> e : value.entrySet()) {
        entries.add(new AbstractMap.SimpleImmutableEntry<String, ConfigValue>(
                e.getKey(), e
                .getValue()));
    }
    return entries;
}
 
Example #23
Source File: DomainSerialiserTest.java    From swblocks-decisiontree with Apache License 2.0 5 votes vote down vote up
@Test
public void testOutputConversion() {
    final Map<String, String> outputMap = Stream.of(new AbstractMap.SimpleEntry<>("Driver1", "Value1"),
            new AbstractMap.SimpleEntry<>("Driver2", "Value2"),
            new AbstractMap.SimpleEntry<>("Driver3", "Value3"))
            .collect(Collectors.toMap(AbstractMap.SimpleEntry::getKey, AbstractMap.SimpleEntry::getValue));

    assertThat(DomainSerialiser.convertOutputs(outputMap), IsCollectionContaining.hasItems(
            "Driver1:Value1", "Driver2:Value2", "Driver3:Value3"));
}
 
Example #24
Source File: Consumer.java    From pravega with Apache License 2.0 5 votes vote down vote up
private void processStorageRead(Event event) {
    val toCompare = new ArrayList<Map.Entry<StoreReader.ReadItem, Event>>();
    synchronized (this.storageQueue) {
        // There's a chance that (due to scheduling reasons), we nay not yet have the Event to compare in memory;
        // if that's the case, then store it, and we'll check it later.
        this.storageReadQueue.addLast(event);

        // Fetch all comparison pairs. Both of these Queues should have elements in the same order, so create the pairs
        // by picking the first element from each.
        while (!this.storageReadQueue.isEmpty() && !this.storageQueue.isEmpty()) {
            toCompare.add(new AbstractMap.SimpleImmutableEntry<>(this.storageQueue.removeFirst(), this.storageReadQueue.removeFirst()));
        }
    }

    // Compare the pairs.
    for (val e : toCompare) {
        ValidationResult validationResult;
        try {
            validationResult = compareReads(e.getKey(), e.getValue());
            this.testState.recordStorageRead(validationResult.getLength());
        } catch (Throwable ex) {
            validationResult = ValidationResult.failed(String.format("General failure: Ex = %s.", ex));
        }

        if (!validationResult.isSuccess()) {
            validationResult.setAddress(e.getKey().getAddress());
            validationFailed(ValidationSource.StorageRead, validationResult);
            break;
        }
    }
}
 
Example #25
Source File: MongoDBQueryEngine.java    From rya with Apache License 2.0 5 votes vote down vote up
@Override
public CloseableIteration<RyaStatement, RyaDAOException> query(
        final RyaStatement stmt, final StatefulMongoDBRdfConfiguration conf)
        throws RyaDAOException {
    checkNotNull(stmt);
    checkNotNull(conf);

    final Entry<RyaStatement, BindingSet> entry = new AbstractMap.SimpleEntry<>(stmt, new MapBindingSet());
    final Collection<Entry<RyaStatement, BindingSet>> collection = Collections.singleton(entry);

    return new RyaStatementCursorIterator(queryWithBindingSet(collection, conf));
}
 
Example #26
Source File: CompletionOrderSpliterator.java    From articles with Apache License 2.0 5 votes vote down vote up
private static <T> Map<Integer, CompletableFuture<Map.Entry<Integer, T>>> toIndexedFutures(Collection<CompletableFuture<T>> futures) {
    Map<Integer, CompletableFuture<Map.Entry<Integer, T>>> map = new HashMap<>(futures.size(), 1);

    int counter = 0;
    for (CompletableFuture<T> f : futures) {
        int index = counter++;
        map.put(index, f.thenApply(value -> new AbstractMap.SimpleEntry<>(index, value)));
    }
    return map;
}
 
Example #27
Source File: ImmutableCollectorsTest.java    From gyro with Apache License 2.0 5 votes vote down vote up
@Test
void toMap() {
    String item0 = "foo";
    String item1 = "bar";
    Map<String, String> map = Stream.of(item0, item1).collect(ImmutableCollectors.toMap(Functions.identity()));

    assertThat(map).containsExactly(
        new AbstractMap.SimpleImmutableEntry<>(item0, item0),
        new AbstractMap.SimpleImmutableEntry<>(item1, item1));
}
 
Example #28
Source File: ChunkMaterialModel.java    From factions-top with MIT License 5 votes vote down vote up
public void addBatch(int chunkId, int materialId, int count) throws SQLException {
    Integer relationId = identityCache.getChunkMaterialId(chunkId, materialId);
    Map.Entry<Integer, Integer> insertionKey = new AbstractMap.SimpleImmutableEntry<>(chunkId, materialId);

    if (relationId == null) {
        if (!insertionQueue.contains(insertionKey)) {
            insertCounter(chunkId, materialId, count);
            insertionQueue.add(insertionKey);
        }
    } else {
        updateCounter(count, relationId);
    }
}
 
Example #29
Source File: JsonDocument.java    From ojai with Apache License 2.0 5 votes vote down vote up
@Override
public Set<Entry<String, Object>> entrySet() {
  /* make a copy of the string and the real object and return that */
  LinkedHashSet<Map.Entry<String, Object>> s = new LinkedHashSet<Map.Entry<String,Object>>();
  for (String k : getRootMap().keySet()) {

    Map.Entry<String, Object> newEntry =
        new AbstractMap.SimpleImmutableEntry<String, Object>(k, getRootMap().get(k).getObject());
    s.add(newEntry);
  }
  return s;
}
 
Example #30
Source File: Dataset.java    From dremio-oss with Apache License 2.0 5 votes vote down vote up
public Iterable<Map.Entry<K, V>> getDatasetSlice(int start, int end) {
  Preconditions.checkArgument(start <= end);
  Preconditions.checkArgument(end < keys.size());
  Preconditions.checkArgument(end < vals.size());

  final ImmutableList.Builder<Map.Entry<K, V>> entriesBuilder = ImmutableList.builder();
  for (int i = start; i <= end; i++) {
    entriesBuilder.add(new AbstractMap.SimpleEntry<>(getKey(i), getVal(i)));
  }
  return entriesBuilder.build();
}