Java Code Examples for com.google.common.collect.HashBasedTable.put()

The following are Jave code examples for showing how to use put() of the com.google.common.collect.HashBasedTable class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: cakes   File: HashBasedTableDemo.java   Source Code and License Vote up 6 votes
@Test
public void testCreate() {
    HashBasedTable<String, String, String> table = HashBasedTable.create();

    table.put("cbooy", "vm", "10.94.97.94");
    table.put("cbooy", "name", "haoc");
    table.put("hello", "name", "hi");
    table.put("hello", "vm", "10999");

    System.out.println(table);

    // 遍历
    table.cellSet().forEach(cell -> {
        String columnKey = cell.getColumnKey();
        String rowKey = cell.getRowKey();
        String value = cell.getValue();

        System.out.println(String.format("%s-%s-%s", rowKey, columnKey, value));
    });
}
 
Example 2
Project: dremio-oss   File: ImmutableCollectionSerializers.java   Source Code and License Vote up 6 votes
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 3
Project: SpigotSource   File: BlockStateList.java   Source Code and License Vote up 6 votes
public void a(Map<Map<IBlockState<?>, Comparable<?>>, BlockStateList.BlockData> map) {
    if (this.c != null) {
        throw new IllegalStateException();
    } else {
        HashBasedTable hashbasedtable = HashBasedTable.create();
        Iterator iterator = this.b.entrySet().iterator();

        while (iterator.hasNext()) {
            Entry entry = (Entry) iterator.next();
            IBlockState iblockstate = (IBlockState) entry.getKey();
            Iterator iterator1 = iblockstate.c().iterator();

            while (iterator1.hasNext()) {
                Comparable comparable = (Comparable) iterator1.next();

                if (comparable != entry.getValue()) {
                    hashbasedtable.put(iblockstate, comparable, map.get(this.b(iblockstate, comparable)));
                }
            }
        }

        this.c = ImmutableTable.copyOf(hashbasedtable);
    }
}
 
Example 4
Project: emodb   File: ScanUploaderTest.java   Source Code and License Vote up 5 votes
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();
    result.setETag("etag");
    return result;
}
 
Example 5
Project: guava   File: FreshValueGenerator.java   Source Code and License Vote up 5 votes
@Generates
private static <R, C, V> HashBasedTable<R, C, V> generateHashBasedTable(
    R row, C column, V value) {
  HashBasedTable<R, C, V> table = HashBasedTable.create();
  table.put(row, column, value);
  return table;
}
 
Example 6
Project: guava   File: FreshValueGenerator.java   Source Code and License Vote up 5 votes
@Generates
private static <R, C, V> HashBasedTable<R, C, V> generateHashBasedTable(
    R row, C column, V value) {
  HashBasedTable<R, C, V> table = HashBasedTable.create();
  table.put(row, column, value);
  return table;
}
 
Example 7
Project: guava-mock   File: FreshValueGenerator.java   Source Code and License Vote up 4 votes
@Generates private static <R, C, V> HashBasedTable<R, C, V> generateHashBasedTable(
    R row, C column, V value) {
  HashBasedTable<R, C, V> table = HashBasedTable.create();
  table.put(row, column, value);
  return table;
}
 
Example 8
Project: googles-monorepo-demo   File: FreshValueGenerator.java   Source Code and License Vote up 4 votes
@Generates private static <R, C, V> HashBasedTable<R, C, V> generateHashBasedTable(
    R row, C column, V value) {
  HashBasedTable<R, C, V> table = HashBasedTable.create();
  table.put(row, column, value);
  return table;
}
 
Example 9
Project: hybris-connector   File: ProductPriceValueProvider.java   Source Code and License Vote up 4 votes
private void addPriceValue(final HashBasedTable<Optional<String>, Optional<Locale>, String> table,
		final PriceInformation priceInformation)
{
	final String value = String.format(java.util.Locale.US, "%.2f", new Double(priceInformation.getPriceValue().getValue()));
	table.put(Optional.empty(), Optional.empty(), value);
}
 
Example 10
Project: guava-libraries   File: FreshValueGenerator.java   Source Code and License Vote up 4 votes
@Generates private static <R, C, V> HashBasedTable<R, C, V> generateHashBasedTable(
    R row, C column, V value) {
  HashBasedTable<R, C, V> table = HashBasedTable.create();
  table.put(row, column, value);
  return table;
}