id
int32
0
165k
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
160,700
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", ".", "columnAs", "(", "BaseNeo4jEntityQueries", ".", "ENTITY_ALIAS", ")", ";", "}" ]
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
160,701
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", ".", "execute", "(", "getRemoveEntityQuery", "(", ")", ",", "params", ")", ";", "}" ]
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
160,702
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", ",", "embeddedColumn", ")", ";", "Map", "<", "String", ",", "Object", ">", "params", "=", "params", "(", "ArrayHelper", ".", "concat", "(", "keyValues", ",", "value", ",", "value", ")", ")", ";", "executionEngine", ".", "execute", "(", "query", ",", "params", ")", ";", "}" ]
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
160,703
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", "(", ")", ";", "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", ";", "}" ]
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
160,704
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", "]", ";", "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", ";", "}" ]
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", "-", "directional", "one", "-", "to", "-", "many", "or", "many", "-", "to", "-", "many", "association", "." ]
9ea971df7c27277029006a6f748d8272fb1d69d2
https://github.com/hibernate/hibernate-ogm/blob/9ea971df7c27277029006a6f748d8272fb1d69d2/core/src/main/java/org/hibernate/ogm/persister/impl/BiDirectionalAssociationHelper.java#L41-L89
160,705
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", "(", ")", "||", "!", "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", ";", "}" ]
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
160,706
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", "(", "inverseSidePersister", ".", "getTableName", "(", ")", ")", ";", "if", "(", "!", "isSameTable", ")", "{", "return", "false", ";", "}", "return", "Arrays", ".", "equals", "(", "mainSideJoinable", ".", "getKeyColumnNames", "(", ")", ",", "inverseSidePersister", ".", "getElementColumnNames", "(", ")", ")", ";", "}" ]
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
160,707
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", ")", ";", "}", "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", ")", ";", "}", "}", "}", "}" ]
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
160,708
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", "(", "collectionName", ".", "startsWith", "(", "\"system.\"", ")", ")", "{", "throw", "log", ".", "collectionNameHasInvalidSystemPrefix", "(", "collectionName", ")", ";", "}", "else", "if", "(", "collectionName", ".", "contains", "(", "\"\\u0000\"", ")", ")", "{", "throw", "log", ".", "collectionNameContainsNULCharacter", "(", "collectionName", ")", ";", "}", "else", "if", "(", "collectionName", ".", "contains", "(", "\"$\"", ")", ")", "{", "throw", "log", ".", "collectionNameContainsDollarCharacter", "(", "collectionName", ")", ";", "}", "}" ]
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
160,709
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", "(", "fieldName", ".", "contains", "(", "\"\\u0000\"", ")", ")", "{", "throw", "log", ".", "fieldNameContainsNULCharacter", "(", "fieldName", ")", ";", "}", "}" ]
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
160,710
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", "if", "(", "!", "canGridDialectDoMultiget", ")", "{", "return", "-", "1", ";", "}", "else", "if", "(", "classBatchSize", "!=", "-", "1", ")", "{", "return", "classBatchSize", ";", "}", "else", "if", "(", "configuredDefaultBatchSize", "!=", "-", "1", ")", "{", "return", "configuredDefaultBatchSize", ";", "}", "else", "{", "return", "DEFAULT_MULTIGET_BATCH_SIZE", ";", "}", "}" ]
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
160,711
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", "=", "otherSidePersister", ".", "getPropertyType", "(", "candidate", ")", ";", "if", "(", "candidateType", ".", "isEntityType", "(", ")", "&&", "(", "(", "(", "EntityType", ")", "candidateType", ")", ".", "isOneToOne", "(", ")", "&&", "isOneToOneMatching", "(", "this", ",", "property", ",", "(", "OneToOneType", ")", "candidateType", ")", ")", ")", "{", "return", "candidate", ";", "}", "}", "return", "null", ";", "}" ]
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
160,712
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", ".", "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", ";", "}" ]
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
160,713
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", ")", "{", "throw", "new", "NotSupportedException", "(", "\"OGM-9\"", ",", "\"Lazy properties not supported in OGM\"", ")", ";", "}" ]
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
160,714
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", "(", "\"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", ")", ";", "}", "}" ]
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
160,715
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", "||", "entityMetamodel", ".", "getOptimisticLockStyle", "(", ")", "==", "OptimisticLockStyle", ".", "ALL", ";", "}" ]
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
160,716
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", ")", ".", "resultset", "(", "resultset", ")", ".", "session", "(", "session", ")", ".", "tableIndex", "(", "tableIndex", ")", ".", "propertyMightRequireInverseAssociationManagement", "(", "propertyMightBeMainSideOfBidirectionalAssociation", ")", ".", "removeNavigationalInformationFromInverseSide", "(", ")", ";", "}" ]
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
160,717
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", ")", ".", "resultset", "(", "resultset", ")", ".", "session", "(", "session", ")", ".", "tableIndex", "(", "tableIndex", ")", ".", "propertyMightRequireInverseAssociationManagement", "(", "propertyMightBeMainSideOfBidirectionalAssociation", ")", ".", "addNavigationalInformationForInverseSide", "(", ")", ";", "}" ]
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
160,718
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", "=", "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", "]", ")", ";", "}", "}", "}" ]
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
160,719
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", "&&", "timingsMatch", "(", "valueGeneration", ".", "getGenerationTiming", "(", ")", ",", "matchTiming", ")", ";", "}" ]
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
160,720
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", "=", "resultTypes", "[", "0", "]", ".", "getReturnedClass", "(", ")", ";", "TupleBasedEntityLoader", "loader", "=", "getLoader", "(", "session", ",", "returnedClass", ")", ";", "OgmLoadingContext", "ogmLoadingContext", "=", "new", "OgmLoadingContext", "(", ")", ";", "ogmLoadingContext", ".", "setTuples", "(", "getTuplesAsList", "(", "tuples", ")", ")", ";", "return", "loader", ".", "loadEntitiesFromTuples", "(", "session", ",", "LockOptions", ".", "NONE", ",", "ogmLoadingContext", ")", ";", "}" ]
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
160,721
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", "(", "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", "}" ]
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
160,722
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", ")", "{", "backend", ".", "optimize", "(", "targetedTypes", ")", ";", "}", "backend", ".", "flush", "(", "targetedTypes", ")", ";", "}" ]
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
160,723
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", "(", "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", ")", ";", "}", "}", "}" ]
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
160,724
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", ")", "{", "return", "Collections", ".", "emptySet", "(", ")", ";", "}", "else", "{", "Set", "<", "T", ">", "set", "=", "new", "HashSet", "<", "T", ">", "(", "getInitialCapacityFromExpectedSize", "(", "ts", ".", "length", ")", ")", ";", "Collections", ".", "addAll", "(", "set", ",", "ts", ")", ";", "return", "Collections", ".", "unmodifiableSet", "(", "set", ")", ";", "}", "}" ]
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
160,725
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", ":", "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", ")", ";", "}", "}" ]
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
160,726
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", ")", "{", "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", ")", ";", "}" ]
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
160,727
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
160,728
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", "=", "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", ";", "}" ]
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
160,729
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", ".", "MILLISECONDS", ",", "new", "LinkedBlockingQueue", "<", "Runnable", ">", "(", "queueSize", ")", ",", "new", "SearchThreadFactory", "(", "groupname", ")", ",", "new", "BlockPolicy", "(", ")", ")", ";", "}" ]
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
160,730
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", "(", ")", ";", "if", "(", "version", "!=", "supportedVersion", ")", "{", "throw", "LOG", ".", "unexpectedKeyVersion", "(", "externalizedType", ",", "version", ",", "supportedVersion", ")", ";", "}", "}" ]
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
160,731
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", "<", "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", ";", "}" ]
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
160,732
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", ")", ";", "return", "this", ";", "}" ]
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
160,733
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", ":", "container", ".", "optionValues", ".", "entrySet", "(", ")", ")", "{", "addAll", "(", "entry", ".", "getKey", "(", ")", ",", "entry", ".", "getValue", "(", ")", ".", "build", "(", ")", ")", ";", "}", "}" ]
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
160,734
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", "<", "?", ">", ">", "(", ")", ";", "//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", "(", ")", "]", ")", ")", ";", "}" ]
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
160,735
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", "(", "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", ")", ";", "}", "}" ]
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
160,736
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", "<", "?", ">", ">", "(", "4", ")", ";", "for", "(", "Class", "<", "?", ">", "current", "=", "clazz", ";", "current", "!=", "null", ";", "current", "=", "current", ".", "getSuperclass", "(", ")", ")", "{", "hierarchy", ".", "add", "(", "current", ")", ";", "}", "return", "hierarchy", ";", "}" ]
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
160,737
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", "<", "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", ")", ";", "}", "}" ]
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
160,738
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", "(", ")", ";", "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", ";", "}" ]
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
160,739
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", "(", "associationKey", ",", "embeddedKey", ")", ";", "Object", "[", "]", "queryValues", "=", "createRelationshipForEmbeddedQueryValues", "(", "associationKey", ",", "embeddedKey", ")", ";", "return", "executeQuery", "(", "executionEngine", ",", "query", ",", "queryValues", ")", ";", "}" ]
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", "db", "." ]
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
160,740
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", "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", ";", "}" ]
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
160,741
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
160,742
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", "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", ")", ";", "}" ]
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
160,743
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", ")", "{", "// 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", ")", ";", "}", "}" ]
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
160,744
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", ".", "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", "(", ")", ";", "}" ]
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
160,745
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", ".", "firstByte", "&", "0xff", ")", "!=", "(", "b", "&", "0xff", ")", ")", "{", "throw", "new", "IllegalArgumentException", "(", ")", ";", "}", "children", ".", "setAt", "(", "children", ".", "size", "(", ")", "-", "1", ",", "new", "ChildReferenceMutable", "(", "b", ",", "child", ")", ")", ";", "}" ]
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
160,746
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", "=", "right", ".", "getSize", "(", ")", ";", "return", "leftSize", "==", "0", "||", "rightSize", "==", "0", "||", "leftSize", "+", "rightSize", "<=", "(", "(", "(", "isDupTree", "(", "left", ")", "?", "getDupPageMaxSize", "(", ")", ":", "getPageMaxSize", "(", ")", ")", "*", "7", ")", ">>", "3", ")", ";", "}" ]
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
160,747
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", ")", "{", "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", ")", ";", "}" ]
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
160,748
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", "=", "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", "(", ")", ")", ";", "}", "}", "}" ]
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
160,749
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", ")", ";", "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", ";", "}" ]
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
160,750
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", "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", ")", ";", "}", "}" ]
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
160,751
JetBrains/xodus
entity-store/src/main/java/jetbrains/exodus/entitystore/PersistentEntityStoreImpl.java
PersistentEntityStoreImpl.getEntityTypeId
@Deprecated public int getEntityTypeId(@NotNull final String entityType, final boolean allowCreate) { return getEntityTypeId(txnProvider, entityType, allowCreate); }
java
@Deprecated public int getEntityTypeId(@NotNull final String entityType, final boolean allowCreate) { return getEntityTypeId(txnProvider, entityType, allowCreate); }
[ "@", "Deprecated", "public", "int", "getEntityTypeId", "(", "@", "NotNull", "final", "String", "entityType", ",", "final", "boolean", "allowCreate", ")", "{", "return", "getEntityTypeId", "(", "txnProvider", ",", "entityType", ",", "allowCreate", ")", ";", "}" ]
Gets or creates id of the entity type. @param entityType entity type name. @param allowCreate if set to true and if there is no entity type like entityType, create the new id for the entityType. @return entity type id.
[ "Gets", "or", "creates", "id", "of", "the", "entity", "type", "." ]
7b3476c4e81db66f9c7529148c761605cc8eea6d
https://github.com/JetBrains/xodus/blob/7b3476c4e81db66f9c7529148c761605cc8eea6d/entity-store/src/main/java/jetbrains/exodus/entitystore/PersistentEntityStoreImpl.java#L1587-L1590
160,752
JetBrains/xodus
entity-store/src/main/java/jetbrains/exodus/entitystore/PersistentEntityStoreImpl.java
PersistentEntityStoreImpl.getPropertyId
public int getPropertyId(@NotNull final PersistentStoreTransaction txn, @NotNull final String propertyName, final boolean allowCreate) { return allowCreate ? propertyIds.getOrAllocateId(txn, propertyName) : propertyIds.getId(txn, propertyName); }
java
public int getPropertyId(@NotNull final PersistentStoreTransaction txn, @NotNull final String propertyName, final boolean allowCreate) { return allowCreate ? propertyIds.getOrAllocateId(txn, propertyName) : propertyIds.getId(txn, propertyName); }
[ "public", "int", "getPropertyId", "(", "@", "NotNull", "final", "PersistentStoreTransaction", "txn", ",", "@", "NotNull", "final", "String", "propertyName", ",", "final", "boolean", "allowCreate", ")", "{", "return", "allowCreate", "?", "propertyIds", ".", "getOrAllocateId", "(", "txn", ",", "propertyName", ")", ":", "propertyIds", ".", "getId", "(", "txn", ",", "propertyName", ")", ";", "}" ]
Gets id of a property and creates the new one if necessary. @param txn transaction @param propertyName name of the property. @param allowCreate if set to true and if there is no property named as propertyName, create the new id for the propertyName. @return < 0 if there is no such property and create=false, else id of the property
[ "Gets", "id", "of", "a", "property", "and", "creates", "the", "new", "one", "if", "necessary", "." ]
7b3476c4e81db66f9c7529148c761605cc8eea6d
https://github.com/JetBrains/xodus/blob/7b3476c4e81db66f9c7529148c761605cc8eea6d/entity-store/src/main/java/jetbrains/exodus/entitystore/PersistentEntityStoreImpl.java#L1725-L1727
160,753
JetBrains/xodus
entity-store/src/main/java/jetbrains/exodus/entitystore/PersistentEntityStoreImpl.java
PersistentEntityStoreImpl.getLinkId
public int getLinkId(@NotNull final PersistentStoreTransaction txn, @NotNull final String linkName, final boolean allowCreate) { return allowCreate ? linkIds.getOrAllocateId(txn, linkName) : linkIds.getId(txn, linkName); }
java
public int getLinkId(@NotNull final PersistentStoreTransaction txn, @NotNull final String linkName, final boolean allowCreate) { return allowCreate ? linkIds.getOrAllocateId(txn, linkName) : linkIds.getId(txn, linkName); }
[ "public", "int", "getLinkId", "(", "@", "NotNull", "final", "PersistentStoreTransaction", "txn", ",", "@", "NotNull", "final", "String", "linkName", ",", "final", "boolean", "allowCreate", ")", "{", "return", "allowCreate", "?", "linkIds", ".", "getOrAllocateId", "(", "txn", ",", "linkName", ")", ":", "linkIds", ".", "getId", "(", "txn", ",", "linkName", ")", ";", "}" ]
Gets id of a link and creates the new one if necessary. @param linkName name of the link. @param allowCreate if set to true and if there is no link named as linkName, create the new id for the linkName. @return < 0 if there is no such link and create=false, else id of the link
[ "Gets", "id", "of", "a", "link", "and", "creates", "the", "new", "one", "if", "necessary", "." ]
7b3476c4e81db66f9c7529148c761605cc8eea6d
https://github.com/JetBrains/xodus/blob/7b3476c4e81db66f9c7529148c761605cc8eea6d/entity-store/src/main/java/jetbrains/exodus/entitystore/PersistentEntityStoreImpl.java#L1751-L1753
160,754
JetBrains/xodus
utils/src/main/java/jetbrains/exodus/core/execution/ThreadJobProcessor.java
ThreadJobProcessor.start
@Override public synchronized void start() { if (!started.getAndSet(true)) { finished.set(false); thread.start(); } }
java
@Override public synchronized void start() { if (!started.getAndSet(true)) { finished.set(false); thread.start(); } }
[ "@", "Override", "public", "synchronized", "void", "start", "(", ")", "{", "if", "(", "!", "started", ".", "getAndSet", "(", "true", ")", ")", "{", "finished", ".", "set", "(", "false", ")", ";", "thread", ".", "start", "(", ")", ";", "}", "}" ]
Starts processor thread.
[ "Starts", "processor", "thread", "." ]
7b3476c4e81db66f9c7529148c761605cc8eea6d
https://github.com/JetBrains/xodus/blob/7b3476c4e81db66f9c7529148c761605cc8eea6d/utils/src/main/java/jetbrains/exodus/core/execution/ThreadJobProcessor.java#L53-L59
160,755
JetBrains/xodus
utils/src/main/java/jetbrains/exodus/core/execution/ThreadJobProcessor.java
ThreadJobProcessor.finish
@Override public void finish() { if (started.get() && !finished.getAndSet(true)) { waitUntilFinished(); super.finish(); // recreate thread (don't start) for processor reuse createProcessorThread(); clearQueues(); started.set(false); } }
java
@Override public void finish() { if (started.get() && !finished.getAndSet(true)) { waitUntilFinished(); super.finish(); // recreate thread (don't start) for processor reuse createProcessorThread(); clearQueues(); started.set(false); } }
[ "@", "Override", "public", "void", "finish", "(", ")", "{", "if", "(", "started", ".", "get", "(", ")", "&&", "!", "finished", ".", "getAndSet", "(", "true", ")", ")", "{", "waitUntilFinished", "(", ")", ";", "super", ".", "finish", "(", ")", ";", "// recreate thread (don't start) for processor reuse", "createProcessorThread", "(", ")", ";", "clearQueues", "(", ")", ";", "started", ".", "set", "(", "false", ")", ";", "}", "}" ]
Signals that the processor to finish and waits until it finishes.
[ "Signals", "that", "the", "processor", "to", "finish", "and", "waits", "until", "it", "finishes", "." ]
7b3476c4e81db66f9c7529148c761605cc8eea6d
https://github.com/JetBrains/xodus/blob/7b3476c4e81db66f9c7529148c761605cc8eea6d/utils/src/main/java/jetbrains/exodus/core/execution/ThreadJobProcessor.java#L64-L74
160,756
JetBrains/xodus
environment/src/main/java/jetbrains/exodus/env/ReentrantTransactionDispatcher.java
ReentrantTransactionDispatcher.acquireTransaction
int acquireTransaction(@NotNull final Thread thread) { try (CriticalSection ignored = criticalSection.enter()) { final int currentThreadPermits = getThreadPermitsToAcquire(thread); waitForPermits(thread, currentThreadPermits > 0 ? nestedQueue : regularQueue, 1, currentThreadPermits); } return 1; }
java
int acquireTransaction(@NotNull final Thread thread) { try (CriticalSection ignored = criticalSection.enter()) { final int currentThreadPermits = getThreadPermitsToAcquire(thread); waitForPermits(thread, currentThreadPermits > 0 ? nestedQueue : regularQueue, 1, currentThreadPermits); } return 1; }
[ "int", "acquireTransaction", "(", "@", "NotNull", "final", "Thread", "thread", ")", "{", "try", "(", "CriticalSection", "ignored", "=", "criticalSection", ".", "enter", "(", ")", ")", "{", "final", "int", "currentThreadPermits", "=", "getThreadPermitsToAcquire", "(", "thread", ")", ";", "waitForPermits", "(", "thread", ",", "currentThreadPermits", ">", "0", "?", "nestedQueue", ":", "regularQueue", ",", "1", ",", "currentThreadPermits", ")", ";", "}", "return", "1", ";", "}" ]
Acquire transaction with a single permit in a thread. Transactions are acquired reentrantly, i.e. with respect to transactions already acquired in the thread. @return the number of acquired permits, identically equal to 1.
[ "Acquire", "transaction", "with", "a", "single", "permit", "in", "a", "thread", ".", "Transactions", "are", "acquired", "reentrantly", "i", ".", "e", ".", "with", "respect", "to", "transactions", "already", "acquired", "in", "the", "thread", "." ]
7b3476c4e81db66f9c7529148c761605cc8eea6d
https://github.com/JetBrains/xodus/blob/7b3476c4e81db66f9c7529148c761605cc8eea6d/environment/src/main/java/jetbrains/exodus/env/ReentrantTransactionDispatcher.java#L68-L74
160,757
JetBrains/xodus
environment/src/main/java/jetbrains/exodus/env/ReentrantTransactionDispatcher.java
ReentrantTransactionDispatcher.releaseTransaction
void releaseTransaction(@NotNull final Thread thread, final int permits) { try (CriticalSection ignored = criticalSection.enter()) { int currentThreadPermits = getThreadPermits(thread); if (permits > currentThreadPermits) { throw new ExodusException("Can't release more permits than it was acquired"); } acquiredPermits -= permits; currentThreadPermits -= permits; if (currentThreadPermits == 0) { threadPermits.remove(thread); } else { threadPermits.put(thread, currentThreadPermits); } notifyNextWaiters(); } }
java
void releaseTransaction(@NotNull final Thread thread, final int permits) { try (CriticalSection ignored = criticalSection.enter()) { int currentThreadPermits = getThreadPermits(thread); if (permits > currentThreadPermits) { throw new ExodusException("Can't release more permits than it was acquired"); } acquiredPermits -= permits; currentThreadPermits -= permits; if (currentThreadPermits == 0) { threadPermits.remove(thread); } else { threadPermits.put(thread, currentThreadPermits); } notifyNextWaiters(); } }
[ "void", "releaseTransaction", "(", "@", "NotNull", "final", "Thread", "thread", ",", "final", "int", "permits", ")", "{", "try", "(", "CriticalSection", "ignored", "=", "criticalSection", ".", "enter", "(", ")", ")", "{", "int", "currentThreadPermits", "=", "getThreadPermits", "(", "thread", ")", ";", "if", "(", "permits", ">", "currentThreadPermits", ")", "{", "throw", "new", "ExodusException", "(", "\"Can't release more permits than it was acquired\"", ")", ";", "}", "acquiredPermits", "-=", "permits", ";", "currentThreadPermits", "-=", "permits", ";", "if", "(", "currentThreadPermits", "==", "0", ")", "{", "threadPermits", ".", "remove", "(", "thread", ")", ";", "}", "else", "{", "threadPermits", ".", "put", "(", "thread", ",", "currentThreadPermits", ")", ";", "}", "notifyNextWaiters", "(", ")", ";", "}", "}" ]
Release transaction that was acquired in a thread with specified permits.
[ "Release", "transaction", "that", "was", "acquired", "in", "a", "thread", "with", "specified", "permits", "." ]
7b3476c4e81db66f9c7529148c761605cc8eea6d
https://github.com/JetBrains/xodus/blob/7b3476c4e81db66f9c7529148c761605cc8eea6d/environment/src/main/java/jetbrains/exodus/env/ReentrantTransactionDispatcher.java#L121-L136
160,758
JetBrains/xodus
environment/src/main/java/jetbrains/exodus/env/ReentrantTransactionDispatcher.java
ReentrantTransactionDispatcher.tryAcquireExclusiveTransaction
private int tryAcquireExclusiveTransaction(@NotNull final Thread thread, final int timeout) { long nanos = TimeUnit.MILLISECONDS.toNanos(timeout); try (CriticalSection ignored = criticalSection.enter()) { if (getThreadPermits(thread) > 0) { throw new ExodusException("Exclusive transaction can't be nested"); } final Condition condition = criticalSection.newCondition(); final long currentOrder = acquireOrder++; regularQueue.put(currentOrder, condition); while (acquiredPermits > 0 || regularQueue.firstKey() != currentOrder) { try { nanos = condition.awaitNanos(nanos); if (nanos < 0) { break; } } catch (InterruptedException e) { Thread.currentThread().interrupt(); break; } } if (acquiredPermits == 0 && regularQueue.firstKey() == currentOrder) { regularQueue.pollFirstEntry(); acquiredPermits = availablePermits; threadPermits.put(thread, availablePermits); return availablePermits; } regularQueue.remove(currentOrder); notifyNextWaiters(); } return 0; }
java
private int tryAcquireExclusiveTransaction(@NotNull final Thread thread, final int timeout) { long nanos = TimeUnit.MILLISECONDS.toNanos(timeout); try (CriticalSection ignored = criticalSection.enter()) { if (getThreadPermits(thread) > 0) { throw new ExodusException("Exclusive transaction can't be nested"); } final Condition condition = criticalSection.newCondition(); final long currentOrder = acquireOrder++; regularQueue.put(currentOrder, condition); while (acquiredPermits > 0 || regularQueue.firstKey() != currentOrder) { try { nanos = condition.awaitNanos(nanos); if (nanos < 0) { break; } } catch (InterruptedException e) { Thread.currentThread().interrupt(); break; } } if (acquiredPermits == 0 && regularQueue.firstKey() == currentOrder) { regularQueue.pollFirstEntry(); acquiredPermits = availablePermits; threadPermits.put(thread, availablePermits); return availablePermits; } regularQueue.remove(currentOrder); notifyNextWaiters(); } return 0; }
[ "private", "int", "tryAcquireExclusiveTransaction", "(", "@", "NotNull", "final", "Thread", "thread", ",", "final", "int", "timeout", ")", "{", "long", "nanos", "=", "TimeUnit", ".", "MILLISECONDS", ".", "toNanos", "(", "timeout", ")", ";", "try", "(", "CriticalSection", "ignored", "=", "criticalSection", ".", "enter", "(", ")", ")", "{", "if", "(", "getThreadPermits", "(", "thread", ")", ">", "0", ")", "{", "throw", "new", "ExodusException", "(", "\"Exclusive transaction can't be nested\"", ")", ";", "}", "final", "Condition", "condition", "=", "criticalSection", ".", "newCondition", "(", ")", ";", "final", "long", "currentOrder", "=", "acquireOrder", "++", ";", "regularQueue", ".", "put", "(", "currentOrder", ",", "condition", ")", ";", "while", "(", "acquiredPermits", ">", "0", "||", "regularQueue", ".", "firstKey", "(", ")", "!=", "currentOrder", ")", "{", "try", "{", "nanos", "=", "condition", ".", "awaitNanos", "(", "nanos", ")", ";", "if", "(", "nanos", "<", "0", ")", "{", "break", ";", "}", "}", "catch", "(", "InterruptedException", "e", ")", "{", "Thread", ".", "currentThread", "(", ")", ".", "interrupt", "(", ")", ";", "break", ";", "}", "}", "if", "(", "acquiredPermits", "==", "0", "&&", "regularQueue", ".", "firstKey", "(", ")", "==", "currentOrder", ")", "{", "regularQueue", ".", "pollFirstEntry", "(", ")", ";", "acquiredPermits", "=", "availablePermits", ";", "threadPermits", ".", "put", "(", "thread", ",", "availablePermits", ")", ";", "return", "availablePermits", ";", "}", "regularQueue", ".", "remove", "(", "currentOrder", ")", ";", "notifyNextWaiters", "(", ")", ";", "}", "return", "0", ";", "}" ]
Wait for exclusive permit during a timeout in milliseconds. @return number of acquired permits if > 0
[ "Wait", "for", "exclusive", "permit", "during", "a", "timeout", "in", "milliseconds", "." ]
7b3476c4e81db66f9c7529148c761605cc8eea6d
https://github.com/JetBrains/xodus/blob/7b3476c4e81db66f9c7529148c761605cc8eea6d/environment/src/main/java/jetbrains/exodus/env/ReentrantTransactionDispatcher.java#L193-L223
160,759
JetBrains/xodus
utils/src/main/java/jetbrains/exodus/core/execution/JobProcessorQueueAdapter.java
JobProcessorQueueAdapter.waitForJobs
protected boolean waitForJobs() throws InterruptedException { final Pair<Long, Job> peekPair; try (Guard ignored = timeQueue.lock()) { peekPair = timeQueue.peekPair(); } if (peekPair == null) { awake.acquire(); return true; } final long timeout = Long.MAX_VALUE - peekPair.getFirst() - System.currentTimeMillis(); if (timeout < 0) { return false; } return awake.tryAcquire(timeout, TimeUnit.MILLISECONDS); }
java
protected boolean waitForJobs() throws InterruptedException { final Pair<Long, Job> peekPair; try (Guard ignored = timeQueue.lock()) { peekPair = timeQueue.peekPair(); } if (peekPair == null) { awake.acquire(); return true; } final long timeout = Long.MAX_VALUE - peekPair.getFirst() - System.currentTimeMillis(); if (timeout < 0) { return false; } return awake.tryAcquire(timeout, TimeUnit.MILLISECONDS); }
[ "protected", "boolean", "waitForJobs", "(", ")", "throws", "InterruptedException", "{", "final", "Pair", "<", "Long", ",", "Job", ">", "peekPair", ";", "try", "(", "Guard", "ignored", "=", "timeQueue", ".", "lock", "(", ")", ")", "{", "peekPair", "=", "timeQueue", ".", "peekPair", "(", ")", ";", "}", "if", "(", "peekPair", "==", "null", ")", "{", "awake", ".", "acquire", "(", ")", ";", "return", "true", ";", "}", "final", "long", "timeout", "=", "Long", ".", "MAX_VALUE", "-", "peekPair", ".", "getFirst", "(", ")", "-", "System", ".", "currentTimeMillis", "(", ")", ";", "if", "(", "timeout", "<", "0", ")", "{", "return", "false", ";", "}", "return", "awake", ".", "tryAcquire", "(", "timeout", ",", "TimeUnit", ".", "MILLISECONDS", ")", ";", "}" ]
returns true if a job was queued within a timeout
[ "returns", "true", "if", "a", "job", "was", "queued", "within", "a", "timeout" ]
7b3476c4e81db66f9c7529148c761605cc8eea6d
https://github.com/JetBrains/xodus/blob/7b3476c4e81db66f9c7529148c761605cc8eea6d/utils/src/main/java/jetbrains/exodus/core/execution/JobProcessorQueueAdapter.java#L229-L243
160,760
JetBrains/xodus
entity-store/src/main/java/jetbrains/exodus/entitystore/PersistentStoreTransaction.java
PersistentStoreTransaction.apply
void apply() { final FlushLog log = new FlushLog(); store.logOperations(txn, log); final BlobVault blobVault = store.getBlobVault(); if (blobVault.requiresTxn()) { try { blobVault.flushBlobs(blobStreams, blobFiles, deferredBlobsToDelete, txn); } catch (Exception e) { // out of disk space not expected there throw ExodusException.toEntityStoreException(e); } } txn.setCommitHook(new Runnable() { @Override public void run() { log.flushed(); final EntityIterableCacheAdapterMutable cache = PersistentStoreTransaction.this.mutableCache; if (cache != null) { // mutableCache can be null if only blobs are modified applyAtomicCaches(cache); } } }); }
java
void apply() { final FlushLog log = new FlushLog(); store.logOperations(txn, log); final BlobVault blobVault = store.getBlobVault(); if (blobVault.requiresTxn()) { try { blobVault.flushBlobs(blobStreams, blobFiles, deferredBlobsToDelete, txn); } catch (Exception e) { // out of disk space not expected there throw ExodusException.toEntityStoreException(e); } } txn.setCommitHook(new Runnable() { @Override public void run() { log.flushed(); final EntityIterableCacheAdapterMutable cache = PersistentStoreTransaction.this.mutableCache; if (cache != null) { // mutableCache can be null if only blobs are modified applyAtomicCaches(cache); } } }); }
[ "void", "apply", "(", ")", "{", "final", "FlushLog", "log", "=", "new", "FlushLog", "(", ")", ";", "store", ".", "logOperations", "(", "txn", ",", "log", ")", ";", "final", "BlobVault", "blobVault", "=", "store", ".", "getBlobVault", "(", ")", ";", "if", "(", "blobVault", ".", "requiresTxn", "(", ")", ")", "{", "try", "{", "blobVault", ".", "flushBlobs", "(", "blobStreams", ",", "blobFiles", ",", "deferredBlobsToDelete", ",", "txn", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "// out of disk space not expected there", "throw", "ExodusException", ".", "toEntityStoreException", "(", "e", ")", ";", "}", "}", "txn", ".", "setCommitHook", "(", "new", "Runnable", "(", ")", "{", "@", "Override", "public", "void", "run", "(", ")", "{", "log", ".", "flushed", "(", ")", ";", "final", "EntityIterableCacheAdapterMutable", "cache", "=", "PersistentStoreTransaction", ".", "this", ".", "mutableCache", ";", "if", "(", "cache", "!=", "null", ")", "{", "// mutableCache can be null if only blobs are modified", "applyAtomicCaches", "(", "cache", ")", ";", "}", "}", "}", ")", ";", "}" ]
exposed only for tests
[ "exposed", "only", "for", "tests" ]
7b3476c4e81db66f9c7529148c761605cc8eea6d
https://github.com/JetBrains/xodus/blob/7b3476c4e81db66f9c7529148c761605cc8eea6d/entity-store/src/main/java/jetbrains/exodus/entitystore/PersistentStoreTransaction.java#L851-L873
160,761
JetBrains/xodus
entity-store/src/main/java/jetbrains/exodus/entitystore/StoreNamingRules.java
StoreNamingRules.getFQName
@NotNull private String getFQName(@NotNull final String localName, Object... params) { final StringBuilder builder = new StringBuilder(); builder.append(storeName); builder.append('.'); builder.append(localName); for (final Object param : params) { builder.append('#'); builder.append(param); } //noinspection ConstantConditions return StringInterner.intern(builder.toString()); }
java
@NotNull private String getFQName(@NotNull final String localName, Object... params) { final StringBuilder builder = new StringBuilder(); builder.append(storeName); builder.append('.'); builder.append(localName); for (final Object param : params) { builder.append('#'); builder.append(param); } //noinspection ConstantConditions return StringInterner.intern(builder.toString()); }
[ "@", "NotNull", "private", "String", "getFQName", "(", "@", "NotNull", "final", "String", "localName", ",", "Object", "...", "params", ")", "{", "final", "StringBuilder", "builder", "=", "new", "StringBuilder", "(", ")", ";", "builder", ".", "append", "(", "storeName", ")", ";", "builder", ".", "append", "(", "'", "'", ")", ";", "builder", ".", "append", "(", "localName", ")", ";", "for", "(", "final", "Object", "param", ":", "params", ")", "{", "builder", ".", "append", "(", "'", "'", ")", ";", "builder", ".", "append", "(", "param", ")", ";", "}", "//noinspection ConstantConditions", "return", "StringInterner", ".", "intern", "(", "builder", ".", "toString", "(", ")", ")", ";", "}" ]
Gets fully-qualified name of a table or sequence. @param localName local table name. @param params params. @return fully-qualified table name.
[ "Gets", "fully", "-", "qualified", "name", "of", "a", "table", "or", "sequence", "." ]
7b3476c4e81db66f9c7529148c761605cc8eea6d
https://github.com/JetBrains/xodus/blob/7b3476c4e81db66f9c7529148c761605cc8eea6d/entity-store/src/main/java/jetbrains/exodus/entitystore/StoreNamingRules.java#L144-L156
160,762
JetBrains/xodus
utils/src/main/java/jetbrains/exodus/util/UTFUtil.java
UTFUtil.writeUTF
public static void writeUTF(@NotNull final OutputStream stream, @NotNull final String str) throws IOException { try (DataOutputStream dataStream = new DataOutputStream(stream)) { int len = str.length(); if (len < SINGLE_UTF_CHUNK_SIZE) { dataStream.writeUTF(str); } else { int startIndex = 0; int endIndex; do { endIndex = startIndex + SINGLE_UTF_CHUNK_SIZE; if (endIndex > len) { endIndex = len; } dataStream.writeUTF(str.substring(startIndex, endIndex)); startIndex += SINGLE_UTF_CHUNK_SIZE; } while (endIndex < len); } } }
java
public static void writeUTF(@NotNull final OutputStream stream, @NotNull final String str) throws IOException { try (DataOutputStream dataStream = new DataOutputStream(stream)) { int len = str.length(); if (len < SINGLE_UTF_CHUNK_SIZE) { dataStream.writeUTF(str); } else { int startIndex = 0; int endIndex; do { endIndex = startIndex + SINGLE_UTF_CHUNK_SIZE; if (endIndex > len) { endIndex = len; } dataStream.writeUTF(str.substring(startIndex, endIndex)); startIndex += SINGLE_UTF_CHUNK_SIZE; } while (endIndex < len); } } }
[ "public", "static", "void", "writeUTF", "(", "@", "NotNull", "final", "OutputStream", "stream", ",", "@", "NotNull", "final", "String", "str", ")", "throws", "IOException", "{", "try", "(", "DataOutputStream", "dataStream", "=", "new", "DataOutputStream", "(", "stream", ")", ")", "{", "int", "len", "=", "str", ".", "length", "(", ")", ";", "if", "(", "len", "<", "SINGLE_UTF_CHUNK_SIZE", ")", "{", "dataStream", ".", "writeUTF", "(", "str", ")", ";", "}", "else", "{", "int", "startIndex", "=", "0", ";", "int", "endIndex", ";", "do", "{", "endIndex", "=", "startIndex", "+", "SINGLE_UTF_CHUNK_SIZE", ";", "if", "(", "endIndex", ">", "len", ")", "{", "endIndex", "=", "len", ";", "}", "dataStream", ".", "writeUTF", "(", "str", ".", "substring", "(", "startIndex", ",", "endIndex", ")", ")", ";", "startIndex", "+=", "SINGLE_UTF_CHUNK_SIZE", ";", "}", "while", "(", "endIndex", "<", "len", ")", ";", "}", "}", "}" ]
Writes long strings to output stream as several chunks. @param stream stream to write to. @param str string to be written. @throws IOException if something went wrong
[ "Writes", "long", "strings", "to", "output", "stream", "as", "several", "chunks", "." ]
7b3476c4e81db66f9c7529148c761605cc8eea6d
https://github.com/JetBrains/xodus/blob/7b3476c4e81db66f9c7529148c761605cc8eea6d/utils/src/main/java/jetbrains/exodus/util/UTFUtil.java#L39-L57
160,763
JetBrains/xodus
utils/src/main/java/jetbrains/exodus/util/UTFUtil.java
UTFUtil.readUTF
@Nullable public static String readUTF(@NotNull final InputStream stream) throws IOException { final DataInputStream dataInput = new DataInputStream(stream); if (stream instanceof ByteArraySizedInputStream) { final ByteArraySizedInputStream sizedStream = (ByteArraySizedInputStream) stream; final int streamSize = sizedStream.size(); if (streamSize >= 2) { sizedStream.mark(Integer.MAX_VALUE); final int utfLen = dataInput.readUnsignedShort(); if (utfLen == streamSize - 2) { boolean isAscii = true; final byte[] bytes = sizedStream.toByteArray(); for (int i = 0; i < utfLen; ++i) { if ((bytes[i + 2] & 0xff) > 127) { isAscii = false; break; } } if (isAscii) { return fromAsciiByteArray(bytes, 2, utfLen); } } sizedStream.reset(); } } try { String result = null; StringBuilder builder = null; for (; ; ) { final String temp; try { temp = dataInput.readUTF(); if (result != null && result.length() == 0 && builder != null && builder.length() == 0 && temp.length() == 0) { break; } } catch (EOFException e) { break; } if (result == null) { result = temp; } else { if (builder == null) { builder = new StringBuilder(); builder.append(result); } builder.append(temp); } } return (builder != null) ? builder.toString() : result; } finally { dataInput.close(); } }
java
@Nullable public static String readUTF(@NotNull final InputStream stream) throws IOException { final DataInputStream dataInput = new DataInputStream(stream); if (stream instanceof ByteArraySizedInputStream) { final ByteArraySizedInputStream sizedStream = (ByteArraySizedInputStream) stream; final int streamSize = sizedStream.size(); if (streamSize >= 2) { sizedStream.mark(Integer.MAX_VALUE); final int utfLen = dataInput.readUnsignedShort(); if (utfLen == streamSize - 2) { boolean isAscii = true; final byte[] bytes = sizedStream.toByteArray(); for (int i = 0; i < utfLen; ++i) { if ((bytes[i + 2] & 0xff) > 127) { isAscii = false; break; } } if (isAscii) { return fromAsciiByteArray(bytes, 2, utfLen); } } sizedStream.reset(); } } try { String result = null; StringBuilder builder = null; for (; ; ) { final String temp; try { temp = dataInput.readUTF(); if (result != null && result.length() == 0 && builder != null && builder.length() == 0 && temp.length() == 0) { break; } } catch (EOFException e) { break; } if (result == null) { result = temp; } else { if (builder == null) { builder = new StringBuilder(); builder.append(result); } builder.append(temp); } } return (builder != null) ? builder.toString() : result; } finally { dataInput.close(); } }
[ "@", "Nullable", "public", "static", "String", "readUTF", "(", "@", "NotNull", "final", "InputStream", "stream", ")", "throws", "IOException", "{", "final", "DataInputStream", "dataInput", "=", "new", "DataInputStream", "(", "stream", ")", ";", "if", "(", "stream", "instanceof", "ByteArraySizedInputStream", ")", "{", "final", "ByteArraySizedInputStream", "sizedStream", "=", "(", "ByteArraySizedInputStream", ")", "stream", ";", "final", "int", "streamSize", "=", "sizedStream", ".", "size", "(", ")", ";", "if", "(", "streamSize", ">=", "2", ")", "{", "sizedStream", ".", "mark", "(", "Integer", ".", "MAX_VALUE", ")", ";", "final", "int", "utfLen", "=", "dataInput", ".", "readUnsignedShort", "(", ")", ";", "if", "(", "utfLen", "==", "streamSize", "-", "2", ")", "{", "boolean", "isAscii", "=", "true", ";", "final", "byte", "[", "]", "bytes", "=", "sizedStream", ".", "toByteArray", "(", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "utfLen", ";", "++", "i", ")", "{", "if", "(", "(", "bytes", "[", "i", "+", "2", "]", "&", "0xff", ")", ">", "127", ")", "{", "isAscii", "=", "false", ";", "break", ";", "}", "}", "if", "(", "isAscii", ")", "{", "return", "fromAsciiByteArray", "(", "bytes", ",", "2", ",", "utfLen", ")", ";", "}", "}", "sizedStream", ".", "reset", "(", ")", ";", "}", "}", "try", "{", "String", "result", "=", "null", ";", "StringBuilder", "builder", "=", "null", ";", "for", "(", ";", ";", ")", "{", "final", "String", "temp", ";", "try", "{", "temp", "=", "dataInput", ".", "readUTF", "(", ")", ";", "if", "(", "result", "!=", "null", "&&", "result", ".", "length", "(", ")", "==", "0", "&&", "builder", "!=", "null", "&&", "builder", ".", "length", "(", ")", "==", "0", "&&", "temp", ".", "length", "(", ")", "==", "0", ")", "{", "break", ";", "}", "}", "catch", "(", "EOFException", "e", ")", "{", "break", ";", "}", "if", "(", "result", "==", "null", ")", "{", "result", "=", "temp", ";", "}", "else", "{", "if", "(", "builder", "==", "null", ")", "{", "builder", "=", "new", "StringBuilder", "(", ")", ";", "builder", ".", "append", "(", "result", ")", ";", "}", "builder", ".", "append", "(", "temp", ")", ";", "}", "}", "return", "(", "builder", "!=", "null", ")", "?", "builder", ".", "toString", "(", ")", ":", "result", ";", "}", "finally", "{", "dataInput", ".", "close", "(", ")", ";", "}", "}" ]
Reads a string from input stream saved as a sequence of UTF chunks. @param stream stream to read from. @return output string @throws IOException if something went wrong
[ "Reads", "a", "string", "from", "input", "stream", "saved", "as", "a", "sequence", "of", "UTF", "chunks", "." ]
7b3476c4e81db66f9c7529148c761605cc8eea6d
https://github.com/JetBrains/xodus/blob/7b3476c4e81db66f9c7529148c761605cc8eea6d/utils/src/main/java/jetbrains/exodus/util/UTFUtil.java#L66-L119
160,764
JetBrains/xodus
environment/src/main/java/jetbrains/exodus/tree/btree/BasePageMutable.java
BasePageMutable.save
protected long save() { // save leaf nodes ReclaimFlag flag = saveChildren(); // save self. complementary to {@link load()} final byte type = getType(); final BTreeBase tree = getTree(); final int structureId = tree.structureId; final Log log = tree.log; if (flag == ReclaimFlag.PRESERVE) { // there is a chance to update the flag to RECLAIM if (log.getWrittenHighAddress() % log.getFileLengthBound() == 0) { // page will be exactly on file border flag = ReclaimFlag.RECLAIM; } else { final ByteIterable[] iterables = getByteIterables(flag); long result = log.tryWrite(type, structureId, new CompoundByteIterable(iterables)); if (result < 0) { iterables[0] = CompressedUnsignedLongByteIterable.getIterable( (size << 1) + ReclaimFlag.RECLAIM.value ); result = log.writeContinuously(type, structureId, new CompoundByteIterable(iterables)); if (result < 0) { throw new TooBigLoggableException(); } } return result; } } return log.write(type, structureId, new CompoundByteIterable(getByteIterables(flag))); }
java
protected long save() { // save leaf nodes ReclaimFlag flag = saveChildren(); // save self. complementary to {@link load()} final byte type = getType(); final BTreeBase tree = getTree(); final int structureId = tree.structureId; final Log log = tree.log; if (flag == ReclaimFlag.PRESERVE) { // there is a chance to update the flag to RECLAIM if (log.getWrittenHighAddress() % log.getFileLengthBound() == 0) { // page will be exactly on file border flag = ReclaimFlag.RECLAIM; } else { final ByteIterable[] iterables = getByteIterables(flag); long result = log.tryWrite(type, structureId, new CompoundByteIterable(iterables)); if (result < 0) { iterables[0] = CompressedUnsignedLongByteIterable.getIterable( (size << 1) + ReclaimFlag.RECLAIM.value ); result = log.writeContinuously(type, structureId, new CompoundByteIterable(iterables)); if (result < 0) { throw new TooBigLoggableException(); } } return result; } } return log.write(type, structureId, new CompoundByteIterable(getByteIterables(flag))); }
[ "protected", "long", "save", "(", ")", "{", "// save leaf nodes", "ReclaimFlag", "flag", "=", "saveChildren", "(", ")", ";", "// save self. complementary to {@link load()}", "final", "byte", "type", "=", "getType", "(", ")", ";", "final", "BTreeBase", "tree", "=", "getTree", "(", ")", ";", "final", "int", "structureId", "=", "tree", ".", "structureId", ";", "final", "Log", "log", "=", "tree", ".", "log", ";", "if", "(", "flag", "==", "ReclaimFlag", ".", "PRESERVE", ")", "{", "// there is a chance to update the flag to RECLAIM", "if", "(", "log", ".", "getWrittenHighAddress", "(", ")", "%", "log", ".", "getFileLengthBound", "(", ")", "==", "0", ")", "{", "// page will be exactly on file border", "flag", "=", "ReclaimFlag", ".", "RECLAIM", ";", "}", "else", "{", "final", "ByteIterable", "[", "]", "iterables", "=", "getByteIterables", "(", "flag", ")", ";", "long", "result", "=", "log", ".", "tryWrite", "(", "type", ",", "structureId", ",", "new", "CompoundByteIterable", "(", "iterables", ")", ")", ";", "if", "(", "result", "<", "0", ")", "{", "iterables", "[", "0", "]", "=", "CompressedUnsignedLongByteIterable", ".", "getIterable", "(", "(", "size", "<<", "1", ")", "+", "ReclaimFlag", ".", "RECLAIM", ".", "value", ")", ";", "result", "=", "log", ".", "writeContinuously", "(", "type", ",", "structureId", ",", "new", "CompoundByteIterable", "(", "iterables", ")", ")", ";", "if", "(", "result", "<", "0", ")", "{", "throw", "new", "TooBigLoggableException", "(", ")", ";", "}", "}", "return", "result", ";", "}", "}", "return", "log", ".", "write", "(", "type", ",", "structureId", ",", "new", "CompoundByteIterable", "(", "getByteIterables", "(", "flag", ")", ")", ")", ";", "}" ]
Save page to log @return address of this page after save
[ "Save", "page", "to", "log" ]
7b3476c4e81db66f9c7529148c761605cc8eea6d
https://github.com/JetBrains/xodus/blob/7b3476c4e81db66f9c7529148c761605cc8eea6d/environment/src/main/java/jetbrains/exodus/tree/btree/BasePageMutable.java#L113-L143
160,765
JetBrains/xodus
openAPI/src/main/java/jetbrains/exodus/env/EnvironmentConfig.java
EnvironmentConfig.setSetting
@Override public EnvironmentConfig setSetting(@NotNull final String key, @NotNull final Object value) { return (EnvironmentConfig) super.setSetting(key, value); }
java
@Override public EnvironmentConfig setSetting(@NotNull final String key, @NotNull final Object value) { return (EnvironmentConfig) super.setSetting(key, value); }
[ "@", "Override", "public", "EnvironmentConfig", "setSetting", "(", "@", "NotNull", "final", "String", "key", ",", "@", "NotNull", "final", "Object", "value", ")", "{", "return", "(", "EnvironmentConfig", ")", "super", ".", "setSetting", "(", "key", ",", "value", ")", ";", "}" ]
Sets the value of the setting with the specified key. @param key name of the setting @param value the setting value @return this {@code EnvironmentConfig} instance
[ "Sets", "the", "value", "of", "the", "setting", "with", "the", "specified", "key", "." ]
7b3476c4e81db66f9c7529148c761605cc8eea6d
https://github.com/JetBrains/xodus/blob/7b3476c4e81db66f9c7529148c761605cc8eea6d/openAPI/src/main/java/jetbrains/exodus/env/EnvironmentConfig.java#L674-L677
160,766
JetBrains/xodus
openAPI/src/main/java/jetbrains/exodus/entitystore/BlobVault.java
BlobVault.getStringContent
@Nullable public final String getStringContent(final long blobHandle, @NotNull final Transaction txn) throws IOException { String result; result = stringContentCache.tryKey(this, blobHandle); if (result == null) { final InputStream content = getContent(blobHandle, txn); if (content == null) { logger.error("Blob string not found: " + getBlobLocation(blobHandle), new FileNotFoundException()); } result = content == null ? null : UTFUtil.readUTF(content); if (result != null && result.length() <= config.getBlobStringsCacheMaxValueSize()) { if (stringContentCache.getObject(this, blobHandle) == null) { stringContentCache.cacheObject(this, blobHandle, result); } } } return result; }
java
@Nullable public final String getStringContent(final long blobHandle, @NotNull final Transaction txn) throws IOException { String result; result = stringContentCache.tryKey(this, blobHandle); if (result == null) { final InputStream content = getContent(blobHandle, txn); if (content == null) { logger.error("Blob string not found: " + getBlobLocation(blobHandle), new FileNotFoundException()); } result = content == null ? null : UTFUtil.readUTF(content); if (result != null && result.length() <= config.getBlobStringsCacheMaxValueSize()) { if (stringContentCache.getObject(this, blobHandle) == null) { stringContentCache.cacheObject(this, blobHandle, result); } } } return result; }
[ "@", "Nullable", "public", "final", "String", "getStringContent", "(", "final", "long", "blobHandle", ",", "@", "NotNull", "final", "Transaction", "txn", ")", "throws", "IOException", "{", "String", "result", ";", "result", "=", "stringContentCache", ".", "tryKey", "(", "this", ",", "blobHandle", ")", ";", "if", "(", "result", "==", "null", ")", "{", "final", "InputStream", "content", "=", "getContent", "(", "blobHandle", ",", "txn", ")", ";", "if", "(", "content", "==", "null", ")", "{", "logger", ".", "error", "(", "\"Blob string not found: \"", "+", "getBlobLocation", "(", "blobHandle", ")", ",", "new", "FileNotFoundException", "(", ")", ")", ";", "}", "result", "=", "content", "==", "null", "?", "null", ":", "UTFUtil", ".", "readUTF", "(", "content", ")", ";", "if", "(", "result", "!=", "null", "&&", "result", ".", "length", "(", ")", "<=", "config", ".", "getBlobStringsCacheMaxValueSize", "(", ")", ")", "{", "if", "(", "stringContentCache", ".", "getObject", "(", "this", ",", "blobHandle", ")", "==", "null", ")", "{", "stringContentCache", ".", "cacheObject", "(", "this", ",", "blobHandle", ",", "result", ")", ";", "}", "}", "}", "return", "result", ";", "}" ]
Returns string content of blob identified by specified blob handle. String contents cache is used. @param blobHandle blob handle @param txn {@linkplain Transaction} instance @return string content of blob identified by specified blob handle @throws IOException if something went wrong
[ "Returns", "string", "content", "of", "blob", "identified", "by", "specified", "blob", "handle", ".", "String", "contents", "cache", "is", "used", "." ]
7b3476c4e81db66f9c7529148c761605cc8eea6d
https://github.com/JetBrains/xodus/blob/7b3476c4e81db66f9c7529148c761605cc8eea6d/openAPI/src/main/java/jetbrains/exodus/entitystore/BlobVault.java#L199-L216
160,767
JetBrains/xodus
utils/src/main/java/jetbrains/exodus/core/execution/JobProcessorAdapter.java
JobProcessorAdapter.queueIn
@Override public final Job queueIn(final Job job, final long millis) { return pushAt(job, System.currentTimeMillis() + millis); }
java
@Override public final Job queueIn(final Job job, final long millis) { return pushAt(job, System.currentTimeMillis() + millis); }
[ "@", "Override", "public", "final", "Job", "queueIn", "(", "final", "Job", "job", ",", "final", "long", "millis", ")", "{", "return", "pushAt", "(", "job", ",", "System", ".", "currentTimeMillis", "(", ")", "+", "millis", ")", ";", "}" ]
Queues a job for execution in specified time. @param job the job. @param millis execute the job in this time.
[ "Queues", "a", "job", "for", "execution", "in", "specified", "time", "." ]
7b3476c4e81db66f9c7529148c761605cc8eea6d
https://github.com/JetBrains/xodus/blob/7b3476c4e81db66f9c7529148c761605cc8eea6d/utils/src/main/java/jetbrains/exodus/core/execution/JobProcessorAdapter.java#L116-L119
160,768
JetBrains/xodus
entity-store/src/main/java/jetbrains/exodus/entitystore/tables/BlobsTable.java
BlobsTable.put
public void put(@NotNull final Transaction txn, final long localId, final int blobId, @NotNull final ByteIterable value) { primaryStore.put(txn, PropertyKey.propertyKeyToEntry(new PropertyKey(localId, blobId)), value); allBlobsIndex.put(txn, IntegerBinding.intToCompressedEntry(blobId), LongBinding.longToCompressedEntry(localId)); }
java
public void put(@NotNull final Transaction txn, final long localId, final int blobId, @NotNull final ByteIterable value) { primaryStore.put(txn, PropertyKey.propertyKeyToEntry(new PropertyKey(localId, blobId)), value); allBlobsIndex.put(txn, IntegerBinding.intToCompressedEntry(blobId), LongBinding.longToCompressedEntry(localId)); }
[ "public", "void", "put", "(", "@", "NotNull", "final", "Transaction", "txn", ",", "final", "long", "localId", ",", "final", "int", "blobId", ",", "@", "NotNull", "final", "ByteIterable", "value", ")", "{", "primaryStore", ".", "put", "(", "txn", ",", "PropertyKey", ".", "propertyKeyToEntry", "(", "new", "PropertyKey", "(", "localId", ",", "blobId", ")", ")", ",", "value", ")", ";", "allBlobsIndex", ".", "put", "(", "txn", ",", "IntegerBinding", ".", "intToCompressedEntry", "(", "blobId", ")", ",", "LongBinding", ".", "longToCompressedEntry", "(", "localId", ")", ")", ";", "}" ]
Setter for blob handle value. @param txn enclosing transaction @param localId entity local id. @param blobId blob id @param value property value.
[ "Setter", "for", "blob", "handle", "value", "." ]
7b3476c4e81db66f9c7529148c761605cc8eea6d
https://github.com/JetBrains/xodus/blob/7b3476c4e81db66f9c7529148c761605cc8eea6d/entity-store/src/main/java/jetbrains/exodus/entitystore/tables/BlobsTable.java#L62-L66
160,769
JetBrains/xodus
entity-store/src/main/java/jetbrains/exodus/entitystore/tables/PropertiesTable.java
PropertiesTable.put
public void put(@NotNull final PersistentStoreTransaction txn, final long localId, @NotNull final ByteIterable value, @Nullable final ByteIterable oldValue, final int propertyId, @NotNull final ComparableValueType type) { final Store valueIdx = getOrCreateValueIndex(txn, propertyId); final ByteIterable key = PropertyKey.propertyKeyToEntry(new PropertyKey(localId, propertyId)); final Transaction envTxn = txn.getEnvironmentTransaction(); primaryStore.put(envTxn, key, value); final ByteIterable secondaryValue = LongBinding.longToCompressedEntry(localId); boolean success; if (oldValue == null) { success = allPropsIndex.put(envTxn, IntegerBinding.intToCompressedEntry(propertyId), secondaryValue); } else { success = deleteFromStore(envTxn, valueIdx, secondaryValue, createSecondaryKeys(store.getPropertyTypes(), oldValue, type)); } if (success) { for (final ByteIterable secondaryKey : createSecondaryKeys(store.getPropertyTypes(), value, type)) { valueIdx.put(envTxn, secondaryKey, secondaryValue); } } checkStatus(success, "Failed to put"); }
java
public void put(@NotNull final PersistentStoreTransaction txn, final long localId, @NotNull final ByteIterable value, @Nullable final ByteIterable oldValue, final int propertyId, @NotNull final ComparableValueType type) { final Store valueIdx = getOrCreateValueIndex(txn, propertyId); final ByteIterable key = PropertyKey.propertyKeyToEntry(new PropertyKey(localId, propertyId)); final Transaction envTxn = txn.getEnvironmentTransaction(); primaryStore.put(envTxn, key, value); final ByteIterable secondaryValue = LongBinding.longToCompressedEntry(localId); boolean success; if (oldValue == null) { success = allPropsIndex.put(envTxn, IntegerBinding.intToCompressedEntry(propertyId), secondaryValue); } else { success = deleteFromStore(envTxn, valueIdx, secondaryValue, createSecondaryKeys(store.getPropertyTypes(), oldValue, type)); } if (success) { for (final ByteIterable secondaryKey : createSecondaryKeys(store.getPropertyTypes(), value, type)) { valueIdx.put(envTxn, secondaryKey, secondaryValue); } } checkStatus(success, "Failed to put"); }
[ "public", "void", "put", "(", "@", "NotNull", "final", "PersistentStoreTransaction", "txn", ",", "final", "long", "localId", ",", "@", "NotNull", "final", "ByteIterable", "value", ",", "@", "Nullable", "final", "ByteIterable", "oldValue", ",", "final", "int", "propertyId", ",", "@", "NotNull", "final", "ComparableValueType", "type", ")", "{", "final", "Store", "valueIdx", "=", "getOrCreateValueIndex", "(", "txn", ",", "propertyId", ")", ";", "final", "ByteIterable", "key", "=", "PropertyKey", ".", "propertyKeyToEntry", "(", "new", "PropertyKey", "(", "localId", ",", "propertyId", ")", ")", ";", "final", "Transaction", "envTxn", "=", "txn", ".", "getEnvironmentTransaction", "(", ")", ";", "primaryStore", ".", "put", "(", "envTxn", ",", "key", ",", "value", ")", ";", "final", "ByteIterable", "secondaryValue", "=", "LongBinding", ".", "longToCompressedEntry", "(", "localId", ")", ";", "boolean", "success", ";", "if", "(", "oldValue", "==", "null", ")", "{", "success", "=", "allPropsIndex", ".", "put", "(", "envTxn", ",", "IntegerBinding", ".", "intToCompressedEntry", "(", "propertyId", ")", ",", "secondaryValue", ")", ";", "}", "else", "{", "success", "=", "deleteFromStore", "(", "envTxn", ",", "valueIdx", ",", "secondaryValue", ",", "createSecondaryKeys", "(", "store", ".", "getPropertyTypes", "(", ")", ",", "oldValue", ",", "type", ")", ")", ";", "}", "if", "(", "success", ")", "{", "for", "(", "final", "ByteIterable", "secondaryKey", ":", "createSecondaryKeys", "(", "store", ".", "getPropertyTypes", "(", ")", ",", "value", ",", "type", ")", ")", "{", "valueIdx", ".", "put", "(", "envTxn", ",", "secondaryKey", ",", "secondaryValue", ")", ";", "}", "}", "checkStatus", "(", "success", ",", "\"Failed to put\"", ")", ";", "}" ]
Setter for property value. Doesn't affect entity version and doesn't invalidate any of the cached entity iterables. @param localId entity local id. @param value property value. @param oldValue property old value @param propertyId property id
[ "Setter", "for", "property", "value", ".", "Doesn", "t", "affect", "entity", "version", "and", "doesn", "t", "invalidate", "any", "of", "the", "cached", "entity", "iterables", "." ]
7b3476c4e81db66f9c7529148c761605cc8eea6d
https://github.com/JetBrains/xodus/blob/7b3476c4e81db66f9c7529148c761605cc8eea6d/entity-store/src/main/java/jetbrains/exodus/entitystore/tables/PropertiesTable.java#L74-L97
160,770
JetBrains/xodus
utils/src/main/java/jetbrains/exodus/core/dataStructures/persistent/AbstractPersistent23Tree.java
AbstractPersistent23Tree.tailIterator
public Iterator<K> tailIterator(@NotNull final K key) { return new Iterator<K>() { private Stack<TreePos<K>> stack; private boolean hasNext; private boolean hasNextValid; @Override public boolean hasNext() { if (hasNextValid) { return hasNext; } hasNextValid = true; if (stack == null) { Node<K> root = getRoot(); if (root == null) { hasNext = false; return hasNext; } stack = new Stack<>(); if (!root.getLess(key, stack)) { stack.push(new TreePos<>(root)); } } TreePos<K> treePos = stack.peek(); if (treePos.node.isLeaf()) { while (treePos.pos >= (treePos.node.isTernary() ? 2 : 1)) { stack.pop(); if (stack.isEmpty()) { hasNext = false; return hasNext; } treePos = stack.peek(); } } else { if (treePos.pos == 0) { treePos = new TreePos<>(treePos.node.getFirstChild()); } else if (treePos.pos == 1) { treePos = new TreePos<>(treePos.node.getSecondChild()); } else { treePos = new TreePos<>(treePos.node.getThirdChild()); } stack.push(treePos); while (!treePos.node.isLeaf()) { treePos = new TreePos<>(treePos.node.getFirstChild()); stack.push(treePos); } } treePos.pos++; hasNext = true; return hasNext; } @Override public K next() { if (!hasNext()) { throw new NoSuchElementException(); } hasNextValid = false; TreePos<K> treePos = stack.peek(); // treePos.pos must be 1 or 2 here return treePos.pos == 1 ? treePos.node.getFirstKey() : treePos.node.getSecondKey(); } @Override public void remove() { throw new UnsupportedOperationException(); } }; }
java
public Iterator<K> tailIterator(@NotNull final K key) { return new Iterator<K>() { private Stack<TreePos<K>> stack; private boolean hasNext; private boolean hasNextValid; @Override public boolean hasNext() { if (hasNextValid) { return hasNext; } hasNextValid = true; if (stack == null) { Node<K> root = getRoot(); if (root == null) { hasNext = false; return hasNext; } stack = new Stack<>(); if (!root.getLess(key, stack)) { stack.push(new TreePos<>(root)); } } TreePos<K> treePos = stack.peek(); if (treePos.node.isLeaf()) { while (treePos.pos >= (treePos.node.isTernary() ? 2 : 1)) { stack.pop(); if (stack.isEmpty()) { hasNext = false; return hasNext; } treePos = stack.peek(); } } else { if (treePos.pos == 0) { treePos = new TreePos<>(treePos.node.getFirstChild()); } else if (treePos.pos == 1) { treePos = new TreePos<>(treePos.node.getSecondChild()); } else { treePos = new TreePos<>(treePos.node.getThirdChild()); } stack.push(treePos); while (!treePos.node.isLeaf()) { treePos = new TreePos<>(treePos.node.getFirstChild()); stack.push(treePos); } } treePos.pos++; hasNext = true; return hasNext; } @Override public K next() { if (!hasNext()) { throw new NoSuchElementException(); } hasNextValid = false; TreePos<K> treePos = stack.peek(); // treePos.pos must be 1 or 2 here return treePos.pos == 1 ? treePos.node.getFirstKey() : treePos.node.getSecondKey(); } @Override public void remove() { throw new UnsupportedOperationException(); } }; }
[ "public", "Iterator", "<", "K", ">", "tailIterator", "(", "@", "NotNull", "final", "K", "key", ")", "{", "return", "new", "Iterator", "<", "K", ">", "(", ")", "{", "private", "Stack", "<", "TreePos", "<", "K", ">", ">", "stack", ";", "private", "boolean", "hasNext", ";", "private", "boolean", "hasNextValid", ";", "@", "Override", "public", "boolean", "hasNext", "(", ")", "{", "if", "(", "hasNextValid", ")", "{", "return", "hasNext", ";", "}", "hasNextValid", "=", "true", ";", "if", "(", "stack", "==", "null", ")", "{", "Node", "<", "K", ">", "root", "=", "getRoot", "(", ")", ";", "if", "(", "root", "==", "null", ")", "{", "hasNext", "=", "false", ";", "return", "hasNext", ";", "}", "stack", "=", "new", "Stack", "<>", "(", ")", ";", "if", "(", "!", "root", ".", "getLess", "(", "key", ",", "stack", ")", ")", "{", "stack", ".", "push", "(", "new", "TreePos", "<>", "(", "root", ")", ")", ";", "}", "}", "TreePos", "<", "K", ">", "treePos", "=", "stack", ".", "peek", "(", ")", ";", "if", "(", "treePos", ".", "node", ".", "isLeaf", "(", ")", ")", "{", "while", "(", "treePos", ".", "pos", ">=", "(", "treePos", ".", "node", ".", "isTernary", "(", ")", "?", "2", ":", "1", ")", ")", "{", "stack", ".", "pop", "(", ")", ";", "if", "(", "stack", ".", "isEmpty", "(", ")", ")", "{", "hasNext", "=", "false", ";", "return", "hasNext", ";", "}", "treePos", "=", "stack", ".", "peek", "(", ")", ";", "}", "}", "else", "{", "if", "(", "treePos", ".", "pos", "==", "0", ")", "{", "treePos", "=", "new", "TreePos", "<>", "(", "treePos", ".", "node", ".", "getFirstChild", "(", ")", ")", ";", "}", "else", "if", "(", "treePos", ".", "pos", "==", "1", ")", "{", "treePos", "=", "new", "TreePos", "<>", "(", "treePos", ".", "node", ".", "getSecondChild", "(", ")", ")", ";", "}", "else", "{", "treePos", "=", "new", "TreePos", "<>", "(", "treePos", ".", "node", ".", "getThirdChild", "(", ")", ")", ";", "}", "stack", ".", "push", "(", "treePos", ")", ";", "while", "(", "!", "treePos", ".", "node", ".", "isLeaf", "(", ")", ")", "{", "treePos", "=", "new", "TreePos", "<>", "(", "treePos", ".", "node", ".", "getFirstChild", "(", ")", ")", ";", "stack", ".", "push", "(", "treePos", ")", ";", "}", "}", "treePos", ".", "pos", "++", ";", "hasNext", "=", "true", ";", "return", "hasNext", ";", "}", "@", "Override", "public", "K", "next", "(", ")", "{", "if", "(", "!", "hasNext", "(", ")", ")", "{", "throw", "new", "NoSuchElementException", "(", ")", ";", "}", "hasNextValid", "=", "false", ";", "TreePos", "<", "K", ">", "treePos", "=", "stack", ".", "peek", "(", ")", ";", "// treePos.pos must be 1 or 2 here", "return", "treePos", ".", "pos", "==", "1", "?", "treePos", ".", "node", ".", "getFirstKey", "(", ")", ":", "treePos", ".", "node", ".", "getSecondKey", "(", ")", ";", "}", "@", "Override", "public", "void", "remove", "(", ")", "{", "throw", "new", "UnsupportedOperationException", "(", ")", ";", "}", "}", ";", "}" ]
Returns an iterator that iterates over all elements greater or equal to key in ascending order @param key key @return iterator
[ "Returns", "an", "iterator", "that", "iterates", "over", "all", "elements", "greater", "or", "equal", "to", "key", "in", "ascending", "order" ]
7b3476c4e81db66f9c7529148c761605cc8eea6d
https://github.com/JetBrains/xodus/blob/7b3476c4e81db66f9c7529148c761605cc8eea6d/utils/src/main/java/jetbrains/exodus/core/dataStructures/persistent/AbstractPersistent23Tree.java#L146-L215
160,771
JetBrains/xodus
entity-store/src/main/java/jetbrains/exodus/entitystore/tables/TwoColumnTable.java
TwoColumnTable.get
@Nullable public ByteIterable get(@NotNull final Transaction txn, @NotNull final ByteIterable first) { return this.first.get(txn, first); }
java
@Nullable public ByteIterable get(@NotNull final Transaction txn, @NotNull final ByteIterable first) { return this.first.get(txn, first); }
[ "@", "Nullable", "public", "ByteIterable", "get", "(", "@", "NotNull", "final", "Transaction", "txn", ",", "@", "NotNull", "final", "ByteIterable", "first", ")", "{", "return", "this", ".", "first", ".", "get", "(", "txn", ",", "first", ")", ";", "}" ]
Search for the first entry in the first database. Use this method for databases configured with no duplicates. @param txn enclosing transaction @param first first key. @return null if no entry found, otherwise the value.
[ "Search", "for", "the", "first", "entry", "in", "the", "first", "database", ".", "Use", "this", "method", "for", "databases", "configured", "with", "no", "duplicates", "." ]
7b3476c4e81db66f9c7529148c761605cc8eea6d
https://github.com/JetBrains/xodus/blob/7b3476c4e81db66f9c7529148c761605cc8eea6d/entity-store/src/main/java/jetbrains/exodus/entitystore/tables/TwoColumnTable.java#L54-L57
160,772
JetBrains/xodus
entity-store/src/main/java/jetbrains/exodus/entitystore/tables/TwoColumnTable.java
TwoColumnTable.get2
@Nullable public ByteIterable get2(@NotNull final Transaction txn, @NotNull final ByteIterable second) { return this.second.get(txn, second); }
java
@Nullable public ByteIterable get2(@NotNull final Transaction txn, @NotNull final ByteIterable second) { return this.second.get(txn, second); }
[ "@", "Nullable", "public", "ByteIterable", "get2", "(", "@", "NotNull", "final", "Transaction", "txn", ",", "@", "NotNull", "final", "ByteIterable", "second", ")", "{", "return", "this", ".", "second", ".", "get", "(", "txn", ",", "second", ")", ";", "}" ]
Search for the second entry in the second database. Use this method for databases configured with no duplicates. @param second second key (value for first). @return null if no entry found, otherwise the value.
[ "Search", "for", "the", "second", "entry", "in", "the", "second", "database", ".", "Use", "this", "method", "for", "databases", "configured", "with", "no", "duplicates", "." ]
7b3476c4e81db66f9c7529148c761605cc8eea6d
https://github.com/JetBrains/xodus/blob/7b3476c4e81db66f9c7529148c761605cc8eea6d/entity-store/src/main/java/jetbrains/exodus/entitystore/tables/TwoColumnTable.java#L65-L68
160,773
OpenHFT/Chronicle-Network
src/main/java/net/openhft/chronicle/network/connection/TcpChannelHub.java
TcpChannelHub.close
@Override public void close() { if (closed) return; closed = true; tcpSocketConsumer.prepareToShutdown(); if (shouldSendCloseMessage) eventLoop.addHandler(new EventHandler() { @Override public boolean action() throws InvalidEventHandlerException { try { TcpChannelHub.this.sendCloseMessage(); tcpSocketConsumer.stop(); closed = true; if (LOG.isDebugEnabled()) Jvm.debug().on(getClass(), "closing connection to " + socketAddressSupplier); while (clientChannel != null) { if (LOG.isDebugEnabled()) Jvm.debug().on(getClass(), "waiting for disconnect to " + socketAddressSupplier); } } catch (ConnectionDroppedException e) { throw new InvalidEventHandlerException(e); } // we just want this to run once throw new InvalidEventHandlerException(); } @NotNull @Override public String toString() { return TcpChannelHub.class.getSimpleName() + "..close()"; } }); }
java
@Override public void close() { if (closed) return; closed = true; tcpSocketConsumer.prepareToShutdown(); if (shouldSendCloseMessage) eventLoop.addHandler(new EventHandler() { @Override public boolean action() throws InvalidEventHandlerException { try { TcpChannelHub.this.sendCloseMessage(); tcpSocketConsumer.stop(); closed = true; if (LOG.isDebugEnabled()) Jvm.debug().on(getClass(), "closing connection to " + socketAddressSupplier); while (clientChannel != null) { if (LOG.isDebugEnabled()) Jvm.debug().on(getClass(), "waiting for disconnect to " + socketAddressSupplier); } } catch (ConnectionDroppedException e) { throw new InvalidEventHandlerException(e); } // we just want this to run once throw new InvalidEventHandlerException(); } @NotNull @Override public String toString() { return TcpChannelHub.class.getSimpleName() + "..close()"; } }); }
[ "@", "Override", "public", "void", "close", "(", ")", "{", "if", "(", "closed", ")", "return", ";", "closed", "=", "true", ";", "tcpSocketConsumer", ".", "prepareToShutdown", "(", ")", ";", "if", "(", "shouldSendCloseMessage", ")", "eventLoop", ".", "addHandler", "(", "new", "EventHandler", "(", ")", "{", "@", "Override", "public", "boolean", "action", "(", ")", "throws", "InvalidEventHandlerException", "{", "try", "{", "TcpChannelHub", ".", "this", ".", "sendCloseMessage", "(", ")", ";", "tcpSocketConsumer", ".", "stop", "(", ")", ";", "closed", "=", "true", ";", "if", "(", "LOG", ".", "isDebugEnabled", "(", ")", ")", "Jvm", ".", "debug", "(", ")", ".", "on", "(", "getClass", "(", ")", ",", "\"closing connection to \"", "+", "socketAddressSupplier", ")", ";", "while", "(", "clientChannel", "!=", "null", ")", "{", "if", "(", "LOG", ".", "isDebugEnabled", "(", ")", ")", "Jvm", ".", "debug", "(", ")", ".", "on", "(", "getClass", "(", ")", ",", "\"waiting for disconnect to \"", "+", "socketAddressSupplier", ")", ";", "}", "}", "catch", "(", "ConnectionDroppedException", "e", ")", "{", "throw", "new", "InvalidEventHandlerException", "(", "e", ")", ";", "}", "// we just want this to run once", "throw", "new", "InvalidEventHandlerException", "(", ")", ";", "}", "@", "NotNull", "@", "Override", "public", "String", "toString", "(", ")", "{", "return", "TcpChannelHub", ".", "class", ".", "getSimpleName", "(", ")", "+", "\"..close()\"", ";", "}", "}", ")", ";", "}" ]
called when we are completed finished with using the TcpChannelHub
[ "called", "when", "we", "are", "completed", "finished", "with", "using", "the", "TcpChannelHub" ]
b50d232a1763b1400d5438c7925dce845e5c387a
https://github.com/OpenHFT/Chronicle-Network/blob/b50d232a1763b1400d5438c7925dce845e5c387a/src/main/java/net/openhft/chronicle/network/connection/TcpChannelHub.java#L490-L529
160,774
OpenHFT/Chronicle-Network
src/main/java/net/openhft/chronicle/network/connection/TcpChannelHub.java
TcpChannelHub.sendCloseMessage
private void sendCloseMessage() { this.lock(() -> { TcpChannelHub.this.writeMetaDataForKnownTID(0, outWire, null, 0); TcpChannelHub.this.outWire.writeDocument(false, w -> w.writeEventName(EventId.onClientClosing).text("")); }, TryLock.LOCK); // wait up to 1 seconds to receive an close request acknowledgment from the server try { final boolean await = receivedClosedAcknowledgement.await(1, TimeUnit.SECONDS); if (!await) if (Jvm.isDebugEnabled(getClass())) Jvm.debug().on(getClass(), "SERVER IGNORED CLOSE REQUEST: shutting down the client anyway as the " + "server did not respond to the close() request."); } catch (InterruptedException ignore) { Thread.currentThread().interrupt(); } }
java
private void sendCloseMessage() { this.lock(() -> { TcpChannelHub.this.writeMetaDataForKnownTID(0, outWire, null, 0); TcpChannelHub.this.outWire.writeDocument(false, w -> w.writeEventName(EventId.onClientClosing).text("")); }, TryLock.LOCK); // wait up to 1 seconds to receive an close request acknowledgment from the server try { final boolean await = receivedClosedAcknowledgement.await(1, TimeUnit.SECONDS); if (!await) if (Jvm.isDebugEnabled(getClass())) Jvm.debug().on(getClass(), "SERVER IGNORED CLOSE REQUEST: shutting down the client anyway as the " + "server did not respond to the close() request."); } catch (InterruptedException ignore) { Thread.currentThread().interrupt(); } }
[ "private", "void", "sendCloseMessage", "(", ")", "{", "this", ".", "lock", "(", "(", ")", "->", "{", "TcpChannelHub", ".", "this", ".", "writeMetaDataForKnownTID", "(", "0", ",", "outWire", ",", "null", ",", "0", ")", ";", "TcpChannelHub", ".", "this", ".", "outWire", ".", "writeDocument", "(", "false", ",", "w", "->", "w", ".", "writeEventName", "(", "EventId", ".", "onClientClosing", ")", ".", "text", "(", "\"\"", ")", ")", ";", "}", ",", "TryLock", ".", "LOCK", ")", ";", "// wait up to 1 seconds to receive an close request acknowledgment from the server", "try", "{", "final", "boolean", "await", "=", "receivedClosedAcknowledgement", ".", "await", "(", "1", ",", "TimeUnit", ".", "SECONDS", ")", ";", "if", "(", "!", "await", ")", "if", "(", "Jvm", ".", "isDebugEnabled", "(", "getClass", "(", ")", ")", ")", "Jvm", ".", "debug", "(", ")", ".", "on", "(", "getClass", "(", ")", ",", "\"SERVER IGNORED CLOSE REQUEST: shutting down the client anyway as the \"", "+", "\"server did not respond to the close() request.\"", ")", ";", "}", "catch", "(", "InterruptedException", "ignore", ")", "{", "Thread", ".", "currentThread", "(", ")", ".", "interrupt", "(", ")", ";", "}", "}" ]
used to signal to the server that the client is going to drop the connection, and waits up to one second for the server to acknowledge the receipt of this message
[ "used", "to", "signal", "to", "the", "server", "that", "the", "client", "is", "going", "to", "drop", "the", "connection", "and", "waits", "up", "to", "one", "second", "for", "the", "server", "to", "acknowledge", "the", "receipt", "of", "this", "message" ]
b50d232a1763b1400d5438c7925dce845e5c387a
https://github.com/OpenHFT/Chronicle-Network/blob/b50d232a1763b1400d5438c7925dce845e5c387a/src/main/java/net/openhft/chronicle/network/connection/TcpChannelHub.java#L535-L556
160,775
OpenHFT/Chronicle-Network
src/main/java/net/openhft/chronicle/network/connection/TcpChannelHub.java
TcpChannelHub.nextUniqueTransaction
public long nextUniqueTransaction(long timeMs) { long id = timeMs; for (; ; ) { long old = transactionID.get(); if (old >= id) id = old + 1; if (transactionID.compareAndSet(old, id)) break; } return id; }
java
public long nextUniqueTransaction(long timeMs) { long id = timeMs; for (; ; ) { long old = transactionID.get(); if (old >= id) id = old + 1; if (transactionID.compareAndSet(old, id)) break; } return id; }
[ "public", "long", "nextUniqueTransaction", "(", "long", "timeMs", ")", "{", "long", "id", "=", "timeMs", ";", "for", "(", ";", ";", ")", "{", "long", "old", "=", "transactionID", ".", "get", "(", ")", ";", "if", "(", "old", ">=", "id", ")", "id", "=", "old", "+", "1", ";", "if", "(", "transactionID", ".", "compareAndSet", "(", "old", ",", "id", ")", ")", "break", ";", "}", "return", "id", ";", "}" ]
the transaction id are generated as unique timestamps @param timeMs in milliseconds @return a unique transactionId
[ "the", "transaction", "id", "are", "generated", "as", "unique", "timestamps" ]
b50d232a1763b1400d5438c7925dce845e5c387a
https://github.com/OpenHFT/Chronicle-Network/blob/b50d232a1763b1400d5438c7925dce845e5c387a/src/main/java/net/openhft/chronicle/network/connection/TcpChannelHub.java#L564-L574
160,776
OpenHFT/Chronicle-Network
src/main/java/net/openhft/chronicle/network/connection/TcpChannelHub.java
TcpChannelHub.checkConnection
public void checkConnection() { long start = Time.currentTimeMillis(); while (clientChannel == null) { tcpSocketConsumer.checkNotShutdown(); if (start + timeoutMs > Time.currentTimeMillis()) try { condition.await(1, TimeUnit.MILLISECONDS); } catch (InterruptedException e) { throw new IORuntimeException("Interrupted"); } else throw new IORuntimeException("Not connected to " + socketAddressSupplier); } if (clientChannel == null) throw new IORuntimeException("Not connected to " + socketAddressSupplier); }
java
public void checkConnection() { long start = Time.currentTimeMillis(); while (clientChannel == null) { tcpSocketConsumer.checkNotShutdown(); if (start + timeoutMs > Time.currentTimeMillis()) try { condition.await(1, TimeUnit.MILLISECONDS); } catch (InterruptedException e) { throw new IORuntimeException("Interrupted"); } else throw new IORuntimeException("Not connected to " + socketAddressSupplier); } if (clientChannel == null) throw new IORuntimeException("Not connected to " + socketAddressSupplier); }
[ "public", "void", "checkConnection", "(", ")", "{", "long", "start", "=", "Time", ".", "currentTimeMillis", "(", ")", ";", "while", "(", "clientChannel", "==", "null", ")", "{", "tcpSocketConsumer", ".", "checkNotShutdown", "(", ")", ";", "if", "(", "start", "+", "timeoutMs", ">", "Time", ".", "currentTimeMillis", "(", ")", ")", "try", "{", "condition", ".", "await", "(", "1", ",", "TimeUnit", ".", "MILLISECONDS", ")", ";", "}", "catch", "(", "InterruptedException", "e", ")", "{", "throw", "new", "IORuntimeException", "(", "\"Interrupted\"", ")", ";", "}", "else", "throw", "new", "IORuntimeException", "(", "\"Not connected to \"", "+", "socketAddressSupplier", ")", ";", "}", "if", "(", "clientChannel", "==", "null", ")", "throw", "new", "IORuntimeException", "(", "\"Not connected to \"", "+", "socketAddressSupplier", ")", ";", "}" ]
blocks until there is a connection
[ "blocks", "until", "there", "is", "a", "connection" ]
b50d232a1763b1400d5438c7925dce845e5c387a
https://github.com/OpenHFT/Chronicle-Network/blob/b50d232a1763b1400d5438c7925dce845e5c387a/src/main/java/net/openhft/chronicle/network/connection/TcpChannelHub.java#L944-L964
160,777
OpenHFT/Chronicle-Network
src/main/java/net/openhft/chronicle/network/VanillaNetworkContext.java
VanillaNetworkContext.closeAtomically
protected boolean closeAtomically() { if (isClosed.compareAndSet(false, true)) { Closeable.closeQuietly(networkStatsListener); return true; } else { //was already closed. return false; } }
java
protected boolean closeAtomically() { if (isClosed.compareAndSet(false, true)) { Closeable.closeQuietly(networkStatsListener); return true; } else { //was already closed. return false; } }
[ "protected", "boolean", "closeAtomically", "(", ")", "{", "if", "(", "isClosed", ".", "compareAndSet", "(", "false", ",", "true", ")", ")", "{", "Closeable", ".", "closeQuietly", "(", "networkStatsListener", ")", ";", "return", "true", ";", "}", "else", "{", "//was already closed.", "return", "false", ";", "}", "}" ]
Close the connection atomically. @return true if state changed to closed; false if nothing changed.
[ "Close", "the", "connection", "atomically", "." ]
b50d232a1763b1400d5438c7925dce845e5c387a
https://github.com/OpenHFT/Chronicle-Network/blob/b50d232a1763b1400d5438c7925dce845e5c387a/src/main/java/net/openhft/chronicle/network/VanillaNetworkContext.java#L183-L191
160,778
OpenHFT/Chronicle-Network
src/main/java/net/openhft/chronicle/network/WireTcpHandler.java
WireTcpHandler.onRead0
private void onRead0() { assert inWire.startUse(); ensureCapacity(); try { while (!inWire.bytes().isEmpty()) { try (DocumentContext dc = inWire.readingDocument()) { if (!dc.isPresent()) return; try { if (YamlLogging.showServerReads()) logYaml(dc); onRead(dc, outWire); onWrite(outWire); } catch (Exception e) { Jvm.warn().on(getClass(), "inWire=" + inWire.getClass() + ",yaml=" + Wires.fromSizePrefixedBlobs(dc), e); } } } } finally { assert inWire.endUse(); } }
java
private void onRead0() { assert inWire.startUse(); ensureCapacity(); try { while (!inWire.bytes().isEmpty()) { try (DocumentContext dc = inWire.readingDocument()) { if (!dc.isPresent()) return; try { if (YamlLogging.showServerReads()) logYaml(dc); onRead(dc, outWire); onWrite(outWire); } catch (Exception e) { Jvm.warn().on(getClass(), "inWire=" + inWire.getClass() + ",yaml=" + Wires.fromSizePrefixedBlobs(dc), e); } } } } finally { assert inWire.endUse(); } }
[ "private", "void", "onRead0", "(", ")", "{", "assert", "inWire", ".", "startUse", "(", ")", ";", "ensureCapacity", "(", ")", ";", "try", "{", "while", "(", "!", "inWire", ".", "bytes", "(", ")", ".", "isEmpty", "(", ")", ")", "{", "try", "(", "DocumentContext", "dc", "=", "inWire", ".", "readingDocument", "(", ")", ")", "{", "if", "(", "!", "dc", ".", "isPresent", "(", ")", ")", "return", ";", "try", "{", "if", "(", "YamlLogging", ".", "showServerReads", "(", ")", ")", "logYaml", "(", "dc", ")", ";", "onRead", "(", "dc", ",", "outWire", ")", ";", "onWrite", "(", "outWire", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "Jvm", ".", "warn", "(", ")", ".", "on", "(", "getClass", "(", ")", ",", "\"inWire=\"", "+", "inWire", ".", "getClass", "(", ")", "+", "\",yaml=\"", "+", "Wires", ".", "fromSizePrefixedBlobs", "(", "dc", ")", ",", "e", ")", ";", "}", "}", "}", "}", "finally", "{", "assert", "inWire", ".", "endUse", "(", ")", ";", "}", "}" ]
process all messages in this batch, provided there is plenty of output space.
[ "process", "all", "messages", "in", "this", "batch", "provided", "there", "is", "plenty", "of", "output", "space", "." ]
b50d232a1763b1400d5438c7925dce845e5c387a
https://github.com/OpenHFT/Chronicle-Network/blob/b50d232a1763b1400d5438c7925dce845e5c387a/src/main/java/net/openhft/chronicle/network/WireTcpHandler.java#L188-L215
160,779
OpenHFT/Chronicle-Network
src/main/java/net/openhft/chronicle/network/cluster/handlers/HeartbeatHandler.java
HeartbeatHandler.hasReceivedHeartbeat
private boolean hasReceivedHeartbeat() { long currentTimeMillis = System.currentTimeMillis(); boolean result = lastTimeMessageReceived + heartbeatTimeoutMs >= currentTimeMillis; if (!result) Jvm.warn().on(getClass(), Integer.toHexString(hashCode()) + " missed heartbeat, lastTimeMessageReceived=" + lastTimeMessageReceived + ", currentTimeMillis=" + currentTimeMillis); return result; }
java
private boolean hasReceivedHeartbeat() { long currentTimeMillis = System.currentTimeMillis(); boolean result = lastTimeMessageReceived + heartbeatTimeoutMs >= currentTimeMillis; if (!result) Jvm.warn().on(getClass(), Integer.toHexString(hashCode()) + " missed heartbeat, lastTimeMessageReceived=" + lastTimeMessageReceived + ", currentTimeMillis=" + currentTimeMillis); return result; }
[ "private", "boolean", "hasReceivedHeartbeat", "(", ")", "{", "long", "currentTimeMillis", "=", "System", ".", "currentTimeMillis", "(", ")", ";", "boolean", "result", "=", "lastTimeMessageReceived", "+", "heartbeatTimeoutMs", ">=", "currentTimeMillis", ";", "if", "(", "!", "result", ")", "Jvm", ".", "warn", "(", ")", ".", "on", "(", "getClass", "(", ")", ",", "Integer", ".", "toHexString", "(", "hashCode", "(", ")", ")", "+", "\" missed heartbeat, lastTimeMessageReceived=\"", "+", "lastTimeMessageReceived", "+", "\", currentTimeMillis=\"", "+", "currentTimeMillis", ")", ";", "return", "result", ";", "}" ]
called periodically to check that the heartbeat has been received @return {@code true} if we have received a heartbeat recently
[ "called", "periodically", "to", "check", "that", "the", "heartbeat", "has", "been", "received" ]
b50d232a1763b1400d5438c7925dce845e5c387a
https://github.com/OpenHFT/Chronicle-Network/blob/b50d232a1763b1400d5438c7925dce845e5c387a/src/main/java/net/openhft/chronicle/network/cluster/handlers/HeartbeatHandler.java#L185-L193
160,780
Stratio/cassandra-lucene-index
plugin/src/main/java/com/stratio/cassandra/lucene/schema/mapping/Mapper.java
Mapper.mapsCell
public boolean mapsCell(String cell) { return mappedCells.stream().anyMatch(x -> x.equals(cell)); }
java
public boolean mapsCell(String cell) { return mappedCells.stream().anyMatch(x -> x.equals(cell)); }
[ "public", "boolean", "mapsCell", "(", "String", "cell", ")", "{", "return", "mappedCells", ".", "stream", "(", ")", ".", "anyMatch", "(", "x", "->", "x", ".", "equals", "(", "cell", ")", ")", ";", "}" ]
Returns if this maps the specified cell. @param cell the cell name @return {@code true} if this maps the column, {@code false} otherwise
[ "Returns", "if", "this", "maps", "the", "specified", "cell", "." ]
a94a4d9af6c25d40e1108729974c35c27c54441c
https://github.com/Stratio/cassandra-lucene-index/blob/a94a4d9af6c25d40e1108729974c35c27c54441c/plugin/src/main/java/com/stratio/cassandra/lucene/schema/mapping/Mapper.java#L192-L194
160,781
Stratio/cassandra-lucene-index
plugin/src/main/java/com/stratio/cassandra/lucene/common/GeoDistance.java
GeoDistance.getDegrees
public double getDegrees() { double kms = getValue(GeoDistanceUnit.KILOMETRES); return DistanceUtils.dist2Degrees(kms, DistanceUtils.EARTH_MEAN_RADIUS_KM); }
java
public double getDegrees() { double kms = getValue(GeoDistanceUnit.KILOMETRES); return DistanceUtils.dist2Degrees(kms, DistanceUtils.EARTH_MEAN_RADIUS_KM); }
[ "public", "double", "getDegrees", "(", ")", "{", "double", "kms", "=", "getValue", "(", "GeoDistanceUnit", ".", "KILOMETRES", ")", ";", "return", "DistanceUtils", ".", "dist2Degrees", "(", "kms", ",", "DistanceUtils", ".", "EARTH_MEAN_RADIUS_KM", ")", ";", "}" ]
Return the numeric distance value in degrees. @return the degrees
[ "Return", "the", "numeric", "distance", "value", "in", "degrees", "." ]
a94a4d9af6c25d40e1108729974c35c27c54441c
https://github.com/Stratio/cassandra-lucene-index/blob/a94a4d9af6c25d40e1108729974c35c27c54441c/plugin/src/main/java/com/stratio/cassandra/lucene/common/GeoDistance.java#L62-L65
160,782
Stratio/cassandra-lucene-index
plugin/src/main/java/com/stratio/cassandra/lucene/schema/mapping/DateRangeMapper.java
DateRangeMapper.makeShape
public NRShape makeShape(Date from, Date to) { UnitNRShape fromShape = tree.toUnitShape(from); UnitNRShape toShape = tree.toUnitShape(to); return tree.toRangeShape(fromShape, toShape); }
java
public NRShape makeShape(Date from, Date to) { UnitNRShape fromShape = tree.toUnitShape(from); UnitNRShape toShape = tree.toUnitShape(to); return tree.toRangeShape(fromShape, toShape); }
[ "public", "NRShape", "makeShape", "(", "Date", "from", ",", "Date", "to", ")", "{", "UnitNRShape", "fromShape", "=", "tree", ".", "toUnitShape", "(", "from", ")", ";", "UnitNRShape", "toShape", "=", "tree", ".", "toUnitShape", "(", "to", ")", ";", "return", "tree", ".", "toRangeShape", "(", "fromShape", ",", "toShape", ")", ";", "}" ]
Makes an spatial shape representing the time range defined by the two specified dates. @param from the start {@link Date} @param to the end {@link Date} @return a shape
[ "Makes", "an", "spatial", "shape", "representing", "the", "time", "range", "defined", "by", "the", "two", "specified", "dates", "." ]
a94a4d9af6c25d40e1108729974c35c27c54441c
https://github.com/Stratio/cassandra-lucene-index/blob/a94a4d9af6c25d40e1108729974c35c27c54441c/plugin/src/main/java/com/stratio/cassandra/lucene/schema/mapping/DateRangeMapper.java#L123-L127
160,783
Stratio/cassandra-lucene-index
plugin/src/main/java/com/stratio/cassandra/lucene/common/GeospatialUtils.java
GeospatialUtils.validateGeohashMaxLevels
public static int validateGeohashMaxLevels(Integer userMaxLevels, int defaultMaxLevels) { int maxLevels = userMaxLevels == null ? defaultMaxLevels : userMaxLevels; if (maxLevels < 1 || maxLevels > GeohashPrefixTree.getMaxLevelsPossible()) { throw new IndexException("max_levels must be in range [1, {}], but found {}", GeohashPrefixTree.getMaxLevelsPossible(), maxLevels); } return maxLevels; }
java
public static int validateGeohashMaxLevels(Integer userMaxLevels, int defaultMaxLevels) { int maxLevels = userMaxLevels == null ? defaultMaxLevels : userMaxLevels; if (maxLevels < 1 || maxLevels > GeohashPrefixTree.getMaxLevelsPossible()) { throw new IndexException("max_levels must be in range [1, {}], but found {}", GeohashPrefixTree.getMaxLevelsPossible(), maxLevels); } return maxLevels; }
[ "public", "static", "int", "validateGeohashMaxLevels", "(", "Integer", "userMaxLevels", ",", "int", "defaultMaxLevels", ")", "{", "int", "maxLevels", "=", "userMaxLevels", "==", "null", "?", "defaultMaxLevels", ":", "userMaxLevels", ";", "if", "(", "maxLevels", "<", "1", "||", "maxLevels", ">", "GeohashPrefixTree", ".", "getMaxLevelsPossible", "(", ")", ")", "{", "throw", "new", "IndexException", "(", "\"max_levels must be in range [1, {}], but found {}\"", ",", "GeohashPrefixTree", ".", "getMaxLevelsPossible", "(", ")", ",", "maxLevels", ")", ";", "}", "return", "maxLevels", ";", "}" ]
Checks if the specified max levels is correct. @param userMaxLevels the maximum number of levels in the tree @param defaultMaxLevels the default max number of levels @return the validated max levels
[ "Checks", "if", "the", "specified", "max", "levels", "is", "correct", "." ]
a94a4d9af6c25d40e1108729974c35c27c54441c
https://github.com/Stratio/cassandra-lucene-index/blob/a94a4d9af6c25d40e1108729974c35c27c54441c/plugin/src/main/java/com/stratio/cassandra/lucene/common/GeospatialUtils.java#L51-L59
160,784
Stratio/cassandra-lucene-index
plugin/src/main/java/com/stratio/cassandra/lucene/common/GeospatialUtils.java
GeospatialUtils.checkLatitude
public static Double checkLatitude(String name, Double latitude) { if (latitude == null) { throw new IndexException("{} required", name); } else if (latitude < MIN_LATITUDE || latitude > MAX_LATITUDE) { throw new IndexException("{} must be in range [{}, {}], but found {}", name, MIN_LATITUDE, MAX_LATITUDE, latitude); } return latitude; }
java
public static Double checkLatitude(String name, Double latitude) { if (latitude == null) { throw new IndexException("{} required", name); } else if (latitude < MIN_LATITUDE || latitude > MAX_LATITUDE) { throw new IndexException("{} must be in range [{}, {}], but found {}", name, MIN_LATITUDE, MAX_LATITUDE, latitude); } return latitude; }
[ "public", "static", "Double", "checkLatitude", "(", "String", "name", ",", "Double", "latitude", ")", "{", "if", "(", "latitude", "==", "null", ")", "{", "throw", "new", "IndexException", "(", "\"{} required\"", ",", "name", ")", ";", "}", "else", "if", "(", "latitude", "<", "MIN_LATITUDE", "||", "latitude", ">", "MAX_LATITUDE", ")", "{", "throw", "new", "IndexException", "(", "\"{} must be in range [{}, {}], but found {}\"", ",", "name", ",", "MIN_LATITUDE", ",", "MAX_LATITUDE", ",", "latitude", ")", ";", "}", "return", "latitude", ";", "}" ]
Checks if the specified latitude is correct. @param name the name of the latitude field @param latitude the value of the latitude field @return the latitude
[ "Checks", "if", "the", "specified", "latitude", "is", "correct", "." ]
a94a4d9af6c25d40e1108729974c35c27c54441c
https://github.com/Stratio/cassandra-lucene-index/blob/a94a4d9af6c25d40e1108729974c35c27c54441c/plugin/src/main/java/com/stratio/cassandra/lucene/common/GeospatialUtils.java#L68-L79
160,785
Stratio/cassandra-lucene-index
plugin/src/main/java/com/stratio/cassandra/lucene/common/GeospatialUtils.java
GeospatialUtils.checkLongitude
public static Double checkLongitude(String name, Double longitude) { if (longitude == null) { throw new IndexException("{} required", name); } else if (longitude < MIN_LONGITUDE || longitude > MAX_LONGITUDE) { throw new IndexException("{} must be in range [{}, {}], but found {}", name, MIN_LONGITUDE, MAX_LONGITUDE, longitude); } return longitude; }
java
public static Double checkLongitude(String name, Double longitude) { if (longitude == null) { throw new IndexException("{} required", name); } else if (longitude < MIN_LONGITUDE || longitude > MAX_LONGITUDE) { throw new IndexException("{} must be in range [{}, {}], but found {}", name, MIN_LONGITUDE, MAX_LONGITUDE, longitude); } return longitude; }
[ "public", "static", "Double", "checkLongitude", "(", "String", "name", ",", "Double", "longitude", ")", "{", "if", "(", "longitude", "==", "null", ")", "{", "throw", "new", "IndexException", "(", "\"{} required\"", ",", "name", ")", ";", "}", "else", "if", "(", "longitude", "<", "MIN_LONGITUDE", "||", "longitude", ">", "MAX_LONGITUDE", ")", "{", "throw", "new", "IndexException", "(", "\"{} must be in range [{}, {}], but found {}\"", ",", "name", ",", "MIN_LONGITUDE", ",", "MAX_LONGITUDE", ",", "longitude", ")", ";", "}", "return", "longitude", ";", "}" ]
Checks if the specified longitude is correct. @param name the name of the longitude field @param longitude the value of the longitude field @return the longitude
[ "Checks", "if", "the", "specified", "longitude", "is", "correct", "." ]
a94a4d9af6c25d40e1108729974c35c27c54441c
https://github.com/Stratio/cassandra-lucene-index/blob/a94a4d9af6c25d40e1108729974c35c27c54441c/plugin/src/main/java/com/stratio/cassandra/lucene/common/GeospatialUtils.java#L88-L99
160,786
Stratio/cassandra-lucene-index
plugin/src/main/java/com/stratio/cassandra/lucene/search/Search.java
Search.postProcessingFields
public Set<String> postProcessingFields() { Set<String> fields = new LinkedHashSet<>(); query.forEach(condition -> fields.addAll(condition.postProcessingFields())); sort.forEach(condition -> fields.addAll(condition.postProcessingFields())); return fields; }
java
public Set<String> postProcessingFields() { Set<String> fields = new LinkedHashSet<>(); query.forEach(condition -> fields.addAll(condition.postProcessingFields())); sort.forEach(condition -> fields.addAll(condition.postProcessingFields())); return fields; }
[ "public", "Set", "<", "String", ">", "postProcessingFields", "(", ")", "{", "Set", "<", "String", ">", "fields", "=", "new", "LinkedHashSet", "<>", "(", ")", ";", "query", ".", "forEach", "(", "condition", "->", "fields", ".", "addAll", "(", "condition", ".", "postProcessingFields", "(", ")", ")", ")", ";", "sort", ".", "forEach", "(", "condition", "->", "fields", ".", "addAll", "(", "condition", ".", "postProcessingFields", "(", ")", ")", ")", ";", "return", "fields", ";", "}" ]
Returns the names of the involved fields when post processing. @return the names of the involved fields
[ "Returns", "the", "names", "of", "the", "involved", "fields", "when", "post", "processing", "." ]
a94a4d9af6c25d40e1108729974c35c27c54441c
https://github.com/Stratio/cassandra-lucene-index/blob/a94a4d9af6c25d40e1108729974c35c27c54441c/plugin/src/main/java/com/stratio/cassandra/lucene/search/Search.java#L189-L194
160,787
Stratio/cassandra-lucene-index
builder/src/main/java/com/stratio/cassandra/lucene/builder/Builder.java
Builder.index
public static Index index(String keyspace, String table, String name) { return new Index(table, name).keyspace(keyspace); }
java
public static Index index(String keyspace, String table, String name) { return new Index(table, name).keyspace(keyspace); }
[ "public", "static", "Index", "index", "(", "String", "keyspace", ",", "String", "table", ",", "String", "name", ")", "{", "return", "new", "Index", "(", "table", ",", "name", ")", ".", "keyspace", "(", "keyspace", ")", ";", "}" ]
Returns a new index creation statement using the session's keyspace. @param keyspace the keyspace name @param table the table name @param name the index name @return a new index creation statement
[ "Returns", "a", "new", "index", "creation", "statement", "using", "the", "session", "s", "keyspace", "." ]
a94a4d9af6c25d40e1108729974c35c27c54441c
https://github.com/Stratio/cassandra-lucene-index/blob/a94a4d9af6c25d40e1108729974c35c27c54441c/builder/src/main/java/com/stratio/cassandra/lucene/builder/Builder.java#L61-L63
160,788
Stratio/cassandra-lucene-index
builder/src/main/java/com/stratio/cassandra/lucene/builder/index/schema/mapping/GeoShapeMapper.java
GeoShapeMapper.transform
public GeoShapeMapper transform(GeoTransformation... transformations) { if (this.transformations == null) { this.transformations = Arrays.asList(transformations); } else { this.transformations.addAll(Arrays.asList(transformations)); } return this; }
java
public GeoShapeMapper transform(GeoTransformation... transformations) { if (this.transformations == null) { this.transformations = Arrays.asList(transformations); } else { this.transformations.addAll(Arrays.asList(transformations)); } return this; }
[ "public", "GeoShapeMapper", "transform", "(", "GeoTransformation", "...", "transformations", ")", "{", "if", "(", "this", ".", "transformations", "==", "null", ")", "{", "this", ".", "transformations", "=", "Arrays", ".", "asList", "(", "transformations", ")", ";", "}", "else", "{", "this", ".", "transformations", ".", "addAll", "(", "Arrays", ".", "asList", "(", "transformations", ")", ")", ";", "}", "return", "this", ";", "}" ]
Sets the transformations to be applied to the shape before indexing it. @param transformations the sequence of transformations @return this with the specified sequence of transformations
[ "Sets", "the", "transformations", "to", "be", "applied", "to", "the", "shape", "before", "indexing", "it", "." ]
a94a4d9af6c25d40e1108729974c35c27c54441c
https://github.com/Stratio/cassandra-lucene-index/blob/a94a4d9af6c25d40e1108729974c35c27c54441c/builder/src/main/java/com/stratio/cassandra/lucene/builder/index/schema/mapping/GeoShapeMapper.java#L74-L81
160,789
Stratio/cassandra-lucene-index
plugin/src/main/java/com/stratio/cassandra/lucene/search/SearchBuilderLegacy.java
SearchBuilderLegacy.paging
@JsonProperty("paging") void paging(String paging) { builder.paging(IndexPagingState.fromByteBuffer(ByteBufferUtils.byteBuffer(paging))); }
java
@JsonProperty("paging") void paging(String paging) { builder.paging(IndexPagingState.fromByteBuffer(ByteBufferUtils.byteBuffer(paging))); }
[ "@", "JsonProperty", "(", "\"paging\"", ")", "void", "paging", "(", "String", "paging", ")", "{", "builder", ".", "paging", "(", "IndexPagingState", ".", "fromByteBuffer", "(", "ByteBufferUtils", ".", "byteBuffer", "(", "paging", ")", ")", ")", ";", "}" ]
Sets the specified starting partition key. @param paging a paging state
[ "Sets", "the", "specified", "starting", "partition", "key", "." ]
a94a4d9af6c25d40e1108729974c35c27c54441c
https://github.com/Stratio/cassandra-lucene-index/blob/a94a4d9af6c25d40e1108729974c35c27c54441c/plugin/src/main/java/com/stratio/cassandra/lucene/search/SearchBuilderLegacy.java#L86-L89
160,790
Stratio/cassandra-lucene-index
plugin/src/main/java/com/stratio/cassandra/lucene/schema/Schema.java
Schema.mapsCell
public boolean mapsCell(String cell) { return mappers.values().stream().anyMatch(mapper -> mapper.mapsCell(cell)); }
java
public boolean mapsCell(String cell) { return mappers.values().stream().anyMatch(mapper -> mapper.mapsCell(cell)); }
[ "public", "boolean", "mapsCell", "(", "String", "cell", ")", "{", "return", "mappers", ".", "values", "(", ")", ".", "stream", "(", ")", ".", "anyMatch", "(", "mapper", "->", "mapper", ".", "mapsCell", "(", "cell", ")", ")", ";", "}" ]
Returns if this has any mapping for the specified cell. @param cell the cell name @return {@code true} if there is any mapping for the cell, {@code false} otherwise
[ "Returns", "if", "this", "has", "any", "mapping", "for", "the", "specified", "cell", "." ]
a94a4d9af6c25d40e1108729974c35c27c54441c
https://github.com/Stratio/cassandra-lucene-index/blob/a94a4d9af6c25d40e1108729974c35c27c54441c/plugin/src/main/java/com/stratio/cassandra/lucene/schema/Schema.java#L150-L152
160,791
dlew/joda-time-android
library/src/main/java/net/danlew/android/joda/ResUtils.java
ResUtils.convertPathToResource
private static String convertPathToResource(String path) { File file = new File(path); List<String> parts = new ArrayList<String>(); do { parts.add(file.getName()); file = file.getParentFile(); } while (file != null); StringBuffer sb = new StringBuffer(); int size = parts.size(); for (int a = size - 1; a >= 0; a--) { if (sb.length() > 0) { sb.append("_"); } sb.append(parts.get(a)); } // TODO: Better regex replacement return sb.toString().replace('-', '_').replace("+", "plus").toLowerCase(Locale.US); }
java
private static String convertPathToResource(String path) { File file = new File(path); List<String> parts = new ArrayList<String>(); do { parts.add(file.getName()); file = file.getParentFile(); } while (file != null); StringBuffer sb = new StringBuffer(); int size = parts.size(); for (int a = size - 1; a >= 0; a--) { if (sb.length() > 0) { sb.append("_"); } sb.append(parts.get(a)); } // TODO: Better regex replacement return sb.toString().replace('-', '_').replace("+", "plus").toLowerCase(Locale.US); }
[ "private", "static", "String", "convertPathToResource", "(", "String", "path", ")", "{", "File", "file", "=", "new", "File", "(", "path", ")", ";", "List", "<", "String", ">", "parts", "=", "new", "ArrayList", "<", "String", ">", "(", ")", ";", "do", "{", "parts", ".", "add", "(", "file", ".", "getName", "(", ")", ")", ";", "file", "=", "file", ".", "getParentFile", "(", ")", ";", "}", "while", "(", "file", "!=", "null", ")", ";", "StringBuffer", "sb", "=", "new", "StringBuffer", "(", ")", ";", "int", "size", "=", "parts", ".", "size", "(", ")", ";", "for", "(", "int", "a", "=", "size", "-", "1", ";", "a", ">=", "0", ";", "a", "--", ")", "{", "if", "(", "sb", ".", "length", "(", ")", ">", "0", ")", "{", "sb", ".", "append", "(", "\"_\"", ")", ";", "}", "sb", ".", "append", "(", "parts", ".", "get", "(", "a", ")", ")", ";", "}", "// TODO: Better regex replacement", "return", "sb", ".", "toString", "(", ")", ".", "replace", "(", "'", "'", ",", "'", "'", ")", ".", "replace", "(", "\"+\"", ",", "\"plus\"", ")", ".", "toLowerCase", "(", "Locale", ".", "US", ")", ";", "}" ]
Converts any path into something that can be placed in an Android directory. Traverses any subdirectories and flattens it all into a single filename. Also gets rid of commonly seen illegal characters in tz identifiers, and lower cases the entire thing. @param path the path to convert @return a flat path with no directories (and lower-cased)
[ "Converts", "any", "path", "into", "something", "that", "can", "be", "placed", "in", "an", "Android", "directory", "." ]
5bf96f6ef4ea63ee91e73e1e528896fa00108dec
https://github.com/dlew/joda-time-android/blob/5bf96f6ef4ea63ee91e73e1e528896fa00108dec/library/src/main/java/net/danlew/android/joda/ResUtils.java#L31-L51
160,792
dlew/joda-time-android
library/src/main/java/net/danlew/android/joda/DateUtils.java
DateUtils.formatDateTime
public static String formatDateTime(Context context, ReadablePartial time, int flags) { return android.text.format.DateUtils.formatDateTime(context, toMillis(time), flags | FORMAT_UTC); }
java
public static String formatDateTime(Context context, ReadablePartial time, int flags) { return android.text.format.DateUtils.formatDateTime(context, toMillis(time), flags | FORMAT_UTC); }
[ "public", "static", "String", "formatDateTime", "(", "Context", "context", ",", "ReadablePartial", "time", ",", "int", "flags", ")", "{", "return", "android", ".", "text", ".", "format", ".", "DateUtils", ".", "formatDateTime", "(", "context", ",", "toMillis", "(", "time", ")", ",", "flags", "|", "FORMAT_UTC", ")", ";", "}" ]
Formats a date or a time according to the local conventions. Since ReadablePartials don't support all fields, we fill in any blanks needed for formatting by using the epoch (1970-01-01T00:00:00Z). See {@link android.text.format.DateUtils#formatDateTime} for full docs. @param context the context is required only if the time is shown @param time a point in time @param flags a bit mask of formatting options @return a string containing the formatted date/time.
[ "Formats", "a", "date", "or", "a", "time", "according", "to", "the", "local", "conventions", "." ]
5bf96f6ef4ea63ee91e73e1e528896fa00108dec
https://github.com/dlew/joda-time-android/blob/5bf96f6ef4ea63ee91e73e1e528896fa00108dec/library/src/main/java/net/danlew/android/joda/DateUtils.java#L79-L81
160,793
dlew/joda-time-android
library/src/main/java/net/danlew/android/joda/DateUtils.java
DateUtils.formatDateRange
public static String formatDateRange(Context context, ReadablePartial start, ReadablePartial end, int flags) { return formatDateRange(context, toMillis(start), toMillis(end), flags); }
java
public static String formatDateRange(Context context, ReadablePartial start, ReadablePartial end, int flags) { return formatDateRange(context, toMillis(start), toMillis(end), flags); }
[ "public", "static", "String", "formatDateRange", "(", "Context", "context", ",", "ReadablePartial", "start", ",", "ReadablePartial", "end", ",", "int", "flags", ")", "{", "return", "formatDateRange", "(", "context", ",", "toMillis", "(", "start", ")", ",", "toMillis", "(", "end", ")", ",", "flags", ")", ";", "}" ]
Formats a date or a time range according to the local conventions. You should ensure that start/end are in the same timezone; formatDateRange() doesn't handle start/end in different timezones well. See {@link android.text.format.DateUtils#formatDateRange} for full docs. @param context the context is required only if the time is shown @param start the start time @param end the end time @param flags a bit mask of options @return a string containing the formatted date/time range
[ "Formats", "a", "date", "or", "a", "time", "range", "according", "to", "the", "local", "conventions", "." ]
5bf96f6ef4ea63ee91e73e1e528896fa00108dec
https://github.com/dlew/joda-time-android/blob/5bf96f6ef4ea63ee91e73e1e528896fa00108dec/library/src/main/java/net/danlew/android/joda/DateUtils.java#L111-L113
160,794
dlew/joda-time-android
library/src/main/java/net/danlew/android/joda/DateUtils.java
DateUtils.getRelativeTimeSpanString
public static CharSequence getRelativeTimeSpanString(Context context, ReadableInstant time, int flags) { boolean abbrevRelative = (flags & (FORMAT_ABBREV_RELATIVE | FORMAT_ABBREV_ALL)) != 0; // We set the millis to 0 so we aren't off by a fraction of a second when counting intervals DateTime now = DateTime.now(time.getZone()).withMillisOfSecond(0); DateTime timeDt = new DateTime(time).withMillisOfSecond(0); boolean past = !now.isBefore(timeDt); Interval interval = past ? new Interval(timeDt, now) : new Interval(now, timeDt); int resId; long count; if (Minutes.minutesIn(interval).isLessThan(Minutes.ONE)) { count = Seconds.secondsIn(interval).getSeconds(); if (past) { if (abbrevRelative) { resId = R.plurals.joda_time_android_abbrev_num_seconds_ago; } else { resId = R.plurals.joda_time_android_num_seconds_ago; } } else { if (abbrevRelative) { resId = R.plurals.joda_time_android_abbrev_in_num_seconds; } else { resId = R.plurals.joda_time_android_in_num_seconds; } } } else if (Hours.hoursIn(interval).isLessThan(Hours.ONE)) { count = Minutes.minutesIn(interval).getMinutes(); if (past) { if (abbrevRelative) { resId = R.plurals.joda_time_android_abbrev_num_minutes_ago; } else { resId = R.plurals.joda_time_android_num_minutes_ago; } } else { if (abbrevRelative) { resId = R.plurals.joda_time_android_abbrev_in_num_minutes; } else { resId = R.plurals.joda_time_android_in_num_minutes; } } } else if (Days.daysIn(interval).isLessThan(Days.ONE)) { count = Hours.hoursIn(interval).getHours(); if (past) { if (abbrevRelative) { resId = R.plurals.joda_time_android_abbrev_num_hours_ago; } else { resId = R.plurals.joda_time_android_num_hours_ago; } } else { if (abbrevRelative) { resId = R.plurals.joda_time_android_abbrev_in_num_hours; } else { resId = R.plurals.joda_time_android_in_num_hours; } } } else if (Weeks.weeksIn(interval).isLessThan(Weeks.ONE)) { count = Days.daysIn(interval).getDays(); if (past) { if (abbrevRelative) { resId = R.plurals.joda_time_android_abbrev_num_days_ago; } else { resId = R.plurals.joda_time_android_num_days_ago; } } else { if (abbrevRelative) { resId = R.plurals.joda_time_android_abbrev_in_num_days; } else { resId = R.plurals.joda_time_android_in_num_days; } } } else { return formatDateRange(context, time, time, flags); } String format = context.getResources().getQuantityString(resId, (int) count); return String.format(format, count); }
java
public static CharSequence getRelativeTimeSpanString(Context context, ReadableInstant time, int flags) { boolean abbrevRelative = (flags & (FORMAT_ABBREV_RELATIVE | FORMAT_ABBREV_ALL)) != 0; // We set the millis to 0 so we aren't off by a fraction of a second when counting intervals DateTime now = DateTime.now(time.getZone()).withMillisOfSecond(0); DateTime timeDt = new DateTime(time).withMillisOfSecond(0); boolean past = !now.isBefore(timeDt); Interval interval = past ? new Interval(timeDt, now) : new Interval(now, timeDt); int resId; long count; if (Minutes.minutesIn(interval).isLessThan(Minutes.ONE)) { count = Seconds.secondsIn(interval).getSeconds(); if (past) { if (abbrevRelative) { resId = R.plurals.joda_time_android_abbrev_num_seconds_ago; } else { resId = R.plurals.joda_time_android_num_seconds_ago; } } else { if (abbrevRelative) { resId = R.plurals.joda_time_android_abbrev_in_num_seconds; } else { resId = R.plurals.joda_time_android_in_num_seconds; } } } else if (Hours.hoursIn(interval).isLessThan(Hours.ONE)) { count = Minutes.minutesIn(interval).getMinutes(); if (past) { if (abbrevRelative) { resId = R.plurals.joda_time_android_abbrev_num_minutes_ago; } else { resId = R.plurals.joda_time_android_num_minutes_ago; } } else { if (abbrevRelative) { resId = R.plurals.joda_time_android_abbrev_in_num_minutes; } else { resId = R.plurals.joda_time_android_in_num_minutes; } } } else if (Days.daysIn(interval).isLessThan(Days.ONE)) { count = Hours.hoursIn(interval).getHours(); if (past) { if (abbrevRelative) { resId = R.plurals.joda_time_android_abbrev_num_hours_ago; } else { resId = R.plurals.joda_time_android_num_hours_ago; } } else { if (abbrevRelative) { resId = R.plurals.joda_time_android_abbrev_in_num_hours; } else { resId = R.plurals.joda_time_android_in_num_hours; } } } else if (Weeks.weeksIn(interval).isLessThan(Weeks.ONE)) { count = Days.daysIn(interval).getDays(); if (past) { if (abbrevRelative) { resId = R.plurals.joda_time_android_abbrev_num_days_ago; } else { resId = R.plurals.joda_time_android_num_days_ago; } } else { if (abbrevRelative) { resId = R.plurals.joda_time_android_abbrev_in_num_days; } else { resId = R.plurals.joda_time_android_in_num_days; } } } else { return formatDateRange(context, time, time, flags); } String format = context.getResources().getQuantityString(resId, (int) count); return String.format(format, count); }
[ "public", "static", "CharSequence", "getRelativeTimeSpanString", "(", "Context", "context", ",", "ReadableInstant", "time", ",", "int", "flags", ")", "{", "boolean", "abbrevRelative", "=", "(", "flags", "&", "(", "FORMAT_ABBREV_RELATIVE", "|", "FORMAT_ABBREV_ALL", ")", ")", "!=", "0", ";", "// We set the millis to 0 so we aren't off by a fraction of a second when counting intervals", "DateTime", "now", "=", "DateTime", ".", "now", "(", "time", ".", "getZone", "(", ")", ")", ".", "withMillisOfSecond", "(", "0", ")", ";", "DateTime", "timeDt", "=", "new", "DateTime", "(", "time", ")", ".", "withMillisOfSecond", "(", "0", ")", ";", "boolean", "past", "=", "!", "now", ".", "isBefore", "(", "timeDt", ")", ";", "Interval", "interval", "=", "past", "?", "new", "Interval", "(", "timeDt", ",", "now", ")", ":", "new", "Interval", "(", "now", ",", "timeDt", ")", ";", "int", "resId", ";", "long", "count", ";", "if", "(", "Minutes", ".", "minutesIn", "(", "interval", ")", ".", "isLessThan", "(", "Minutes", ".", "ONE", ")", ")", "{", "count", "=", "Seconds", ".", "secondsIn", "(", "interval", ")", ".", "getSeconds", "(", ")", ";", "if", "(", "past", ")", "{", "if", "(", "abbrevRelative", ")", "{", "resId", "=", "R", ".", "plurals", ".", "joda_time_android_abbrev_num_seconds_ago", ";", "}", "else", "{", "resId", "=", "R", ".", "plurals", ".", "joda_time_android_num_seconds_ago", ";", "}", "}", "else", "{", "if", "(", "abbrevRelative", ")", "{", "resId", "=", "R", ".", "plurals", ".", "joda_time_android_abbrev_in_num_seconds", ";", "}", "else", "{", "resId", "=", "R", ".", "plurals", ".", "joda_time_android_in_num_seconds", ";", "}", "}", "}", "else", "if", "(", "Hours", ".", "hoursIn", "(", "interval", ")", ".", "isLessThan", "(", "Hours", ".", "ONE", ")", ")", "{", "count", "=", "Minutes", ".", "minutesIn", "(", "interval", ")", ".", "getMinutes", "(", ")", ";", "if", "(", "past", ")", "{", "if", "(", "abbrevRelative", ")", "{", "resId", "=", "R", ".", "plurals", ".", "joda_time_android_abbrev_num_minutes_ago", ";", "}", "else", "{", "resId", "=", "R", ".", "plurals", ".", "joda_time_android_num_minutes_ago", ";", "}", "}", "else", "{", "if", "(", "abbrevRelative", ")", "{", "resId", "=", "R", ".", "plurals", ".", "joda_time_android_abbrev_in_num_minutes", ";", "}", "else", "{", "resId", "=", "R", ".", "plurals", ".", "joda_time_android_in_num_minutes", ";", "}", "}", "}", "else", "if", "(", "Days", ".", "daysIn", "(", "interval", ")", ".", "isLessThan", "(", "Days", ".", "ONE", ")", ")", "{", "count", "=", "Hours", ".", "hoursIn", "(", "interval", ")", ".", "getHours", "(", ")", ";", "if", "(", "past", ")", "{", "if", "(", "abbrevRelative", ")", "{", "resId", "=", "R", ".", "plurals", ".", "joda_time_android_abbrev_num_hours_ago", ";", "}", "else", "{", "resId", "=", "R", ".", "plurals", ".", "joda_time_android_num_hours_ago", ";", "}", "}", "else", "{", "if", "(", "abbrevRelative", ")", "{", "resId", "=", "R", ".", "plurals", ".", "joda_time_android_abbrev_in_num_hours", ";", "}", "else", "{", "resId", "=", "R", ".", "plurals", ".", "joda_time_android_in_num_hours", ";", "}", "}", "}", "else", "if", "(", "Weeks", ".", "weeksIn", "(", "interval", ")", ".", "isLessThan", "(", "Weeks", ".", "ONE", ")", ")", "{", "count", "=", "Days", ".", "daysIn", "(", "interval", ")", ".", "getDays", "(", ")", ";", "if", "(", "past", ")", "{", "if", "(", "abbrevRelative", ")", "{", "resId", "=", "R", ".", "plurals", ".", "joda_time_android_abbrev_num_days_ago", ";", "}", "else", "{", "resId", "=", "R", ".", "plurals", ".", "joda_time_android_num_days_ago", ";", "}", "}", "else", "{", "if", "(", "abbrevRelative", ")", "{", "resId", "=", "R", ".", "plurals", ".", "joda_time_android_abbrev_in_num_days", ";", "}", "else", "{", "resId", "=", "R", ".", "plurals", ".", "joda_time_android_in_num_days", ";", "}", "}", "}", "else", "{", "return", "formatDateRange", "(", "context", ",", "time", ",", "time", ",", "flags", ")", ";", "}", "String", "format", "=", "context", ".", "getResources", "(", ")", ".", "getQuantityString", "(", "resId", ",", "(", "int", ")", "count", ")", ";", "return", "String", ".", "format", "(", "format", ",", "count", ")", ";", "}" ]
Returns a string describing 'time' as a time relative to 'now'. See {@link android.text.format.DateUtils#getRelativeTimeSpanString} for full docs. @param context the context @param time the time to describe @param flags a bit mask for formatting options, usually FORMAT_ABBREV_RELATIVE @return a string describing 'time' as a time relative to 'now'.
[ "Returns", "a", "string", "describing", "time", "as", "a", "time", "relative", "to", "now", "." ]
5bf96f6ef4ea63ee91e73e1e528896fa00108dec
https://github.com/dlew/joda-time-android/blob/5bf96f6ef4ea63ee91e73e1e528896fa00108dec/library/src/main/java/net/danlew/android/joda/DateUtils.java#L246-L339
160,795
dlew/joda-time-android
library/src/main/java/net/danlew/android/joda/DateUtils.java
DateUtils.formatDuration
public static CharSequence formatDuration(Context context, ReadableDuration readableDuration) { Resources res = context.getResources(); Duration duration = readableDuration.toDuration(); final int hours = (int) duration.getStandardHours(); if (hours != 0) { return res.getQuantityString(R.plurals.joda_time_android_duration_hours, hours, hours); } final int minutes = (int) duration.getStandardMinutes(); if (minutes != 0) { return res.getQuantityString(R.plurals.joda_time_android_duration_minutes, minutes, minutes); } final int seconds = (int) duration.getStandardSeconds(); return res.getQuantityString(R.plurals.joda_time_android_duration_seconds, seconds, seconds); }
java
public static CharSequence formatDuration(Context context, ReadableDuration readableDuration) { Resources res = context.getResources(); Duration duration = readableDuration.toDuration(); final int hours = (int) duration.getStandardHours(); if (hours != 0) { return res.getQuantityString(R.plurals.joda_time_android_duration_hours, hours, hours); } final int minutes = (int) duration.getStandardMinutes(); if (minutes != 0) { return res.getQuantityString(R.plurals.joda_time_android_duration_minutes, minutes, minutes); } final int seconds = (int) duration.getStandardSeconds(); return res.getQuantityString(R.plurals.joda_time_android_duration_seconds, seconds, seconds); }
[ "public", "static", "CharSequence", "formatDuration", "(", "Context", "context", ",", "ReadableDuration", "readableDuration", ")", "{", "Resources", "res", "=", "context", ".", "getResources", "(", ")", ";", "Duration", "duration", "=", "readableDuration", ".", "toDuration", "(", ")", ";", "final", "int", "hours", "=", "(", "int", ")", "duration", ".", "getStandardHours", "(", ")", ";", "if", "(", "hours", "!=", "0", ")", "{", "return", "res", ".", "getQuantityString", "(", "R", ".", "plurals", ".", "joda_time_android_duration_hours", ",", "hours", ",", "hours", ")", ";", "}", "final", "int", "minutes", "=", "(", "int", ")", "duration", ".", "getStandardMinutes", "(", ")", ";", "if", "(", "minutes", "!=", "0", ")", "{", "return", "res", ".", "getQuantityString", "(", "R", ".", "plurals", ".", "joda_time_android_duration_minutes", ",", "minutes", ",", "minutes", ")", ";", "}", "final", "int", "seconds", "=", "(", "int", ")", "duration", ".", "getStandardSeconds", "(", ")", ";", "return", "res", ".", "getQuantityString", "(", "R", ".", "plurals", ".", "joda_time_android_duration_seconds", ",", "seconds", ",", "seconds", ")", ";", "}" ]
Return given duration in a human-friendly format. For example, "4 minutes" or "1 second". Returns only largest meaningful unit of time, from seconds up to hours. The longest duration it supports is hours. This method assumes that there are 60 minutes in an hour, 60 seconds in a minute and 1000 milliseconds in a second. All currently supplied chronologies use this definition.
[ "Return", "given", "duration", "in", "a", "human", "-", "friendly", "format", ".", "For", "example", "4", "minutes", "or", "1", "second", ".", "Returns", "only", "largest", "meaningful", "unit", "of", "time", "from", "seconds", "up", "to", "hours", "." ]
5bf96f6ef4ea63ee91e73e1e528896fa00108dec
https://github.com/dlew/joda-time-android/blob/5bf96f6ef4ea63ee91e73e1e528896fa00108dec/library/src/main/java/net/danlew/android/joda/DateUtils.java#L489-L505
160,796
dlew/joda-time-android
library/src/main/java/net/danlew/android/joda/ResourceZoneInfoProvider.java
ResourceZoneInfoProvider.getZone
public DateTimeZone getZone(String id) { if (id == null) { return null; } Object obj = iZoneInfoMap.get(id); if (obj == null) { return null; } if (id.equals(obj)) { // Load zone data for the first time. return loadZoneData(id); } if (obj instanceof SoftReference<?>) { @SuppressWarnings("unchecked") SoftReference<DateTimeZone> ref = (SoftReference<DateTimeZone>) obj; DateTimeZone tz = ref.get(); if (tz != null) { return tz; } // Reference cleared; load data again. return loadZoneData(id); } // If this point is reached, mapping must link to another. return getZone((String) obj); }
java
public DateTimeZone getZone(String id) { if (id == null) { return null; } Object obj = iZoneInfoMap.get(id); if (obj == null) { return null; } if (id.equals(obj)) { // Load zone data for the first time. return loadZoneData(id); } if (obj instanceof SoftReference<?>) { @SuppressWarnings("unchecked") SoftReference<DateTimeZone> ref = (SoftReference<DateTimeZone>) obj; DateTimeZone tz = ref.get(); if (tz != null) { return tz; } // Reference cleared; load data again. return loadZoneData(id); } // If this point is reached, mapping must link to another. return getZone((String) obj); }
[ "public", "DateTimeZone", "getZone", "(", "String", "id", ")", "{", "if", "(", "id", "==", "null", ")", "{", "return", "null", ";", "}", "Object", "obj", "=", "iZoneInfoMap", ".", "get", "(", "id", ")", ";", "if", "(", "obj", "==", "null", ")", "{", "return", "null", ";", "}", "if", "(", "id", ".", "equals", "(", "obj", ")", ")", "{", "// Load zone data for the first time.", "return", "loadZoneData", "(", "id", ")", ";", "}", "if", "(", "obj", "instanceof", "SoftReference", "<", "?", ">", ")", "{", "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "SoftReference", "<", "DateTimeZone", ">", "ref", "=", "(", "SoftReference", "<", "DateTimeZone", ">", ")", "obj", ";", "DateTimeZone", "tz", "=", "ref", ".", "get", "(", ")", ";", "if", "(", "tz", "!=", "null", ")", "{", "return", "tz", ";", "}", "// Reference cleared; load data again.", "return", "loadZoneData", "(", "id", ")", ";", "}", "// If this point is reached, mapping must link to another.", "return", "getZone", "(", "(", "String", ")", "obj", ")", ";", "}" ]
If an error is thrown while loading zone data, the exception is logged to system error and null is returned for this and all future requests. @param id the id to load @return the loaded zone
[ "If", "an", "error", "is", "thrown", "while", "loading", "zone", "data", "the", "exception", "is", "logged", "to", "system", "error", "and", "null", "is", "returned", "for", "this", "and", "all", "future", "requests", "." ]
5bf96f6ef4ea63ee91e73e1e528896fa00108dec
https://github.com/dlew/joda-time-android/blob/5bf96f6ef4ea63ee91e73e1e528896fa00108dec/library/src/main/java/net/danlew/android/joda/ResourceZoneInfoProvider.java#L49-L77
160,797
kiegroup/jbpm-designer
jbpm-designer-client/src/main/java/org/jbpm/designer/client/notification/DesignerNotificationPopupsManager.java
DesignerNotificationPopupsManager.addNotification
public void addNotification(@Observes final DesignerNotificationEvent event) { if (user.getIdentifier().equals(event.getUserId())) { if (event.getNotification() != null && !event.getNotification().equals("openinxmleditor")) { final NotificationPopupView view = new NotificationPopupView(); activeNotifications.add(view); view.setPopupPosition(getMargin(), activeNotifications.size() * SPACING); view.setNotification(event.getNotification()); view.setType(event.getType()); view.setNotificationWidth(getWidth() + "px"); view.show(new Command() { @Override public void execute() { //The notification has been shown and can now be removed deactiveNotifications.add(view); remove(); } }); } } }
java
public void addNotification(@Observes final DesignerNotificationEvent event) { if (user.getIdentifier().equals(event.getUserId())) { if (event.getNotification() != null && !event.getNotification().equals("openinxmleditor")) { final NotificationPopupView view = new NotificationPopupView(); activeNotifications.add(view); view.setPopupPosition(getMargin(), activeNotifications.size() * SPACING); view.setNotification(event.getNotification()); view.setType(event.getType()); view.setNotificationWidth(getWidth() + "px"); view.show(new Command() { @Override public void execute() { //The notification has been shown and can now be removed deactiveNotifications.add(view); remove(); } }); } } }
[ "public", "void", "addNotification", "(", "@", "Observes", "final", "DesignerNotificationEvent", "event", ")", "{", "if", "(", "user", ".", "getIdentifier", "(", ")", ".", "equals", "(", "event", ".", "getUserId", "(", ")", ")", ")", "{", "if", "(", "event", ".", "getNotification", "(", ")", "!=", "null", "&&", "!", "event", ".", "getNotification", "(", ")", ".", "equals", "(", "\"openinxmleditor\"", ")", ")", "{", "final", "NotificationPopupView", "view", "=", "new", "NotificationPopupView", "(", ")", ";", "activeNotifications", ".", "add", "(", "view", ")", ";", "view", ".", "setPopupPosition", "(", "getMargin", "(", ")", ",", "activeNotifications", ".", "size", "(", ")", "*", "SPACING", ")", ";", "view", ".", "setNotification", "(", "event", ".", "getNotification", "(", ")", ")", ";", "view", ".", "setType", "(", "event", ".", "getType", "(", ")", ")", ";", "view", ".", "setNotificationWidth", "(", "getWidth", "(", ")", "+", "\"px\"", ")", ";", "view", ".", "show", "(", "new", "Command", "(", ")", "{", "@", "Override", "public", "void", "execute", "(", ")", "{", "//The notification has been shown and can now be removed", "deactiveNotifications", ".", "add", "(", "view", ")", ";", "remove", "(", ")", ";", "}", "}", ")", ";", "}", "}", "}" ]
Display a Notification message @param event
[ "Display", "a", "Notification", "message" ]
97b048d06f083a1f831c971c2e9fdfd0952d2b0b
https://github.com/kiegroup/jbpm-designer/blob/97b048d06f083a1f831c971c2e9fdfd0952d2b0b/jbpm-designer-client/src/main/java/org/jbpm/designer/client/notification/DesignerNotificationPopupsManager.java#L51-L74
160,798
kiegroup/jbpm-designer
jbpm-designer-client/src/main/java/org/jbpm/designer/client/notification/DesignerNotificationPopupsManager.java
DesignerNotificationPopupsManager.remove
private void remove() { if (removing) { return; } if (deactiveNotifications.size() == 0) { return; } removing = true; final NotificationPopupView view = deactiveNotifications.get(0); final LinearFadeOutAnimation fadeOutAnimation = new LinearFadeOutAnimation(view) { @Override public void onUpdate(double progress) { super.onUpdate(progress); for (int i = 0; i < activeNotifications.size(); i++) { NotificationPopupView v = activeNotifications.get(i); final int left = v.getPopupLeft(); final int top = (int) (((i + 1) * SPACING) - (progress * SPACING)); v.setPopupPosition(left, top); } } @Override public void onComplete() { super.onComplete(); view.hide(); deactiveNotifications.remove(view); activeNotifications.remove(view); removing = false; remove(); } }; fadeOutAnimation.run(500); }
java
private void remove() { if (removing) { return; } if (deactiveNotifications.size() == 0) { return; } removing = true; final NotificationPopupView view = deactiveNotifications.get(0); final LinearFadeOutAnimation fadeOutAnimation = new LinearFadeOutAnimation(view) { @Override public void onUpdate(double progress) { super.onUpdate(progress); for (int i = 0; i < activeNotifications.size(); i++) { NotificationPopupView v = activeNotifications.get(i); final int left = v.getPopupLeft(); final int top = (int) (((i + 1) * SPACING) - (progress * SPACING)); v.setPopupPosition(left, top); } } @Override public void onComplete() { super.onComplete(); view.hide(); deactiveNotifications.remove(view); activeNotifications.remove(view); removing = false; remove(); } }; fadeOutAnimation.run(500); }
[ "private", "void", "remove", "(", ")", "{", "if", "(", "removing", ")", "{", "return", ";", "}", "if", "(", "deactiveNotifications", ".", "size", "(", ")", "==", "0", ")", "{", "return", ";", "}", "removing", "=", "true", ";", "final", "NotificationPopupView", "view", "=", "deactiveNotifications", ".", "get", "(", "0", ")", ";", "final", "LinearFadeOutAnimation", "fadeOutAnimation", "=", "new", "LinearFadeOutAnimation", "(", "view", ")", "{", "@", "Override", "public", "void", "onUpdate", "(", "double", "progress", ")", "{", "super", ".", "onUpdate", "(", "progress", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "activeNotifications", ".", "size", "(", ")", ";", "i", "++", ")", "{", "NotificationPopupView", "v", "=", "activeNotifications", ".", "get", "(", "i", ")", ";", "final", "int", "left", "=", "v", ".", "getPopupLeft", "(", ")", ";", "final", "int", "top", "=", "(", "int", ")", "(", "(", "(", "i", "+", "1", ")", "*", "SPACING", ")", "-", "(", "progress", "*", "SPACING", ")", ")", ";", "v", ".", "setPopupPosition", "(", "left", ",", "top", ")", ";", "}", "}", "@", "Override", "public", "void", "onComplete", "(", ")", "{", "super", ".", "onComplete", "(", ")", ";", "view", ".", "hide", "(", ")", ";", "deactiveNotifications", ".", "remove", "(", "view", ")", ";", "activeNotifications", ".", "remove", "(", "view", ")", ";", "removing", "=", "false", ";", "remove", "(", ")", ";", "}", "}", ";", "fadeOutAnimation", ".", "run", "(", "500", ")", ";", "}" ]
Remove a notification message. Recursive until all pending removals have been completed.
[ "Remove", "a", "notification", "message", ".", "Recursive", "until", "all", "pending", "removals", "have", "been", "completed", "." ]
97b048d06f083a1f831c971c2e9fdfd0952d2b0b
https://github.com/kiegroup/jbpm-designer/blob/97b048d06f083a1f831c971c2e9fdfd0952d2b0b/jbpm-designer-client/src/main/java/org/jbpm/designer/client/notification/DesignerNotificationPopupsManager.java#L87-L121
160,799
kiegroup/jbpm-designer
jbpm-designer-backend/src/main/java/org/jbpm/designer/server/EditorHandler.java
EditorHandler.readDesignerVersion
public static String readDesignerVersion(ServletContext context) { String retStr = ""; BufferedReader br = null; try { InputStream inputStream = context.getResourceAsStream("/META-INF/MANIFEST.MF"); br = new BufferedReader(new InputStreamReader(inputStream, "UTF-8")); String line; while ((line = br.readLine()) != null) { if (line.startsWith(BUNDLE_VERSION)) { retStr = line.substring(BUNDLE_VERSION.length() + 1); retStr = retStr.trim(); } } inputStream.close(); } catch (Exception e) { logger.error(e.getMessage(), e); } finally { if (br != null) { IOUtils.closeQuietly(br); } } return retStr; }
java
public static String readDesignerVersion(ServletContext context) { String retStr = ""; BufferedReader br = null; try { InputStream inputStream = context.getResourceAsStream("/META-INF/MANIFEST.MF"); br = new BufferedReader(new InputStreamReader(inputStream, "UTF-8")); String line; while ((line = br.readLine()) != null) { if (line.startsWith(BUNDLE_VERSION)) { retStr = line.substring(BUNDLE_VERSION.length() + 1); retStr = retStr.trim(); } } inputStream.close(); } catch (Exception e) { logger.error(e.getMessage(), e); } finally { if (br != null) { IOUtils.closeQuietly(br); } } return retStr; }
[ "public", "static", "String", "readDesignerVersion", "(", "ServletContext", "context", ")", "{", "String", "retStr", "=", "\"\"", ";", "BufferedReader", "br", "=", "null", ";", "try", "{", "InputStream", "inputStream", "=", "context", ".", "getResourceAsStream", "(", "\"/META-INF/MANIFEST.MF\"", ")", ";", "br", "=", "new", "BufferedReader", "(", "new", "InputStreamReader", "(", "inputStream", ",", "\"UTF-8\"", ")", ")", ";", "String", "line", ";", "while", "(", "(", "line", "=", "br", ".", "readLine", "(", ")", ")", "!=", "null", ")", "{", "if", "(", "line", ".", "startsWith", "(", "BUNDLE_VERSION", ")", ")", "{", "retStr", "=", "line", ".", "substring", "(", "BUNDLE_VERSION", ".", "length", "(", ")", "+", "1", ")", ";", "retStr", "=", "retStr", ".", "trim", "(", ")", ";", "}", "}", "inputStream", ".", "close", "(", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "logger", ".", "error", "(", "e", ".", "getMessage", "(", ")", ",", "e", ")", ";", "}", "finally", "{", "if", "(", "br", "!=", "null", ")", "{", "IOUtils", ".", "closeQuietly", "(", "br", ")", ";", "}", "}", "return", "retStr", ";", "}" ]
Returns the designer version from the manifest. @param context @return version
[ "Returns", "the", "designer", "version", "from", "the", "manifest", "." ]
97b048d06f083a1f831c971c2e9fdfd0952d2b0b
https://github.com/kiegroup/jbpm-designer/blob/97b048d06f083a1f831c971c2e9fdfd0952d2b0b/jbpm-designer-backend/src/main/java/org/jbpm/designer/server/EditorHandler.java#L476-L500