List of usage examples for com.google.common.collect ImmutableMap.Builder put
public final V put(K k, V v)
From source file:com.facebook.presto.hive.orc.OrcPageSourceFactory.java
public static OrcPageSource createOrcPageSource(MetadataReader metadataReader, Configuration configuration, Path path, long start, long length, List<HiveColumnHandle> columns, List<HivePartitionKey> partitionKeys, TupleDomain<HiveColumnHandle> effectivePredicate, DateTimeZone hiveStorageTimeZone, TypeManager typeManager, DataSize maxMergeDistance, DataSize maxBufferSize, DataSize streamBufferSize) { OrcDataSource orcDataSource;/*from w w w . j a v a2 s . c o m*/ try { FileSystem fileSystem = path.getFileSystem(configuration); long size = fileSystem.getFileStatus(path).getLen(); FSDataInputStream inputStream = fileSystem.open(path); orcDataSource = new HdfsOrcDataSource(path.toString(), size, maxMergeDistance, maxBufferSize, streamBufferSize, inputStream); } catch (Exception e) { if (nullToEmpty(e.getMessage()).trim().equals("Filesystem closed") || e instanceof FileNotFoundException) { throw new PrestoException(HIVE_CANNOT_OPEN_SPLIT, e); } throw new PrestoException(HIVE_CANNOT_OPEN_SPLIT, splitError(e, path, start, length), e); } ImmutableMap.Builder<Integer, Type> includedColumns = ImmutableMap.builder(); ImmutableList.Builder<ColumnReference<HiveColumnHandle>> columnReferences = ImmutableList.builder(); for (HiveColumnHandle column : columns) { if (!column.isPartitionKey()) { Type type = typeManager.getType(column.getTypeSignature()); includedColumns.put(column.getHiveColumnIndex(), type); columnReferences.add(new ColumnReference<>(column, column.getHiveColumnIndex(), type)); } } OrcPredicate predicate = new TupleDomainOrcPredicate<>(effectivePredicate, columnReferences.build()); try { OrcReader reader = new OrcReader(orcDataSource, metadataReader, maxMergeDistance, maxBufferSize); OrcRecordReader recordReader = reader.createRecordReader(includedColumns.build(), predicate, start, length, hiveStorageTimeZone); return new OrcPageSource(recordReader, orcDataSource, partitionKeys, columns, hiveStorageTimeZone, typeManager); } catch (Exception e) { try { orcDataSource.close(); } catch (IOException ignored) { } if (e instanceof PrestoException) { throw (PrestoException) e; } String message = splitError(e, path, start, length); if (e.getClass().getSimpleName().equals("BlockMissingException")) { throw new PrestoException(HIVE_MISSING_DATA, message, e); } throw new PrestoException(HIVE_CANNOT_OPEN_SPLIT, message, e); } }
From source file:com.splicemachine.orc.checkpoint.Checkpoints.java
private static Map<StreamId, StreamCheckpoint> getBooleanColumnCheckpoints(int column, CompressionKind compressionKind, Set<StreamKind> availableStreams, ColumnPositionsList positionsList) { ImmutableMap.Builder<StreamId, StreamCheckpoint> checkpoints = ImmutableMap.builder(); if (availableStreams.contains(PRESENT)) { checkpoints.put(new StreamId(column, PRESENT), new BooleanStreamCheckpoint(compressionKind, positionsList)); }/*from ww w . ja va2 s . c o m*/ if (availableStreams.contains(DATA)) { checkpoints.put(new StreamId(column, DATA), new BooleanStreamCheckpoint(compressionKind, positionsList)); } return checkpoints.build(); }
From source file:org.zanata.model.tm.TMXMetadataHelper.java
@Nonnull private static ImmutableMap<String, String> getSharedMetadata(HasTMMetadata fromEntity) { ImmutableMap.Builder<String, String> m = ImmutableMap.builder(); m.putAll(getGenericMetadata(fromEntity)); Date creationDate = fromEntity.getCreationDate(); if (creationDate != null) { m.put(CREATION_DATE, toString(creationDate)); }/* w w w . j a v a 2s . c o m*/ Date lastChanged = fromEntity.getLastChanged(); if (lastChanged != null) { m.put(CHANGE_DATE, toString(lastChanged)); } return m.build(); }
From source file:org.apache.brooklyn.rest.transform.LocationTransformer.java
private static Map<String, ?> copyConfig(Map<String, ?> entries, LocationDetailLevel level) { ImmutableMap.Builder<String, Object> builder = ImmutableMap.builder(); if (level != LocationDetailLevel.NONE) { for (Map.Entry<String, ?> entry : entries.entrySet()) { if (level == LocationDetailLevel.FULL_INCLUDING_SECRET || !Sanitizer.IS_SECRET_PREDICATE.apply(entry.getKey())) { builder.put(entry.getKey(), WebResourceUtils.getValueForDisplay(entry.getValue(), true, false)); }//from www . ja v a 2s. c o m } } return builder.build(); }
From source file:com.splicemachine.orc.checkpoint.Checkpoints.java
private static Map<StreamId, StreamCheckpoint> getListOrMapColumnCheckpoints(int column, ColumnEncodingKind encoding, CompressionKind compressionKind, Set<StreamKind> availableStreams, ColumnPositionsList positionsList) { ImmutableMap.Builder<StreamId, StreamCheckpoint> checkpoints = ImmutableMap.builder(); if (availableStreams.contains(PRESENT)) { checkpoints.put(new StreamId(column, PRESENT), new BooleanStreamCheckpoint(compressionKind, positionsList)); }//from w w w . ja v a2 s .c om if (availableStreams.contains(LENGTH)) { checkpoints.put(new StreamId(column, LENGTH), createLongStreamCheckpoint(encoding, compressionKind, positionsList)); } return checkpoints.build(); }
From source file:com.google.gerrit.util.cli.OptionHandlers.java
private static ImmutableMap<Class<?>, Provider<OptionHandlerFactory<?>>> build(Injector i) { ImmutableMap.Builder<Class<?>, Provider<OptionHandlerFactory<?>>> map = ImmutableMap.builder(); for (; i != null; i = i.getParent()) { for (Entry<Key<?>, Binding<?>> e : i.getBindings().entrySet()) { TypeLiteral<?> type = e.getKey().getTypeLiteral(); if (type.getRawType() == OptionHandlerFactory.class && e.getKey().getAnnotation() == null && type.getType() instanceof ParameterizedType) { map.put(getType(type), cast(e.getValue()).getProvider()); }//from w w w. j a v a2s .c om } } return map.build(); }
From source file:com.facebook.buck.apple.CxxPlatformXcodeConfigGenerator.java
private static void setSdkRootAndDeploymentTargetValues(ImmutableMap.Builder<String, String> configBuilder, CxxPlatform cxxPlatform, List<String> notProcessedCxxFlags, Map<String, String> notProcessedAppendedConfig) { String sdkRootValue = getSdkRoot(cxxPlatform, notProcessedCxxFlags, notProcessedAppendedConfig); if (sdkRootValue != null) { configBuilder.put(SDKROOT, sdkRootValue); notProcessedAppendedConfig.remove(SDKROOT); setDeploymentTargetValue(configBuilder, sdkRootValue, notProcessedCxxFlags, notProcessedAppendedConfig); }//from w w w .jav a 2 s.c o m }