private OptionsContextImpl(List<OptionValueSource> sources, Class<?> entityType, String propertyName) { this.sources = sources; this.entityType = entityType; this.propertyName = propertyName; this.hierarchy = getClassHierarchy( entityType ); this.optionCache = newConcurrentHashMap(); }
public OptionsContainerBuilder() { this.optionValues = newHashMap(); }
public static <T> List<T> toList(Iterable<T> iterable) { return toStream( iterable ).collect( Collectors.toList() ); }
private ClosableIterator<Tuple> extractResultSet(String storedProcedureName, Object res) { try { return CollectionHelper.newClosableIterator( TupleExtractor.extractTuplesFromObject( res ) ); } catch (Exception e) { throw log.cannotExtractStoredProcedureResultSet( storedProcedureName, res, e ); } } }
public static <K, V> LinkedHashMap<K, V> newLinkedHashMap(int initialCapacity) { return new LinkedHashMap<K, V>( getInitialCapacityFromExpectedSize( initialCapacity ) ); }
public IgniteTupleSnapshot(Object id, BinaryObject binaryObject, EntityKeyMetadata keyMetadata) { this.id = id; this.binaryObject = binaryObject; this.keyMetadata = keyMetadata; Set<String> idColumnNames = new HashSet<>(); for ( String columnName : keyMetadata.getColumnNames() ) { if ( keyMetadata.isKeyColumn( columnName ) ) { idColumnNames.add( columnName ); } } if ( idColumnNames.isEmpty() ) { throw new UnsupportedOperationException( "There is no id column in entity " + keyMetadata.getTable() + ". Hmm..." ); } this.isSimpleId = idColumnNames.size() == 1; this.columnNames = CollectionHelper.asSet( keyMetadata.getColumnNames() ); }
/** * Updates all inverse associations managed by a given entity. */ public void addNavigationalInformationForInverseSide() { if ( log.isTraceEnabled() ) { log.trace( "Adding inverse navigational information for entity: " + MessageHelper.infoString( persister, id, persister.getFactory() ) ); } for ( int propertyIndex = 0; propertyIndex < persister.getEntityMetamodel().getPropertySpan(); propertyIndex++ ) { if ( persister.isPropertyOfTable( propertyIndex, tableIndex ) ) { AssociationKeyMetadata associationKeyMetadata = getInverseAssociationKeyMetadata( propertyIndex ); // there is no inverse association for the given property if ( associationKeyMetadata == null ) { continue; } Object[] newColumnValues = LogicalPhysicalConverterHelper.getColumnValuesFromResultset( resultset, persister.getPropertyColumnNames( propertyIndex ) ); //don't index null columns, this means no association if ( ! CollectionHelper.isEmptyOrContainsOnlyNull( ( newColumnValues ) ) ) { addNavigationalInformationForInverseSide( propertyIndex, associationKeyMetadata, newColumnValues ); } } } }
public AssociationRows(AssociationKey associationKey, Collection<?> wrapped, AssociationRowFactory associationRowFactory) { this.rows = CollectionHelper.newLinkedHashMap( wrapped.size() ); for ( Object object : wrapped ) { AssociationRow<?> row = associationRowFactory.createAssociationRow( associationKey, object ); rows.put( row.getKey(), row ); } }
Set<RowKey> keys = CollectionHelper.newLinkedHashSet( cleared ? currentState.size() : snapshot.size() + currentState.size() );
private ClosableIterator<Tuple> extractResultSet(String storedProcedureName, Object res) { try { return CollectionHelper.newClosableIterator( TupleExtractor.extractTuplesFromObject( res ) ); } catch (Exception e) { throw log.cannotExtractStoredProcedureResultSet( storedProcedureName, res, e ); } } }
public static <K, V> HashMap<K, V> newHashMap(int initialCapacity) { return new HashMap<K, V>( getInitialCapacityFromExpectedSize( initialCapacity ) ); }
public IgniteAssociationRowSnapshot(Object id, BinaryObject binaryObject, AssociationKeyMetadata associationMetadata) { this.id = id; this.binaryObject = binaryObject; this.associationMetadata = associationMetadata; this.thirdTableLink = IgniteAssociationSnapshot.isThirdTableAssociation( associationMetadata ); if ( this.thirdTableLink ) { Set<String> cn = new HashSet<>(); Collections.addAll( cn, associationMetadata.getRowKeyColumnNames() ); Collections.addAll( cn, associationMetadata.getAssociatedEntityKeyMetadata().getAssociationKeyColumns() ); this.columnNames = Collections.unmodifiableSet( cn ); this.isSimpleId = true; //vk: not used in this case } else { Set<String> idColumnNames = new HashSet<>(); EntityKeyMetadata entityKeyMetadata = associationMetadata.getAssociatedEntityKeyMetadata().getEntityKeyMetadata(); for ( String columnName : entityKeyMetadata.getColumnNames() ) { if ( entityKeyMetadata.isKeyColumn( columnName ) ) { idColumnNames.add( columnName ); } } if ( idColumnNames.isEmpty() ) { throw new UnsupportedOperationException( "There is no id column in entity " + entityKeyMetadata.getTable() + ". Hmm..." ); } this.columnNames = CollectionHelper.asSet( entityKeyMetadata.getColumnNames() ); this.isSimpleId = idColumnNames.size() == 1; } }
/** * Removes all inverse associations managed by a given entity. */ public void removeNavigationalInformationFromInverseSide() { if ( log.isTraceEnabled() ) { log.trace( "Removing inverse navigational information for entity: " + MessageHelper.infoString( persister, id, persister.getFactory() ) ); } for ( int propertyIndex = 0; propertyIndex < persister.getEntityMetamodel().getPropertySpan(); propertyIndex++ ) { if ( persister.isPropertyOfTable( propertyIndex, tableIndex ) ) { AssociationKeyMetadata associationKeyMetadata = getInverseAssociationKeyMetadata( propertyIndex ); // there is no inverse association for the given property if ( associationKeyMetadata == null ) { continue; } Object[] oldColumnValues = LogicalPhysicalConverterHelper.getColumnValuesFromResultset( resultset, persister.getPropertyColumnNames( propertyIndex ) ); //don't index null columns, this means no association if ( ! CollectionHelper.isEmptyOrContainsOnlyNull( oldColumnValues ) ) { removeNavigationalInformationFromInverseSide( propertyIndex, associationKeyMetadata, oldColumnValues ); } } } }
private ClosableIterator<Tuple> extractResultSet(String storedProcedureName, Object res) { try { return CollectionHelper.newClosableIterator( TupleExtractor.extractTuplesFromObject( res ) ); } catch (Exception e) { throw log.cannotExtractStoredProcedureResultSet( storedProcedureName, res, e ); } } }
private static ConcurrentMap<String, Cache<PersistentAssociationKey, Map<RowKey, Map<String, Object>>>> initializeAssociationCaches(EmbeddedCacheManager embeddedCacheManager, Set<AssociationKeyMetadata> associationTypes) { ConcurrentHashMap<String, Cache<PersistentAssociationKey, Map<RowKey, Map<String, Object>>>> associationCaches = newConcurrentHashMap( associationTypes.size() ); for ( AssociationKeyMetadata associationKeyMetadata : associationTypes ) { String cacheName = getCacheName( associationKeyMetadata ); associationCaches.put( cacheName, embeddedCacheManager.<PersistentAssociationKey, Map<RowKey, Map<String, Object>>>getCache( cacheName ) ); } return associationCaches; }
private static <K> Map<K, OptionsContainer> immutable(Map<K, OptionsContainerBuilder> options) { Map<K, OptionsContainer> result = newHashMap( options.size() ); for ( Entry<K, OptionsContainerBuilder> option : options.entrySet() ) { result.put( option.getKey(), option.getValue().build() ); } return Collections.unmodifiableMap( result ); }
private void addIndex(Label label, Index index) { if ( index != null ) { if ( index.getName() != null ) { log.cannotSetNameForIndex( index.getName() ); } List<String> properties = CollectionHelper.toStream( index.getColumnIterator() ) .map( Column::getName ).collect( Collectors.toList() ); indexSpecs.add( new Neo4jIndexSpec( label, properties ) ); } }
public static <T> LinkedHashSet<T> newLinkedHashSet(int initialCapacity) { return new LinkedHashSet<T>( getInitialCapacityFromExpectedSize( initialCapacity ) ); }
private static ClosableIterator<Tuple> doCount(MongoDBQueryDescriptor query, MongoCollection<Document> collection) { long count = collection.countDocuments( query.getCriteria() ); MapTupleSnapshot snapshot = new MapTupleSnapshot( Collections.<String, Object>singletonMap( "n", count ) ); return CollectionHelper.newClosableIterator( Collections.singletonList( new Tuple( snapshot, SnapshotType.UNKNOWN ) ) ); }
private static ConcurrentMap<String, Cache<PersistentAssociationKey, Map<RowKey, Map<String, Object>>>> initializeAssociationCaches(EmbeddedCacheManager embeddedCacheManager, Set<AssociationKeyMetadata> associationTypes) { ConcurrentHashMap<String, Cache<PersistentAssociationKey, Map<RowKey, Map<String, Object>>>> associationCaches = newConcurrentHashMap( associationTypes.size() ); for ( AssociationKeyMetadata associationKeyMetadata : associationTypes ) { String cacheName = getCacheName( associationKeyMetadata ); associationCaches.put( cacheName, embeddedCacheManager.<PersistentAssociationKey, Map<RowKey, Map<String, Object>>>getCache( cacheName ) ); } return associationCaches; }