Java Code Examples for

The following examples show how to use . These examples are extracted from open source projects. 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 want to check out the right sidebar which shows the related API usage.
Example 1
public static void register(final Kryo kryo) {
  // register list
  final ImmutableListSerializer serializer = new ImmutableListSerializer();
  kryo.register(ImmutableList.class, serializer);
  kryo.register(ImmutableList.of().getClass(), serializer);
  kryo.register(ImmutableList.of(Integer.valueOf(1)).getClass(), serializer);
  kryo.register(ImmutableList.of(Integer.valueOf(1), Integer.valueOf(2), Integer.valueOf(3)).subList(1, 2).getClass(), serializer);
  kryo.register(ImmutableList.of().reverse().getClass(), serializer);
  kryo.register(Lists.charactersOf("dremio").getClass(), serializer);

  final HashBasedTable baseTable = HashBasedTable.create();
  baseTable.put(Integer.valueOf(1), Integer.valueOf(2), Integer.valueOf(3));
  baseTable.put(Integer.valueOf(4), Integer.valueOf(5), Integer.valueOf(6));
  ImmutableTable table = ImmutableTable.copyOf(baseTable);
  kryo.register(table.values().getClass(), serializer);
Example 2
Source Project: SPDS   File:    License: Eclipse Public License 2.0 5 votes vote down vote up
public String toLabelGroupedDotString() {
    HashBasedTable<D, N, Collection<D>> groupedByTargetAndLabel = HashBasedTable.create();
    for (Transition<N, D> t : transitions) {
        Collection<D> collection = groupedByTargetAndLabel.get(t.getTarget(), t.getLabel());
        if (collection == null)
            collection = Sets.newHashSet();
        groupedByTargetAndLabel.put(t.getTarget(), t.getLabel(), collection);
    String s = "digraph {\n";
    for (D target : groupedByTargetAndLabel.rowKeySet()) {
        for (N label : groupedByTargetAndLabel.columnKeySet()) {
            Collection<D> source = groupedByTargetAndLabel.get(target, label);
            if (source == null)
            s += "\t\"" + Joiner.on("\\n").join(source) + "\"";
            s += " -> \"" + wrapIfInitialOrFinalState(target) + "\"";
            s += "[label=\"" + label + "\"];\n";
    s += "}\n";
    s += "Transitions: " + transitions.size() + "\n";
    for (WeightedPAutomaton<N, D, W> nested : nestedAutomatons) {
        s += "NESTED -> \n";
        s += nested.toDotString();
    return s;
Example 3
Source Project: emodb   File:    License: Apache License 2.0 5 votes vote down vote up
private PutObjectResult mockUploadS3File(String bucket, String key, byte[] contents, HashBasedTable<String, String, ByteBuffer> s3FileTable) {
    // Place the contents in the s3 file table keyed by the file's parent directory and file name
    int idx = key.lastIndexOf('/');
    String parentDir = key.substring(0, idx);
    String fileName = key.substring(idx + 1);
    // HashBasedTable is not thread-safe if multiple threads try to write to the same directory concurrently
    synchronized (s3FileTable) {
        s3FileTable.put(format("%s/%s", bucket, parentDir), fileName, ByteBuffer.wrap(contents));

    PutObjectResult result = new PutObjectResult();
    return result;
Example 4
public DataPlane loadDataPlane(NetworkSnapshot snapshot) {
  SortedMap<String, Configuration> configs = loadConfigurations(snapshot);
  HashBasedTable<String, String, Set<Layer2Vni>> vnis = HashBasedTable.create();
                  ImmutableSortedSet.of(Ip.parse(""), Ip.parse("")))
  return MockDataPlane.builder().setConfigs(configs).setVniSettings(vnis).build();