repo
stringlengths
7
58
path
stringlengths
12
218
func_name
stringlengths
3
140
original_string
stringlengths
73
34.1k
language
stringclasses
1 value
code
stringlengths
73
34.1k
code_tokens
list
docstring
stringlengths
3
16k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
105
339
partition
stringclasses
1 value
hibernate/hibernate-ogm
core/src/main/java/org/hibernate/ogm/util/impl/ReflectionHelper.java
ReflectionHelper.propertyExists
public static boolean propertyExists(Class<?> clazz, String property, ElementType elementType) { if ( ElementType.FIELD.equals( elementType ) ) { return getDeclaredField( clazz, property ) != null; } else { String capitalizedPropertyName = capitalize( property ); Method method = getMethod( clazz, PROPERTY_ACCESSOR_PREFIX_GET + capitalizedPropertyName ); if ( method != null && method.getReturnType() != void.class ) { return true; } method = getMethod( clazz, PROPERTY_ACCESSOR_PREFIX_IS + capitalizedPropertyName ); if ( method != null && method.getReturnType() == boolean.class ) { return true; } } return false; }
java
public static boolean propertyExists(Class<?> clazz, String property, ElementType elementType) { if ( ElementType.FIELD.equals( elementType ) ) { return getDeclaredField( clazz, property ) != null; } else { String capitalizedPropertyName = capitalize( property ); Method method = getMethod( clazz, PROPERTY_ACCESSOR_PREFIX_GET + capitalizedPropertyName ); if ( method != null && method.getReturnType() != void.class ) { return true; } method = getMethod( clazz, PROPERTY_ACCESSOR_PREFIX_IS + capitalizedPropertyName ); if ( method != null && method.getReturnType() == boolean.class ) { return true; } } return false; }
[ "public", "static", "boolean", "propertyExists", "(", "Class", "<", "?", ">", "clazz", ",", "String", "property", ",", "ElementType", "elementType", ")", "{", "if", "(", "ElementType", ".", "FIELD", ".", "equals", "(", "elementType", ")", ")", "{", "return...
Whether the specified JavaBeans property exists on the given type or not. @param clazz the type of interest @param property the JavaBeans property name @param elementType the element type to check, must be either {@link ElementType#FIELD} or {@link ElementType#METHOD}. @return {@code true} if the specified property exists, {@code false} otherwise
[ "Whether", "the", "specified", "JavaBeans", "property", "exists", "on", "the", "given", "type", "or", "not", "." ]
9ea971df7c27277029006a6f748d8272fb1d69d2
https://github.com/hibernate/hibernate-ogm/blob/9ea971df7c27277029006a6f748d8272fb1d69d2/core/src/main/java/org/hibernate/ogm/util/impl/ReflectionHelper.java#L65-L84
train
hibernate/hibernate-ogm
core/src/main/java/org/hibernate/ogm/util/impl/ReflectionHelper.java
ReflectionHelper.setField
public static void setField(Object object, String field, Object value) throws NoSuchMethodException, InvocationTargetException, IllegalAccessException { Class<?> clazz = object.getClass(); Method m = clazz.getMethod( PROPERTY_ACCESSOR_PREFIX_SET + capitalize( field ), value.getClass() ); m.invoke( object, value ); }
java
public static void setField(Object object, String field, Object value) throws NoSuchMethodException, InvocationTargetException, IllegalAccessException { Class<?> clazz = object.getClass(); Method m = clazz.getMethod( PROPERTY_ACCESSOR_PREFIX_SET + capitalize( field ), value.getClass() ); m.invoke( object, value ); }
[ "public", "static", "void", "setField", "(", "Object", "object", ",", "String", "field", ",", "Object", "value", ")", "throws", "NoSuchMethodException", ",", "InvocationTargetException", ",", "IllegalAccessException", "{", "Class", "<", "?", ">", "clazz", "=", "...
Set value for given object field. @param object object to be updated @param field field name @param value field value @throws NoSuchMethodException if property writer is not available @throws InvocationTargetException if property writer throws an exception @throws IllegalAccessException if property writer is inaccessible
[ "Set", "value", "for", "given", "object", "field", "." ]
9ea971df7c27277029006a6f748d8272fb1d69d2
https://github.com/hibernate/hibernate-ogm/blob/9ea971df7c27277029006a6f748d8272fb1d69d2/core/src/main/java/org/hibernate/ogm/util/impl/ReflectionHelper.java#L127-L131
train
hibernate/hibernate-ogm
core/src/main/java/org/hibernate/ogm/query/parsing/impl/ParserPropertyHelper.java
ParserPropertyHelper.isEmbeddedProperty
public boolean isEmbeddedProperty(String targetTypeName, List<String> namesWithoutAlias) { OgmEntityPersister persister = getPersister( targetTypeName ); Type propertyType = persister.getPropertyType( namesWithoutAlias.get( 0 ) ); if ( propertyType.isComponentType() ) { // Embedded return true; } else if ( propertyType.isAssociationType() ) { Joinable associatedJoinable = ( (AssociationType) propertyType ).getAssociatedJoinable( persister.getFactory() ); if ( associatedJoinable.isCollection() ) { OgmCollectionPersister collectionPersister = (OgmCollectionPersister) associatedJoinable; return collectionPersister.getType().isComponentType(); } } return false; }
java
public boolean isEmbeddedProperty(String targetTypeName, List<String> namesWithoutAlias) { OgmEntityPersister persister = getPersister( targetTypeName ); Type propertyType = persister.getPropertyType( namesWithoutAlias.get( 0 ) ); if ( propertyType.isComponentType() ) { // Embedded return true; } else if ( propertyType.isAssociationType() ) { Joinable associatedJoinable = ( (AssociationType) propertyType ).getAssociatedJoinable( persister.getFactory() ); if ( associatedJoinable.isCollection() ) { OgmCollectionPersister collectionPersister = (OgmCollectionPersister) associatedJoinable; return collectionPersister.getType().isComponentType(); } } return false; }
[ "public", "boolean", "isEmbeddedProperty", "(", "String", "targetTypeName", ",", "List", "<", "String", ">", "namesWithoutAlias", ")", "{", "OgmEntityPersister", "persister", "=", "getPersister", "(", "targetTypeName", ")", ";", "Type", "propertyType", "=", "persist...
Checks if the path leads to an embedded property or association. @param targetTypeName the entity with the property @param namesWithoutAlias the path to the property with all the aliases resolved @return {@code true} if the property is an embedded, {@code false} otherwise.
[ "Checks", "if", "the", "path", "leads", "to", "an", "embedded", "property", "or", "association", "." ]
9ea971df7c27277029006a6f748d8272fb1d69d2
https://github.com/hibernate/hibernate-ogm/blob/9ea971df7c27277029006a6f748d8272fb1d69d2/core/src/main/java/org/hibernate/ogm/query/parsing/impl/ParserPropertyHelper.java#L158-L173
train
hibernate/hibernate-ogm
core/src/main/java/org/hibernate/ogm/query/parsing/impl/ParserPropertyHelper.java
ParserPropertyHelper.isAssociation
public boolean isAssociation(String targetTypeName, List<String> pathWithoutAlias) { OgmEntityPersister persister = getPersister( targetTypeName ); Type propertyType = persister.getPropertyType( pathWithoutAlias.get( 0 ) ); return propertyType.isAssociationType(); }
java
public boolean isAssociation(String targetTypeName, List<String> pathWithoutAlias) { OgmEntityPersister persister = getPersister( targetTypeName ); Type propertyType = persister.getPropertyType( pathWithoutAlias.get( 0 ) ); return propertyType.isAssociationType(); }
[ "public", "boolean", "isAssociation", "(", "String", "targetTypeName", ",", "List", "<", "String", ">", "pathWithoutAlias", ")", "{", "OgmEntityPersister", "persister", "=", "getPersister", "(", "targetTypeName", ")", ";", "Type", "propertyType", "=", "persister", ...
Check if the path to the property correspond to an association. @param targetTypeName the name of the entity containing the property @param pathWithoutAlias the path to the property WITHOUT aliases @return {@code true} if the property is an association or {@code false} otherwise
[ "Check", "if", "the", "path", "to", "the", "property", "correspond", "to", "an", "association", "." ]
9ea971df7c27277029006a6f748d8272fb1d69d2
https://github.com/hibernate/hibernate-ogm/blob/9ea971df7c27277029006a6f748d8272fb1d69d2/core/src/main/java/org/hibernate/ogm/query/parsing/impl/ParserPropertyHelper.java#L182-L186
train
hibernate/hibernate-ogm
core/src/main/java/org/hibernate/ogm/query/parsing/impl/ParserPropertyHelper.java
ParserPropertyHelper.findAssociationPath
public List<String> findAssociationPath(String targetTypeName, List<String> pathWithoutAlias) { List<String> subPath = new ArrayList<String>( pathWithoutAlias.size() ); for ( String name : pathWithoutAlias ) { subPath.add( name ); if ( isAssociation( targetTypeName, subPath ) ) { return subPath; } } return null; }
java
public List<String> findAssociationPath(String targetTypeName, List<String> pathWithoutAlias) { List<String> subPath = new ArrayList<String>( pathWithoutAlias.size() ); for ( String name : pathWithoutAlias ) { subPath.add( name ); if ( isAssociation( targetTypeName, subPath ) ) { return subPath; } } return null; }
[ "public", "List", "<", "String", ">", "findAssociationPath", "(", "String", "targetTypeName", ",", "List", "<", "String", ">", "pathWithoutAlias", ")", "{", "List", "<", "String", ">", "subPath", "=", "new", "ArrayList", "<", "String", ">", "(", "pathWithout...
Find the path to the first association in the property path. @param targetTypeName the entity with the property @param pathWithoutAlias the path to the property WITHOUT the alias @return the path to the first association or {@code null} if there isn't an association in the property path
[ "Find", "the", "path", "to", "the", "first", "association", "in", "the", "property", "path", "." ]
9ea971df7c27277029006a6f748d8272fb1d69d2
https://github.com/hibernate/hibernate-ogm/blob/9ea971df7c27277029006a6f748d8272fb1d69d2/core/src/main/java/org/hibernate/ogm/query/parsing/impl/ParserPropertyHelper.java#L195-L204
train
hibernate/hibernate-ogm
core/src/main/java/org/hibernate/ogm/datastore/document/association/spi/AssociationRow.java
AssociationRow.buildRowKey
private static <R> RowKey buildRowKey(AssociationKey associationKey, R row, AssociationRowAccessor<R> accessor) { String[] columnNames = associationKey.getMetadata().getRowKeyColumnNames(); Object[] columnValues = new Object[columnNames.length]; for ( int i = 0; i < columnNames.length; i++ ) { String columnName = columnNames[i]; columnValues[i] = associationKey.getMetadata().isKeyColumn( columnName ) ? associationKey.getColumnValue( columnName ) : accessor.get( row, columnName ); } return new RowKey( columnNames, columnValues ); }
java
private static <R> RowKey buildRowKey(AssociationKey associationKey, R row, AssociationRowAccessor<R> accessor) { String[] columnNames = associationKey.getMetadata().getRowKeyColumnNames(); Object[] columnValues = new Object[columnNames.length]; for ( int i = 0; i < columnNames.length; i++ ) { String columnName = columnNames[i]; columnValues[i] = associationKey.getMetadata().isKeyColumn( columnName ) ? associationKey.getColumnValue( columnName ) : accessor.get( row, columnName ); } return new RowKey( columnNames, columnValues ); }
[ "private", "static", "<", "R", ">", "RowKey", "buildRowKey", "(", "AssociationKey", "associationKey", ",", "R", "row", ",", "AssociationRowAccessor", "<", "R", ">", "accessor", ")", "{", "String", "[", "]", "columnNames", "=", "associationKey", ".", "getMetada...
Creates the row key of the given association row; columns present in the given association key will be obtained from there, all other columns from the given native association row.
[ "Creates", "the", "row", "key", "of", "the", "given", "association", "row", ";", "columns", "present", "in", "the", "given", "association", "key", "will", "be", "obtained", "from", "there", "all", "other", "columns", "from", "the", "given", "native", "associ...
9ea971df7c27277029006a6f748d8272fb1d69d2
https://github.com/hibernate/hibernate-ogm/blob/9ea971df7c27277029006a6f748d8272fb1d69d2/core/src/main/java/org/hibernate/ogm/datastore/document/association/spi/AssociationRow.java#L74-L84
train
hibernate/hibernate-ogm
neo4j/src/main/java/org/hibernate/ogm/datastore/neo4j/BaseNeo4jDialect.java
BaseNeo4jDialect.getEntityKey
protected EntityKey getEntityKey(Tuple tuple, AssociatedEntityKeyMetadata associatedEntityKeyMetadata) { Object[] columnValues = new Object[ associatedEntityKeyMetadata.getAssociationKeyColumns().length]; int i = 0; for ( String associationKeyColumn : associatedEntityKeyMetadata.getAssociationKeyColumns() ) { columnValues[i] = tuple.get( associationKeyColumn ); i++; } return new EntityKey( associatedEntityKeyMetadata.getEntityKeyMetadata(), columnValues ); }
java
protected EntityKey getEntityKey(Tuple tuple, AssociatedEntityKeyMetadata associatedEntityKeyMetadata) { Object[] columnValues = new Object[ associatedEntityKeyMetadata.getAssociationKeyColumns().length]; int i = 0; for ( String associationKeyColumn : associatedEntityKeyMetadata.getAssociationKeyColumns() ) { columnValues[i] = tuple.get( associationKeyColumn ); i++; } return new EntityKey( associatedEntityKeyMetadata.getEntityKeyMetadata(), columnValues ); }
[ "protected", "EntityKey", "getEntityKey", "(", "Tuple", "tuple", ",", "AssociatedEntityKeyMetadata", "associatedEntityKeyMetadata", ")", "{", "Object", "[", "]", "columnValues", "=", "new", "Object", "[", "associatedEntityKeyMetadata", ".", "getAssociationKeyColumns", "("...
Returns the key of the entity targeted by the represented association, retrieved from the given tuple. @param tuple the tuple from which to retrieve the referenced entity key @return the key of the entity targeted by the represented association
[ "Returns", "the", "key", "of", "the", "entity", "targeted", "by", "the", "represented", "association", "retrieved", "from", "the", "given", "tuple", "." ]
9ea971df7c27277029006a6f748d8272fb1d69d2
https://github.com/hibernate/hibernate-ogm/blob/9ea971df7c27277029006a6f748d8272fb1d69d2/neo4j/src/main/java/org/hibernate/ogm/datastore/neo4j/BaseNeo4jDialect.java#L191-L201
train
hibernate/hibernate-ogm
neo4j/src/main/java/org/hibernate/ogm/datastore/neo4j/BaseNeo4jDialect.java
BaseNeo4jDialect.isPartOfRegularEmbedded
public static boolean isPartOfRegularEmbedded(String[] keyColumnNames, String column) { return isPartOfEmbedded( column ) && !ArrayHelper.contains( keyColumnNames, column ); }
java
public static boolean isPartOfRegularEmbedded(String[] keyColumnNames, String column) { return isPartOfEmbedded( column ) && !ArrayHelper.contains( keyColumnNames, column ); }
[ "public", "static", "boolean", "isPartOfRegularEmbedded", "(", "String", "[", "]", "keyColumnNames", ",", "String", "column", ")", "{", "return", "isPartOfEmbedded", "(", "column", ")", "&&", "!", "ArrayHelper", ".", "contains", "(", "keyColumnNames", ",", "colu...
A regular embedded is an element that it is embedded but it is not a key or a collection. @param keyColumnNames the column names representing the identifier of the entity @param column the column we want to check @return {@code true} if the column represent an attribute of a regular embedded element, {@code false} otherwise
[ "A", "regular", "embedded", "is", "an", "element", "that", "it", "is", "embedded", "but", "it", "is", "not", "a", "key", "or", "a", "collection", "." ]
9ea971df7c27277029006a6f748d8272fb1d69d2
https://github.com/hibernate/hibernate-ogm/blob/9ea971df7c27277029006a6f748d8272fb1d69d2/neo4j/src/main/java/org/hibernate/ogm/datastore/neo4j/BaseNeo4jDialect.java#L219-L221
train
hibernate/hibernate-ogm
core/src/main/java/org/hibernate/ogm/datastore/document/impl/EmbeddableStateFinder.java
EmbeddableStateFinder.getOuterMostNullEmbeddableIfAny
public String getOuterMostNullEmbeddableIfAny(String column) { String[] path = column.split( "\\." ); if ( !isEmbeddableColumn( path ) ) { return null; } // the cached value may be null hence the explicit key lookup if ( columnToOuterMostNullEmbeddableCache.containsKey( column ) ) { return columnToOuterMostNullEmbeddableCache.get( column ); } return determineAndCacheOuterMostNullEmbeddable( column, path ); }
java
public String getOuterMostNullEmbeddableIfAny(String column) { String[] path = column.split( "\\." ); if ( !isEmbeddableColumn( path ) ) { return null; } // the cached value may be null hence the explicit key lookup if ( columnToOuterMostNullEmbeddableCache.containsKey( column ) ) { return columnToOuterMostNullEmbeddableCache.get( column ); } return determineAndCacheOuterMostNullEmbeddable( column, path ); }
[ "public", "String", "getOuterMostNullEmbeddableIfAny", "(", "String", "column", ")", "{", "String", "[", "]", "path", "=", "column", ".", "split", "(", "\"\\\\.\"", ")", ";", "if", "(", "!", "isEmbeddableColumn", "(", "path", ")", ")", "{", "return", "null...
Should only called on a column that is being set to null. Returns the most outer embeddable containing {@code column} that is entirely null. Return null otherwise i.e. not embeddable. The implementation lazily compute the embeddable state and caches it. The idea behind the lazy computation is that only some columns will be set to null and only in some situations. The idea behind caching is that an embeddable contains several columns, no need to recompute its state.
[ "Should", "only", "called", "on", "a", "column", "that", "is", "being", "set", "to", "null", "." ]
9ea971df7c27277029006a6f748d8272fb1d69d2
https://github.com/hibernate/hibernate-ogm/blob/9ea971df7c27277029006a6f748d8272fb1d69d2/core/src/main/java/org/hibernate/ogm/datastore/document/impl/EmbeddableStateFinder.java#L48-L58
train
hibernate/hibernate-ogm
core/src/main/java/org/hibernate/ogm/datastore/document/impl/EmbeddableStateFinder.java
EmbeddableStateFinder.determineAndCacheOuterMostNullEmbeddable
private String determineAndCacheOuterMostNullEmbeddable(String column, String[] path) { String embeddable = path[0]; // process each embeddable from less specific to most specific // exclude path leaves as it's a column and not an embeddable for ( int index = 0; index < path.length - 1; index++ ) { Set<String> columnsOfEmbeddable = getColumnsOfEmbeddableAndComputeEmbeddableNullness( embeddable ); if ( nullEmbeddables.contains( embeddable ) ) { // the current embeddable only has null columns; cache that info for all the columns for ( String columnOfEmbeddable : columnsOfEmbeddable ) { columnToOuterMostNullEmbeddableCache.put( columnOfEmbeddable, embeddable ); } break; } else { maybeCacheOnNonNullEmbeddable( path, index, columnsOfEmbeddable ); } // a more specific null embeddable might be present, carry on embeddable += "." + path[index + 1]; } return columnToOuterMostNullEmbeddableCache.get( column ); }
java
private String determineAndCacheOuterMostNullEmbeddable(String column, String[] path) { String embeddable = path[0]; // process each embeddable from less specific to most specific // exclude path leaves as it's a column and not an embeddable for ( int index = 0; index < path.length - 1; index++ ) { Set<String> columnsOfEmbeddable = getColumnsOfEmbeddableAndComputeEmbeddableNullness( embeddable ); if ( nullEmbeddables.contains( embeddable ) ) { // the current embeddable only has null columns; cache that info for all the columns for ( String columnOfEmbeddable : columnsOfEmbeddable ) { columnToOuterMostNullEmbeddableCache.put( columnOfEmbeddable, embeddable ); } break; } else { maybeCacheOnNonNullEmbeddable( path, index, columnsOfEmbeddable ); } // a more specific null embeddable might be present, carry on embeddable += "." + path[index + 1]; } return columnToOuterMostNullEmbeddableCache.get( column ); }
[ "private", "String", "determineAndCacheOuterMostNullEmbeddable", "(", "String", "column", ",", "String", "[", "]", "path", ")", "{", "String", "embeddable", "=", "path", "[", "0", "]", ";", "// process each embeddable from less specific to most specific", "// exclude path...
Walks from the most outer embeddable to the most inner one look for all columns contained in these embeddables and exclude the embeddables that have a non null column because of caching, the algorithm is only run once per column parameter
[ "Walks", "from", "the", "most", "outer", "embeddable", "to", "the", "most", "inner", "one", "look", "for", "all", "columns", "contained", "in", "these", "embeddables", "and", "exclude", "the", "embeddables", "that", "have", "a", "non", "null", "column", "bec...
9ea971df7c27277029006a6f748d8272fb1d69d2
https://github.com/hibernate/hibernate-ogm/blob/9ea971df7c27277029006a6f748d8272fb1d69d2/core/src/main/java/org/hibernate/ogm/datastore/document/impl/EmbeddableStateFinder.java#L66-L87
train
hibernate/hibernate-ogm
core/src/main/java/org/hibernate/ogm/persister/impl/EntityAssociationUpdater.java
EntityAssociationUpdater.addNavigationalInformationForInverseSide
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 ); } } } }
java
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", "void", "addNavigationalInformationForInverseSide", "(", ")", "{", "if", "(", "log", ".", "isTraceEnabled", "(", ")", ")", "{", "log", ".", "trace", "(", "\"Adding inverse navigational information for entity: \"", "+", "MessageHelper", ".", "infoString", "("...
Updates all inverse associations managed by a given entity.
[ "Updates", "all", "inverse", "associations", "managed", "by", "a", "given", "entity", "." ]
9ea971df7c27277029006a6f748d8272fb1d69d2
https://github.com/hibernate/hibernate-ogm/blob/9ea971df7c27277029006a6f748d8272fb1d69d2/core/src/main/java/org/hibernate/ogm/persister/impl/EntityAssociationUpdater.java#L97-L122
train
hibernate/hibernate-ogm
core/src/main/java/org/hibernate/ogm/util/impl/StringHelper.java
StringHelper.escapeDoubleQuotesForJson
public static String escapeDoubleQuotesForJson(String text) { if ( text == null ) { return null; } StringBuilder builder = new StringBuilder( text.length() ); for ( int i = 0; i < text.length(); i++ ) { char c = text.charAt( i ); switch ( c ) { case '"': case '\\': builder.append( "\\" ); default: builder.append( c ); } } return builder.toString(); }
java
public static String escapeDoubleQuotesForJson(String text) { if ( text == null ) { return null; } StringBuilder builder = new StringBuilder( text.length() ); for ( int i = 0; i < text.length(); i++ ) { char c = text.charAt( i ); switch ( c ) { case '"': case '\\': builder.append( "\\" ); default: builder.append( c ); } } return builder.toString(); }
[ "public", "static", "String", "escapeDoubleQuotesForJson", "(", "String", "text", ")", "{", "if", "(", "text", "==", "null", ")", "{", "return", "null", ";", "}", "StringBuilder", "builder", "=", "new", "StringBuilder", "(", "text", ".", "length", "(", ")"...
If a text contains double quotes, escape them. @param text the text to escape @return Escaped text or {@code null} if the text is null
[ "If", "a", "text", "contains", "double", "quotes", "escape", "them", "." ]
9ea971df7c27277029006a6f748d8272fb1d69d2
https://github.com/hibernate/hibernate-ogm/blob/9ea971df7c27277029006a6f748d8272fb1d69d2/core/src/main/java/org/hibernate/ogm/util/impl/StringHelper.java#L89-L105
train
hibernate/hibernate-ogm
neo4j/src/main/java/org/hibernate/ogm/datastore/neo4j/remote/http/dialect/impl/HttpNeo4jEntityQueries.java
HttpNeo4jEntityQueries.row
private static Row row(List<StatementResult> results) { Row row = results.get( 0 ).getData().get( 0 ); return row; }
java
private static Row row(List<StatementResult> results) { Row row = results.get( 0 ).getData().get( 0 ); return row; }
[ "private", "static", "Row", "row", "(", "List", "<", "StatementResult", ">", "results", ")", "{", "Row", "row", "=", "results", ".", "get", "(", "0", ")", ".", "getData", "(", ")", ".", "get", "(", "0", ")", ";", "return", "row", ";", "}" ]
When we execute a single statement we only need the corresponding Row with the result. @param results a list of {@link StatementResult} @return the result of a single query
[ "When", "we", "execute", "a", "single", "statement", "we", "only", "need", "the", "corresponding", "Row", "with", "the", "result", "." ]
9ea971df7c27277029006a6f748d8272fb1d69d2
https://github.com/hibernate/hibernate-ogm/blob/9ea971df7c27277029006a6f748d8272fb1d69d2/neo4j/src/main/java/org/hibernate/ogm/datastore/neo4j/remote/http/dialect/impl/HttpNeo4jEntityQueries.java#L342-L345
train
hibernate/hibernate-ogm
core/src/main/java/org/hibernate/ogm/dialect/impl/GridDialects.java
GridDialects.getDialectFacetOrNull
static <T extends GridDialect> T getDialectFacetOrNull(GridDialect gridDialect, Class<T> facetType) { if ( hasFacet( gridDialect, facetType ) ) { @SuppressWarnings("unchecked") T asFacet = (T) gridDialect; return asFacet; } return null; }
java
static <T extends GridDialect> T getDialectFacetOrNull(GridDialect gridDialect, Class<T> facetType) { if ( hasFacet( gridDialect, facetType ) ) { @SuppressWarnings("unchecked") T asFacet = (T) gridDialect; return asFacet; } return null; }
[ "static", "<", "T", "extends", "GridDialect", ">", "T", "getDialectFacetOrNull", "(", "GridDialect", "gridDialect", ",", "Class", "<", "T", ">", "facetType", ")", "{", "if", "(", "hasFacet", "(", "gridDialect", ",", "facetType", ")", ")", "{", "@", "Suppre...
Returns the given dialect, narrowed down to the given dialect facet in case it is implemented by the dialect. @param gridDialect the dialect of interest @param facetType the dialect facet type of interest @return the given dialect, narrowed down to the given dialect facet or {@code null} in case the given dialect does not implement the given facet
[ "Returns", "the", "given", "dialect", "narrowed", "down", "to", "the", "given", "dialect", "facet", "in", "case", "it", "is", "implemented", "by", "the", "dialect", "." ]
9ea971df7c27277029006a6f748d8272fb1d69d2
https://github.com/hibernate/hibernate-ogm/blob/9ea971df7c27277029006a6f748d8272fb1d69d2/core/src/main/java/org/hibernate/ogm/dialect/impl/GridDialects.java#L37-L45
train
hibernate/hibernate-ogm
core/src/main/java/org/hibernate/ogm/dialect/impl/GridDialects.java
GridDialects.hasFacet
public static boolean hasFacet(GridDialect gridDialect, Class<? extends GridDialect> facetType) { if ( gridDialect instanceof ForwardingGridDialect ) { return hasFacet( ( (ForwardingGridDialect<?>) gridDialect ).getGridDialect(), facetType ); } else { return facetType.isAssignableFrom( gridDialect.getClass() ); } }
java
public static boolean hasFacet(GridDialect gridDialect, Class<? extends GridDialect> facetType) { if ( gridDialect instanceof ForwardingGridDialect ) { return hasFacet( ( (ForwardingGridDialect<?>) gridDialect ).getGridDialect(), facetType ); } else { return facetType.isAssignableFrom( gridDialect.getClass() ); } }
[ "public", "static", "boolean", "hasFacet", "(", "GridDialect", "gridDialect", ",", "Class", "<", "?", "extends", "GridDialect", ">", "facetType", ")", "{", "if", "(", "gridDialect", "instanceof", "ForwardingGridDialect", ")", "{", "return", "hasFacet", "(", "(",...
Whether the given grid dialect implements the specified facet or not. @param gridDialect the dialect of interest @param facetType the dialect facet type of interest @return {@code true} in case the given dialect implements the specified facet, {@code false} otherwise
[ "Whether", "the", "given", "grid", "dialect", "implements", "the", "specified", "facet", "or", "not", "." ]
9ea971df7c27277029006a6f748d8272fb1d69d2
https://github.com/hibernate/hibernate-ogm/blob/9ea971df7c27277029006a6f748d8272fb1d69d2/core/src/main/java/org/hibernate/ogm/dialect/impl/GridDialects.java#L54-L61
train
hibernate/hibernate-ogm
infinispan-embedded/src/main/java/org/hibernate/ogm/datastore/infinispan/impl/InfinispanEmbeddedDatastoreProvider.java
InfinispanEmbeddedDatastoreProvider.initializePersistenceStrategy
public void initializePersistenceStrategy(CacheMappingType cacheMappingType, Set<EntityKeyMetadata> entityTypes, Set<AssociationKeyMetadata> associationTypes, Set<IdSourceKeyMetadata> idSourceTypes, Iterable<Namespace> namespaces) { persistenceStrategy = PersistenceStrategy.getInstance( cacheMappingType, externalCacheManager, config.getConfigurationUrl(), jtaPlatform, entityTypes, associationTypes, idSourceTypes ); // creates handler for TableGenerator Id sources boolean requiresCounter = hasIdGeneration( idSourceTypes ); if ( requiresCounter ) { this.tableClusterHandler = new TableClusteredCounterHandler( persistenceStrategy.getCacheManager().getCacheManager() ); } // creates handlers for SequenceGenerator Id sources for ( Namespace namespace : namespaces ) { for ( Sequence seq : namespace.getSequences() ) { this.sequenceCounterHandlers.put( seq.getExportIdentifier(), new SequenceClusteredCounterHandler( persistenceStrategy.getCacheManager().getCacheManager(), seq ) ); } } // clear resources this.externalCacheManager = null; this.jtaPlatform = null; }
java
public void initializePersistenceStrategy(CacheMappingType cacheMappingType, Set<EntityKeyMetadata> entityTypes, Set<AssociationKeyMetadata> associationTypes, Set<IdSourceKeyMetadata> idSourceTypes, Iterable<Namespace> namespaces) { persistenceStrategy = PersistenceStrategy.getInstance( cacheMappingType, externalCacheManager, config.getConfigurationUrl(), jtaPlatform, entityTypes, associationTypes, idSourceTypes ); // creates handler for TableGenerator Id sources boolean requiresCounter = hasIdGeneration( idSourceTypes ); if ( requiresCounter ) { this.tableClusterHandler = new TableClusteredCounterHandler( persistenceStrategy.getCacheManager().getCacheManager() ); } // creates handlers for SequenceGenerator Id sources for ( Namespace namespace : namespaces ) { for ( Sequence seq : namespace.getSequences() ) { this.sequenceCounterHandlers.put( seq.getExportIdentifier(), new SequenceClusteredCounterHandler( persistenceStrategy.getCacheManager().getCacheManager(), seq ) ); } } // clear resources this.externalCacheManager = null; this.jtaPlatform = null; }
[ "public", "void", "initializePersistenceStrategy", "(", "CacheMappingType", "cacheMappingType", ",", "Set", "<", "EntityKeyMetadata", ">", "entityTypes", ",", "Set", "<", "AssociationKeyMetadata", ">", "associationTypes", ",", "Set", "<", "IdSourceKeyMetadata", ">", "id...
Initializes the persistence strategy to be used when accessing the datastore. In particular, all the required caches will be configured and initialized. @param cacheMappingType the {@link org.hibernate.ogm.datastore.keyvalue.options.CacheMappingType} to be used @param entityTypes meta-data of all the entity types registered with the current session factory @param associationTypes meta-data of all the association types registered with the current session factory @param idSourceTypes meta-data of all the id source types registered with the current session factory @param namespaces from the database currently in use
[ "Initializes", "the", "persistence", "strategy", "to", "be", "used", "when", "accessing", "the", "datastore", ".", "In", "particular", "all", "the", "required", "caches", "will", "be", "configured", "and", "initialized", "." ]
9ea971df7c27277029006a6f748d8272fb1d69d2
https://github.com/hibernate/hibernate-ogm/blob/9ea971df7c27277029006a6f748d8272fb1d69d2/infinispan-embedded/src/main/java/org/hibernate/ogm/datastore/infinispan/impl/InfinispanEmbeddedDatastoreProvider.java#L108-L136
train
hibernate/hibernate-ogm
mongodb/src/main/java/org/hibernate/ogm/datastore/mongodb/MongoDBDialect.java
MongoDBDialect.getProjection
private static Document getProjection(List<String> fieldNames) { Document projection = new Document(); for ( String column : fieldNames ) { projection.put( column, 1 ); } return projection; }
java
private static Document getProjection(List<String> fieldNames) { Document projection = new Document(); for ( String column : fieldNames ) { projection.put( column, 1 ); } return projection; }
[ "private", "static", "Document", "getProjection", "(", "List", "<", "String", ">", "fieldNames", ")", "{", "Document", "projection", "=", "new", "Document", "(", ")", ";", "for", "(", "String", "column", ":", "fieldNames", ")", "{", "projection", ".", "put...
Returns a projection object for specifying the fields to retrieve during a specific find operation.
[ "Returns", "a", "projection", "object", "for", "specifying", "the", "fields", "to", "retrieve", "during", "a", "specific", "find", "operation", "." ]
9ea971df7c27277029006a6f748d8272fb1d69d2
https://github.com/hibernate/hibernate-ogm/blob/9ea971df7c27277029006a6f748d8272fb1d69d2/mongodb/src/main/java/org/hibernate/ogm/datastore/mongodb/MongoDBDialect.java#L365-L372
train
hibernate/hibernate-ogm
mongodb/src/main/java/org/hibernate/ogm/datastore/mongodb/MongoDBDialect.java
MongoDBDialect.objectForInsert
private static Document objectForInsert(Tuple tuple, Document dbObject) { MongoDBTupleSnapshot snapshot = (MongoDBTupleSnapshot) tuple.getSnapshot(); for ( TupleOperation operation : tuple.getOperations() ) { String column = operation.getColumn(); if ( notInIdField( snapshot, column ) ) { switch ( operation.getType() ) { case PUT: MongoHelpers.setValue( dbObject, column, operation.getValue() ); break; case PUT_NULL: case REMOVE: MongoHelpers.resetValue( dbObject, column ); break; } } } return dbObject; }
java
private static Document objectForInsert(Tuple tuple, Document dbObject) { MongoDBTupleSnapshot snapshot = (MongoDBTupleSnapshot) tuple.getSnapshot(); for ( TupleOperation operation : tuple.getOperations() ) { String column = operation.getColumn(); if ( notInIdField( snapshot, column ) ) { switch ( operation.getType() ) { case PUT: MongoHelpers.setValue( dbObject, column, operation.getValue() ); break; case PUT_NULL: case REMOVE: MongoHelpers.resetValue( dbObject, column ); break; } } } return dbObject; }
[ "private", "static", "Document", "objectForInsert", "(", "Tuple", "tuple", ",", "Document", "dbObject", ")", "{", "MongoDBTupleSnapshot", "snapshot", "=", "(", "MongoDBTupleSnapshot", ")", "tuple", ".", "getSnapshot", "(", ")", ";", "for", "(", "TupleOperation", ...
Creates a Document that can be passed to the MongoDB batch insert function
[ "Creates", "a", "Document", "that", "can", "be", "passed", "to", "the", "MongoDB", "batch", "insert", "function" ]
9ea971df7c27277029006a6f748d8272fb1d69d2
https://github.com/hibernate/hibernate-ogm/blob/9ea971df7c27277029006a6f748d8272fb1d69d2/mongodb/src/main/java/org/hibernate/ogm/datastore/mongodb/MongoDBDialect.java#L554-L571
train
hibernate/hibernate-ogm
mongodb/src/main/java/org/hibernate/ogm/datastore/mongodb/MongoDBDialect.java
MongoDBDialect.doDistinct
private static ClosableIterator<Tuple> doDistinct(final MongoDBQueryDescriptor queryDescriptor, final MongoCollection<Document> collection) { DistinctIterable<?> distinctFieldValues = collection.distinct( queryDescriptor.getDistinctFieldName(), queryDescriptor.getCriteria(), String.class ); Collation collation = getCollation( queryDescriptor.getOptions() ); distinctFieldValues = collation != null ? distinctFieldValues.collation( collation ) : distinctFieldValues; MongoCursor<?> cursor = distinctFieldValues.iterator(); List<Object> documents = new ArrayList<>(); while ( cursor.hasNext() ) { documents.add( cursor.next() ); } MapTupleSnapshot snapshot = new MapTupleSnapshot( Collections.<String, Object>singletonMap( "n", documents ) ); return CollectionHelper.newClosableIterator( Collections.singletonList( new Tuple( snapshot, SnapshotType.UNKNOWN ) ) ); }
java
private static ClosableIterator<Tuple> doDistinct(final MongoDBQueryDescriptor queryDescriptor, final MongoCollection<Document> collection) { DistinctIterable<?> distinctFieldValues = collection.distinct( queryDescriptor.getDistinctFieldName(), queryDescriptor.getCriteria(), String.class ); Collation collation = getCollation( queryDescriptor.getOptions() ); distinctFieldValues = collation != null ? distinctFieldValues.collation( collation ) : distinctFieldValues; MongoCursor<?> cursor = distinctFieldValues.iterator(); List<Object> documents = new ArrayList<>(); while ( cursor.hasNext() ) { documents.add( cursor.next() ); } MapTupleSnapshot snapshot = new MapTupleSnapshot( Collections.<String, Object>singletonMap( "n", documents ) ); return CollectionHelper.newClosableIterator( Collections.singletonList( new Tuple( snapshot, SnapshotType.UNKNOWN ) ) ); }
[ "private", "static", "ClosableIterator", "<", "Tuple", ">", "doDistinct", "(", "final", "MongoDBQueryDescriptor", "queryDescriptor", ",", "final", "MongoCollection", "<", "Document", ">", "collection", ")", "{", "DistinctIterable", "<", "?", ">", "distinctFieldValues"...
do 'Distinct' operation @param queryDescriptor descriptor of MongoDB query @param collection collection for execute the operation @return result iterator @see <a href ="https://docs.mongodb.com/manual/reference/method/db.collection.distinct/">distinct</a>
[ "do", "Distinct", "operation" ]
9ea971df7c27277029006a6f748d8272fb1d69d2
https://github.com/hibernate/hibernate-ogm/blob/9ea971df7c27277029006a6f748d8272fb1d69d2/mongodb/src/main/java/org/hibernate/ogm/datastore/mongodb/MongoDBDialect.java#L1106-L1119
train
hibernate/hibernate-ogm
mongodb/src/main/java/org/hibernate/ogm/datastore/mongodb/MongoDBDialect.java
MongoDBDialect.mergeWriteConcern
@SuppressWarnings("deprecation") private static WriteConcern mergeWriteConcern(WriteConcern original, WriteConcern writeConcern) { if ( original == null ) { return writeConcern; } else if ( writeConcern == null ) { return original; } else if ( original.equals( writeConcern ) ) { return original; } Object wObject; int wTimeoutMS; boolean fsync; Boolean journal; if ( original.getWObject() instanceof String ) { wObject = original.getWString(); } else if ( writeConcern.getWObject() instanceof String ) { wObject = writeConcern.getWString(); } else { wObject = Math.max( original.getW(), writeConcern.getW() ); } wTimeoutMS = Math.min( original.getWtimeout(), writeConcern.getWtimeout() ); fsync = original.getFsync() || writeConcern.getFsync(); if ( original.getJournal() == null ) { journal = writeConcern.getJournal(); } else if ( writeConcern.getJournal() == null ) { journal = original.getJournal(); } else { journal = original.getJournal() || writeConcern.getJournal(); } if ( wObject instanceof String ) { return new WriteConcern( (String) wObject, wTimeoutMS, fsync, journal ); } else { return new WriteConcern( (int) wObject, wTimeoutMS, fsync, journal ); } }
java
@SuppressWarnings("deprecation") private static WriteConcern mergeWriteConcern(WriteConcern original, WriteConcern writeConcern) { if ( original == null ) { return writeConcern; } else if ( writeConcern == null ) { return original; } else if ( original.equals( writeConcern ) ) { return original; } Object wObject; int wTimeoutMS; boolean fsync; Boolean journal; if ( original.getWObject() instanceof String ) { wObject = original.getWString(); } else if ( writeConcern.getWObject() instanceof String ) { wObject = writeConcern.getWString(); } else { wObject = Math.max( original.getW(), writeConcern.getW() ); } wTimeoutMS = Math.min( original.getWtimeout(), writeConcern.getWtimeout() ); fsync = original.getFsync() || writeConcern.getFsync(); if ( original.getJournal() == null ) { journal = writeConcern.getJournal(); } else if ( writeConcern.getJournal() == null ) { journal = original.getJournal(); } else { journal = original.getJournal() || writeConcern.getJournal(); } if ( wObject instanceof String ) { return new WriteConcern( (String) wObject, wTimeoutMS, fsync, journal ); } else { return new WriteConcern( (int) wObject, wTimeoutMS, fsync, journal ); } }
[ "@", "SuppressWarnings", "(", "\"deprecation\"", ")", "private", "static", "WriteConcern", "mergeWriteConcern", "(", "WriteConcern", "original", ",", "WriteConcern", "writeConcern", ")", "{", "if", "(", "original", "==", "null", ")", "{", "return", "writeConcern", ...
As we merge several operations into one operation, we need to be sure the write concern applied to the aggregated operation respects all the requirements expressed for each separate operation. Thus, for each parameter of the write concern, we keep the stricter one for the resulting merged write concern.
[ "As", "we", "merge", "several", "operations", "into", "one", "operation", "we", "need", "to", "be", "sure", "the", "write", "concern", "applied", "to", "the", "aggregated", "operation", "respects", "all", "the", "requirements", "expressed", "for", "each", "sep...
9ea971df7c27277029006a6f748d8272fb1d69d2
https://github.com/hibernate/hibernate-ogm/blob/9ea971df7c27277029006a6f748d8272fb1d69d2/mongodb/src/main/java/org/hibernate/ogm/datastore/mongodb/MongoDBDialect.java#L1807-L1854
train
hibernate/hibernate-ogm
mongodb/src/main/java/org/hibernate/ogm/datastore/mongodb/MongoDBDialect.java
MongoDBDialect.callStoredProcedure
@Override public ClosableIterator<Tuple> callStoredProcedure(String storedProcedureName, ProcedureQueryParameters params, TupleContext tupleContext) { validate( params ); StringBuilder commandLine = createCallStoreProcedureCommand( storedProcedureName, params ); Document result = callStoredProcedure( commandLine ); Object resultValue = result.get( "retval" ); List<Tuple> resultTuples = extractTuples( storedProcedureName, resultValue ); return CollectionHelper.newClosableIterator( resultTuples ); }
java
@Override public ClosableIterator<Tuple> callStoredProcedure(String storedProcedureName, ProcedureQueryParameters params, TupleContext tupleContext) { validate( params ); StringBuilder commandLine = createCallStoreProcedureCommand( storedProcedureName, params ); Document result = callStoredProcedure( commandLine ); Object resultValue = result.get( "retval" ); List<Tuple> resultTuples = extractTuples( storedProcedureName, resultValue ); return CollectionHelper.newClosableIterator( resultTuples ); }
[ "@", "Override", "public", "ClosableIterator", "<", "Tuple", ">", "callStoredProcedure", "(", "String", "storedProcedureName", ",", "ProcedureQueryParameters", "params", ",", "TupleContext", "tupleContext", ")", "{", "validate", "(", "params", ")", ";", "StringBuilder...
In MongoDB the equivalent of a stored procedure is a stored Javascript. @param storedProcedureName name of stored procedure @param params query parameters @param tupleContext the tuple context @return the result as a {@link ClosableIterator}
[ "In", "MongoDB", "the", "equivalent", "of", "a", "stored", "procedure", "is", "a", "stored", "Javascript", "." ]
9ea971df7c27277029006a6f748d8272fb1d69d2
https://github.com/hibernate/hibernate-ogm/blob/9ea971df7c27277029006a6f748d8272fb1d69d2/mongodb/src/main/java/org/hibernate/ogm/datastore/mongodb/MongoDBDialect.java#L1865-L1873
train
hibernate/hibernate-ogm
core/src/main/java/org/hibernate/ogm/loader/entity/impl/BatchingEntityLoaderBuilder.java
BatchingEntityLoaderBuilder.buildLoader
public UniqueEntityLoader buildLoader( OuterJoinLoadable persister, int batchSize, LockMode lockMode, SessionFactoryImplementor factory, LoadQueryInfluencers influencers, BatchableEntityLoaderBuilder innerEntityLoaderBuilder) { if ( batchSize <= 1 ) { // no batching return buildNonBatchingLoader( persister, lockMode, factory, influencers, innerEntityLoaderBuilder ); } return buildBatchingLoader( persister, batchSize, lockMode, factory, influencers, innerEntityLoaderBuilder ); }
java
public UniqueEntityLoader buildLoader( OuterJoinLoadable persister, int batchSize, LockMode lockMode, SessionFactoryImplementor factory, LoadQueryInfluencers influencers, BatchableEntityLoaderBuilder innerEntityLoaderBuilder) { if ( batchSize <= 1 ) { // no batching return buildNonBatchingLoader( persister, lockMode, factory, influencers, innerEntityLoaderBuilder ); } return buildBatchingLoader( persister, batchSize, lockMode, factory, influencers, innerEntityLoaderBuilder ); }
[ "public", "UniqueEntityLoader", "buildLoader", "(", "OuterJoinLoadable", "persister", ",", "int", "batchSize", ",", "LockMode", "lockMode", ",", "SessionFactoryImplementor", "factory", ",", "LoadQueryInfluencers", "influencers", ",", "BatchableEntityLoaderBuilder", "innerEnti...
Builds a batch-fetch capable loader based on the given persister, lock-mode, etc. @param persister The entity persister @param batchSize The maximum number of ids to batch-fetch at once @param lockMode The lock mode @param factory The SessionFactory @param influencers Any influencers that should affect the built query @param innerEntityLoaderBuilder Builder of the entity loader receiving the subset of batches @return The loader.
[ "Builds", "a", "batch", "-", "fetch", "capable", "loader", "based", "on", "the", "given", "persister", "lock", "-", "mode", "etc", "." ]
9ea971df7c27277029006a6f748d8272fb1d69d2
https://github.com/hibernate/hibernate-ogm/blob/9ea971df7c27277029006a6f748d8272fb1d69d2/core/src/main/java/org/hibernate/ogm/loader/entity/impl/BatchingEntityLoaderBuilder.java#L89-L101
train
hibernate/hibernate-ogm
core/src/main/java/org/hibernate/ogm/loader/entity/impl/BatchingEntityLoaderBuilder.java
BatchingEntityLoaderBuilder.buildLoader
public UniqueEntityLoader buildLoader( OuterJoinLoadable persister, int batchSize, LockOptions lockOptions, SessionFactoryImplementor factory, LoadQueryInfluencers influencers, BatchableEntityLoaderBuilder innerEntityLoaderBuilder) { if ( batchSize <= 1 ) { // no batching return buildNonBatchingLoader( persister, lockOptions, factory, influencers, innerEntityLoaderBuilder ); } return buildBatchingLoader( persister, batchSize, lockOptions, factory, influencers, innerEntityLoaderBuilder ); }
java
public UniqueEntityLoader buildLoader( OuterJoinLoadable persister, int batchSize, LockOptions lockOptions, SessionFactoryImplementor factory, LoadQueryInfluencers influencers, BatchableEntityLoaderBuilder innerEntityLoaderBuilder) { if ( batchSize <= 1 ) { // no batching return buildNonBatchingLoader( persister, lockOptions, factory, influencers, innerEntityLoaderBuilder ); } return buildBatchingLoader( persister, batchSize, lockOptions, factory, influencers, innerEntityLoaderBuilder ); }
[ "public", "UniqueEntityLoader", "buildLoader", "(", "OuterJoinLoadable", "persister", ",", "int", "batchSize", ",", "LockOptions", "lockOptions", ",", "SessionFactoryImplementor", "factory", ",", "LoadQueryInfluencers", "influencers", ",", "BatchableEntityLoaderBuilder", "inn...
Builds a batch-fetch capable loader based on the given persister, lock-options, etc. @param persister The entity persister @param batchSize The maximum number of ids to batch-fetch at once @param lockOptions The lock options @param factory The SessionFactory @param influencers Any influencers that should affect the built query @param innerEntityLoaderBuilder Builder of the entity loader receiving the subset of batches @return The loader.
[ "Builds", "a", "batch", "-", "fetch", "capable", "loader", "based", "on", "the", "given", "persister", "lock", "-", "options", "etc", "." ]
9ea971df7c27277029006a6f748d8272fb1d69d2
https://github.com/hibernate/hibernate-ogm/blob/9ea971df7c27277029006a6f748d8272fb1d69d2/core/src/main/java/org/hibernate/ogm/loader/entity/impl/BatchingEntityLoaderBuilder.java#L141-L153
train
hibernate/hibernate-ogm
neo4j/src/main/java/org/hibernate/ogm/datastore/neo4j/EmbeddedNeo4jDialect.java
EmbeddedNeo4jDialect.applyProperties
private void applyProperties(AssociationKey associationKey, Tuple associationRow, Relationship relationship) { String[] indexColumns = associationKey.getMetadata().getRowKeyIndexColumnNames(); for ( int i = 0; i < indexColumns.length; i++ ) { String propertyName = indexColumns[i]; Object propertyValue = associationRow.get( propertyName ); relationship.setProperty( propertyName, propertyValue ); } }
java
private void applyProperties(AssociationKey associationKey, Tuple associationRow, Relationship relationship) { String[] indexColumns = associationKey.getMetadata().getRowKeyIndexColumnNames(); for ( int i = 0; i < indexColumns.length; i++ ) { String propertyName = indexColumns[i]; Object propertyValue = associationRow.get( propertyName ); relationship.setProperty( propertyName, propertyValue ); } }
[ "private", "void", "applyProperties", "(", "AssociationKey", "associationKey", ",", "Tuple", "associationRow", ",", "Relationship", "relationship", ")", "{", "String", "[", "]", "indexColumns", "=", "associationKey", ".", "getMetadata", "(", ")", ".", "getRowKeyInde...
The only properties added to a relationship are the columns representing the index of the association.
[ "The", "only", "properties", "added", "to", "a", "relationship", "are", "the", "columns", "representing", "the", "index", "of", "the", "association", "." ]
9ea971df7c27277029006a6f748d8272fb1d69d2
https://github.com/hibernate/hibernate-ogm/blob/9ea971df7c27277029006a6f748d8272fb1d69d2/neo4j/src/main/java/org/hibernate/ogm/datastore/neo4j/EmbeddedNeo4jDialect.java#L276-L283
train
hibernate/hibernate-ogm
core/src/main/java/org/hibernate/ogm/entityentry/impl/OgmEntityEntryState.java
OgmEntityEntryState.getAssociation
public Association getAssociation(String collectionRole) { if ( associations == null ) { return null; } return associations.get( collectionRole ); }
java
public Association getAssociation(String collectionRole) { if ( associations == null ) { return null; } return associations.get( collectionRole ); }
[ "public", "Association", "getAssociation", "(", "String", "collectionRole", ")", "{", "if", "(", "associations", "==", "null", ")", "{", "return", "null", ";", "}", "return", "associations", ".", "get", "(", "collectionRole", ")", ";", "}" ]
Return the association as cached in the entry state. @param collectionRole the role of the association @return the cached association
[ "Return", "the", "association", "as", "cached", "in", "the", "entry", "state", "." ]
9ea971df7c27277029006a6f748d8272fb1d69d2
https://github.com/hibernate/hibernate-ogm/blob/9ea971df7c27277029006a6f748d8272fb1d69d2/core/src/main/java/org/hibernate/ogm/entityentry/impl/OgmEntityEntryState.java#L50-L55
train
hibernate/hibernate-ogm
core/src/main/java/org/hibernate/ogm/entityentry/impl/OgmEntityEntryState.java
OgmEntityEntryState.setAssociation
public void setAssociation(String collectionRole, Association association) { if ( associations == null ) { associations = new HashMap<>(); } associations.put( collectionRole, association ); }
java
public void setAssociation(String collectionRole, Association association) { if ( associations == null ) { associations = new HashMap<>(); } associations.put( collectionRole, association ); }
[ "public", "void", "setAssociation", "(", "String", "collectionRole", ",", "Association", "association", ")", "{", "if", "(", "associations", "==", "null", ")", "{", "associations", "=", "new", "HashMap", "<>", "(", ")", ";", "}", "associations", ".", "put", ...
Set the association in the entry state. @param collectionRole the role of the association @param association the association
[ "Set", "the", "association", "in", "the", "entry", "state", "." ]
9ea971df7c27277029006a6f748d8272fb1d69d2
https://github.com/hibernate/hibernate-ogm/blob/9ea971df7c27277029006a6f748d8272fb1d69d2/core/src/main/java/org/hibernate/ogm/entityentry/impl/OgmEntityEntryState.java#L76-L81
train
hibernate/hibernate-ogm
core/src/main/java/org/hibernate/ogm/entityentry/impl/OgmEntityEntryState.java
OgmEntityEntryState.addExtraState
@Override public void addExtraState(EntityEntryExtraState extraState) { if ( next == null ) { next = extraState; } else { next.addExtraState( extraState ); } }
java
@Override public void addExtraState(EntityEntryExtraState extraState) { if ( next == null ) { next = extraState; } else { next.addExtraState( extraState ); } }
[ "@", "Override", "public", "void", "addExtraState", "(", "EntityEntryExtraState", "extraState", ")", "{", "if", "(", "next", "==", "null", ")", "{", "next", "=", "extraState", ";", "}", "else", "{", "next", ".", "addExtraState", "(", "extraState", ")", ";"...
state chain management ops below
[ "state", "chain", "management", "ops", "below" ]
9ea971df7c27277029006a6f748d8272fb1d69d2
https://github.com/hibernate/hibernate-ogm/blob/9ea971df7c27277029006a6f748d8272fb1d69d2/core/src/main/java/org/hibernate/ogm/entityentry/impl/OgmEntityEntryState.java#L100-L108
train
hibernate/hibernate-ogm
infinispan-embedded/src/main/java/org/hibernate/ogm/datastore/infinispan/persistencestrategy/counter/ClusteredCounterHandler.java
ClusteredCounterHandler.getCounterOrCreateIt
protected StrongCounter getCounterOrCreateIt(String counterName, int initialValue) { CounterManager counterManager = EmbeddedCounterManagerFactory.asCounterManager( cacheManager ); if ( !counterManager.isDefined( counterName ) ) { LOG.tracef( "Counter %s is not defined, creating it", counterName ); // global configuration is mandatory in order to define // a new clustered counter with persistent storage validateGlobalConfiguration(); counterManager.defineCounter( counterName, CounterConfiguration.builder( CounterType.UNBOUNDED_STRONG ) .initialValue( initialValue ) .storage( Storage.PERSISTENT ) .build() ); } StrongCounter strongCounter = counterManager.getStrongCounter( counterName ); return strongCounter; }
java
protected StrongCounter getCounterOrCreateIt(String counterName, int initialValue) { CounterManager counterManager = EmbeddedCounterManagerFactory.asCounterManager( cacheManager ); if ( !counterManager.isDefined( counterName ) ) { LOG.tracef( "Counter %s is not defined, creating it", counterName ); // global configuration is mandatory in order to define // a new clustered counter with persistent storage validateGlobalConfiguration(); counterManager.defineCounter( counterName, CounterConfiguration.builder( CounterType.UNBOUNDED_STRONG ) .initialValue( initialValue ) .storage( Storage.PERSISTENT ) .build() ); } StrongCounter strongCounter = counterManager.getStrongCounter( counterName ); return strongCounter; }
[ "protected", "StrongCounter", "getCounterOrCreateIt", "(", "String", "counterName", ",", "int", "initialValue", ")", "{", "CounterManager", "counterManager", "=", "EmbeddedCounterManagerFactory", ".", "asCounterManager", "(", "cacheManager", ")", ";", "if", "(", "!", ...
Create a counter if one is not defined already, otherwise return the existing one. @param counterName unique name for the counter @param initialValue initial value for the counter @return a {@link StrongCounter}
[ "Create", "a", "counter", "if", "one", "is", "not", "defined", "already", "otherwise", "return", "the", "existing", "one", "." ]
9ea971df7c27277029006a6f748d8272fb1d69d2
https://github.com/hibernate/hibernate-ogm/blob/9ea971df7c27277029006a6f748d8272fb1d69d2/infinispan-embedded/src/main/java/org/hibernate/ogm/datastore/infinispan/persistencestrategy/counter/ClusteredCounterHandler.java#L47-L66
train
hibernate/hibernate-ogm
core/src/main/java/org/hibernate/ogm/model/spi/Tuple.java
Tuple.getOperations
public Set<TupleOperation> getOperations() { if ( currentState == null ) { return Collections.emptySet(); } else { return new SetFromCollection<TupleOperation>( currentState.values() ); } }
java
public Set<TupleOperation> getOperations() { if ( currentState == null ) { return Collections.emptySet(); } else { return new SetFromCollection<TupleOperation>( currentState.values() ); } }
[ "public", "Set", "<", "TupleOperation", ">", "getOperations", "(", ")", "{", "if", "(", "currentState", "==", "null", ")", "{", "return", "Collections", ".", "emptySet", "(", ")", ";", "}", "else", "{", "return", "new", "SetFromCollection", "<", "TupleOper...
Return the list of actions on the tuple. Inherently deduplicated operations @return the operations to execute on the Tuple
[ "Return", "the", "list", "of", "actions", "on", "the", "tuple", ".", "Inherently", "deduplicated", "operations" ]
9ea971df7c27277029006a6f748d8272fb1d69d2
https://github.com/hibernate/hibernate-ogm/blob/9ea971df7c27277029006a6f748d8272fb1d69d2/core/src/main/java/org/hibernate/ogm/model/spi/Tuple.java#L104-L111
train
hibernate/hibernate-ogm
core/src/main/java/org/hibernate/ogm/options/navigation/source/impl/AnnotationOptionValueSource.java
AnnotationOptionValueSource.getConverter
private <A extends Annotation> AnnotationConverter<A> getConverter(Annotation annotation) { MappingOption mappingOption = annotation.annotationType().getAnnotation( MappingOption.class ); if ( mappingOption == null ) { return null; } // wrong type would be a programming error of the annotation developer @SuppressWarnings("unchecked") Class<? extends AnnotationConverter<A>> converterClass = (Class<? extends AnnotationConverter<A>>) mappingOption.value(); try { return converterClass.newInstance(); } catch (Exception e) { throw log.cannotConvertAnnotation( converterClass, e ); } }
java
private <A extends Annotation> AnnotationConverter<A> getConverter(Annotation annotation) { MappingOption mappingOption = annotation.annotationType().getAnnotation( MappingOption.class ); if ( mappingOption == null ) { return null; } // wrong type would be a programming error of the annotation developer @SuppressWarnings("unchecked") Class<? extends AnnotationConverter<A>> converterClass = (Class<? extends AnnotationConverter<A>>) mappingOption.value(); try { return converterClass.newInstance(); } catch (Exception e) { throw log.cannotConvertAnnotation( converterClass, e ); } }
[ "private", "<", "A", "extends", "Annotation", ">", "AnnotationConverter", "<", "A", ">", "getConverter", "(", "Annotation", "annotation", ")", "{", "MappingOption", "mappingOption", "=", "annotation", ".", "annotationType", "(", ")", ".", "getAnnotation", "(", "...
Returns a converter instance for the given annotation. @param annotation the annotation @return a converter instance or {@code null} if the given annotation is no option annotation
[ "Returns", "a", "converter", "instance", "for", "the", "given", "annotation", "." ]
9ea971df7c27277029006a6f748d8272fb1d69d2
https://github.com/hibernate/hibernate-ogm/blob/9ea971df7c27277029006a6f748d8272fb1d69d2/core/src/main/java/org/hibernate/ogm/options/navigation/source/impl/AnnotationOptionValueSource.java#L115-L131
train
hibernate/hibernate-ogm
core/src/main/java/org/hibernate/ogm/util/impl/ArrayHelper.java
ArrayHelper.slice
public static String[] slice(String[] strings, int begin, int length) { String[] result = new String[length]; System.arraycopy( strings, begin, result, 0, length ); return result; }
java
public static String[] slice(String[] strings, int begin, int length) { String[] result = new String[length]; System.arraycopy( strings, begin, result, 0, length ); return result; }
[ "public", "static", "String", "[", "]", "slice", "(", "String", "[", "]", "strings", ",", "int", "begin", ",", "int", "length", ")", "{", "String", "[", "]", "result", "=", "new", "String", "[", "length", "]", ";", "System", ".", "arraycopy", "(", ...
Create a smaller array from an existing one. @param strings an array containing element of type {@link String} @param begin the starting position of the sub-array @param length the number of element to consider @return a new array continaining only the selected elements
[ "Create", "a", "smaller", "array", "from", "an", "existing", "one", "." ]
9ea971df7c27277029006a6f748d8272fb1d69d2
https://github.com/hibernate/hibernate-ogm/blob/9ea971df7c27277029006a6f748d8272fb1d69d2/core/src/main/java/org/hibernate/ogm/util/impl/ArrayHelper.java#L37-L41
train
hibernate/hibernate-ogm
core/src/main/java/org/hibernate/ogm/util/impl/ArrayHelper.java
ArrayHelper.indexOf
public static <T> int indexOf(T[] array, T element) { for ( int i = 0; i < array.length; i++ ) { if ( array[i].equals( element ) ) { return i; } } return -1; }
java
public static <T> int indexOf(T[] array, T element) { for ( int i = 0; i < array.length; i++ ) { if ( array[i].equals( element ) ) { return i; } } return -1; }
[ "public", "static", "<", "T", ">", "int", "indexOf", "(", "T", "[", "]", "array", ",", "T", "element", ")", "{", "for", "(", "int", "i", "=", "0", ";", "i", "<", "array", ".", "length", ";", "i", "++", ")", "{", "if", "(", "array", "[", "i"...
Return the position of an element inside an array @param array the array where it looks for an element @param element the element to find in the array @param <T> the type of elements in the array @return the position of the element if it's found in the array, -1 otherwise
[ "Return", "the", "position", "of", "an", "element", "inside", "an", "array" ]
9ea971df7c27277029006a6f748d8272fb1d69d2
https://github.com/hibernate/hibernate-ogm/blob/9ea971df7c27277029006a6f748d8272fb1d69d2/core/src/main/java/org/hibernate/ogm/util/impl/ArrayHelper.java#L51-L58
train
hibernate/hibernate-ogm
core/src/main/java/org/hibernate/ogm/util/impl/ArrayHelper.java
ArrayHelper.concat
public static <T> T[] concat(T[] first, T... second) { int firstLength = first.length; int secondLength = second.length; @SuppressWarnings("unchecked") T[] result = (T[]) Array.newInstance( first.getClass().getComponentType(), firstLength + secondLength ); System.arraycopy( first, 0, result, 0, firstLength ); System.arraycopy( second, 0, result, firstLength, secondLength ); return result; }
java
public static <T> T[] concat(T[] first, T... second) { int firstLength = first.length; int secondLength = second.length; @SuppressWarnings("unchecked") T[] result = (T[]) Array.newInstance( first.getClass().getComponentType(), firstLength + secondLength ); System.arraycopy( first, 0, result, 0, firstLength ); System.arraycopy( second, 0, result, firstLength, secondLength ); return result; }
[ "public", "static", "<", "T", ">", "T", "[", "]", "concat", "(", "T", "[", "]", "first", ",", "T", "...", "second", ")", "{", "int", "firstLength", "=", "first", ".", "length", ";", "int", "secondLength", "=", "second", ".", "length", ";", "@", "...
Concats two arrays. @param first the first array @param second the second array @param <T> the type of the element in the array @return a new array created adding the element in the second array after the first one
[ "Concats", "two", "arrays", "." ]
9ea971df7c27277029006a6f748d8272fb1d69d2
https://github.com/hibernate/hibernate-ogm/blob/9ea971df7c27277029006a6f748d8272fb1d69d2/core/src/main/java/org/hibernate/ogm/util/impl/ArrayHelper.java#L79-L89
train
hibernate/hibernate-ogm
core/src/main/java/org/hibernate/ogm/util/impl/ArrayHelper.java
ArrayHelper.concat
public static <T> T[] concat(T firstElement, T... array) { @SuppressWarnings("unchecked") T[] result = (T[]) Array.newInstance( firstElement.getClass(), 1 + array.length ); result[0] = firstElement; System.arraycopy( array, 0, result, 1, array.length ); return result; }
java
public static <T> T[] concat(T firstElement, T... array) { @SuppressWarnings("unchecked") T[] result = (T[]) Array.newInstance( firstElement.getClass(), 1 + array.length ); result[0] = firstElement; System.arraycopy( array, 0, result, 1, array.length ); return result; }
[ "public", "static", "<", "T", ">", "T", "[", "]", "concat", "(", "T", "firstElement", ",", "T", "...", "array", ")", "{", "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "T", "[", "]", "result", "=", "(", "T", "[", "]", ")", "Array", ".", "ne...
Concats an element and an array. @param firstElement the first element @param array the array @param <T> the type of the element in the array @return a new array created adding the element in the second array after the first element
[ "Concats", "an", "element", "and", "an", "array", "." ]
9ea971df7c27277029006a6f748d8272fb1d69d2
https://github.com/hibernate/hibernate-ogm/blob/9ea971df7c27277029006a6f748d8272fb1d69d2/core/src/main/java/org/hibernate/ogm/util/impl/ArrayHelper.java#L123-L130
train
hibernate/hibernate-ogm
core/src/main/java/org/hibernate/ogm/id/impl/OgmGeneratorBase.java
OgmGeneratorBase.doWorkInIsolationTransaction
private Serializable doWorkInIsolationTransaction(final SharedSessionContractImplementor session) throws HibernateException { class Work extends AbstractReturningWork<IntegralDataTypeHolder> { private final SharedSessionContractImplementor localSession = session; @Override public IntegralDataTypeHolder execute(Connection connection) throws SQLException { try { return doWorkInCurrentTransactionIfAny( localSession ); } catch ( RuntimeException sqle ) { throw new HibernateException( "Could not get or update next value", sqle ); } } } //we want to work out of transaction boolean workInTransaction = false; Work work = new Work(); Serializable generatedValue = session.getTransactionCoordinator().createIsolationDelegate().delegateWork( work, workInTransaction ); return generatedValue; }
java
private Serializable doWorkInIsolationTransaction(final SharedSessionContractImplementor session) throws HibernateException { class Work extends AbstractReturningWork<IntegralDataTypeHolder> { private final SharedSessionContractImplementor localSession = session; @Override public IntegralDataTypeHolder execute(Connection connection) throws SQLException { try { return doWorkInCurrentTransactionIfAny( localSession ); } catch ( RuntimeException sqle ) { throw new HibernateException( "Could not get or update next value", sqle ); } } } //we want to work out of transaction boolean workInTransaction = false; Work work = new Work(); Serializable generatedValue = session.getTransactionCoordinator().createIsolationDelegate().delegateWork( work, workInTransaction ); return generatedValue; }
[ "private", "Serializable", "doWorkInIsolationTransaction", "(", "final", "SharedSessionContractImplementor", "session", ")", "throws", "HibernateException", "{", "class", "Work", "extends", "AbstractReturningWork", "<", "IntegralDataTypeHolder", ">", "{", "private", "final", ...
copied and altered from TransactionHelper
[ "copied", "and", "altered", "from", "TransactionHelper" ]
9ea971df7c27277029006a6f748d8272fb1d69d2
https://github.com/hibernate/hibernate-ogm/blob/9ea971df7c27277029006a6f748d8272fb1d69d2/core/src/main/java/org/hibernate/ogm/id/impl/OgmGeneratorBase.java#L132-L152
train
hibernate/hibernate-ogm
infinispan-embedded/src/main/java/org/hibernate/ogm/datastore/infinispan/persistencestrategy/impl/ExternalizersIntegration.java
ExternalizersIntegration.registerOgmExternalizers
public static void registerOgmExternalizers(SerializationConfigurationBuilder cfg) { for ( AdvancedExternalizer<?> advancedExternalizer : ogmExternalizers.values() ) { cfg.addAdvancedExternalizer( advancedExternalizer ); } }
java
public static void registerOgmExternalizers(SerializationConfigurationBuilder cfg) { for ( AdvancedExternalizer<?> advancedExternalizer : ogmExternalizers.values() ) { cfg.addAdvancedExternalizer( advancedExternalizer ); } }
[ "public", "static", "void", "registerOgmExternalizers", "(", "SerializationConfigurationBuilder", "cfg", ")", "{", "for", "(", "AdvancedExternalizer", "<", "?", ">", "advancedExternalizer", ":", "ogmExternalizers", ".", "values", "(", ")", ")", "{", "cfg", ".", "a...
Registers all custom Externalizer implementations that Hibernate OGM needs into an Infinispan CacheManager configuration. @see ExternalizerIds @param cfg the Serialization section of a GlobalConfiguration builder
[ "Registers", "all", "custom", "Externalizer", "implementations", "that", "Hibernate", "OGM", "needs", "into", "an", "Infinispan", "CacheManager", "configuration", "." ]
9ea971df7c27277029006a6f748d8272fb1d69d2
https://github.com/hibernate/hibernate-ogm/blob/9ea971df7c27277029006a6f748d8272fb1d69d2/infinispan-embedded/src/main/java/org/hibernate/ogm/datastore/infinispan/persistencestrategy/impl/ExternalizersIntegration.java#L76-L80
train
hibernate/hibernate-ogm
infinispan-embedded/src/main/java/org/hibernate/ogm/datastore/infinispan/persistencestrategy/impl/ExternalizersIntegration.java
ExternalizersIntegration.registerOgmExternalizers
public static void registerOgmExternalizers(GlobalConfiguration globalCfg) { Map<Integer, AdvancedExternalizer<?>> externalizerMap = globalCfg.serialization().advancedExternalizers(); externalizerMap.putAll( ogmExternalizers ); }
java
public static void registerOgmExternalizers(GlobalConfiguration globalCfg) { Map<Integer, AdvancedExternalizer<?>> externalizerMap = globalCfg.serialization().advancedExternalizers(); externalizerMap.putAll( ogmExternalizers ); }
[ "public", "static", "void", "registerOgmExternalizers", "(", "GlobalConfiguration", "globalCfg", ")", "{", "Map", "<", "Integer", ",", "AdvancedExternalizer", "<", "?", ">", ">", "externalizerMap", "=", "globalCfg", ".", "serialization", "(", ")", ".", "advancedEx...
Registers all custom Externalizer implementations that Hibernate OGM needs into a running Infinispan CacheManager configuration. This is only safe to do when Caches from this CacheManager haven't been started yet, or the ones already started do not contain any data needing these. @see ExternalizerIds @param globalCfg the Serialization section of a GlobalConfiguration builder
[ "Registers", "all", "custom", "Externalizer", "implementations", "that", "Hibernate", "OGM", "needs", "into", "a", "running", "Infinispan", "CacheManager", "configuration", ".", "This", "is", "only", "safe", "to", "do", "when", "Caches", "from", "this", "CacheMana...
9ea971df7c27277029006a6f748d8272fb1d69d2
https://github.com/hibernate/hibernate-ogm/blob/9ea971df7c27277029006a6f748d8272fb1d69d2/infinispan-embedded/src/main/java/org/hibernate/ogm/datastore/infinispan/persistencestrategy/impl/ExternalizersIntegration.java#L91-L94
train
hibernate/hibernate-ogm
infinispan-embedded/src/main/java/org/hibernate/ogm/datastore/infinispan/persistencestrategy/impl/ExternalizersIntegration.java
ExternalizersIntegration.validateExternalizersPresent
public static void validateExternalizersPresent(EmbeddedCacheManager externalCacheManager) { Map<Integer, AdvancedExternalizer<?>> externalizerMap = externalCacheManager .getCacheManagerConfiguration() .serialization() .advancedExternalizers(); for ( AdvancedExternalizer<?> ogmExternalizer : ogmExternalizers.values() ) { final Integer externalizerId = ogmExternalizer.getId(); AdvancedExternalizer<?> registeredExternalizer = externalizerMap.get( externalizerId ); if ( registeredExternalizer == null ) { throw log.externalizersNotRegistered( externalizerId, ogmExternalizer.getClass() ); } else if ( !registeredExternalizer.getClass().equals( ogmExternalizer ) ) { if ( registeredExternalizer.getClass().toString().equals( ogmExternalizer.getClass().toString() ) ) { // same class name, yet different Class definition! throw log.registeredExternalizerNotLoadedFromOGMClassloader( registeredExternalizer.getClass() ); } else { throw log.externalizerIdNotMatchingType( externalizerId, registeredExternalizer, ogmExternalizer ); } } } }
java
public static void validateExternalizersPresent(EmbeddedCacheManager externalCacheManager) { Map<Integer, AdvancedExternalizer<?>> externalizerMap = externalCacheManager .getCacheManagerConfiguration() .serialization() .advancedExternalizers(); for ( AdvancedExternalizer<?> ogmExternalizer : ogmExternalizers.values() ) { final Integer externalizerId = ogmExternalizer.getId(); AdvancedExternalizer<?> registeredExternalizer = externalizerMap.get( externalizerId ); if ( registeredExternalizer == null ) { throw log.externalizersNotRegistered( externalizerId, ogmExternalizer.getClass() ); } else if ( !registeredExternalizer.getClass().equals( ogmExternalizer ) ) { if ( registeredExternalizer.getClass().toString().equals( ogmExternalizer.getClass().toString() ) ) { // same class name, yet different Class definition! throw log.registeredExternalizerNotLoadedFromOGMClassloader( registeredExternalizer.getClass() ); } else { throw log.externalizerIdNotMatchingType( externalizerId, registeredExternalizer, ogmExternalizer ); } } } }
[ "public", "static", "void", "validateExternalizersPresent", "(", "EmbeddedCacheManager", "externalCacheManager", ")", "{", "Map", "<", "Integer", ",", "AdvancedExternalizer", "<", "?", ">", ">", "externalizerMap", "=", "externalCacheManager", ".", "getCacheManagerConfigur...
Verify that all OGM custom externalizers are present. N.B. even if some Externalizer is only needed in specific configuration, it is not safe to start a CacheManager without one as the same CacheManager might be used, or have been used in the past, to store data using a different configuration. @see ExternalizerIds @see AdvancedExternalizer @param externalCacheManager the provided CacheManager to validate
[ "Verify", "that", "all", "OGM", "custom", "externalizers", "are", "present", ".", "N", ".", "B", ".", "even", "if", "some", "Externalizer", "is", "only", "needed", "in", "specific", "configuration", "it", "is", "not", "safe", "to", "start", "a", "CacheMana...
9ea971df7c27277029006a6f748d8272fb1d69d2
https://github.com/hibernate/hibernate-ogm/blob/9ea971df7c27277029006a6f748d8272fb1d69d2/infinispan-embedded/src/main/java/org/hibernate/ogm/datastore/infinispan/persistencestrategy/impl/ExternalizersIntegration.java#L107-L128
train
hibernate/hibernate-ogm
core/src/main/java/org/hibernate/ogm/datastore/map/impl/MapDatastoreProvider.java
MapDatastoreProvider.writeLock
public void writeLock(EntityKey key, int timeout) { ReadWriteLock lock = getLock( key ); Lock writeLock = lock.writeLock(); acquireLock( key, timeout, writeLock ); }
java
public void writeLock(EntityKey key, int timeout) { ReadWriteLock lock = getLock( key ); Lock writeLock = lock.writeLock(); acquireLock( key, timeout, writeLock ); }
[ "public", "void", "writeLock", "(", "EntityKey", "key", ",", "int", "timeout", ")", "{", "ReadWriteLock", "lock", "=", "getLock", "(", "key", ")", ";", "Lock", "writeLock", "=", "lock", ".", "writeLock", "(", ")", ";", "acquireLock", "(", "key", ",", "...
Acquires a write lock on a specific key. @param key The key to lock @param timeout in milliseconds; -1 means wait indefinitely, 0 means no wait.
[ "Acquires", "a", "write", "lock", "on", "a", "specific", "key", "." ]
9ea971df7c27277029006a6f748d8272fb1d69d2
https://github.com/hibernate/hibernate-ogm/blob/9ea971df7c27277029006a6f748d8272fb1d69d2/core/src/main/java/org/hibernate/ogm/datastore/map/impl/MapDatastoreProvider.java#L94-L98
train
hibernate/hibernate-ogm
core/src/main/java/org/hibernate/ogm/datastore/map/impl/MapDatastoreProvider.java
MapDatastoreProvider.readLock
public void readLock(EntityKey key, int timeout) { ReadWriteLock lock = getLock( key ); Lock readLock = lock.readLock(); acquireLock( key, timeout, readLock ); }
java
public void readLock(EntityKey key, int timeout) { ReadWriteLock lock = getLock( key ); Lock readLock = lock.readLock(); acquireLock( key, timeout, readLock ); }
[ "public", "void", "readLock", "(", "EntityKey", "key", ",", "int", "timeout", ")", "{", "ReadWriteLock", "lock", "=", "getLock", "(", "key", ")", ";", "Lock", "readLock", "=", "lock", ".", "readLock", "(", ")", ";", "acquireLock", "(", "key", ",", "tim...
Acquires a read lock on a specific key. @param key The key to lock @param timeout in milliseconds; -1 means wait indefinitely, 0 means no wait.
[ "Acquires", "a", "read", "lock", "on", "a", "specific", "key", "." ]
9ea971df7c27277029006a6f748d8272fb1d69d2
https://github.com/hibernate/hibernate-ogm/blob/9ea971df7c27277029006a6f748d8272fb1d69d2/core/src/main/java/org/hibernate/ogm/datastore/map/impl/MapDatastoreProvider.java#L105-L109
train
hibernate/hibernate-ogm
core/src/main/java/org/hibernate/ogm/datastore/map/impl/MapDatastoreProvider.java
MapDatastoreProvider.getAssociationsMap
public Map<AssociationKey, Map<RowKey, Map<String, Object>>> getAssociationsMap() { return Collections.unmodifiableMap( associationsKeyValueStorage ); }
java
public Map<AssociationKey, Map<RowKey, Map<String, Object>>> getAssociationsMap() { return Collections.unmodifiableMap( associationsKeyValueStorage ); }
[ "public", "Map", "<", "AssociationKey", ",", "Map", "<", "RowKey", ",", "Map", "<", "String", ",", "Object", ">", ">", ">", "getAssociationsMap", "(", ")", "{", "return", "Collections", ".", "unmodifiableMap", "(", "associationsKeyValueStorage", ")", ";", "}...
Meant to execute assertions in tests only @return a read-only view of the map containing the relations between entities
[ "Meant", "to", "execute", "assertions", "in", "tests", "only" ]
9ea971df7c27277029006a6f748d8272fb1d69d2
https://github.com/hibernate/hibernate-ogm/blob/9ea971df7c27277029006a6f748d8272fb1d69d2/core/src/main/java/org/hibernate/ogm/datastore/map/impl/MapDatastoreProvider.java#L188-L190
train
hibernate/hibernate-ogm
core/src/main/java/org/hibernate/ogm/datastore/document/impl/DotPatternMapHelpers.java
DotPatternMapHelpers.flatten
public static String flatten(String left, String right) { return left == null || left.isEmpty() ? right : left + "." + right; }
java
public static String flatten(String left, String right) { return left == null || left.isEmpty() ? right : left + "." + right; }
[ "public", "static", "String", "flatten", "(", "String", "left", ",", "String", "right", ")", "{", "return", "left", "==", "null", "||", "left", ".", "isEmpty", "(", ")", "?", "right", ":", "left", "+", "\".\"", "+", "right", ";", "}" ]
Links the two field names into a single left.right field name. If the left field is empty, right is returned @param left one field name @param right the other field name @return left.right or right if left is an empty string
[ "Links", "the", "two", "field", "names", "into", "a", "single", "left", ".", "right", "field", "name", ".", "If", "the", "left", "field", "is", "empty", "right", "is", "returned" ]
9ea971df7c27277029006a6f748d8272fb1d69d2
https://github.com/hibernate/hibernate-ogm/blob/9ea971df7c27277029006a6f748d8272fb1d69d2/core/src/main/java/org/hibernate/ogm/datastore/document/impl/DotPatternMapHelpers.java#L100-L102
train
hibernate/hibernate-ogm
core/src/main/java/org/hibernate/ogm/datastore/document/impl/DotPatternMapHelpers.java
DotPatternMapHelpers.organizeAssociationMapByRowKey
public static boolean organizeAssociationMapByRowKey( org.hibernate.ogm.model.spi.Association association, AssociationKey key, AssociationContext associationContext) { if ( association.isEmpty() ) { return false; } if ( key.getMetadata().getRowKeyIndexColumnNames().length != 1 ) { return false; } Object valueOfFirstRow = association.get( association.getKeys().iterator().next() ) .get( key.getMetadata().getRowKeyIndexColumnNames()[0] ); if ( !( valueOfFirstRow instanceof String ) ) { return false; } // The list style may be explicitly enforced for compatibility reasons return getMapStorage( associationContext ) == MapStorageType.BY_KEY; }
java
public static boolean organizeAssociationMapByRowKey( org.hibernate.ogm.model.spi.Association association, AssociationKey key, AssociationContext associationContext) { if ( association.isEmpty() ) { return false; } if ( key.getMetadata().getRowKeyIndexColumnNames().length != 1 ) { return false; } Object valueOfFirstRow = association.get( association.getKeys().iterator().next() ) .get( key.getMetadata().getRowKeyIndexColumnNames()[0] ); if ( !( valueOfFirstRow instanceof String ) ) { return false; } // The list style may be explicitly enforced for compatibility reasons return getMapStorage( associationContext ) == MapStorageType.BY_KEY; }
[ "public", "static", "boolean", "organizeAssociationMapByRowKey", "(", "org", ".", "hibernate", ".", "ogm", ".", "model", ".", "spi", ".", "Association", "association", ",", "AssociationKey", "key", ",", "AssociationContext", "associationContext", ")", "{", "if", "...
Whether the rows of the given association should be stored in a hash using the single row key column as key or not.
[ "Whether", "the", "rows", "of", "the", "given", "association", "should", "be", "stored", "in", "a", "hash", "using", "the", "single", "row", "key", "column", "as", "key", "or", "not", "." ]
9ea971df7c27277029006a6f748d8272fb1d69d2
https://github.com/hibernate/hibernate-ogm/blob/9ea971df7c27277029006a6f748d8272fb1d69d2/core/src/main/java/org/hibernate/ogm/datastore/document/impl/DotPatternMapHelpers.java#L108-L130
train
hibernate/hibernate-ogm
core/src/main/java/org/hibernate/ogm/type/impl/ManyToOneType.java
ManyToOneType.scheduleBatchLoadIfNeeded
private void scheduleBatchLoadIfNeeded(Serializable id, SharedSessionContractImplementor session) throws MappingException { //cannot batch fetch by unique key (property-ref associations) if ( StringHelper.isEmpty( delegate.getRHSUniqueKeyPropertyName() ) && id != null ) { EntityPersister persister = session.getFactory().getMetamodel().entityPersister( delegate.getAssociatedEntityName() ); EntityKey entityKey = session.generateEntityKey( id, persister ); if ( !session.getPersistenceContext().containsEntity( entityKey ) ) { session.getPersistenceContext().getBatchFetchQueue().addBatchLoadableEntityKey( entityKey ); } } }
java
private void scheduleBatchLoadIfNeeded(Serializable id, SharedSessionContractImplementor session) throws MappingException { //cannot batch fetch by unique key (property-ref associations) if ( StringHelper.isEmpty( delegate.getRHSUniqueKeyPropertyName() ) && id != null ) { EntityPersister persister = session.getFactory().getMetamodel().entityPersister( delegate.getAssociatedEntityName() ); EntityKey entityKey = session.generateEntityKey( id, persister ); if ( !session.getPersistenceContext().containsEntity( entityKey ) ) { session.getPersistenceContext().getBatchFetchQueue().addBatchLoadableEntityKey( entityKey ); } } }
[ "private", "void", "scheduleBatchLoadIfNeeded", "(", "Serializable", "id", ",", "SharedSessionContractImplementor", "session", ")", "throws", "MappingException", "{", "//cannot batch fetch by unique key (property-ref associations)", "if", "(", "StringHelper", ".", "isEmpty", "(...
Register the entity as batch loadable, if enabled Copied from {@link org.hibernate.type.ManyToOneType#scheduleBatchLoadIfNeeded}
[ "Register", "the", "entity", "as", "batch", "loadable", "if", "enabled" ]
9ea971df7c27277029006a6f748d8272fb1d69d2
https://github.com/hibernate/hibernate-ogm/blob/9ea971df7c27277029006a6f748d8272fb1d69d2/core/src/main/java/org/hibernate/ogm/type/impl/ManyToOneType.java#L80-L89
train
hibernate/hibernate-ogm
mongodb/src/main/java/org/hibernate/ogm/datastore/mongodb/type/GeoMultiPoint.java
GeoMultiPoint.addPoint
public GeoMultiPoint addPoint(GeoPoint point) { Contracts.assertNotNull( point, "point" ); this.points.add( point ); return this; }
java
public GeoMultiPoint addPoint(GeoPoint point) { Contracts.assertNotNull( point, "point" ); this.points.add( point ); return this; }
[ "public", "GeoMultiPoint", "addPoint", "(", "GeoPoint", "point", ")", "{", "Contracts", ".", "assertNotNull", "(", "point", ",", "\"point\"", ")", ";", "this", ".", "points", ".", "add", "(", "point", ")", ";", "return", "this", ";", "}" ]
Adds a new point. @param point a point @return this for chaining
[ "Adds", "a", "new", "point", "." ]
9ea971df7c27277029006a6f748d8272fb1d69d2
https://github.com/hibernate/hibernate-ogm/blob/9ea971df7c27277029006a6f748d8272fb1d69d2/mongodb/src/main/java/org/hibernate/ogm/datastore/mongodb/type/GeoMultiPoint.java#L76-L80
train
hibernate/hibernate-ogm
neo4j/src/main/java/org/hibernate/ogm/datastore/neo4j/query/parsing/impl/Neo4jAliasResolver.java
Neo4jAliasResolver.findAlias
public String findAlias(String entityAlias, List<String> propertyPathWithoutAlias) { RelationshipAliasTree aliasTree = relationshipAliases.get( entityAlias ); if ( aliasTree == null ) { return null; } RelationshipAliasTree associationAlias = aliasTree; for ( int i = 0; i < propertyPathWithoutAlias.size(); i++ ) { associationAlias = associationAlias.findChild( propertyPathWithoutAlias.get( i ) ); if ( associationAlias == null ) { return null; } } return associationAlias.getAlias(); }
java
public String findAlias(String entityAlias, List<String> propertyPathWithoutAlias) { RelationshipAliasTree aliasTree = relationshipAliases.get( entityAlias ); if ( aliasTree == null ) { return null; } RelationshipAliasTree associationAlias = aliasTree; for ( int i = 0; i < propertyPathWithoutAlias.size(); i++ ) { associationAlias = associationAlias.findChild( propertyPathWithoutAlias.get( i ) ); if ( associationAlias == null ) { return null; } } return associationAlias.getAlias(); }
[ "public", "String", "findAlias", "(", "String", "entityAlias", ",", "List", "<", "String", ">", "propertyPathWithoutAlias", ")", "{", "RelationshipAliasTree", "aliasTree", "=", "relationshipAliases", ".", "get", "(", "entityAlias", ")", ";", "if", "(", "aliasTree"...
Given the alias of the entity and the path to the relationship it will return the alias of the component. @param entityAlias the alias of the entity @param propertyPathWithoutAlias the path to the property without the alias @return the alias the relationship or null
[ "Given", "the", "alias", "of", "the", "entity", "and", "the", "path", "to", "the", "relationship", "it", "will", "return", "the", "alias", "of", "the", "component", "." ]
9ea971df7c27277029006a6f748d8272fb1d69d2
https://github.com/hibernate/hibernate-ogm/blob/9ea971df7c27277029006a6f748d8272fb1d69d2/neo4j/src/main/java/org/hibernate/ogm/datastore/neo4j/query/parsing/impl/Neo4jAliasResolver.java#L130-L143
train
hibernate/hibernate-ogm
neo4j/src/main/java/org/hibernate/ogm/datastore/neo4j/embedded/dialect/impl/EmbeddedNeo4jEntityQueries.java
EmbeddedNeo4jEntityQueries.createEmbedded
public Node createEmbedded(GraphDatabaseService executionEngine, Object[] columnValues) { Map<String, Object> params = params( columnValues ); Result result = executionEngine.execute( getCreateEmbeddedNodeQuery(), params ); return singleResult( result ); }
java
public Node createEmbedded(GraphDatabaseService executionEngine, Object[] columnValues) { Map<String, Object> params = params( columnValues ); Result result = executionEngine.execute( getCreateEmbeddedNodeQuery(), params ); return singleResult( result ); }
[ "public", "Node", "createEmbedded", "(", "GraphDatabaseService", "executionEngine", ",", "Object", "[", "]", "columnValues", ")", "{", "Map", "<", "String", ",", "Object", ">", "params", "=", "params", "(", "columnValues", ")", ";", "Result", "result", "=", ...
Create a single node representing an embedded element. @param executionEngine the {@link GraphDatabaseService} used to run the query @param columnValues the values in {@link org.hibernate.ogm.model.key.spi.EntityKey#getColumnValues()} @return the corresponding node;
[ "Create", "a", "single", "node", "representing", "an", "embedded", "element", "." ]
9ea971df7c27277029006a6f748d8272fb1d69d2
https://github.com/hibernate/hibernate-ogm/blob/9ea971df7c27277029006a6f748d8272fb1d69d2/neo4j/src/main/java/org/hibernate/ogm/datastore/neo4j/embedded/dialect/impl/EmbeddedNeo4jEntityQueries.java#L66-L70
train
hibernate/hibernate-ogm
neo4j/src/main/java/org/hibernate/ogm/datastore/neo4j/embedded/dialect/impl/EmbeddedNeo4jEntityQueries.java
EmbeddedNeo4jEntityQueries.findEntity
public Node findEntity(GraphDatabaseService executionEngine, Object[] columnValues) { Map<String, Object> params = params( columnValues ); Result result = executionEngine.execute( getFindEntityQuery(), params ); return singleResult( result ); }
java
public Node findEntity(GraphDatabaseService executionEngine, Object[] columnValues) { Map<String, Object> params = params( columnValues ); Result result = executionEngine.execute( getFindEntityQuery(), params ); return singleResult( result ); }
[ "public", "Node", "findEntity", "(", "GraphDatabaseService", "executionEngine", ",", "Object", "[", "]", "columnValues", ")", "{", "Map", "<", "String", ",", "Object", ">", "params", "=", "params", "(", "columnValues", ")", ";", "Result", "result", "=", "exe...
Find the node corresponding to an entity. @param executionEngine the {@link GraphDatabaseService} used to run the query @param columnValues the values in {@link org.hibernate.ogm.model.key.spi.EntityKey#getColumnValues()} @return the corresponding node
[ "Find", "the", "node", "corresponding", "to", "an", "entity", "." ]
9ea971df7c27277029006a6f748d8272fb1d69d2
https://github.com/hibernate/hibernate-ogm/blob/9ea971df7c27277029006a6f748d8272fb1d69d2/neo4j/src/main/java/org/hibernate/ogm/datastore/neo4j/embedded/dialect/impl/EmbeddedNeo4jEntityQueries.java#L79-L83
train
hibernate/hibernate-ogm
neo4j/src/main/java/org/hibernate/ogm/datastore/neo4j/embedded/dialect/impl/EmbeddedNeo4jEntityQueries.java
EmbeddedNeo4jEntityQueries.insertEntity
public Node insertEntity(GraphDatabaseService executionEngine, Object[] columnValues) { Map<String, Object> params = params( columnValues ); Result result = executionEngine.execute( getCreateEntityQuery(), params ); return singleResult( result ); }
java
public Node insertEntity(GraphDatabaseService executionEngine, Object[] columnValues) { Map<String, Object> params = params( columnValues ); Result result = executionEngine.execute( getCreateEntityQuery(), params ); return singleResult( result ); }
[ "public", "Node", "insertEntity", "(", "GraphDatabaseService", "executionEngine", ",", "Object", "[", "]", "columnValues", ")", "{", "Map", "<", "String", ",", "Object", ">", "params", "=", "params", "(", "columnValues", ")", ";", "Result", "result", "=", "e...
Creates the node corresponding to an entity. @param executionEngine the {@link GraphDatabaseService} used to run the query @param columnValues the values in {@link org.hibernate.ogm.model.key.spi.EntityKey#getColumnValues()} @return the corresponding node
[ "Creates", "the", "node", "corresponding", "to", "an", "entity", "." ]
9ea971df7c27277029006a6f748d8272fb1d69d2
https://github.com/hibernate/hibernate-ogm/blob/9ea971df7c27277029006a6f748d8272fb1d69d2/neo4j/src/main/java/org/hibernate/ogm/datastore/neo4j/embedded/dialect/impl/EmbeddedNeo4jEntityQueries.java#L131-L135
train
hibernate/hibernate-ogm
neo4j/src/main/java/org/hibernate/ogm/datastore/neo4j/embedded/dialect/impl/EmbeddedNeo4jEntityQueries.java
EmbeddedNeo4jEntityQueries.findEntities
public ResourceIterator<Node> findEntities(GraphDatabaseService executionEngine) { Result result = executionEngine.execute( getFindEntitiesQuery() ); return result.columnAs( BaseNeo4jEntityQueries.ENTITY_ALIAS ); }
java
public ResourceIterator<Node> findEntities(GraphDatabaseService executionEngine) { Result result = executionEngine.execute( getFindEntitiesQuery() ); return result.columnAs( BaseNeo4jEntityQueries.ENTITY_ALIAS ); }
[ "public", "ResourceIterator", "<", "Node", ">", "findEntities", "(", "GraphDatabaseService", "executionEngine", ")", "{", "Result", "result", "=", "executionEngine", ".", "execute", "(", "getFindEntitiesQuery", "(", ")", ")", ";", "return", "result", ".", "columnA...
Find all the node representing the entity. @param executionEngine the {@link GraphDatabaseService} used to run the query @return an iterator over the nodes representing an entity
[ "Find", "all", "the", "node", "representing", "the", "entity", "." ]
9ea971df7c27277029006a6f748d8272fb1d69d2
https://github.com/hibernate/hibernate-ogm/blob/9ea971df7c27277029006a6f748d8272fb1d69d2/neo4j/src/main/java/org/hibernate/ogm/datastore/neo4j/embedded/dialect/impl/EmbeddedNeo4jEntityQueries.java#L143-L146
train
hibernate/hibernate-ogm
neo4j/src/main/java/org/hibernate/ogm/datastore/neo4j/embedded/dialect/impl/EmbeddedNeo4jEntityQueries.java
EmbeddedNeo4jEntityQueries.removeEntity
public void removeEntity(GraphDatabaseService executionEngine, Object[] columnValues) { Map<String, Object> params = params( columnValues ); executionEngine.execute( getRemoveEntityQuery(), params ); }
java
public void removeEntity(GraphDatabaseService executionEngine, Object[] columnValues) { Map<String, Object> params = params( columnValues ); executionEngine.execute( getRemoveEntityQuery(), params ); }
[ "public", "void", "removeEntity", "(", "GraphDatabaseService", "executionEngine", ",", "Object", "[", "]", "columnValues", ")", "{", "Map", "<", "String", ",", "Object", ">", "params", "=", "params", "(", "columnValues", ")", ";", "executionEngine", ".", "exec...
Remove the nodes representing the entity and the embedded elements attached to it. @param executionEngine the {@link GraphDatabaseService} used to run the query @param columnValues the values of the key identifying the entity to remove
[ "Remove", "the", "nodes", "representing", "the", "entity", "and", "the", "embedded", "elements", "attached", "to", "it", "." ]
9ea971df7c27277029006a6f748d8272fb1d69d2
https://github.com/hibernate/hibernate-ogm/blob/9ea971df7c27277029006a6f748d8272fb1d69d2/neo4j/src/main/java/org/hibernate/ogm/datastore/neo4j/embedded/dialect/impl/EmbeddedNeo4jEntityQueries.java#L154-L157
train
hibernate/hibernate-ogm
neo4j/src/main/java/org/hibernate/ogm/datastore/neo4j/embedded/dialect/impl/EmbeddedNeo4jEntityQueries.java
EmbeddedNeo4jEntityQueries.updateEmbeddedColumn
public void updateEmbeddedColumn(GraphDatabaseService executionEngine, Object[] keyValues, String embeddedColumn, Object value) { String query = getUpdateEmbeddedColumnQuery( keyValues, embeddedColumn ); Map<String, Object> params = params( ArrayHelper.concat( keyValues, value, value ) ); executionEngine.execute( query, params ); }
java
public void updateEmbeddedColumn(GraphDatabaseService executionEngine, Object[] keyValues, String embeddedColumn, Object value) { String query = getUpdateEmbeddedColumnQuery( keyValues, embeddedColumn ); Map<String, Object> params = params( ArrayHelper.concat( keyValues, value, value ) ); executionEngine.execute( query, params ); }
[ "public", "void", "updateEmbeddedColumn", "(", "GraphDatabaseService", "executionEngine", ",", "Object", "[", "]", "keyValues", ",", "String", "embeddedColumn", ",", "Object", "value", ")", "{", "String", "query", "=", "getUpdateEmbeddedColumnQuery", "(", "keyValues",...
Update the value of an embedded node property. @param executionEngine the {@link GraphDatabaseService} used to run the query @param keyValues the columns representing the identifier in the entity owning the embedded @param embeddedColumn the column on the embedded node (dot-separated properties) @param value the new value for the property
[ "Update", "the", "value", "of", "an", "embedded", "node", "property", "." ]
9ea971df7c27277029006a6f748d8272fb1d69d2
https://github.com/hibernate/hibernate-ogm/blob/9ea971df7c27277029006a6f748d8272fb1d69d2/neo4j/src/main/java/org/hibernate/ogm/datastore/neo4j/embedded/dialect/impl/EmbeddedNeo4jEntityQueries.java#L167-L171
train
hibernate/hibernate-ogm
mongodb/src/main/java/org/hibernate/ogm/datastore/mongodb/index/impl/MongoDBIndexSpec.java
MongoDBIndexSpec.prepareOptions
private static IndexOptions prepareOptions(MongoDBIndexType indexType, Document options, String indexName, boolean unique) { IndexOptions indexOptions = new IndexOptions(); indexOptions.name( indexName ).unique( unique ).background( options.getBoolean( "background" , false ) ); if ( unique ) { // MongoDB only allows one null value per unique index which is not in line with what we usually consider // as the definition of a unique constraint. Thus, we mark the index as sparse to only index values // defined and avoid this issue. We do this only if a partialFilterExpression has not been defined // as partialFilterExpression and sparse are exclusive. indexOptions.sparse( !options.containsKey( "partialFilterExpression" ) ); } else if ( options.containsKey( "partialFilterExpression" ) ) { indexOptions.partialFilterExpression( (Bson) options.get( "partialFilterExpression" ) ); } if ( options.containsKey( "expireAfterSeconds" ) ) { //@todo is it correct? indexOptions.expireAfter( options.getInteger( "expireAfterSeconds" ).longValue() , TimeUnit.SECONDS ); } if ( MongoDBIndexType.TEXT.equals( indexType ) ) { // text is an option we take into account to mark an index as a full text index as we cannot put "text" as // the order like MongoDB as ORM explicitly checks that the order is either asc or desc. // we remove the option from the Document so that we don't pass it to MongoDB if ( options.containsKey( "default_language" ) ) { indexOptions.defaultLanguage( options.getString( "default_language" ) ); } if ( options.containsKey( "weights" ) ) { indexOptions.weights( (Bson) options.get( "weights" ) ); } options.remove( "text" ); } return indexOptions; }
java
private static IndexOptions prepareOptions(MongoDBIndexType indexType, Document options, String indexName, boolean unique) { IndexOptions indexOptions = new IndexOptions(); indexOptions.name( indexName ).unique( unique ).background( options.getBoolean( "background" , false ) ); if ( unique ) { // MongoDB only allows one null value per unique index which is not in line with what we usually consider // as the definition of a unique constraint. Thus, we mark the index as sparse to only index values // defined and avoid this issue. We do this only if a partialFilterExpression has not been defined // as partialFilterExpression and sparse are exclusive. indexOptions.sparse( !options.containsKey( "partialFilterExpression" ) ); } else if ( options.containsKey( "partialFilterExpression" ) ) { indexOptions.partialFilterExpression( (Bson) options.get( "partialFilterExpression" ) ); } if ( options.containsKey( "expireAfterSeconds" ) ) { //@todo is it correct? indexOptions.expireAfter( options.getInteger( "expireAfterSeconds" ).longValue() , TimeUnit.SECONDS ); } if ( MongoDBIndexType.TEXT.equals( indexType ) ) { // text is an option we take into account to mark an index as a full text index as we cannot put "text" as // the order like MongoDB as ORM explicitly checks that the order is either asc or desc. // we remove the option from the Document so that we don't pass it to MongoDB if ( options.containsKey( "default_language" ) ) { indexOptions.defaultLanguage( options.getString( "default_language" ) ); } if ( options.containsKey( "weights" ) ) { indexOptions.weights( (Bson) options.get( "weights" ) ); } options.remove( "text" ); } return indexOptions; }
[ "private", "static", "IndexOptions", "prepareOptions", "(", "MongoDBIndexType", "indexType", ",", "Document", "options", ",", "String", "indexName", ",", "boolean", "unique", ")", "{", "IndexOptions", "indexOptions", "=", "new", "IndexOptions", "(", ")", ";", "ind...
Prepare the options by adding additional information to them. @see <a href="https://docs.mongodb.com/manual/core/index-ttl/">TTL Indexes</a>
[ "Prepare", "the", "options", "by", "adding", "additional", "information", "to", "them", "." ]
9ea971df7c27277029006a6f748d8272fb1d69d2
https://github.com/hibernate/hibernate-ogm/blob/9ea971df7c27277029006a6f748d8272fb1d69d2/mongodb/src/main/java/org/hibernate/ogm/datastore/mongodb/index/impl/MongoDBIndexSpec.java#L112-L146
train
hibernate/hibernate-ogm
core/src/main/java/org/hibernate/ogm/persister/impl/BiDirectionalAssociationHelper.java
BiDirectionalAssociationHelper.getInverseAssociationKeyMetadata
public static AssociationKeyMetadata getInverseAssociationKeyMetadata(OgmEntityPersister mainSidePersister, int propertyIndex) { Type propertyType = mainSidePersister.getPropertyTypes()[propertyIndex]; SessionFactoryImplementor factory = mainSidePersister.getFactory(); // property represents no association, so no inverse meta-data can exist if ( !propertyType.isAssociationType() ) { return null; } Joinable mainSideJoinable = ( (AssociationType) propertyType ).getAssociatedJoinable( factory ); OgmEntityPersister inverseSidePersister = null; // to-many association if ( mainSideJoinable.isCollection() ) { inverseSidePersister = (OgmEntityPersister) ( (OgmCollectionPersister) mainSideJoinable ).getElementPersister(); } // to-one else { inverseSidePersister = (OgmEntityPersister) mainSideJoinable; mainSideJoinable = mainSidePersister; } String mainSideProperty = mainSidePersister.getPropertyNames()[propertyIndex]; // property is a one-to-one association (a many-to-one cannot be on the inverse side) -> get the meta-data // straight from the main-side persister AssociationKeyMetadata inverseOneToOneMetadata = mainSidePersister.getInverseOneToOneAssociationKeyMetadata( mainSideProperty ); if ( inverseOneToOneMetadata != null ) { return inverseOneToOneMetadata; } // process properties of inverse side and try to find association back to main side for ( String candidateProperty : inverseSidePersister.getPropertyNames() ) { Type type = inverseSidePersister.getPropertyType( candidateProperty ); // candidate is a *-to-many association if ( type.isCollectionType() ) { OgmCollectionPersister inverseCollectionPersister = getPersister( factory, (CollectionType) type ); String mappedByProperty = inverseCollectionPersister.getMappedByProperty(); if ( mainSideProperty.equals( mappedByProperty ) ) { if ( isCollectionMatching( mainSideJoinable, inverseCollectionPersister ) ) { return inverseCollectionPersister.getAssociationKeyMetadata(); } } } } return null; }
java
public static AssociationKeyMetadata getInverseAssociationKeyMetadata(OgmEntityPersister mainSidePersister, int propertyIndex) { Type propertyType = mainSidePersister.getPropertyTypes()[propertyIndex]; SessionFactoryImplementor factory = mainSidePersister.getFactory(); // property represents no association, so no inverse meta-data can exist if ( !propertyType.isAssociationType() ) { return null; } Joinable mainSideJoinable = ( (AssociationType) propertyType ).getAssociatedJoinable( factory ); OgmEntityPersister inverseSidePersister = null; // to-many association if ( mainSideJoinable.isCollection() ) { inverseSidePersister = (OgmEntityPersister) ( (OgmCollectionPersister) mainSideJoinable ).getElementPersister(); } // to-one else { inverseSidePersister = (OgmEntityPersister) mainSideJoinable; mainSideJoinable = mainSidePersister; } String mainSideProperty = mainSidePersister.getPropertyNames()[propertyIndex]; // property is a one-to-one association (a many-to-one cannot be on the inverse side) -> get the meta-data // straight from the main-side persister AssociationKeyMetadata inverseOneToOneMetadata = mainSidePersister.getInverseOneToOneAssociationKeyMetadata( mainSideProperty ); if ( inverseOneToOneMetadata != null ) { return inverseOneToOneMetadata; } // process properties of inverse side and try to find association back to main side for ( String candidateProperty : inverseSidePersister.getPropertyNames() ) { Type type = inverseSidePersister.getPropertyType( candidateProperty ); // candidate is a *-to-many association if ( type.isCollectionType() ) { OgmCollectionPersister inverseCollectionPersister = getPersister( factory, (CollectionType) type ); String mappedByProperty = inverseCollectionPersister.getMappedByProperty(); if ( mainSideProperty.equals( mappedByProperty ) ) { if ( isCollectionMatching( mainSideJoinable, inverseCollectionPersister ) ) { return inverseCollectionPersister.getAssociationKeyMetadata(); } } } } return null; }
[ "public", "static", "AssociationKeyMetadata", "getInverseAssociationKeyMetadata", "(", "OgmEntityPersister", "mainSidePersister", ",", "int", "propertyIndex", ")", "{", "Type", "propertyType", "=", "mainSidePersister", ".", "getPropertyTypes", "(", ")", "[", "propertyIndex"...
Returns the meta-data for the inverse side of the association represented by the given property on the given persister in case it represents the main side of a bi-directional one-to-many or many-to-many association. @param mainSidePersister persister of the entity hosting the property of interest @param propertyIndex index of the property of interest @return the meta-data of the inverse side of the specified association or {@code null} if no such meta-data exists
[ "Returns", "the", "meta", "-", "data", "for", "the", "inverse", "side", "of", "the", "association", "represented", "by", "the", "given", "property", "on", "the", "given", "persister", "in", "case", "it", "represents", "the", "main", "side", "of", "a", "bi"...
9ea971df7c27277029006a6f748d8272fb1d69d2
https://github.com/hibernate/hibernate-ogm/blob/9ea971df7c27277029006a6f748d8272fb1d69d2/core/src/main/java/org/hibernate/ogm/persister/impl/BiDirectionalAssociationHelper.java#L41-L89
train
hibernate/hibernate-ogm
core/src/main/java/org/hibernate/ogm/persister/impl/BiDirectionalAssociationHelper.java
BiDirectionalAssociationHelper.getInverseCollectionPersister
public static OgmCollectionPersister getInverseCollectionPersister(OgmCollectionPersister mainSidePersister) { if ( mainSidePersister.isInverse() || !mainSidePersister.isManyToMany() || !mainSidePersister.getElementType().isEntityType() ) { return null; } EntityPersister inverseSidePersister = mainSidePersister.getElementPersister(); // process collection-typed properties of inverse side and try to find association back to main side for ( Type type : inverseSidePersister.getPropertyTypes() ) { if ( type.isCollectionType() ) { OgmCollectionPersister inverseCollectionPersister = getPersister( mainSidePersister.getFactory(), (CollectionType) type ); if ( isCollectionMatching( mainSidePersister, inverseCollectionPersister ) ) { return inverseCollectionPersister; } } } return null; }
java
public static OgmCollectionPersister getInverseCollectionPersister(OgmCollectionPersister mainSidePersister) { if ( mainSidePersister.isInverse() || !mainSidePersister.isManyToMany() || !mainSidePersister.getElementType().isEntityType() ) { return null; } EntityPersister inverseSidePersister = mainSidePersister.getElementPersister(); // process collection-typed properties of inverse side and try to find association back to main side for ( Type type : inverseSidePersister.getPropertyTypes() ) { if ( type.isCollectionType() ) { OgmCollectionPersister inverseCollectionPersister = getPersister( mainSidePersister.getFactory(), (CollectionType) type ); if ( isCollectionMatching( mainSidePersister, inverseCollectionPersister ) ) { return inverseCollectionPersister; } } } return null; }
[ "public", "static", "OgmCollectionPersister", "getInverseCollectionPersister", "(", "OgmCollectionPersister", "mainSidePersister", ")", "{", "if", "(", "mainSidePersister", ".", "isInverse", "(", ")", "||", "!", "mainSidePersister", ".", "isManyToMany", "(", ")", "||", ...
Returns the given collection persister for the inverse side in case the given persister represents the main side of a bi-directional many-to-many association. @param mainSidePersister the collection persister on the main side of a bi-directional many-to-many association @return the collection persister for the inverse side of the given persister or {@code null} in case it represents the inverse side itself or the association is uni-directional
[ "Returns", "the", "given", "collection", "persister", "for", "the", "inverse", "side", "in", "case", "the", "given", "persister", "represents", "the", "main", "side", "of", "a", "bi", "-", "directional", "many", "-", "to", "-", "many", "association", "." ]
9ea971df7c27277029006a6f748d8272fb1d69d2
https://github.com/hibernate/hibernate-ogm/blob/9ea971df7c27277029006a6f748d8272fb1d69d2/core/src/main/java/org/hibernate/ogm/persister/impl/BiDirectionalAssociationHelper.java#L99-L117
train
hibernate/hibernate-ogm
core/src/main/java/org/hibernate/ogm/persister/impl/BiDirectionalAssociationHelper.java
BiDirectionalAssociationHelper.isCollectionMatching
private static boolean isCollectionMatching(Joinable mainSideJoinable, OgmCollectionPersister inverseSidePersister) { boolean isSameTable = mainSideJoinable.getTableName().equals( inverseSidePersister.getTableName() ); if ( !isSameTable ) { return false; } return Arrays.equals( mainSideJoinable.getKeyColumnNames(), inverseSidePersister.getElementColumnNames() ); }
java
private static boolean isCollectionMatching(Joinable mainSideJoinable, OgmCollectionPersister inverseSidePersister) { boolean isSameTable = mainSideJoinable.getTableName().equals( inverseSidePersister.getTableName() ); if ( !isSameTable ) { return false; } return Arrays.equals( mainSideJoinable.getKeyColumnNames(), inverseSidePersister.getElementColumnNames() ); }
[ "private", "static", "boolean", "isCollectionMatching", "(", "Joinable", "mainSideJoinable", ",", "OgmCollectionPersister", "inverseSidePersister", ")", "{", "boolean", "isSameTable", "=", "mainSideJoinable", ".", "getTableName", "(", ")", ".", "equals", "(", "inverseSi...
Checks whether table name and key column names of the given joinable and inverse collection persister match.
[ "Checks", "whether", "table", "name", "and", "key", "column", "names", "of", "the", "given", "joinable", "and", "inverse", "collection", "persister", "match", "." ]
9ea971df7c27277029006a6f748d8272fb1d69d2
https://github.com/hibernate/hibernate-ogm/blob/9ea971df7c27277029006a6f748d8272fb1d69d2/core/src/main/java/org/hibernate/ogm/persister/impl/BiDirectionalAssociationHelper.java#L160-L168
train
hibernate/hibernate-ogm
mongodb/src/main/java/org/hibernate/ogm/datastore/mongodb/dialect/impl/MongoHelpers.java
MongoHelpers.resetValue
public static void resetValue(Document entity, String column) { // fast path for non-embedded case if ( !column.contains( "." ) ) { entity.remove( column ); } else { String[] path = DOT_SEPARATOR_PATTERN.split( column ); Object field = entity; int size = path.length; for ( int index = 0; index < size; index++ ) { String node = path[index]; Document parent = (Document) field; field = parent.get( node ); if ( field == null && index < size - 1 ) { //TODO clean up the hierarchy of empty containers // no way to reach the leaf, nothing to do return; } if ( index == size - 1 ) { parent.remove( node ); } } } }
java
public static void resetValue(Document entity, String column) { // fast path for non-embedded case if ( !column.contains( "." ) ) { entity.remove( column ); } else { String[] path = DOT_SEPARATOR_PATTERN.split( column ); Object field = entity; int size = path.length; for ( int index = 0; index < size; index++ ) { String node = path[index]; Document parent = (Document) field; field = parent.get( node ); if ( field == null && index < size - 1 ) { //TODO clean up the hierarchy of empty containers // no way to reach the leaf, nothing to do return; } if ( index == size - 1 ) { parent.remove( node ); } } } }
[ "public", "static", "void", "resetValue", "(", "Document", "entity", ",", "String", "column", ")", "{", "// fast path for non-embedded case", "if", "(", "!", "column", ".", "contains", "(", "\".\"", ")", ")", "{", "entity", ".", "remove", "(", "column", ")",...
Remove a column from the Document @param entity the {@link Document} with the column @param column the column to remove
[ "Remove", "a", "column", "from", "the", "Document" ]
9ea971df7c27277029006a6f748d8272fb1d69d2
https://github.com/hibernate/hibernate-ogm/blob/9ea971df7c27277029006a6f748d8272fb1d69d2/mongodb/src/main/java/org/hibernate/ogm/datastore/mongodb/dialect/impl/MongoHelpers.java#L56-L79
train
hibernate/hibernate-ogm
mongodb/src/main/java/org/hibernate/ogm/datastore/mongodb/impl/MongoDBSchemaDefiner.java
MongoDBSchemaDefiner.validateAsMongoDBCollectionName
private static void validateAsMongoDBCollectionName(String collectionName) { Contracts.assertStringParameterNotEmpty( collectionName, "requestedName" ); //Yes it has some strange requirements. if ( collectionName.startsWith( "system." ) ) { throw log.collectionNameHasInvalidSystemPrefix( collectionName ); } else if ( collectionName.contains( "\u0000" ) ) { throw log.collectionNameContainsNULCharacter( collectionName ); } else if ( collectionName.contains( "$" ) ) { throw log.collectionNameContainsDollarCharacter( collectionName ); } }
java
private static void validateAsMongoDBCollectionName(String collectionName) { Contracts.assertStringParameterNotEmpty( collectionName, "requestedName" ); //Yes it has some strange requirements. if ( collectionName.startsWith( "system." ) ) { throw log.collectionNameHasInvalidSystemPrefix( collectionName ); } else if ( collectionName.contains( "\u0000" ) ) { throw log.collectionNameContainsNULCharacter( collectionName ); } else if ( collectionName.contains( "$" ) ) { throw log.collectionNameContainsDollarCharacter( collectionName ); } }
[ "private", "static", "void", "validateAsMongoDBCollectionName", "(", "String", "collectionName", ")", "{", "Contracts", ".", "assertStringParameterNotEmpty", "(", "collectionName", ",", "\"requestedName\"", ")", ";", "//Yes it has some strange requirements.", "if", "(", "co...
Validates a String to be a valid name to be used in MongoDB for a collection name. @param collectionName
[ "Validates", "a", "String", "to", "be", "a", "valid", "name", "to", "be", "used", "in", "MongoDB", "for", "a", "collection", "name", "." ]
9ea971df7c27277029006a6f748d8272fb1d69d2
https://github.com/hibernate/hibernate-ogm/blob/9ea971df7c27277029006a6f748d8272fb1d69d2/mongodb/src/main/java/org/hibernate/ogm/datastore/mongodb/impl/MongoDBSchemaDefiner.java#L360-L372
train
hibernate/hibernate-ogm
mongodb/src/main/java/org/hibernate/ogm/datastore/mongodb/impl/MongoDBSchemaDefiner.java
MongoDBSchemaDefiner.validateAsMongoDBFieldName
private void validateAsMongoDBFieldName(String fieldName) { if ( fieldName.startsWith( "$" ) ) { throw log.fieldNameHasInvalidDollarPrefix( fieldName ); } else if ( fieldName.contains( "\u0000" ) ) { throw log.fieldNameContainsNULCharacter( fieldName ); } }
java
private void validateAsMongoDBFieldName(String fieldName) { if ( fieldName.startsWith( "$" ) ) { throw log.fieldNameHasInvalidDollarPrefix( fieldName ); } else if ( fieldName.contains( "\u0000" ) ) { throw log.fieldNameContainsNULCharacter( fieldName ); } }
[ "private", "void", "validateAsMongoDBFieldName", "(", "String", "fieldName", ")", "{", "if", "(", "fieldName", ".", "startsWith", "(", "\"$\"", ")", ")", "{", "throw", "log", ".", "fieldNameHasInvalidDollarPrefix", "(", "fieldName", ")", ";", "}", "else", "if"...
Validates a String to be a valid name to be used in MongoDB for a field name. @param fieldName
[ "Validates", "a", "String", "to", "be", "a", "valid", "name", "to", "be", "used", "in", "MongoDB", "for", "a", "field", "name", "." ]
9ea971df7c27277029006a6f748d8272fb1d69d2
https://github.com/hibernate/hibernate-ogm/blob/9ea971df7c27277029006a6f748d8272fb1d69d2/mongodb/src/main/java/org/hibernate/ogm/datastore/mongodb/impl/MongoDBSchemaDefiner.java#L379-L386
train
hibernate/hibernate-ogm
core/src/main/java/org/hibernate/ogm/persister/impl/OgmEntityPersister.java
OgmEntityPersister.determineBatchSize
private static int determineBatchSize(boolean canGridDialectDoMultiget, int classBatchSize, int configuredDefaultBatchSize) { // if the dialect does not support it, don't batch so that we can avoid skewing the ORM fetch statistics if ( !canGridDialectDoMultiget ) { return -1; } else if ( classBatchSize != -1 ) { return classBatchSize; } else if ( configuredDefaultBatchSize != -1 ) { return configuredDefaultBatchSize; } else { return DEFAULT_MULTIGET_BATCH_SIZE; } }
java
private static int determineBatchSize(boolean canGridDialectDoMultiget, int classBatchSize, int configuredDefaultBatchSize) { // if the dialect does not support it, don't batch so that we can avoid skewing the ORM fetch statistics if ( !canGridDialectDoMultiget ) { return -1; } else if ( classBatchSize != -1 ) { return classBatchSize; } else if ( configuredDefaultBatchSize != -1 ) { return configuredDefaultBatchSize; } else { return DEFAULT_MULTIGET_BATCH_SIZE; } }
[ "private", "static", "int", "determineBatchSize", "(", "boolean", "canGridDialectDoMultiget", ",", "int", "classBatchSize", ",", "int", "configuredDefaultBatchSize", ")", "{", "// if the dialect does not support it, don't batch so that we can avoid skewing the ORM fetch statistics", ...
Returns the effective batch size. If the dialect is multiget capable and a batch size has been configured, use that one, otherwise the default.
[ "Returns", "the", "effective", "batch", "size", ".", "If", "the", "dialect", "is", "multiget", "capable", "and", "a", "batch", "size", "has", "been", "configured", "use", "that", "one", "otherwise", "the", "default", "." ]
9ea971df7c27277029006a6f748d8272fb1d69d2
https://github.com/hibernate/hibernate-ogm/blob/9ea971df7c27277029006a6f748d8272fb1d69d2/core/src/main/java/org/hibernate/ogm/persister/impl/OgmEntityPersister.java#L354-L368
train
hibernate/hibernate-ogm
core/src/main/java/org/hibernate/ogm/persister/impl/OgmEntityPersister.java
OgmEntityPersister.getInverseOneToOneProperty
private String getInverseOneToOneProperty(String property, OgmEntityPersister otherSidePersister) { for ( String candidate : otherSidePersister.getPropertyNames() ) { Type candidateType = otherSidePersister.getPropertyType( candidate ); if ( candidateType.isEntityType() && ( ( (EntityType) candidateType ).isOneToOne() && isOneToOneMatching( this, property, (OneToOneType) candidateType ) ) ) { return candidate; } } return null; }
java
private String getInverseOneToOneProperty(String property, OgmEntityPersister otherSidePersister) { for ( String candidate : otherSidePersister.getPropertyNames() ) { Type candidateType = otherSidePersister.getPropertyType( candidate ); if ( candidateType.isEntityType() && ( ( (EntityType) candidateType ).isOneToOne() && isOneToOneMatching( this, property, (OneToOneType) candidateType ) ) ) { return candidate; } } return null; }
[ "private", "String", "getInverseOneToOneProperty", "(", "String", "property", ",", "OgmEntityPersister", "otherSidePersister", ")", "{", "for", "(", "String", "candidate", ":", "otherSidePersister", ".", "getPropertyNames", "(", ")", ")", "{", "Type", "candidateType",...
Returns the name from the inverse side if the given property de-notes a one-to-one association.
[ "Returns", "the", "name", "from", "the", "inverse", "side", "if", "the", "given", "property", "de", "-", "notes", "a", "one", "-", "to", "-", "one", "association", "." ]
9ea971df7c27277029006a6f748d8272fb1d69d2
https://github.com/hibernate/hibernate-ogm/blob/9ea971df7c27277029006a6f748d8272fb1d69d2/core/src/main/java/org/hibernate/ogm/persister/impl/OgmEntityPersister.java#L415-L426
train
hibernate/hibernate-ogm
core/src/main/java/org/hibernate/ogm/persister/impl/OgmEntityPersister.java
OgmEntityPersister.getDatabaseSnapshot
@Override public Object[] getDatabaseSnapshot(Serializable id, SharedSessionContractImplementor session) throws HibernateException { if ( log.isTraceEnabled() ) { log.trace( "Getting current persistent state for: " + MessageHelper.infoString( this, id, getFactory() ) ); } //snapshot is a Map in the end final Tuple resultset = getFreshTuple( EntityKeyBuilder.fromPersister( this, id, session ), session ); //if there is no resulting row, return null if ( resultset == null || resultset.getSnapshot().isEmpty() ) { return null; } //otherwise return the "hydrated" state (ie. associations are not resolved) GridType[] types = gridPropertyTypes; Object[] values = new Object[types.length]; boolean[] includeProperty = getPropertyUpdateability(); for ( int i = 0; i < types.length; i++ ) { if ( includeProperty[i] ) { values[i] = types[i].hydrate( resultset, getPropertyAliases( "", i ), session, null ); //null owner ok?? } } return values; }
java
@Override public Object[] getDatabaseSnapshot(Serializable id, SharedSessionContractImplementor session) throws HibernateException { if ( log.isTraceEnabled() ) { log.trace( "Getting current persistent state for: " + MessageHelper.infoString( this, id, getFactory() ) ); } //snapshot is a Map in the end final Tuple resultset = getFreshTuple( EntityKeyBuilder.fromPersister( this, id, session ), session ); //if there is no resulting row, return null if ( resultset == null || resultset.getSnapshot().isEmpty() ) { return null; } //otherwise return the "hydrated" state (ie. associations are not resolved) GridType[] types = gridPropertyTypes; Object[] values = new Object[types.length]; boolean[] includeProperty = getPropertyUpdateability(); for ( int i = 0; i < types.length; i++ ) { if ( includeProperty[i] ) { values[i] = types[i].hydrate( resultset, getPropertyAliases( "", i ), session, null ); //null owner ok?? } } return values; }
[ "@", "Override", "public", "Object", "[", "]", "getDatabaseSnapshot", "(", "Serializable", "id", ",", "SharedSessionContractImplementor", "session", ")", "throws", "HibernateException", "{", "if", "(", "log", ".", "isTraceEnabled", "(", ")", ")", "{", "log", "."...
This snapshot is meant to be used when updating data.
[ "This", "snapshot", "is", "meant", "to", "be", "used", "when", "updating", "data", "." ]
9ea971df7c27277029006a6f748d8272fb1d69d2
https://github.com/hibernate/hibernate-ogm/blob/9ea971df7c27277029006a6f748d8272fb1d69d2/core/src/main/java/org/hibernate/ogm/persister/impl/OgmEntityPersister.java#L644-L669
train
hibernate/hibernate-ogm
core/src/main/java/org/hibernate/ogm/persister/impl/OgmEntityPersister.java
OgmEntityPersister.initializeLazyPropertiesFromCache
private Object initializeLazyPropertiesFromCache( final String fieldName, final Object entity, final SharedSessionContractImplementor session, final EntityEntry entry, final CacheEntry cacheEntry ) { throw new NotSupportedException( "OGM-9", "Lazy properties not supported in OGM" ); }
java
private Object initializeLazyPropertiesFromCache( final String fieldName, final Object entity, final SharedSessionContractImplementor session, final EntityEntry entry, final CacheEntry cacheEntry ) { throw new NotSupportedException( "OGM-9", "Lazy properties not supported in OGM" ); }
[ "private", "Object", "initializeLazyPropertiesFromCache", "(", "final", "String", "fieldName", ",", "final", "Object", "entity", ",", "final", "SharedSessionContractImplementor", "session", ",", "final", "EntityEntry", "entry", ",", "final", "CacheEntry", "cacheEntry", ...
Make superclasses method protected??
[ "Make", "superclasses", "method", "protected??" ]
9ea971df7c27277029006a6f748d8272fb1d69d2
https://github.com/hibernate/hibernate-ogm/blob/9ea971df7c27277029006a6f748d8272fb1d69d2/core/src/main/java/org/hibernate/ogm/persister/impl/OgmEntityPersister.java#L708-L716
train
hibernate/hibernate-ogm
core/src/main/java/org/hibernate/ogm/persister/impl/OgmEntityPersister.java
OgmEntityPersister.getCurrentVersion
@Override public Object getCurrentVersion(Serializable id, SharedSessionContractImplementor session) throws HibernateException { if ( log.isTraceEnabled() ) { log.trace( "Getting version: " + MessageHelper.infoString( this, id, getFactory() ) ); } final Tuple resultset = getFreshTuple( EntityKeyBuilder.fromPersister( this, id, session ), session ); if ( resultset == null ) { return null; } else { return gridVersionType.nullSafeGet( resultset, getVersionColumnName(), session, null ); } }
java
@Override public Object getCurrentVersion(Serializable id, SharedSessionContractImplementor session) throws HibernateException { if ( log.isTraceEnabled() ) { log.trace( "Getting version: " + MessageHelper.infoString( this, id, getFactory() ) ); } final Tuple resultset = getFreshTuple( EntityKeyBuilder.fromPersister( this, id, session ), session ); if ( resultset == null ) { return null; } else { return gridVersionType.nullSafeGet( resultset, getVersionColumnName(), session, null ); } }
[ "@", "Override", "public", "Object", "getCurrentVersion", "(", "Serializable", "id", ",", "SharedSessionContractImplementor", "session", ")", "throws", "HibernateException", "{", "if", "(", "log", ".", "isTraceEnabled", "(", ")", ")", "{", "log", ".", "trace", "...
Retrieve the version number
[ "Retrieve", "the", "version", "number" ]
9ea971df7c27277029006a6f748d8272fb1d69d2
https://github.com/hibernate/hibernate-ogm/blob/9ea971df7c27277029006a6f748d8272fb1d69d2/core/src/main/java/org/hibernate/ogm/persister/impl/OgmEntityPersister.java#L730-L744
train
hibernate/hibernate-ogm
core/src/main/java/org/hibernate/ogm/persister/impl/OgmEntityPersister.java
OgmEntityPersister.isAllOrDirtyOptLocking
private boolean isAllOrDirtyOptLocking() { EntityMetamodel entityMetamodel = getEntityMetamodel(); return entityMetamodel.getOptimisticLockStyle() == OptimisticLockStyle.DIRTY || entityMetamodel.getOptimisticLockStyle() == OptimisticLockStyle.ALL; }
java
private boolean isAllOrDirtyOptLocking() { EntityMetamodel entityMetamodel = getEntityMetamodel(); return entityMetamodel.getOptimisticLockStyle() == OptimisticLockStyle.DIRTY || entityMetamodel.getOptimisticLockStyle() == OptimisticLockStyle.ALL; }
[ "private", "boolean", "isAllOrDirtyOptLocking", "(", ")", "{", "EntityMetamodel", "entityMetamodel", "=", "getEntityMetamodel", "(", ")", ";", "return", "entityMetamodel", ".", "getOptimisticLockStyle", "(", ")", "==", "OptimisticLockStyle", ".", "DIRTY", "||", "entit...
Copied from AbstractEntityPersister
[ "Copied", "from", "AbstractEntityPersister" ]
9ea971df7c27277029006a6f748d8272fb1d69d2
https://github.com/hibernate/hibernate-ogm/blob/9ea971df7c27277029006a6f748d8272fb1d69d2/core/src/main/java/org/hibernate/ogm/persister/impl/OgmEntityPersister.java#L1296-L1300
train
hibernate/hibernate-ogm
core/src/main/java/org/hibernate/ogm/persister/impl/OgmEntityPersister.java
OgmEntityPersister.removeFromInverseAssociations
private void removeFromInverseAssociations( Tuple resultset, int tableIndex, Serializable id, SharedSessionContractImplementor session) { new EntityAssociationUpdater( this ) .id( id ) .resultset( resultset ) .session( session ) .tableIndex( tableIndex ) .propertyMightRequireInverseAssociationManagement( propertyMightBeMainSideOfBidirectionalAssociation ) .removeNavigationalInformationFromInverseSide(); }
java
private void removeFromInverseAssociations( Tuple resultset, int tableIndex, Serializable id, SharedSessionContractImplementor session) { new EntityAssociationUpdater( this ) .id( id ) .resultset( resultset ) .session( session ) .tableIndex( tableIndex ) .propertyMightRequireInverseAssociationManagement( propertyMightBeMainSideOfBidirectionalAssociation ) .removeNavigationalInformationFromInverseSide(); }
[ "private", "void", "removeFromInverseAssociations", "(", "Tuple", "resultset", ",", "int", "tableIndex", ",", "Serializable", "id", ",", "SharedSessionContractImplementor", "session", ")", "{", "new", "EntityAssociationUpdater", "(", "this", ")", ".", "id", "(", "id...
Removes the given entity from the inverse associations it manages.
[ "Removes", "the", "given", "entity", "from", "the", "inverse", "associations", "it", "manages", "." ]
9ea971df7c27277029006a6f748d8272fb1d69d2
https://github.com/hibernate/hibernate-ogm/blob/9ea971df7c27277029006a6f748d8272fb1d69d2/core/src/main/java/org/hibernate/ogm/persister/impl/OgmEntityPersister.java#L1349-L1361
train
hibernate/hibernate-ogm
core/src/main/java/org/hibernate/ogm/persister/impl/OgmEntityPersister.java
OgmEntityPersister.addToInverseAssociations
private void addToInverseAssociations( Tuple resultset, int tableIndex, Serializable id, SharedSessionContractImplementor session) { new EntityAssociationUpdater( this ) .id( id ) .resultset( resultset ) .session( session ) .tableIndex( tableIndex ) .propertyMightRequireInverseAssociationManagement( propertyMightBeMainSideOfBidirectionalAssociation ) .addNavigationalInformationForInverseSide(); }
java
private void addToInverseAssociations( Tuple resultset, int tableIndex, Serializable id, SharedSessionContractImplementor session) { new EntityAssociationUpdater( this ) .id( id ) .resultset( resultset ) .session( session ) .tableIndex( tableIndex ) .propertyMightRequireInverseAssociationManagement( propertyMightBeMainSideOfBidirectionalAssociation ) .addNavigationalInformationForInverseSide(); }
[ "private", "void", "addToInverseAssociations", "(", "Tuple", "resultset", ",", "int", "tableIndex", ",", "Serializable", "id", ",", "SharedSessionContractImplementor", "session", ")", "{", "new", "EntityAssociationUpdater", "(", "this", ")", ".", "id", "(", "id", ...
Adds the given entity to the inverse associations it manages.
[ "Adds", "the", "given", "entity", "to", "the", "inverse", "associations", "it", "manages", "." ]
9ea971df7c27277029006a6f748d8272fb1d69d2
https://github.com/hibernate/hibernate-ogm/blob/9ea971df7c27277029006a6f748d8272fb1d69d2/core/src/main/java/org/hibernate/ogm/persister/impl/OgmEntityPersister.java#L1366-L1378
train
hibernate/hibernate-ogm
core/src/main/java/org/hibernate/ogm/persister/impl/OgmEntityPersister.java
OgmEntityPersister.processGeneratedProperties
private void processGeneratedProperties( Serializable id, Object entity, Object[] state, SharedSessionContractImplementor session, GenerationTiming matchTiming) { Tuple tuple = getFreshTuple( EntityKeyBuilder.fromPersister( this, id, session ), session ); saveSharedTuple( entity, tuple, session ); if ( tuple == null || tuple.getSnapshot().isEmpty() ) { throw log.couldNotRetrieveEntityForRetrievalOfGeneratedProperties( getEntityName(), id ); } int propertyIndex = -1; for ( NonIdentifierAttribute attribute : getEntityMetamodel().getProperties() ) { propertyIndex++; final ValueGeneration valueGeneration = attribute.getValueGenerationStrategy(); if ( isReadRequired( valueGeneration, matchTiming ) ) { Object hydratedState = gridPropertyTypes[propertyIndex].hydrate( tuple, getPropertyAliases( "", propertyIndex ), session, entity ); state[propertyIndex] = gridPropertyTypes[propertyIndex].resolve( hydratedState, session, entity ); setPropertyValue( entity, propertyIndex, state[propertyIndex] ); } } }
java
private void processGeneratedProperties( Serializable id, Object entity, Object[] state, SharedSessionContractImplementor session, GenerationTiming matchTiming) { Tuple tuple = getFreshTuple( EntityKeyBuilder.fromPersister( this, id, session ), session ); saveSharedTuple( entity, tuple, session ); if ( tuple == null || tuple.getSnapshot().isEmpty() ) { throw log.couldNotRetrieveEntityForRetrievalOfGeneratedProperties( getEntityName(), id ); } int propertyIndex = -1; for ( NonIdentifierAttribute attribute : getEntityMetamodel().getProperties() ) { propertyIndex++; final ValueGeneration valueGeneration = attribute.getValueGenerationStrategy(); if ( isReadRequired( valueGeneration, matchTiming ) ) { Object hydratedState = gridPropertyTypes[propertyIndex].hydrate( tuple, getPropertyAliases( "", propertyIndex ), session, entity ); state[propertyIndex] = gridPropertyTypes[propertyIndex].resolve( hydratedState, session, entity ); setPropertyValue( entity, propertyIndex, state[propertyIndex] ); } } }
[ "private", "void", "processGeneratedProperties", "(", "Serializable", "id", ",", "Object", "entity", ",", "Object", "[", "]", "state", ",", "SharedSessionContractImplementor", "session", ",", "GenerationTiming", "matchTiming", ")", "{", "Tuple", "tuple", "=", "getFr...
Re-reads the given entity, refreshing any properties updated on the server-side during insert or update.
[ "Re", "-", "reads", "the", "given", "entity", "refreshing", "any", "properties", "updated", "on", "the", "server", "-", "side", "during", "insert", "or", "update", "." ]
9ea971df7c27277029006a6f748d8272fb1d69d2
https://github.com/hibernate/hibernate-ogm/blob/9ea971df7c27277029006a6f748d8272fb1d69d2/core/src/main/java/org/hibernate/ogm/persister/impl/OgmEntityPersister.java#L1873-L1897
train
hibernate/hibernate-ogm
core/src/main/java/org/hibernate/ogm/persister/impl/OgmEntityPersister.java
OgmEntityPersister.isReadRequired
private boolean isReadRequired(ValueGeneration valueGeneration, GenerationTiming matchTiming) { return valueGeneration != null && valueGeneration.getValueGenerator() == null && timingsMatch( valueGeneration.getGenerationTiming(), matchTiming ); }
java
private boolean isReadRequired(ValueGeneration valueGeneration, GenerationTiming matchTiming) { return valueGeneration != null && valueGeneration.getValueGenerator() == null && timingsMatch( valueGeneration.getGenerationTiming(), matchTiming ); }
[ "private", "boolean", "isReadRequired", "(", "ValueGeneration", "valueGeneration", ",", "GenerationTiming", "matchTiming", ")", "{", "return", "valueGeneration", "!=", "null", "&&", "valueGeneration", ".", "getValueGenerator", "(", ")", "==", "null", "&&", "timingsMat...
Whether the given value generation strategy requires to read the value from the database or not.
[ "Whether", "the", "given", "value", "generation", "strategy", "requires", "to", "read", "the", "value", "from", "the", "database", "or", "not", "." ]
9ea971df7c27277029006a6f748d8272fb1d69d2
https://github.com/hibernate/hibernate-ogm/blob/9ea971df7c27277029006a6f748d8272fb1d69d2/core/src/main/java/org/hibernate/ogm/persister/impl/OgmEntityPersister.java#L1902-L1905
train
hibernate/hibernate-ogm
core/src/main/java/org/hibernate/ogm/util/impl/CustomLoaderHelper.java
CustomLoaderHelper.listOfEntities
public static List<Object> listOfEntities(SharedSessionContractImplementor session, Type[] resultTypes, ClosableIterator<Tuple> tuples) { Class<?> returnedClass = resultTypes[0].getReturnedClass(); TupleBasedEntityLoader loader = getLoader( session, returnedClass ); OgmLoadingContext ogmLoadingContext = new OgmLoadingContext(); ogmLoadingContext.setTuples( getTuplesAsList( tuples ) ); return loader.loadEntitiesFromTuples( session, LockOptions.NONE, ogmLoadingContext ); }
java
public static List<Object> listOfEntities(SharedSessionContractImplementor session, Type[] resultTypes, ClosableIterator<Tuple> tuples) { Class<?> returnedClass = resultTypes[0].getReturnedClass(); TupleBasedEntityLoader loader = getLoader( session, returnedClass ); OgmLoadingContext ogmLoadingContext = new OgmLoadingContext(); ogmLoadingContext.setTuples( getTuplesAsList( tuples ) ); return loader.loadEntitiesFromTuples( session, LockOptions.NONE, ogmLoadingContext ); }
[ "public", "static", "List", "<", "Object", ">", "listOfEntities", "(", "SharedSessionContractImplementor", "session", ",", "Type", "[", "]", "resultTypes", ",", "ClosableIterator", "<", "Tuple", ">", "tuples", ")", "{", "Class", "<", "?", ">", "returnedClass", ...
At the moment we only support the case where one entity type is returned
[ "At", "the", "moment", "we", "only", "support", "the", "case", "where", "one", "entity", "type", "is", "returned" ]
9ea971df7c27277029006a6f748d8272fb1d69d2
https://github.com/hibernate/hibernate-ogm/blob/9ea971df7c27277029006a6f748d8272fb1d69d2/core/src/main/java/org/hibernate/ogm/util/impl/CustomLoaderHelper.java#L29-L35
train
hibernate/hibernate-ogm
core/src/main/java/org/hibernate/ogm/massindex/impl/BatchCoordinator.java
BatchCoordinator.doBatchWork
private void doBatchWork(BatchBackend backend) throws InterruptedException { ExecutorService executor = Executors.newFixedThreadPool( typesToIndexInParallel, "BatchIndexingWorkspace" ); for ( IndexedTypeIdentifier indexedTypeIdentifier : rootIndexedTypes ) { executor.execute( new BatchIndexingWorkspace( gridDialect, searchFactoryImplementor, sessionFactory, indexedTypeIdentifier, cacheMode, endAllSignal, monitor, backend, tenantId ) ); } executor.shutdown(); endAllSignal.await(); // waits for the executor to finish }
java
private void doBatchWork(BatchBackend backend) throws InterruptedException { ExecutorService executor = Executors.newFixedThreadPool( typesToIndexInParallel, "BatchIndexingWorkspace" ); for ( IndexedTypeIdentifier indexedTypeIdentifier : rootIndexedTypes ) { executor.execute( new BatchIndexingWorkspace( gridDialect, searchFactoryImplementor, sessionFactory, indexedTypeIdentifier, cacheMode, endAllSignal, monitor, backend, tenantId ) ); } executor.shutdown(); endAllSignal.await(); // waits for the executor to finish }
[ "private", "void", "doBatchWork", "(", "BatchBackend", "backend", ")", "throws", "InterruptedException", "{", "ExecutorService", "executor", "=", "Executors", ".", "newFixedThreadPool", "(", "typesToIndexInParallel", ",", "\"BatchIndexingWorkspace\"", ")", ";", "for", "...
Will spawn a thread for each type in rootEntities, they will all re-join on endAllSignal when finished. @param backend @throws InterruptedException if interrupted while waiting for endAllSignal.
[ "Will", "spawn", "a", "thread", "for", "each", "type", "in", "rootEntities", "they", "will", "all", "re", "-", "join", "on", "endAllSignal", "when", "finished", "." ]
9ea971df7c27277029006a6f748d8272fb1d69d2
https://github.com/hibernate/hibernate-ogm/blob/9ea971df7c27277029006a6f748d8272fb1d69d2/core/src/main/java/org/hibernate/ogm/massindex/impl/BatchCoordinator.java#L105-L113
train
hibernate/hibernate-ogm
core/src/main/java/org/hibernate/ogm/massindex/impl/BatchCoordinator.java
BatchCoordinator.afterBatch
private void afterBatch(BatchBackend backend) { IndexedTypeSet targetedTypes = searchFactoryImplementor.getIndexedTypesPolymorphic( rootIndexedTypes ); if ( this.optimizeAtEnd ) { backend.optimize( targetedTypes ); } backend.flush( targetedTypes ); }
java
private void afterBatch(BatchBackend backend) { IndexedTypeSet targetedTypes = searchFactoryImplementor.getIndexedTypesPolymorphic( rootIndexedTypes ); if ( this.optimizeAtEnd ) { backend.optimize( targetedTypes ); } backend.flush( targetedTypes ); }
[ "private", "void", "afterBatch", "(", "BatchBackend", "backend", ")", "{", "IndexedTypeSet", "targetedTypes", "=", "searchFactoryImplementor", ".", "getIndexedTypesPolymorphic", "(", "rootIndexedTypes", ")", ";", "if", "(", "this", ".", "optimizeAtEnd", ")", "{", "b...
Operations to do after all subthreads finished their work on index @param backend
[ "Operations", "to", "do", "after", "all", "subthreads", "finished", "their", "work", "on", "index" ]
9ea971df7c27277029006a6f748d8272fb1d69d2
https://github.com/hibernate/hibernate-ogm/blob/9ea971df7c27277029006a6f748d8272fb1d69d2/core/src/main/java/org/hibernate/ogm/massindex/impl/BatchCoordinator.java#L120-L126
train
hibernate/hibernate-ogm
core/src/main/java/org/hibernate/ogm/massindex/impl/BatchCoordinator.java
BatchCoordinator.beforeBatch
private void beforeBatch(BatchBackend backend) { if ( this.purgeAtStart ) { // purgeAll for affected entities IndexedTypeSet targetedTypes = searchFactoryImplementor.getIndexedTypesPolymorphic( rootIndexedTypes ); for ( IndexedTypeIdentifier type : targetedTypes ) { // needs do be in-sync work to make sure we wait for the end of it. backend.doWorkInSync( new PurgeAllLuceneWork( tenantId, type ) ); } if ( this.optimizeAfterPurge ) { backend.optimize( targetedTypes ); } } }
java
private void beforeBatch(BatchBackend backend) { if ( this.purgeAtStart ) { // purgeAll for affected entities IndexedTypeSet targetedTypes = searchFactoryImplementor.getIndexedTypesPolymorphic( rootIndexedTypes ); for ( IndexedTypeIdentifier type : targetedTypes ) { // needs do be in-sync work to make sure we wait for the end of it. backend.doWorkInSync( new PurgeAllLuceneWork( tenantId, type ) ); } if ( this.optimizeAfterPurge ) { backend.optimize( targetedTypes ); } } }
[ "private", "void", "beforeBatch", "(", "BatchBackend", "backend", ")", "{", "if", "(", "this", ".", "purgeAtStart", ")", "{", "// purgeAll for affected entities", "IndexedTypeSet", "targetedTypes", "=", "searchFactoryImplementor", ".", "getIndexedTypesPolymorphic", "(", ...
Optional operations to do before the multiple-threads start indexing @param backend
[ "Optional", "operations", "to", "do", "before", "the", "multiple", "-", "threads", "start", "indexing" ]
9ea971df7c27277029006a6f748d8272fb1d69d2
https://github.com/hibernate/hibernate-ogm/blob/9ea971df7c27277029006a6f748d8272fb1d69d2/core/src/main/java/org/hibernate/ogm/massindex/impl/BatchCoordinator.java#L133-L145
train
hibernate/hibernate-ogm
core/src/main/java/org/hibernate/ogm/util/impl/CollectionHelper.java
CollectionHelper.asSet
@SafeVarargs public static <T> Set<T> asSet(T... ts) { if ( ts == null ) { return null; } else if ( ts.length == 0 ) { return Collections.emptySet(); } else { Set<T> set = new HashSet<T>( getInitialCapacityFromExpectedSize( ts.length ) ); Collections.addAll( set, ts ); return Collections.unmodifiableSet( set ); } }
java
@SafeVarargs public static <T> Set<T> asSet(T... ts) { if ( ts == null ) { return null; } else if ( ts.length == 0 ) { return Collections.emptySet(); } else { Set<T> set = new HashSet<T>( getInitialCapacityFromExpectedSize( ts.length ) ); Collections.addAll( set, ts ); return Collections.unmodifiableSet( set ); } }
[ "@", "SafeVarargs", "public", "static", "<", "T", ">", "Set", "<", "T", ">", "asSet", "(", "T", "...", "ts", ")", "{", "if", "(", "ts", "==", "null", ")", "{", "return", "null", ";", "}", "else", "if", "(", "ts", ".", "length", "==", "0", ")"...
Returns an unmodifiable set containing the given elements. @param ts the elements from which to create a set @param <T> the type of the element in the set @return an unmodifiable set containing the given elements or {@code null} in case the given element array is {@code null}.
[ "Returns", "an", "unmodifiable", "set", "containing", "the", "given", "elements", "." ]
9ea971df7c27277029006a6f748d8272fb1d69d2
https://github.com/hibernate/hibernate-ogm/blob/9ea971df7c27277029006a6f748d8272fb1d69d2/core/src/main/java/org/hibernate/ogm/util/impl/CollectionHelper.java#L46-L59
train
hibernate/hibernate-ogm
core/src/main/java/org/hibernate/ogm/type/impl/EnumType.java
EnumType.isOrdinal
private boolean isOrdinal(int paramType) { switch ( paramType ) { case Types.INTEGER: case Types.NUMERIC: case Types.SMALLINT: case Types.TINYINT: case Types.BIGINT: case Types.DECIMAL: //for Oracle Driver case Types.DOUBLE: //for Oracle Driver case Types.FLOAT: //for Oracle Driver return true; case Types.CHAR: case Types.LONGVARCHAR: case Types.VARCHAR: return false; default: throw new HibernateException( "Unable to persist an Enum in a column of SQL Type: " + paramType ); } }
java
private boolean isOrdinal(int paramType) { switch ( paramType ) { case Types.INTEGER: case Types.NUMERIC: case Types.SMALLINT: case Types.TINYINT: case Types.BIGINT: case Types.DECIMAL: //for Oracle Driver case Types.DOUBLE: //for Oracle Driver case Types.FLOAT: //for Oracle Driver return true; case Types.CHAR: case Types.LONGVARCHAR: case Types.VARCHAR: return false; default: throw new HibernateException( "Unable to persist an Enum in a column of SQL Type: " + paramType ); } }
[ "private", "boolean", "isOrdinal", "(", "int", "paramType", ")", "{", "switch", "(", "paramType", ")", "{", "case", "Types", ".", "INTEGER", ":", "case", "Types", ".", "NUMERIC", ":", "case", "Types", ".", "SMALLINT", ":", "case", "Types", ".", "TINYINT"...
in truth we probably only need the types as injected by the metadata binder
[ "in", "truth", "we", "probably", "only", "need", "the", "types", "as", "injected", "by", "the", "metadata", "binder" ]
9ea971df7c27277029006a6f748d8272fb1d69d2
https://github.com/hibernate/hibernate-ogm/blob/9ea971df7c27277029006a6f748d8272fb1d69d2/core/src/main/java/org/hibernate/ogm/type/impl/EnumType.java#L143-L161
train
hibernate/hibernate-ogm
infinispan-embedded/src/main/java/org/hibernate/ogm/datastore/infinispan/impl/InfinispanEmbeddedStoredProceduresManager.java
InfinispanEmbeddedStoredProceduresManager.callStoredProcedure
public ClosableIterator<Tuple> callStoredProcedure(EmbeddedCacheManager embeddedCacheManager, String storedProcedureName, ProcedureQueryParameters queryParameters, ClassLoaderService classLoaderService ) { validate( queryParameters ); Cache<String, String> cache = embeddedCacheManager.getCache( STORED_PROCEDURES_CACHE_NAME, true ); String className = cache.getOrDefault( storedProcedureName, storedProcedureName ); Callable<?> callable = instantiate( storedProcedureName, className, classLoaderService ); setParams( storedProcedureName, queryParameters, callable ); Object res = execute( storedProcedureName, embeddedCacheManager, callable ); return extractResultSet( storedProcedureName, res ); }
java
public ClosableIterator<Tuple> callStoredProcedure(EmbeddedCacheManager embeddedCacheManager, String storedProcedureName, ProcedureQueryParameters queryParameters, ClassLoaderService classLoaderService ) { validate( queryParameters ); Cache<String, String> cache = embeddedCacheManager.getCache( STORED_PROCEDURES_CACHE_NAME, true ); String className = cache.getOrDefault( storedProcedureName, storedProcedureName ); Callable<?> callable = instantiate( storedProcedureName, className, classLoaderService ); setParams( storedProcedureName, queryParameters, callable ); Object res = execute( storedProcedureName, embeddedCacheManager, callable ); return extractResultSet( storedProcedureName, res ); }
[ "public", "ClosableIterator", "<", "Tuple", ">", "callStoredProcedure", "(", "EmbeddedCacheManager", "embeddedCacheManager", ",", "String", "storedProcedureName", ",", "ProcedureQueryParameters", "queryParameters", ",", "ClassLoaderService", "classLoaderService", ")", "{", "v...
Returns the result of a stored procedure executed on the backend. @param embeddedCacheManager embedded cache manager @param storedProcedureName name of stored procedure @param queryParameters parameters passed for this query @param classLoaderService the class loader service @return a {@link ClosableIterator} with the result of the query
[ "Returns", "the", "result", "of", "a", "stored", "procedure", "executed", "on", "the", "backend", "." ]
9ea971df7c27277029006a6f748d8272fb1d69d2
https://github.com/hibernate/hibernate-ogm/blob/9ea971df7c27277029006a6f748d8272fb1d69d2/infinispan-embedded/src/main/java/org/hibernate/ogm/datastore/infinispan/impl/InfinispanEmbeddedStoredProceduresManager.java#L51-L59
train
hibernate/hibernate-ogm
core/src/main/java/org/hibernate/ogm/datastore/document/association/impl/DocumentHelpers.java
DocumentHelpers.getPrefix
public static String getPrefix(String column) { return column.contains( "." ) ? DOT_SEPARATOR_PATTERN.split( column )[0] : null; }
java
public static String getPrefix(String column) { return column.contains( "." ) ? DOT_SEPARATOR_PATTERN.split( column )[0] : null; }
[ "public", "static", "String", "getPrefix", "(", "String", "column", ")", "{", "return", "column", ".", "contains", "(", "\".\"", ")", "?", "DOT_SEPARATOR_PATTERN", ".", "split", "(", "column", ")", "[", "0", "]", ":", "null", ";", "}" ]
If the column name is a dotted column, returns the first part. Returns null otherwise. @param column the column that might have a prefix @return the first part of the prefix of the column or {@code null} if the column does not have a prefix.
[ "If", "the", "column", "name", "is", "a", "dotted", "column", "returns", "the", "first", "part", ".", "Returns", "null", "otherwise", "." ]
9ea971df7c27277029006a6f748d8272fb1d69d2
https://github.com/hibernate/hibernate-ogm/blob/9ea971df7c27277029006a6f748d8272fb1d69d2/core/src/main/java/org/hibernate/ogm/datastore/document/association/impl/DocumentHelpers.java#L26-L28
train
hibernate/hibernate-ogm
core/src/main/java/org/hibernate/ogm/datastore/document/association/impl/DocumentHelpers.java
DocumentHelpers.getColumnSharedPrefix
public static String getColumnSharedPrefix(String[] associationKeyColumns) { String prefix = null; for ( String column : associationKeyColumns ) { String newPrefix = getPrefix( column ); if ( prefix == null ) { // first iteration prefix = newPrefix; if ( prefix == null ) { // no prefix, quit break; } } else { // subsequent iterations if ( ! equals( prefix, newPrefix ) ) { // different prefixes prefix = null; break; } } } return prefix; }
java
public static String getColumnSharedPrefix(String[] associationKeyColumns) { String prefix = null; for ( String column : associationKeyColumns ) { String newPrefix = getPrefix( column ); if ( prefix == null ) { // first iteration prefix = newPrefix; if ( prefix == null ) { // no prefix, quit break; } } else { // subsequent iterations if ( ! equals( prefix, newPrefix ) ) { // different prefixes prefix = null; break; } } } return prefix; }
[ "public", "static", "String", "getColumnSharedPrefix", "(", "String", "[", "]", "associationKeyColumns", ")", "{", "String", "prefix", "=", "null", ";", "for", "(", "String", "column", ":", "associationKeyColumns", ")", "{", "String", "newPrefix", "=", "getPrefi...
Returns the shared prefix of these columns. Null otherwise. @param associationKeyColumns the columns sharing a prefix @return the shared prefix of these columns. {@code null} otherwise.
[ "Returns", "the", "shared", "prefix", "of", "these", "columns", ".", "Null", "otherwise", "." ]
9ea971df7c27277029006a6f748d8272fb1d69d2
https://github.com/hibernate/hibernate-ogm/blob/9ea971df7c27277029006a6f748d8272fb1d69d2/core/src/main/java/org/hibernate/ogm/datastore/document/association/impl/DocumentHelpers.java#L36-L54
train
hibernate/hibernate-ogm
core/src/main/java/org/hibernate/ogm/massindex/impl/Executors.java
Executors.newFixedThreadPool
public static ThreadPoolExecutor newFixedThreadPool(int threads, String groupname, int queueSize) { return new ThreadPoolExecutor( threads, threads, 0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<Runnable>( queueSize ), new SearchThreadFactory( groupname ), new BlockPolicy() ); }
java
public static ThreadPoolExecutor newFixedThreadPool(int threads, String groupname, int queueSize) { return new ThreadPoolExecutor( threads, threads, 0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<Runnable>( queueSize ), new SearchThreadFactory( groupname ), new BlockPolicy() ); }
[ "public", "static", "ThreadPoolExecutor", "newFixedThreadPool", "(", "int", "threads", ",", "String", "groupname", ",", "int", "queueSize", ")", "{", "return", "new", "ThreadPoolExecutor", "(", "threads", ",", "threads", ",", "0L", ",", "TimeUnit", ".", "MILLISE...
Creates a new fixed size ThreadPoolExecutor @param threads the number of threads @param groupname a label to identify the threadpool; useful for profiling. @param queueSize the size of the queue to store Runnables when all threads are busy @return the new ExecutorService
[ "Creates", "a", "new", "fixed", "size", "ThreadPoolExecutor" ]
9ea971df7c27277029006a6f748d8272fb1d69d2
https://github.com/hibernate/hibernate-ogm/blob/9ea971df7c27277029006a6f748d8272fb1d69d2/core/src/main/java/org/hibernate/ogm/massindex/impl/Executors.java#L61-L64
train
hibernate/hibernate-ogm
infinispan-embedded/src/main/java/org/hibernate/ogm/datastore/infinispan/persistencestrategy/common/externalizer/impl/VersionChecker.java
VersionChecker.readAndCheckVersion
public static void readAndCheckVersion(ObjectInput input, int supportedVersion, Class<?> externalizedType) throws IOException { int version = input.readInt(); if ( version != supportedVersion ) { throw LOG.unexpectedKeyVersion( externalizedType, version, supportedVersion ); } }
java
public static void readAndCheckVersion(ObjectInput input, int supportedVersion, Class<?> externalizedType) throws IOException { int version = input.readInt(); if ( version != supportedVersion ) { throw LOG.unexpectedKeyVersion( externalizedType, version, supportedVersion ); } }
[ "public", "static", "void", "readAndCheckVersion", "(", "ObjectInput", "input", ",", "int", "supportedVersion", ",", "Class", "<", "?", ">", "externalizedType", ")", "throws", "IOException", "{", "int", "version", "=", "input", ".", "readInt", "(", ")", ";", ...
Consumes the version field from the given input and raises an exception if the record is in a newer version, written by a newer version of Hibernate OGM. @param input the input to read from @param supportedVersion the type version supported by this version of OGM @param externalizedType the type to be unmarshalled @throws IOException if an error occurs while reading the input
[ "Consumes", "the", "version", "field", "from", "the", "given", "input", "and", "raises", "an", "exception", "if", "the", "record", "is", "in", "a", "newer", "version", "written", "by", "a", "newer", "version", "of", "Hibernate", "OGM", "." ]
9ea971df7c27277029006a6f748d8272fb1d69d2
https://github.com/hibernate/hibernate-ogm/blob/9ea971df7c27277029006a6f748d8272fb1d69d2/infinispan-embedded/src/main/java/org/hibernate/ogm/datastore/infinispan/persistencestrategy/common/externalizer/impl/VersionChecker.java#L35-L41
train
hibernate/hibernate-ogm
neo4j/src/main/java/org/hibernate/ogm/datastore/neo4j/remote/common/util/impl/RemoteNeo4jHelper.java
RemoteNeo4jHelper.matches
public static boolean matches(Map<String, Object> nodeProperties, String[] keyColumnNames, Object[] keyColumnValues) { for ( int i = 0; i < keyColumnNames.length; i++ ) { String property = keyColumnNames[i]; Object expectedValue = keyColumnValues[i]; boolean containsProperty = nodeProperties.containsKey( property ); if ( containsProperty ) { Object actualValue = nodeProperties.get( property ); if ( !sameValue( expectedValue, actualValue ) ) { return false; } } else if ( expectedValue != null ) { return false; } } return true; }
java
public static boolean matches(Map<String, Object> nodeProperties, String[] keyColumnNames, Object[] keyColumnValues) { for ( int i = 0; i < keyColumnNames.length; i++ ) { String property = keyColumnNames[i]; Object expectedValue = keyColumnValues[i]; boolean containsProperty = nodeProperties.containsKey( property ); if ( containsProperty ) { Object actualValue = nodeProperties.get( property ); if ( !sameValue( expectedValue, actualValue ) ) { return false; } } else if ( expectedValue != null ) { return false; } } return true; }
[ "public", "static", "boolean", "matches", "(", "Map", "<", "String", ",", "Object", ">", "nodeProperties", ",", "String", "[", "]", "keyColumnNames", ",", "Object", "[", "]", "keyColumnValues", ")", "{", "for", "(", "int", "i", "=", "0", ";", "i", "<",...
Check if the node matches the column values @param nodeProperties the properties on the node @param keyColumnNames the name of the columns to check @param keyColumnValues the value of the columns to check @return true if the properties of the node match the column names and values
[ "Check", "if", "the", "node", "matches", "the", "column", "values" ]
9ea971df7c27277029006a6f748d8272fb1d69d2
https://github.com/hibernate/hibernate-ogm/blob/9ea971df7c27277029006a6f748d8272fb1d69d2/neo4j/src/main/java/org/hibernate/ogm/datastore/neo4j/remote/common/util/impl/RemoteNeo4jHelper.java#L29-L45
train
hibernate/hibernate-ogm
mongodb/src/main/java/org/hibernate/ogm/datastore/mongodb/type/GeoPolygon.java
GeoPolygon.addHoles
public GeoPolygon addHoles(List<List<GeoPoint>> holes) { Contracts.assertNotNull( holes, "holes" ); this.rings.addAll( holes ); return this; }
java
public GeoPolygon addHoles(List<List<GeoPoint>> holes) { Contracts.assertNotNull( holes, "holes" ); this.rings.addAll( holes ); return this; }
[ "public", "GeoPolygon", "addHoles", "(", "List", "<", "List", "<", "GeoPoint", ">", ">", "holes", ")", "{", "Contracts", ".", "assertNotNull", "(", "holes", ",", "\"holes\"", ")", ";", "this", ".", "rings", ".", "addAll", "(", "holes", ")", ";", "retur...
Adds new holes to the polygon. @param holes holes, must be contained in the exterior ring and must not overlap or intersect another hole @return this for chaining
[ "Adds", "new", "holes", "to", "the", "polygon", "." ]
9ea971df7c27277029006a6f748d8272fb1d69d2
https://github.com/hibernate/hibernate-ogm/blob/9ea971df7c27277029006a6f748d8272fb1d69d2/mongodb/src/main/java/org/hibernate/ogm/datastore/mongodb/type/GeoPolygon.java#L117-L121
train
hibernate/hibernate-ogm
core/src/main/java/org/hibernate/ogm/options/container/impl/OptionsContainerBuilder.java
OptionsContainerBuilder.addAll
public void addAll(OptionsContainerBuilder container) { for ( Entry<Class<? extends Option<?, ?>>, ValueContainerBuilder<?, ?>> entry : container.optionValues.entrySet() ) { addAll( entry.getKey(), entry.getValue().build() ); } }
java
public void addAll(OptionsContainerBuilder container) { for ( Entry<Class<? extends Option<?, ?>>, ValueContainerBuilder<?, ?>> entry : container.optionValues.entrySet() ) { addAll( entry.getKey(), entry.getValue().build() ); } }
[ "public", "void", "addAll", "(", "OptionsContainerBuilder", "container", ")", "{", "for", "(", "Entry", "<", "Class", "<", "?", "extends", "Option", "<", "?", ",", "?", ">", ">", ",", "ValueContainerBuilder", "<", "?", ",", "?", ">", ">", "entry", ":",...
Adds all options from the passed container to this container. @param container a container with options to add
[ "Adds", "all", "options", "from", "the", "passed", "container", "to", "this", "container", "." ]
9ea971df7c27277029006a6f748d8272fb1d69d2
https://github.com/hibernate/hibernate-ogm/blob/9ea971df7c27277029006a6f748d8272fb1d69d2/core/src/main/java/org/hibernate/ogm/options/container/impl/OptionsContainerBuilder.java#L59-L63
train
hibernate/hibernate-ogm
core/src/main/java/org/hibernate/ogm/massindex/impl/OgmMassIndexer.java
OgmMassIndexer.toRootEntities
private static IndexedTypeSet toRootEntities(ExtendedSearchIntegrator extendedIntegrator, Class<?>... selection) { Set<Class<?>> entities = new HashSet<Class<?>>(); //first build the "entities" set containing all indexed subtypes of "selection". for ( Class<?> entityType : selection ) { IndexedTypeSet targetedClasses = extendedIntegrator.getIndexedTypesPolymorphic( IndexedTypeSets.fromClass( entityType ) ); if ( targetedClasses.isEmpty() ) { String msg = entityType.getName() + " is not an indexed entity or a subclass of an indexed entity"; throw new IllegalArgumentException( msg ); } entities.addAll( targetedClasses.toPojosSet() ); } Set<Class<?>> cleaned = new HashSet<Class<?>>(); Set<Class<?>> toRemove = new HashSet<Class<?>>(); //now remove all repeated types to avoid duplicate loading by polymorphic query loading for ( Class<?> type : entities ) { boolean typeIsOk = true; for ( Class<?> existing : cleaned ) { if ( existing.isAssignableFrom( type ) ) { typeIsOk = false; break; } if ( type.isAssignableFrom( existing ) ) { toRemove.add( existing ); } } if ( typeIsOk ) { cleaned.add( type ); } } cleaned.removeAll( toRemove ); log.debugf( "Targets for indexing job: %s", cleaned ); return IndexedTypeSets.fromClasses( cleaned.toArray( new Class[cleaned.size()] ) ); }
java
private static IndexedTypeSet toRootEntities(ExtendedSearchIntegrator extendedIntegrator, Class<?>... selection) { Set<Class<?>> entities = new HashSet<Class<?>>(); //first build the "entities" set containing all indexed subtypes of "selection". for ( Class<?> entityType : selection ) { IndexedTypeSet targetedClasses = extendedIntegrator.getIndexedTypesPolymorphic( IndexedTypeSets.fromClass( entityType ) ); if ( targetedClasses.isEmpty() ) { String msg = entityType.getName() + " is not an indexed entity or a subclass of an indexed entity"; throw new IllegalArgumentException( msg ); } entities.addAll( targetedClasses.toPojosSet() ); } Set<Class<?>> cleaned = new HashSet<Class<?>>(); Set<Class<?>> toRemove = new HashSet<Class<?>>(); //now remove all repeated types to avoid duplicate loading by polymorphic query loading for ( Class<?> type : entities ) { boolean typeIsOk = true; for ( Class<?> existing : cleaned ) { if ( existing.isAssignableFrom( type ) ) { typeIsOk = false; break; } if ( type.isAssignableFrom( existing ) ) { toRemove.add( existing ); } } if ( typeIsOk ) { cleaned.add( type ); } } cleaned.removeAll( toRemove ); log.debugf( "Targets for indexing job: %s", cleaned ); return IndexedTypeSets.fromClasses( cleaned.toArray( new Class[cleaned.size()] ) ); }
[ "private", "static", "IndexedTypeSet", "toRootEntities", "(", "ExtendedSearchIntegrator", "extendedIntegrator", ",", "Class", "<", "?", ">", "...", "selection", ")", "{", "Set", "<", "Class", "<", "?", ">", ">", "entities", "=", "new", "HashSet", "<", "Class",...
From the set of classes a new set is built containing all indexed subclasses, but removing then all subtypes of indexed entities. @param selection @return a new set of entities
[ "From", "the", "set", "of", "classes", "a", "new", "set", "is", "built", "containing", "all", "indexed", "subclasses", "but", "removing", "then", "all", "subtypes", "of", "indexed", "entities", "." ]
9ea971df7c27277029006a6f748d8272fb1d69d2
https://github.com/hibernate/hibernate-ogm/blob/9ea971df7c27277029006a6f748d8272fb1d69d2/core/src/main/java/org/hibernate/ogm/massindex/impl/OgmMassIndexer.java#L181-L213
train
hibernate/hibernate-ogm
core/src/main/java/org/hibernate/ogm/util/impl/AssociationPersister.java
AssociationPersister.updateHostingEntityIfRequired
private void updateHostingEntityIfRequired() { if ( hostingEntity != null && hostingEntityRequiresReadAfterUpdate() ) { OgmEntityPersister entityPersister = getHostingEntityPersister(); if ( GridDialects.hasFacet( gridDialect, GroupingByEntityDialect.class ) ) { ( (GroupingByEntityDialect) gridDialect ).flushPendingOperations( getAssociationKey().getEntityKey(), entityPersister.getTupleContext( session ) ); } entityPersister.processUpdateGeneratedProperties( entityPersister.getIdentifier( hostingEntity, session ), hostingEntity, new Object[entityPersister.getPropertyNames().length], session ); } }
java
private void updateHostingEntityIfRequired() { if ( hostingEntity != null && hostingEntityRequiresReadAfterUpdate() ) { OgmEntityPersister entityPersister = getHostingEntityPersister(); if ( GridDialects.hasFacet( gridDialect, GroupingByEntityDialect.class ) ) { ( (GroupingByEntityDialect) gridDialect ).flushPendingOperations( getAssociationKey().getEntityKey(), entityPersister.getTupleContext( session ) ); } entityPersister.processUpdateGeneratedProperties( entityPersister.getIdentifier( hostingEntity, session ), hostingEntity, new Object[entityPersister.getPropertyNames().length], session ); } }
[ "private", "void", "updateHostingEntityIfRequired", "(", ")", "{", "if", "(", "hostingEntity", "!=", "null", "&&", "hostingEntityRequiresReadAfterUpdate", "(", ")", ")", "{", "OgmEntityPersister", "entityPersister", "=", "getHostingEntityPersister", "(", ")", ";", "if...
Reads the entity hosting the association from the datastore and applies any property changes from the server side.
[ "Reads", "the", "entity", "hosting", "the", "association", "from", "the", "datastore", "and", "applies", "any", "property", "changes", "from", "the", "server", "side", "." ]
9ea971df7c27277029006a6f748d8272fb1d69d2
https://github.com/hibernate/hibernate-ogm/blob/9ea971df7c27277029006a6f748d8272fb1d69d2/core/src/main/java/org/hibernate/ogm/util/impl/AssociationPersister.java#L249-L265
train
hibernate/hibernate-ogm
core/src/main/java/org/hibernate/ogm/options/navigation/impl/OptionsContextImpl.java
OptionsContextImpl.getClassHierarchy
private static List<Class<?>> getClassHierarchy(Class<?> clazz) { List<Class<?>> hierarchy = new ArrayList<Class<?>>( 4 ); for ( Class<?> current = clazz; current != null; current = current.getSuperclass() ) { hierarchy.add( current ); } return hierarchy; }
java
private static List<Class<?>> getClassHierarchy(Class<?> clazz) { List<Class<?>> hierarchy = new ArrayList<Class<?>>( 4 ); for ( Class<?> current = clazz; current != null; current = current.getSuperclass() ) { hierarchy.add( current ); } return hierarchy; }
[ "private", "static", "List", "<", "Class", "<", "?", ">", ">", "getClassHierarchy", "(", "Class", "<", "?", ">", "clazz", ")", "{", "List", "<", "Class", "<", "?", ">", ">", "hierarchy", "=", "new", "ArrayList", "<", "Class", "<", "?", ">", ">", ...
Returns the class hierarchy of the given type, from bottom to top, starting with the given class itself. Interfaces are not included. @param clazz the class of interest @return the class hierarchy of the given class
[ "Returns", "the", "class", "hierarchy", "of", "the", "given", "type", "from", "bottom", "to", "top", "starting", "with", "the", "given", "class", "itself", ".", "Interfaces", "are", "not", "included", "." ]
9ea971df7c27277029006a6f748d8272fb1d69d2
https://github.com/hibernate/hibernate-ogm/blob/9ea971df7c27277029006a6f748d8272fb1d69d2/core/src/main/java/org/hibernate/ogm/options/navigation/impl/OptionsContextImpl.java#L153-L161
train
hibernate/hibernate-ogm
infinispan-embedded/src/main/java/org/hibernate/ogm/datastore/infinispan/persistencestrategy/impl/PersistenceStrategy.java
PersistenceStrategy.getInstance
public static PersistenceStrategy<?, ?, ?> getInstance( CacheMappingType cacheMapping, EmbeddedCacheManager externalCacheManager, URL configurationUrl, JtaPlatform jtaPlatform, Set<EntityKeyMetadata> entityTypes, Set<AssociationKeyMetadata> associationTypes, Set<IdSourceKeyMetadata> idSourceTypes ) { if ( cacheMapping == CacheMappingType.CACHE_PER_KIND ) { return getPerKindStrategy( externalCacheManager, configurationUrl, jtaPlatform ); } else { return getPerTableStrategy( externalCacheManager, configurationUrl, jtaPlatform, entityTypes, associationTypes, idSourceTypes ); } }
java
public static PersistenceStrategy<?, ?, ?> getInstance( CacheMappingType cacheMapping, EmbeddedCacheManager externalCacheManager, URL configurationUrl, JtaPlatform jtaPlatform, Set<EntityKeyMetadata> entityTypes, Set<AssociationKeyMetadata> associationTypes, Set<IdSourceKeyMetadata> idSourceTypes ) { if ( cacheMapping == CacheMappingType.CACHE_PER_KIND ) { return getPerKindStrategy( externalCacheManager, configurationUrl, jtaPlatform ); } else { return getPerTableStrategy( externalCacheManager, configurationUrl, jtaPlatform, entityTypes, associationTypes, idSourceTypes ); } }
[ "public", "static", "PersistenceStrategy", "<", "?", ",", "?", ",", "?", ">", "getInstance", "(", "CacheMappingType", "cacheMapping", ",", "EmbeddedCacheManager", "externalCacheManager", ",", "URL", "configurationUrl", ",", "JtaPlatform", "jtaPlatform", ",", "Set", ...
Returns a persistence strategy based on the passed configuration. @param cacheMapping the selected {@link org.hibernate.ogm.datastore.keyvalue.options.CacheMappingType} @param externalCacheManager the infinispan cache manager @param configurationUrl the location of the configuration file @param jtaPlatform the {@link JtaPlatform} @param entityTypes the meta-data of the entities @param associationTypes the meta-data of the associations @param idSourceTypes the meta-data of the id generators @return the persistence strategy
[ "Returns", "a", "persistence", "strategy", "based", "on", "the", "passed", "configuration", "." ]
9ea971df7c27277029006a6f748d8272fb1d69d2
https://github.com/hibernate/hibernate-ogm/blob/9ea971df7c27277029006a6f748d8272fb1d69d2/infinispan-embedded/src/main/java/org/hibernate/ogm/datastore/infinispan/persistencestrategy/impl/PersistenceStrategy.java#L61-L87
train
hibernate/hibernate-ogm
core/src/main/java/org/hibernate/ogm/service/impl/DefaultSchemaInitializationContext.java
DefaultSchemaInitializationContext.getPersistentGenerators
private Iterable<PersistentNoSqlIdentifierGenerator> getPersistentGenerators() { Map<String, EntityPersister> entityPersisters = factory.getMetamodel().entityPersisters(); Set<PersistentNoSqlIdentifierGenerator> persistentGenerators = new HashSet<PersistentNoSqlIdentifierGenerator>( entityPersisters.size() ); for ( EntityPersister persister : entityPersisters.values() ) { if ( persister.getIdentifierGenerator() instanceof PersistentNoSqlIdentifierGenerator ) { persistentGenerators.add( (PersistentNoSqlIdentifierGenerator) persister.getIdentifierGenerator() ); } } return persistentGenerators; }
java
private Iterable<PersistentNoSqlIdentifierGenerator> getPersistentGenerators() { Map<String, EntityPersister> entityPersisters = factory.getMetamodel().entityPersisters(); Set<PersistentNoSqlIdentifierGenerator> persistentGenerators = new HashSet<PersistentNoSqlIdentifierGenerator>( entityPersisters.size() ); for ( EntityPersister persister : entityPersisters.values() ) { if ( persister.getIdentifierGenerator() instanceof PersistentNoSqlIdentifierGenerator ) { persistentGenerators.add( (PersistentNoSqlIdentifierGenerator) persister.getIdentifierGenerator() ); } } return persistentGenerators; }
[ "private", "Iterable", "<", "PersistentNoSqlIdentifierGenerator", ">", "getPersistentGenerators", "(", ")", "{", "Map", "<", "String", ",", "EntityPersister", ">", "entityPersisters", "=", "factory", ".", "getMetamodel", "(", ")", ".", "entityPersisters", "(", ")", ...
Returns all the persistent id generators which potentially require the creation of an object in the schema.
[ "Returns", "all", "the", "persistent", "id", "generators", "which", "potentially", "require", "the", "creation", "of", "an", "object", "in", "the", "schema", "." ]
9ea971df7c27277029006a6f748d8272fb1d69d2
https://github.com/hibernate/hibernate-ogm/blob/9ea971df7c27277029006a6f748d8272fb1d69d2/core/src/main/java/org/hibernate/ogm/service/impl/DefaultSchemaInitializationContext.java#L105-L116
train
hibernate/hibernate-ogm
neo4j/src/main/java/org/hibernate/ogm/datastore/neo4j/embedded/dialect/impl/EmbeddedNeo4jAssociationQueries.java
EmbeddedNeo4jAssociationQueries.createRelationshipForEmbeddedAssociation
public Relationship createRelationshipForEmbeddedAssociation(GraphDatabaseService executionEngine, AssociationKey associationKey, EntityKey embeddedKey) { String query = initCreateEmbeddedAssociationQuery( associationKey, embeddedKey ); Object[] queryValues = createRelationshipForEmbeddedQueryValues( associationKey, embeddedKey ); return executeQuery( executionEngine, query, queryValues ); }
java
public Relationship createRelationshipForEmbeddedAssociation(GraphDatabaseService executionEngine, AssociationKey associationKey, EntityKey embeddedKey) { String query = initCreateEmbeddedAssociationQuery( associationKey, embeddedKey ); Object[] queryValues = createRelationshipForEmbeddedQueryValues( associationKey, embeddedKey ); return executeQuery( executionEngine, query, queryValues ); }
[ "public", "Relationship", "createRelationshipForEmbeddedAssociation", "(", "GraphDatabaseService", "executionEngine", ",", "AssociationKey", "associationKey", ",", "EntityKey", "embeddedKey", ")", "{", "String", "query", "=", "initCreateEmbeddedAssociationQuery", "(", "associat...
Give an embedded association, creates all the nodes and relationships required to represent it. It assumes that the entity node containing the association already exists in the db. @param executionEngine the {@link GraphDatabaseService} to run the query @param associationKey the {@link AssociationKey} identifying the association @param embeddedKey the {@link EntityKey} identifying the embedded component @return the created {@link Relationship} that represents the association
[ "Give", "an", "embedded", "association", "creates", "all", "the", "nodes", "and", "relationships", "required", "to", "represent", "it", ".", "It", "assumes", "that", "the", "entity", "node", "containing", "the", "association", "already", "exists", "in", "the", ...
9ea971df7c27277029006a6f748d8272fb1d69d2
https://github.com/hibernate/hibernate-ogm/blob/9ea971df7c27277029006a6f748d8272fb1d69d2/neo4j/src/main/java/org/hibernate/ogm/datastore/neo4j/embedded/dialect/impl/EmbeddedNeo4jAssociationQueries.java#L136-L140
train
hibernate/hibernate-ogm
core/src/main/java/org/hibernate/ogm/persister/impl/OgmCollectionPersister.java
OgmCollectionPersister.createAndPutAssociationRowForInsert
private RowKeyAndTuple createAndPutAssociationRowForInsert(Serializable key, PersistentCollection collection, AssociationPersister associationPersister, SharedSessionContractImplementor session, int i, Object entry) { RowKeyBuilder rowKeyBuilder = initializeRowKeyBuilder(); Tuple associationRow = new Tuple(); // the collection has a surrogate key (see @CollectionId) if ( hasIdentifier ) { final Object identifier = collection.getIdentifier( entry, i ); String[] names = { getIdentifierColumnName() }; identifierGridType.nullSafeSet( associationRow, identifier, names, session ); } getKeyGridType().nullSafeSet( associationRow, key, getKeyColumnNames(), session ); // No need to write to where as we don't do where clauses in OGM :) if ( hasIndex ) { Object index = collection.getIndex( entry, i, this ); indexGridType.nullSafeSet( associationRow, incrementIndexByBase( index ), getIndexColumnNames(), session ); } // columns of referenced key final Object element = collection.getElement( entry ); getElementGridType().nullSafeSet( associationRow, element, getElementColumnNames(), session ); RowKeyAndTuple result = new RowKeyAndTuple(); result.key = rowKeyBuilder.values( associationRow ).build(); result.tuple = associationRow; associationPersister.getAssociation().put( result.key, result.tuple ); return result; }
java
private RowKeyAndTuple createAndPutAssociationRowForInsert(Serializable key, PersistentCollection collection, AssociationPersister associationPersister, SharedSessionContractImplementor session, int i, Object entry) { RowKeyBuilder rowKeyBuilder = initializeRowKeyBuilder(); Tuple associationRow = new Tuple(); // the collection has a surrogate key (see @CollectionId) if ( hasIdentifier ) { final Object identifier = collection.getIdentifier( entry, i ); String[] names = { getIdentifierColumnName() }; identifierGridType.nullSafeSet( associationRow, identifier, names, session ); } getKeyGridType().nullSafeSet( associationRow, key, getKeyColumnNames(), session ); // No need to write to where as we don't do where clauses in OGM :) if ( hasIndex ) { Object index = collection.getIndex( entry, i, this ); indexGridType.nullSafeSet( associationRow, incrementIndexByBase( index ), getIndexColumnNames(), session ); } // columns of referenced key final Object element = collection.getElement( entry ); getElementGridType().nullSafeSet( associationRow, element, getElementColumnNames(), session ); RowKeyAndTuple result = new RowKeyAndTuple(); result.key = rowKeyBuilder.values( associationRow ).build(); result.tuple = associationRow; associationPersister.getAssociation().put( result.key, result.tuple ); return result; }
[ "private", "RowKeyAndTuple", "createAndPutAssociationRowForInsert", "(", "Serializable", "key", ",", "PersistentCollection", "collection", ",", "AssociationPersister", "associationPersister", ",", "SharedSessionContractImplementor", "session", ",", "int", "i", ",", "Object", ...
Creates an association row representing the given entry and adds it to the association managed by the given persister.
[ "Creates", "an", "association", "row", "representing", "the", "given", "entry", "and", "adds", "it", "to", "the", "association", "managed", "by", "the", "given", "persister", "." ]
9ea971df7c27277029006a6f748d8272fb1d69d2
https://github.com/hibernate/hibernate-ogm/blob/9ea971df7c27277029006a6f748d8272fb1d69d2/core/src/main/java/org/hibernate/ogm/persister/impl/OgmCollectionPersister.java#L384-L414
train
hibernate/hibernate-ogm
core/src/main/java/org/hibernate/ogm/persister/impl/OgmCollectionPersister.java
OgmCollectionPersister.doProcessQueuedOps
@Override protected void doProcessQueuedOps(PersistentCollection collection, Serializable key, int nextIndex, SharedSessionContractImplementor session) throws HibernateException { // nothing to do }
java
@Override protected void doProcessQueuedOps(PersistentCollection collection, Serializable key, int nextIndex, SharedSessionContractImplementor session) throws HibernateException { // nothing to do }
[ "@", "Override", "protected", "void", "doProcessQueuedOps", "(", "PersistentCollection", "collection", ",", "Serializable", "key", ",", "int", "nextIndex", ",", "SharedSessionContractImplementor", "session", ")", "throws", "HibernateException", "{", "// nothing to do", "}...
once we're on ORM 5
[ "once", "we", "re", "on", "ORM", "5" ]
9ea971df7c27277029006a6f748d8272fb1d69d2
https://github.com/hibernate/hibernate-ogm/blob/9ea971df7c27277029006a6f748d8272fb1d69d2/core/src/main/java/org/hibernate/ogm/persister/impl/OgmCollectionPersister.java#L834-L838
train
hibernate/hibernate-ogm
neo4j/src/main/java/org/hibernate/ogm/datastore/neo4j/query/parsing/impl/Neo4jPropertyHelper.java
Neo4jPropertyHelper.isIdProperty
public boolean isIdProperty(OgmEntityPersister persister, List<String> namesWithoutAlias) { String join = StringHelper.join( namesWithoutAlias, "." ); Type propertyType = persister.getPropertyType( namesWithoutAlias.get( 0 ) ); String[] identifierColumnNames = persister.getIdentifierColumnNames(); if ( propertyType.isComponentType() ) { String[] embeddedColumnNames = persister.getPropertyColumnNames( join ); for ( String embeddedColumn : embeddedColumnNames ) { if ( !ArrayHelper.contains( identifierColumnNames, embeddedColumn ) ) { return false; } } return true; } return ArrayHelper.contains( identifierColumnNames, join ); }
java
public boolean isIdProperty(OgmEntityPersister persister, List<String> namesWithoutAlias) { String join = StringHelper.join( namesWithoutAlias, "." ); Type propertyType = persister.getPropertyType( namesWithoutAlias.get( 0 ) ); String[] identifierColumnNames = persister.getIdentifierColumnNames(); if ( propertyType.isComponentType() ) { String[] embeddedColumnNames = persister.getPropertyColumnNames( join ); for ( String embeddedColumn : embeddedColumnNames ) { if ( !ArrayHelper.contains( identifierColumnNames, embeddedColumn ) ) { return false; } } return true; } return ArrayHelper.contains( identifierColumnNames, join ); }
[ "public", "boolean", "isIdProperty", "(", "OgmEntityPersister", "persister", ",", "List", "<", "String", ">", "namesWithoutAlias", ")", "{", "String", "join", "=", "StringHelper", ".", "join", "(", "namesWithoutAlias", ",", "\".\"", ")", ";", "Type", "propertyTy...
Check if the property is part of the identifier of the entity. @param persister the {@link OgmEntityPersister} of the entity with the property @param namesWithoutAlias the path to the property with all the aliases resolved @return {@code true} if the property is part of the id, {@code false} otherwise.
[ "Check", "if", "the", "property", "is", "part", "of", "the", "identifier", "of", "the", "entity", "." ]
9ea971df7c27277029006a6f748d8272fb1d69d2
https://github.com/hibernate/hibernate-ogm/blob/9ea971df7c27277029006a6f748d8272fb1d69d2/neo4j/src/main/java/org/hibernate/ogm/datastore/neo4j/query/parsing/impl/Neo4jPropertyHelper.java#L164-L178
train
hibernate/hibernate-ogm
infinispan-remote/src/main/java/org/hibernate/ogm/datastore/infinispanremote/impl/protobuf/schema/SchemaDefinitions.java
SchemaDefinitions.deploySchema
public void deploySchema(String generatedProtobufName, RemoteCache<String, String> protobufCache, SchemaCapture schemaCapture, SchemaOverride schemaOverrideService, URL schemaOverrideResource) { // user defined schema if ( schemaOverrideService != null || schemaOverrideResource != null ) { cachedSchema = new SchemaValidator( this, schemaOverrideService, schemaOverrideResource, generatedProtobufName ).provideSchema(); } // or generate them generateProtoschema(); try { protobufCache.put( generatedProtobufName, cachedSchema ); String errors = protobufCache.get( generatedProtobufName + ".errors" ); if ( errors != null ) { throw LOG.errorAtSchemaDeploy( generatedProtobufName, errors ); } LOG.successfulSchemaDeploy( generatedProtobufName ); } catch (HotRodClientException hrce) { throw LOG.errorAtSchemaDeploy( generatedProtobufName, hrce ); } if ( schemaCapture != null ) { schemaCapture.put( generatedProtobufName, cachedSchema ); } }
java
public void deploySchema(String generatedProtobufName, RemoteCache<String, String> protobufCache, SchemaCapture schemaCapture, SchemaOverride schemaOverrideService, URL schemaOverrideResource) { // user defined schema if ( schemaOverrideService != null || schemaOverrideResource != null ) { cachedSchema = new SchemaValidator( this, schemaOverrideService, schemaOverrideResource, generatedProtobufName ).provideSchema(); } // or generate them generateProtoschema(); try { protobufCache.put( generatedProtobufName, cachedSchema ); String errors = protobufCache.get( generatedProtobufName + ".errors" ); if ( errors != null ) { throw LOG.errorAtSchemaDeploy( generatedProtobufName, errors ); } LOG.successfulSchemaDeploy( generatedProtobufName ); } catch (HotRodClientException hrce) { throw LOG.errorAtSchemaDeploy( generatedProtobufName, hrce ); } if ( schemaCapture != null ) { schemaCapture.put( generatedProtobufName, cachedSchema ); } }
[ "public", "void", "deploySchema", "(", "String", "generatedProtobufName", ",", "RemoteCache", "<", "String", ",", "String", ">", "protobufCache", ",", "SchemaCapture", "schemaCapture", ",", "SchemaOverride", "schemaOverrideService", ",", "URL", "schemaOverrideResource", ...
Typically this is transparently handled by using the Protostream codecs but be aware of it when bypassing Protostream.
[ "Typically", "this", "is", "transparently", "handled", "by", "using", "the", "Protostream", "codecs", "but", "be", "aware", "of", "it", "when", "bypassing", "Protostream", "." ]
9ea971df7c27277029006a6f748d8272fb1d69d2
https://github.com/hibernate/hibernate-ogm/blob/9ea971df7c27277029006a6f748d8272fb1d69d2/infinispan-remote/src/main/java/org/hibernate/ogm/datastore/infinispanremote/impl/protobuf/schema/SchemaDefinitions.java#L54-L78
train
JetBrains/xodus
compress/src/main/java/jetbrains/exodus/util/CompressBackupUtil.java
CompressBackupUtil.archiveFile
public static void archiveFile(@NotNull final ArchiveOutputStream out, @NotNull final VirtualFileDescriptor source, final long fileSize) throws IOException { if (!source.hasContent()) { throw new IllegalArgumentException("Provided source is not a file: " + source.getPath()); } //noinspection ChainOfInstanceofChecks if (out instanceof TarArchiveOutputStream) { final TarArchiveEntry entry = new TarArchiveEntry(source.getPath() + source.getName()); entry.setSize(fileSize); entry.setModTime(source.getTimeStamp()); out.putArchiveEntry(entry); } else if (out instanceof ZipArchiveOutputStream) { final ZipArchiveEntry entry = new ZipArchiveEntry(source.getPath() + source.getName()); entry.setSize(fileSize); entry.setTime(source.getTimeStamp()); out.putArchiveEntry(entry); } else { throw new IOException("Unknown archive output stream"); } final InputStream input = source.getInputStream(); try { IOUtil.copyStreams(input, fileSize, out, IOUtil.BUFFER_ALLOCATOR); } finally { if (source.shouldCloseStream()) { input.close(); } } out.closeArchiveEntry(); }
java
public static void archiveFile(@NotNull final ArchiveOutputStream out, @NotNull final VirtualFileDescriptor source, final long fileSize) throws IOException { if (!source.hasContent()) { throw new IllegalArgumentException("Provided source is not a file: " + source.getPath()); } //noinspection ChainOfInstanceofChecks if (out instanceof TarArchiveOutputStream) { final TarArchiveEntry entry = new TarArchiveEntry(source.getPath() + source.getName()); entry.setSize(fileSize); entry.setModTime(source.getTimeStamp()); out.putArchiveEntry(entry); } else if (out instanceof ZipArchiveOutputStream) { final ZipArchiveEntry entry = new ZipArchiveEntry(source.getPath() + source.getName()); entry.setSize(fileSize); entry.setTime(source.getTimeStamp()); out.putArchiveEntry(entry); } else { throw new IOException("Unknown archive output stream"); } final InputStream input = source.getInputStream(); try { IOUtil.copyStreams(input, fileSize, out, IOUtil.BUFFER_ALLOCATOR); } finally { if (source.shouldCloseStream()) { input.close(); } } out.closeArchiveEntry(); }
[ "public", "static", "void", "archiveFile", "(", "@", "NotNull", "final", "ArchiveOutputStream", "out", ",", "@", "NotNull", "final", "VirtualFileDescriptor", "source", ",", "final", "long", "fileSize", ")", "throws", "IOException", "{", "if", "(", "!", "source",...
Adds the file to the tar archive represented by output stream. It's caller's responsibility to close output stream properly. @param out target archive. @param source file to be added. @param fileSize size of the file (which is known in most cases). @throws IOException in case of any issues with underlying store.
[ "Adds", "the", "file", "to", "the", "tar", "archive", "represented", "by", "output", "stream", ".", "It", "s", "caller", "s", "responsibility", "to", "close", "output", "stream", "properly", "." ]
7b3476c4e81db66f9c7529148c761605cc8eea6d
https://github.com/JetBrains/xodus/blob/7b3476c4e81db66f9c7529148c761605cc8eea6d/compress/src/main/java/jetbrains/exodus/util/CompressBackupUtil.java#L226-L255
train
JetBrains/xodus
environment/src/main/java/jetbrains/exodus/tree/patricia/MutableNode.java
MutableNode.setRightChild
void setRightChild(final byte b, @NotNull final MutableNode child) { final ChildReference right = children.getRight(); if (right == null || (right.firstByte & 0xff) != (b & 0xff)) { throw new IllegalArgumentException(); } children.setAt(children.size() - 1, new ChildReferenceMutable(b, child)); }
java
void setRightChild(final byte b, @NotNull final MutableNode child) { final ChildReference right = children.getRight(); if (right == null || (right.firstByte & 0xff) != (b & 0xff)) { throw new IllegalArgumentException(); } children.setAt(children.size() - 1, new ChildReferenceMutable(b, child)); }
[ "void", "setRightChild", "(", "final", "byte", "b", ",", "@", "NotNull", "final", "MutableNode", "child", ")", "{", "final", "ChildReference", "right", "=", "children", ".", "getRight", "(", ")", ";", "if", "(", "right", "==", "null", "||", "(", "right",...
Sets in-place the right child with the same first byte. @param b next byte of child suffix. @param child child node.
[ "Sets", "in", "-", "place", "the", "right", "child", "with", "the", "same", "first", "byte", "." ]
7b3476c4e81db66f9c7529148c761605cc8eea6d
https://github.com/JetBrains/xodus/blob/7b3476c4e81db66f9c7529148c761605cc8eea6d/environment/src/main/java/jetbrains/exodus/tree/patricia/MutableNode.java#L190-L196
train
JetBrains/xodus
environment/src/main/java/jetbrains/exodus/tree/btree/BTreeBalancePolicy.java
BTreeBalancePolicy.needMerge
public boolean needMerge(@NotNull final BasePage left, @NotNull final BasePage right) { final int leftSize = left.getSize(); final int rightSize = right.getSize(); return leftSize == 0 || rightSize == 0 || leftSize + rightSize <= (((isDupTree(left) ? getDupPageMaxSize() : getPageMaxSize()) * 7) >> 3); }
java
public boolean needMerge(@NotNull final BasePage left, @NotNull final BasePage right) { final int leftSize = left.getSize(); final int rightSize = right.getSize(); return leftSize == 0 || rightSize == 0 || leftSize + rightSize <= (((isDupTree(left) ? getDupPageMaxSize() : getPageMaxSize()) * 7) >> 3); }
[ "public", "boolean", "needMerge", "(", "@", "NotNull", "final", "BasePage", "left", ",", "@", "NotNull", "final", "BasePage", "right", ")", "{", "final", "int", "leftSize", "=", "left", ".", "getSize", "(", ")", ";", "final", "int", "rightSize", "=", "ri...
Is invoked on the leaf deletion only. @param left left page. @param right right page. @return true if the left page ought to be merged with the right one.
[ "Is", "invoked", "on", "the", "leaf", "deletion", "only", "." ]
7b3476c4e81db66f9c7529148c761605cc8eea6d
https://github.com/JetBrains/xodus/blob/7b3476c4e81db66f9c7529148c761605cc8eea6d/environment/src/main/java/jetbrains/exodus/tree/btree/BTreeBalancePolicy.java#L70-L75
train
JetBrains/xodus
environment/src/main/java/jetbrains/exodus/env/MetaTreeImpl.java
MetaTreeImpl.saveMetaTree
@NotNull static MetaTreeImpl.Proto saveMetaTree(@NotNull final ITreeMutable metaTree, @NotNull final EnvironmentImpl env, @NotNull final ExpiredLoggableCollection expired) { final long newMetaTreeAddress = metaTree.save(); final Log log = env.getLog(); final int lastStructureId = env.getLastStructureId(); final long dbRootAddress = log.write(DatabaseRoot.DATABASE_ROOT_TYPE, Loggable.NO_STRUCTURE_ID, DatabaseRoot.asByteIterable(newMetaTreeAddress, lastStructureId)); expired.add(dbRootAddress, (int) (log.getWrittenHighAddress() - dbRootAddress)); return new MetaTreeImpl.Proto(newMetaTreeAddress, dbRootAddress); }
java
@NotNull static MetaTreeImpl.Proto saveMetaTree(@NotNull final ITreeMutable metaTree, @NotNull final EnvironmentImpl env, @NotNull final ExpiredLoggableCollection expired) { final long newMetaTreeAddress = metaTree.save(); final Log log = env.getLog(); final int lastStructureId = env.getLastStructureId(); final long dbRootAddress = log.write(DatabaseRoot.DATABASE_ROOT_TYPE, Loggable.NO_STRUCTURE_ID, DatabaseRoot.asByteIterable(newMetaTreeAddress, lastStructureId)); expired.add(dbRootAddress, (int) (log.getWrittenHighAddress() - dbRootAddress)); return new MetaTreeImpl.Proto(newMetaTreeAddress, dbRootAddress); }
[ "@", "NotNull", "static", "MetaTreeImpl", ".", "Proto", "saveMetaTree", "(", "@", "NotNull", "final", "ITreeMutable", "metaTree", ",", "@", "NotNull", "final", "EnvironmentImpl", "env", ",", "@", "NotNull", "final", "ExpiredLoggableCollection", "expired", ")", "{"...
Saves meta tree, writes database root and flushes the log. @param metaTree mutable meta tree @param env enclosing environment @param expired expired loggables (database root to be added) @return database root loggable which is read again from the log.
[ "Saves", "meta", "tree", "writes", "database", "root", "and", "flushes", "the", "log", "." ]
7b3476c4e81db66f9c7529148c761605cc8eea6d
https://github.com/JetBrains/xodus/blob/7b3476c4e81db66f9c7529148c761605cc8eea6d/environment/src/main/java/jetbrains/exodus/env/MetaTreeImpl.java#L180-L191
train
JetBrains/xodus
entity-store/src/main/java/jetbrains/exodus/entitystore/PersistentEntityStoreImpl.java
PersistentEntityStoreImpl.clearProperties
@SuppressWarnings({"OverlyLongMethod"}) public void clearProperties(@NotNull final PersistentStoreTransaction txn, @NotNull final Entity entity) { final Transaction envTxn = txn.getEnvironmentTransaction(); final PersistentEntityId id = (PersistentEntityId) entity.getId(); final int entityTypeId = id.getTypeId(); final long entityLocalId = id.getLocalId(); final PropertiesTable properties = getPropertiesTable(txn, entityTypeId); final PropertyKey propertyKey = new PropertyKey(entityLocalId, 0); try (Cursor cursor = getPrimaryPropertyIndexCursor(txn, properties)) { for (boolean success = cursor.getSearchKeyRange(PropertyKey.propertyKeyToEntry(propertyKey)) != null; success; success = cursor.getNext()) { ByteIterable keyEntry = cursor.getKey(); final PropertyKey key = PropertyKey.entryToPropertyKey(keyEntry); if (key.getEntityLocalId() != entityLocalId) { break; } final int propertyId = key.getPropertyId(); final ByteIterable value = cursor.getValue(); final PropertyValue propValue = propertyTypes.entryToPropertyValue(value); txn.propertyChanged(id, propertyId, propValue.getData(), null); properties.deleteNoFail(txn, entityLocalId, value, propertyId, propValue.getType()); } } }
java
@SuppressWarnings({"OverlyLongMethod"}) public void clearProperties(@NotNull final PersistentStoreTransaction txn, @NotNull final Entity entity) { final Transaction envTxn = txn.getEnvironmentTransaction(); final PersistentEntityId id = (PersistentEntityId) entity.getId(); final int entityTypeId = id.getTypeId(); final long entityLocalId = id.getLocalId(); final PropertiesTable properties = getPropertiesTable(txn, entityTypeId); final PropertyKey propertyKey = new PropertyKey(entityLocalId, 0); try (Cursor cursor = getPrimaryPropertyIndexCursor(txn, properties)) { for (boolean success = cursor.getSearchKeyRange(PropertyKey.propertyKeyToEntry(propertyKey)) != null; success; success = cursor.getNext()) { ByteIterable keyEntry = cursor.getKey(); final PropertyKey key = PropertyKey.entryToPropertyKey(keyEntry); if (key.getEntityLocalId() != entityLocalId) { break; } final int propertyId = key.getPropertyId(); final ByteIterable value = cursor.getValue(); final PropertyValue propValue = propertyTypes.entryToPropertyValue(value); txn.propertyChanged(id, propertyId, propValue.getData(), null); properties.deleteNoFail(txn, entityLocalId, value, propertyId, propValue.getType()); } } }
[ "@", "SuppressWarnings", "(", "{", "\"OverlyLongMethod\"", "}", ")", "public", "void", "clearProperties", "(", "@", "NotNull", "final", "PersistentStoreTransaction", "txn", ",", "@", "NotNull", "final", "Entity", "entity", ")", "{", "final", "Transaction", "envTxn...
Clears all properties of specified entity. @param entity to clear.
[ "Clears", "all", "properties", "of", "specified", "entity", "." ]
7b3476c4e81db66f9c7529148c761605cc8eea6d
https://github.com/JetBrains/xodus/blob/7b3476c4e81db66f9c7529148c761605cc8eea6d/entity-store/src/main/java/jetbrains/exodus/entitystore/PersistentEntityStoreImpl.java#L967-L990
train
JetBrains/xodus
entity-store/src/main/java/jetbrains/exodus/entitystore/PersistentEntityStoreImpl.java
PersistentEntityStoreImpl.deleteEntity
boolean deleteEntity(@NotNull final PersistentStoreTransaction txn, @NotNull final PersistentEntity entity) { clearProperties(txn, entity); clearBlobs(txn, entity); deleteLinks(txn, entity); final PersistentEntityId id = entity.getId(); final int entityTypeId = id.getTypeId(); final long entityLocalId = id.getLocalId(); final ByteIterable key = LongBinding.longToCompressedEntry(entityLocalId); if (config.isDebugSearchForIncomingLinksOnDelete()) { // search for incoming links final List<String> allLinkNames = getAllLinkNames(txn); for (final String entityType : txn.getEntityTypes()) { for (final String linkName : allLinkNames) { //noinspection LoopStatementThatDoesntLoop for (final Entity referrer : txn.findLinks(entityType, entity, linkName)) { throw new EntityStoreException(entity + " is about to be deleted, but it is referenced by " + referrer + ", link name: " + linkName); } } } } if (getEntitiesTable(txn, entityTypeId).delete(txn.getEnvironmentTransaction(), key)) { txn.entityDeleted(id); return true; } return false; }
java
boolean deleteEntity(@NotNull final PersistentStoreTransaction txn, @NotNull final PersistentEntity entity) { clearProperties(txn, entity); clearBlobs(txn, entity); deleteLinks(txn, entity); final PersistentEntityId id = entity.getId(); final int entityTypeId = id.getTypeId(); final long entityLocalId = id.getLocalId(); final ByteIterable key = LongBinding.longToCompressedEntry(entityLocalId); if (config.isDebugSearchForIncomingLinksOnDelete()) { // search for incoming links final List<String> allLinkNames = getAllLinkNames(txn); for (final String entityType : txn.getEntityTypes()) { for (final String linkName : allLinkNames) { //noinspection LoopStatementThatDoesntLoop for (final Entity referrer : txn.findLinks(entityType, entity, linkName)) { throw new EntityStoreException(entity + " is about to be deleted, but it is referenced by " + referrer + ", link name: " + linkName); } } } } if (getEntitiesTable(txn, entityTypeId).delete(txn.getEnvironmentTransaction(), key)) { txn.entityDeleted(id); return true; } return false; }
[ "boolean", "deleteEntity", "(", "@", "NotNull", "final", "PersistentStoreTransaction", "txn", ",", "@", "NotNull", "final", "PersistentEntity", "entity", ")", "{", "clearProperties", "(", "txn", ",", "entity", ")", ";", "clearBlobs", "(", "txn", ",", "entity", ...
Deletes specified entity clearing all its properties and deleting all its outgoing links. @param entity to delete.
[ "Deletes", "specified", "entity", "clearing", "all", "its", "properties", "and", "deleting", "all", "its", "outgoing", "links", "." ]
7b3476c4e81db66f9c7529148c761605cc8eea6d
https://github.com/JetBrains/xodus/blob/7b3476c4e81db66f9c7529148c761605cc8eea6d/entity-store/src/main/java/jetbrains/exodus/entitystore/PersistentEntityStoreImpl.java#L1510-L1536
train
JetBrains/xodus
entity-store/src/main/java/jetbrains/exodus/entitystore/PersistentEntityStoreImpl.java
PersistentEntityStoreImpl.deleteLinks
private void deleteLinks(@NotNull final PersistentStoreTransaction txn, @NotNull final PersistentEntity entity) { final PersistentEntityId id = entity.getId(); final int entityTypeId = id.getTypeId(); final long entityLocalId = id.getLocalId(); final Transaction envTxn = txn.getEnvironmentTransaction(); final LinksTable links = getLinksTable(txn, entityTypeId); final IntHashSet deletedLinks = new IntHashSet(); try (Cursor cursor = links.getFirstIndexCursor(envTxn)) { for (boolean success = cursor.getSearchKeyRange(PropertyKey.propertyKeyToEntry(new PropertyKey(entityLocalId, 0))) != null; success; success = cursor.getNext()) { final ByteIterable keyEntry = cursor.getKey(); final PropertyKey key = PropertyKey.entryToPropertyKey(keyEntry); if (key.getEntityLocalId() != entityLocalId) { break; } final ByteIterable valueEntry = cursor.getValue(); if (links.delete(envTxn, keyEntry, valueEntry)) { int linkId = key.getPropertyId(); if (getLinkName(txn, linkId) != null) { deletedLinks.add(linkId); final LinkValue linkValue = LinkValue.entryToLinkValue(valueEntry); txn.linkDeleted(entity.getId(), (PersistentEntityId) linkValue.getEntityId(), linkValue.getLinkId()); } } } } for (Integer linkId : deletedLinks) { links.deleteAllIndex(envTxn, linkId, entityLocalId); } }
java
private void deleteLinks(@NotNull final PersistentStoreTransaction txn, @NotNull final PersistentEntity entity) { final PersistentEntityId id = entity.getId(); final int entityTypeId = id.getTypeId(); final long entityLocalId = id.getLocalId(); final Transaction envTxn = txn.getEnvironmentTransaction(); final LinksTable links = getLinksTable(txn, entityTypeId); final IntHashSet deletedLinks = new IntHashSet(); try (Cursor cursor = links.getFirstIndexCursor(envTxn)) { for (boolean success = cursor.getSearchKeyRange(PropertyKey.propertyKeyToEntry(new PropertyKey(entityLocalId, 0))) != null; success; success = cursor.getNext()) { final ByteIterable keyEntry = cursor.getKey(); final PropertyKey key = PropertyKey.entryToPropertyKey(keyEntry); if (key.getEntityLocalId() != entityLocalId) { break; } final ByteIterable valueEntry = cursor.getValue(); if (links.delete(envTxn, keyEntry, valueEntry)) { int linkId = key.getPropertyId(); if (getLinkName(txn, linkId) != null) { deletedLinks.add(linkId); final LinkValue linkValue = LinkValue.entryToLinkValue(valueEntry); txn.linkDeleted(entity.getId(), (PersistentEntityId) linkValue.getEntityId(), linkValue.getLinkId()); } } } } for (Integer linkId : deletedLinks) { links.deleteAllIndex(envTxn, linkId, entityLocalId); } }
[ "private", "void", "deleteLinks", "(", "@", "NotNull", "final", "PersistentStoreTransaction", "txn", ",", "@", "NotNull", "final", "PersistentEntity", "entity", ")", "{", "final", "PersistentEntityId", "id", "=", "entity", ".", "getId", "(", ")", ";", "final", ...
Deletes all outgoing links of specified entity. @param entity the entity.
[ "Deletes", "all", "outgoing", "links", "of", "specified", "entity", "." ]
7b3476c4e81db66f9c7529148c761605cc8eea6d
https://github.com/JetBrains/xodus/blob/7b3476c4e81db66f9c7529148c761605cc8eea6d/entity-store/src/main/java/jetbrains/exodus/entitystore/PersistentEntityStoreImpl.java#L1543-L1572
train