Example usage for com.google.common.collect Maps newTreeMap

List of usage examples for com.google.common.collect Maps newTreeMap

Introduction

In this page you can find the example usage for com.google.common.collect Maps newTreeMap.

Prototype

public static <C, K extends C, V> TreeMap<K, V> newTreeMap(@Nullable Comparator<C> comparator) 

Source Link

Document

Creates a mutable, empty TreeMap instance using the given comparator.

Usage

From source file:com.spotify.styx.cli.CliUtil.java

private static TreeMap<WorkflowId, SortedSet<RunStateData>> newSortedWorkflowIdSet() {
    return Maps.newTreeMap(WorkflowId.KEY_COMPARATOR);
}

From source file:co.cask.cdap.data2.transaction.queue.leveldb.LevelDBQueueProducer.java

public LevelDBQueueProducer(LevelDBTableCore tableCore, QueueName queueName, QueueMetrics queueMetrics) {
    super(queueMetrics, queueName);
    core = tableCore;//from w  ww.j a  v a  2 s.com
    changes = Maps.newTreeMap(Bytes.BYTES_COMPARATOR);
    queueRowPrefix = QueueEntryRow.getQueueRowPrefix(queueName);
}

From source file:org.rm3l.ddwrt.prefs.sort.SortingStrategy.java

@NotNull
public final DDWRTBaseFragment[] sort(@NotNull final DDWRTBaseFragment[] tabs) {
    if (doCompare()) {

        final TreeMap<String, DDWRTBaseFragment> tabsMap = Maps.newTreeMap(this.getComparator());
        for (int i = 0; i < tabs.length; i++) {
            final DDWRTBaseFragment tab = tabs[i];
            tabsMap.put(tab.getTabTitle().toString(), tab);
        }/*from   www.  ja  v  a 2s .co  m*/

        @NotNull
        final DDWRTBaseFragment[] output = new DDWRTBaseFragment[tabsMap.size()];
        int j = 0;
        for (@NotNull
        Map.Entry<String, DDWRTBaseFragment> DDWRTBaseFragmentEntry : tabsMap.entrySet()) {
            output[j++] = DDWRTBaseFragmentEntry.getValue();
        }
        return output;
    }

    return tabs;

}

From source file:co.cask.cdap.api.dataset.table.Put.java

/**
 * Write to a row.//from   w  w w  .j a v a2s . c o m
 * @param row Row to write to.
 */
public Put(byte[] row) {
    this.row = row;
    this.values = Maps.newTreeMap(Bytes.BYTES_COMPARATOR);
}

From source file:dk.ilios.spanner.model.BenchmarkSpec.java

private BenchmarkSpec(Builder builder) {
    this.className = builder.className;
    this.methodName = builder.methodName;
    this.parameters = Maps.newTreeMap(builder.parameters);
}

From source file:io.druid.indexer.HadoopDruidDetermineConfigurationJob.java

@Override
public boolean run() {
    List<Jobby> jobs = Lists.newArrayList();

    JobHelper.ensurePaths(config);/*from  w ww . j av a 2  s  . c om*/

    if (config.isDeterminingPartitions()) {
        jobs.add(config.getPartitionsSpec().getPartitionJob(config));
    } else {
        int shardsPerInterval = config.getPartitionsSpec().getNumShards();
        Map<DateTime, List<HadoopyShardSpec>> shardSpecs = Maps.newTreeMap(DateTimeComparator.getInstance());
        int shardCount = 0;
        for (Interval segmentGranularity : config.getSegmentGranularIntervals().get()) {
            DateTime bucket = segmentGranularity.getStart();
            if (shardsPerInterval > 0) {
                List<HadoopyShardSpec> specs = Lists.newArrayListWithCapacity(shardsPerInterval);
                for (int i = 0; i < shardsPerInterval; i++) {
                    specs.add(new HadoopyShardSpec(new HashBasedNumberedShardSpec(i, shardsPerInterval,
                            HadoopDruidIndexerConfig.jsonMapper), shardCount++));
                }
                shardSpecs.put(bucket, specs);
                log.info("DateTime[%s], spec[%s]", bucket, specs);
            } else {
                final HadoopyShardSpec spec = new HadoopyShardSpec(new NoneShardSpec(), shardCount++);
                shardSpecs.put(bucket, Lists.newArrayList(spec));
                log.info("DateTime[%s], spec[%s]", bucket, spec);
            }
        }
        config.setShardSpecs(shardSpecs);
    }

    return JobHelper.runJobs(jobs, config);

}

From source file:com.sk89q.worldedit.world.block.BlockState.java

static Map<Map<Property<?>, Object>, BlockState> generateStateMap(BlockType blockType) {
    Map<Map<Property<?>, Object>, BlockState> stateMap = new LinkedHashMap<>();
    List<? extends Property<?>> properties = blockType.getProperties();

    if (!properties.isEmpty()) {
        List<List<Object>> separatedValues = Lists.newArrayList();
        for (Property<?> prop : properties) {
            List<Object> vals = Lists.newArrayList();
            vals.addAll(prop.getValues());
            separatedValues.add(vals);/*from   ww w. j  a v a 2 s .c om*/
        }
        List<List<Object>> valueLists = Lists.cartesianProduct(separatedValues);
        for (List<Object> valueList : valueLists) {
            Map<Property<?>, Object> valueMap = Maps.newTreeMap(Comparator.comparing(Property::getName));
            BlockState stateMaker = new BlockState(blockType);
            for (int i = 0; i < valueList.size(); i++) {
                Property<?> property = properties.get(i);
                Object value = valueList.get(i);
                valueMap.put(property, value);
                stateMaker.setState(property, value);
            }
            stateMap.put(valueMap, stateMaker);
        }
    }

    if (stateMap.isEmpty()) {
        // No properties.
        stateMap.put(new LinkedHashMap<>(), new BlockState(blockType));
    }

    for (BlockState state : stateMap.values()) {
        state.populate(stateMap);
    }

    return stateMap;
}

From source file:kr.co.vcnc.haeinsa.HaeinsaPut.java

/**
 * Copy constructor. Creates a Put operation cloned from the specified Put.
 *
 * @param putToCopy put to copy/*from w w w  .  j a va 2 s .  c om*/
 */
public HaeinsaPut(HaeinsaPut putToCopy) {
    this(putToCopy.getRow());
    this.familyMap = Maps.newTreeMap(Bytes.BYTES_COMPARATOR);
    for (Map.Entry<byte[], NavigableSet<HaeinsaKeyValue>> entry : putToCopy.getFamilyMap().entrySet()) {
        this.familyMap.put(entry.getKey(), entry.getValue());
    }
}

From source file:kr.co.vcnc.haeinsa.HaeinsaDeleteTracker.java

/**
 * Update family map or column map if kv is not exist in map or sequenceId is lower.
 *
 * @param kv  HaeinsaKeyValue to track//from   w ww .  j a v  a 2  s .  c  om
 * @param sequenceID sequence ID, lower is newer.
 */
public void add(HaeinsaKeyValue kv, long sequenceID) {
    switch (kv.getType()) {
    case DeleteFamily: {
        Long previous = families.get(kv.getFamily());
        if (previous == null || previous.compareTo(sequenceID) > 0) {
            // sequenceId is lower than previous one.
            families.put(kv.getFamily(), sequenceID);
        }
        break;
    }
    case DeleteColumn: {
        NavigableMap<byte[], Long> cellMap = cells.get(kv.getFamily());
        if (cellMap == null) {
            cellMap = Maps.newTreeMap(Bytes.BYTES_COMPARATOR);
            cells.put(kv.getFamily(), cellMap);
        }
        Long previous = families.get(kv.getQualifier());
        if (previous == null || previous.compareTo(sequenceID) > 0) {
            // sequenceId is lower than previous one.
            cellMap.put(kv.getQualifier(), sequenceID);
        }
        break;
    }
    default: {
        break;
    }
    }
}

From source file:co.cask.cdap.api.dataset.table.Increment.java

/**
 * Changes the values of columns in a row.
 * @param row Row to change./*from w  w w  .  ja v a2  s . c  o  m*/
 */
public Increment(byte[] row) {
    this.row = row;
    this.values = Maps.newTreeMap(Bytes.BYTES_COMPARATOR);
}