idx int64 0 165k | question stringlengths 73 5.81k | target stringlengths 5 918 |
|---|---|---|
124,700 | public void setGeometries ( List < Geometry > geometries ) { this . mGeometries . clear ( ) ; if ( geometries != null ) { this . mGeometries . addAll ( geometries ) ; } } | Sets the list of geometries contained within this geometry collection . All previously existing geometries are removed as a result of setting this property . |
124,701 | public static String parent ( String node ) { final int index = node . lastIndexOf ( '/' ) ; if ( index < 0 ) return null ; return node . substring ( 0 , index ) ; } | Returns the parent tree node of a given node . |
124,702 | public void addDependency ( Service service ) { assertDuringInitialization ( ) ; LOG . info ( "Adding a dependency on {} to {}" , service . getName ( ) , getName ( ) ) ; addDependsOn ( service ) ; service . addDependedBy ( this ) ; } | Adds a service this service depends on . |
124,703 | protected void setReady ( boolean ready ) { synchronized ( SERVICE_AVILABILITY_LOCK ) { LOG . info ( "Service {} is now {}" , getName ( ) , ready ? "READY" : "NOT READY" ) ; this . ready = ready ; checkAvailability ( ) ; } runAvailableMethod ( ) ; } | Sets the readiness of this service . If this service is ready and all its dependencies are available than this service becomes available . |
124,704 | public void create ( String fqn , boolean ephemeral ) { awaitRunning ( ) ; try { LOG . trace ( "Creating {} {}" , fqn , ephemeral ? "(ephemeral)" : "" ) ; channel . send ( new Message ( null , new Request ( Request . CREATE , fqn , ephemeral ) ) ) ; synchronized ( updateCondition ) { while ( ! exists ( fqn ) ) updateCo... | Adds a new node to the tree . If the node does not exist yet it will be created . Also parent nodes will be created if non - existent . If the node already exists this is a no - op it s status as ephemeral may change . |
124,705 | public byte [ ] get ( String fqn ) { final Node n = findNode ( fqn ) ; if ( n == null ) return null ; final byte [ ] buffer = n . getData ( ) ; if ( buffer == null ) return null ; return Arrays . copyOf ( buffer , buffer . length ) ; } | Finds a node given its name and returns the data associated with it . Returns null if the node was not found in the tree or the data is null . |
124,706 | public List < String > getChildren ( String fqn ) { final Node n = findNode ( fqn ) ; if ( n == null ) return null ; final Set < String > names = n . getChildrenNames ( ) ; return new ArrayList < String > ( names ) ; } | Returns all children of a given node . |
124,707 | public void write ( ByteBuffer buffer ) { if ( obj != null ) buffer . put ( getSerialized ( ) ) ; tmpBuffer = null ; } | This method is not thread safe! |
124,708 | public void handleDownstream ( ChannelHandlerContext ctx , ChannelEvent evt ) throws Exception { if ( ! ( evt instanceof MessageEvent ) ) { ctx . sendDownstream ( evt ) ; return ; } final MessageEvent e = ( MessageEvent ) evt ; final Object originalMessage = e . getMessage ( ) ; final Object encodedMessage = encode ( c... | Code copied from org . jboss . netty . handler . codec . oneone . OneToOneEncoder and org . jboss . netty . handler . codec . oneone . OneToOneDecoder |
124,709 | protected void postInit ( ) throws Exception { if ( controlTree == null ) { throw new RuntimeException ( "controlTree not set" ) ; } controlTree . create ( NODES , false ) ; controlTree . create ( LEADERS , false ) ; if ( controlTree . exists ( myNodeInfo . treeNodePath ) ) { LOG . error ( "A node with the name " + myN... | This is perhaps ugly but overriding implementations must call this method at the end or at least after calling setControlTree |
124,710 | protected void sendToNode ( Message message , short node , InetSocketAddress address ) { try { if ( LOG . isDebugEnabled ( ) ) LOG . debug ( "Sending to node {} ({}): {}" , new Object [ ] { node , address , message } ) ; message . cloneDataBuffers ( ) ; final NodePeer peer = peers . get ( node ) ; if ( peer == null ) t... | Can block if buffer is full |
124,711 | public static Throwable unwrap ( Throwable t ) { for ( ; ; ) { if ( t == null ) throw new NullPointerException ( ) ; if ( t instanceof java . util . concurrent . ExecutionException ) t = t . getCause ( ) ; else if ( t instanceof java . lang . reflect . InvocationTargetException ) t = t . getCause ( ) ; else if ( t . ge... | Unwraps several common wrapper exceptions and returns the underlying cause . |
124,712 | public void read ( ByteBuffer buffer ) { Persistables . persistable ( streamableNoBuffers ( ) ) . read ( buffer ) ; final int n = getNumDataBuffers ( ) ; int lengthsPosition = buffer . position ( ) ; buffer . position ( buffer . position ( ) + 2 * n ) ; for ( int i = 0 ; i < n ; i ++ ) { final int size = buffer . getSh... | Note that you cannot use this method to read a buffer wrapping the array returned from toByteArray as the internal representation is different! |
124,713 | public static int calcUtfLength ( String str ) { final int strlen = str . length ( ) ; int utflen = 0 ; for ( int i = 0 ; i < strlen ; i ++ ) { int c = str . charAt ( i ) ; if ( ( c >= 0x0001 ) && ( c <= 0x007F ) ) { utflen ++ ; } else if ( c > 0x07FF ) { utflen += 3 ; } else { utflen += 2 ; } } return utflen ; } | Returns the length in bytes of a string s UTF - 8 encoding . |
124,714 | private static DefaultListableBeanFactory createBeanFactory ( ) { return new DefaultListableBeanFactory ( ) { { final InstantiationStrategy is = getInstantiationStrategy ( ) ; setInstantiationStrategy ( new InstantiationStrategy ( ) { public Object instantiate ( RootBeanDefinition beanDefinition , String beanName , Bea... | adds hooks to capture autowired constructor args and add them as dependencies |
124,715 | private Object doOp ( Op op ) throws TimeoutException { try { if ( op . txn != null ) op . txn . add ( op ) ; Object result = runOp ( op ) ; if ( result == PENDING ) return op . getResult ( timeout , TimeUnit . MILLISECONDS ) ; else if ( result == null && op . isCancelled ( ) ) throw new CancellationException ( ) ; els... | This one blocks! |
124,716 | private boolean handleMessageMessengerMsg ( Message . MSG message ) { if ( ! message . isMessenger ( ) ) return false ; if ( receiver == null ) return true ; setOwnerClockPut ( message ) ; if ( message . getLine ( ) == - 1 ) { receiver . receive ( message ) ; if ( message . isReplyRequired ( ) ) send ( Message . MSGACK... | Special handling for msg . |
124,717 | public static P < Object > propertyRef ( Compare p , String columnName ) { return new RefP ( p , new PropertyReference ( columnName ) ) ; } | build a predicate from a compare operation and a column name |
124,718 | private String constructDuplicatePathSql ( SqlgGraph sqlgGraph , List < LinkedList < SchemaTableTree > > subQueryLinkedLists , Set < SchemaTableTree > leftJoinOn ) { StringBuilder singlePathSql = new StringBuilder ( "\nFROM (" ) ; int count = 1 ; SchemaTableTree lastOfPrevious = null ; for ( LinkedList < SchemaTableTre... | Construct a sql statement for one original path to a leaf node . As the path contains the same label more than once its been split into a List of Stacks . |
124,719 | private String constructSinglePathSql ( SqlgGraph sqlgGraph , boolean partOfDuplicateQuery , LinkedList < SchemaTableTree > distinctQueryStack , SchemaTableTree lastOfPrevious , SchemaTableTree firstOfNextStack , Set < SchemaTableTree > leftJoinOn , boolean dropStep ) { return constructSelectSinglePathSql ( sqlgGraph ,... | Constructs a sql select statement from the SchemaTableTree call stack . The SchemaTableTree is not used as a tree . It is used only as as SchemaTable with a direction . first and last is needed to facilitate generating the from statement . If both first and last is true then the gremlin does not contain duplicate label... |
124,720 | public boolean duplicatesInStack ( LinkedList < SchemaTableTree > distinctQueryStack ) { Set < SchemaTable > alreadyVisited = new HashSet < > ( ) ; for ( SchemaTableTree schemaTableTree : distinctQueryStack ) { if ( ! alreadyVisited . contains ( schemaTableTree . getSchemaTable ( ) ) ) { alreadyVisited . add ( schemaTa... | Checks if the stack has the same element more than once . |
124,721 | private static void constructEmitFromClause ( LinkedList < SchemaTableTree > distinctQueryStack , ColumnList cols ) { int count = 1 ; for ( SchemaTableTree schemaTableTree : distinctQueryStack ) { if ( count > 1 ) { if ( ! schemaTableTree . getSchemaTable ( ) . isEdgeTable ( ) && schemaTableTree . isEmit ( ) ) { printE... | If emit is true then the edge id also needs to be printed . This is required when there are multiple edges to the same vertex . Only by having access to the edge id can on tell if the vertex needs to be emitted . |
124,722 | private void removeOrTransformHasContainers ( final SchemaTableTree schemaTableTree ) { Set < HasContainer > toRemove = new HashSet < > ( ) ; Set < HasContainer > toAdd = new HashSet < > ( ) ; for ( HasContainer hasContainer : schemaTableTree . hasContainers ) { if ( hasContainer . getKey ( ) . equals ( label . getAcce... | remove has containers that are not valid anymore transform has containers that are equivalent to simpler statements . |
124,723 | @ SuppressWarnings ( "unchecked" ) private boolean invalidateByHas ( SchemaTableTree schemaTableTree ) { for ( HasContainer hasContainer : schemaTableTree . hasContainers ) { if ( ! hasContainer . getKey ( ) . equals ( TopologyStrategy . TOPOLOGY_SELECTION_SQLG_SCHEMA ) && ! hasContainer . getKey ( ) . equals ( Topolog... | verify the has containers we have are valid with the schema table tree given |
124,724 | public boolean shouldSelectProperty ( String property ) { if ( getRoot ( ) . eagerLoad || restrictedProperties == null ) { return true ; } if ( getRoot ( ) . eagerLoad || restrictedProperties . contains ( property ) ) { return true ; } return false ; } | should we select the given property? |
124,725 | private void calculatePropertyRestrictions ( ) { if ( restrictedProperties == null ) { return ; } for ( org . javatuples . Pair < Traversal . Admin < ? , ? > , Comparator < ? > > comparator : this . getDbComparators ( ) ) { if ( comparator . getValue1 ( ) instanceof ElementValueComparator ) { restrictedProperties . add... | calculate property restrictions from explicit restrictions and required properties |
124,726 | public boolean orderByHasSelectOneStepAndForLabelNotInTree ( ) { Set < String > labels = new HashSet < > ( ) ; for ( ReplacedStep < ? , ? > replacedStep : linearPathToLeafNode ( ) ) { for ( String label : labels ) { labels . add ( SqlgUtil . originalLabel ( label ) ) ; } for ( Pair < Traversal . Admin < ? , ? > , Compa... | This happens when a SqlgVertexStep has a SelectOne step where the label is for an element on the path that is before the current optimized steps . |
124,727 | public static String updateGraph ( SqlgGraph sqlgGraph , String version ) { Connection conn = sqlgGraph . tx ( ) . getConnection ( ) ; try { DatabaseMetaData metadata = conn . getMetaData ( ) ; GraphTraversalSource traversalSource = sqlgGraph . topology ( ) ; List < Vertex > graphVertices = traversalSource . V ( ) . ha... | Updates sqlg_schema . V_graph s version to the new version and returns the old version . |
124,728 | public static void addIndex ( SqlgGraph sqlgGraph , String schema , String label , boolean vertex , String index , IndexType indexType , List < String > properties ) { BatchManager . BatchModeType batchModeType = flushAndSetTxToNone ( sqlgGraph ) ; try { GraphTraversalSource traversalSource = sqlgGraph . topology ( ) ;... | add an index from information schema |
124,729 | public static void addSubPartition ( SqlgGraph sqlgGraph , Partition partition ) { AbstractLabel abstractLabel = partition . getAbstractLabel ( ) ; addSubPartition ( sqlgGraph , partition . getParentPartition ( ) . getParentPartition ( ) != null , abstractLabel instanceof VertexLabel , abstractLabel . getSchema ( ) . g... | Adds the partition to a partition . A new Vertex with label Partition is added and in linked to its parent with the SQLG_SCHEMA_PARTITION_PARTITION_EDGE edge label . |
124,730 | SqlgVertex putVertexIfAbsent ( SqlgGraph sqlgGraph , String schema , String table , Long id ) { RecordId recordId = RecordId . from ( SchemaTable . of ( schema , table ) , id ) ; SqlgVertex sqlgVertex ; if ( this . cacheVertices ) { sqlgVertex = this . vertexCache . get ( recordId ) ; if ( sqlgVertex == null ) { sqlgVe... | The recordId is not referenced in the SqlgVertex . It is important that the value of the WeakHashMap does not reference the key . |
124,731 | private JsonNode toJson ( ) { ObjectNode result = new ObjectNode ( Topology . OBJECT_MAPPER . getNodeFactory ( ) ) ; ArrayNode propertyArrayNode = new ArrayNode ( Topology . OBJECT_MAPPER . getNodeFactory ( ) ) ; for ( PropertyColumn property : this . properties ) { ObjectNode objectNode = property . toNotifyJson ( ) ;... | JSON representation of committed state |
124,732 | public static ReplacedStep from ( Topology topology ) { ReplacedStep replacedStep = new ReplacedStep < > ( ) ; replacedStep . step = null ; replacedStep . labels = new HashSet < > ( ) ; replacedStep . topology = topology ; replacedStep . fake = true ; return replacedStep ; } | Used for SqlgVertexStepStrategy . It is a fake ReplacedStep to simulate the incoming vertex from which the traversal continues . |
124,733 | private Map < SchemaTable , List < Multimap < BiPredicate , RecordId > > > groupIdsBySchemaTable ( ) { Map < SchemaTable , List < Multimap < BiPredicate , RecordId > > > result = new HashMap < > ( ) ; for ( HasContainer idHasContainer : this . idHasContainers ) { Map < SchemaTable , Boolean > newHasContainerMap = new H... | Groups the idHasContainers by SchemaTable . Each SchemaTable has a list representing the idHasContainers with the relevant BiPredicate and RecordId |
124,734 | private void captureLabels ( Step < ? , ? > step , Map < String , Object > stepsByLabel ) { for ( String s : step . getLabels ( ) ) { stepsByLabel . put ( s , step ) ; } if ( step instanceof SqlgGraphStep < ? , ? > ) { SqlgGraphStep < ? , ? > sgs = ( SqlgGraphStep < ? , ? > ) step ; for ( ReplacedStep < ? , ? > rs : sg... | add all labels for the step in the given map |
124,735 | private String createOrUpdateGraph ( String version ) { String oldVersion = null ; Connection conn = this . sqlgGraph . tx ( ) . getConnection ( ) ; try { DatabaseMetaData metadata = conn . getMetaData ( ) ; String [ ] types = new String [ ] { "TABLE" } ; try ( ResultSet vertexRs = metadata . getTables ( null , Schema ... | create or update the graph metadata |
124,736 | String getBuildVersion ( ) { if ( this . buildVersion == null ) { Properties prop = new Properties ( ) ; try { URL u = ClassLoader . getSystemResource ( SQLG_APPLICATION_PROPERTIES ) ; if ( u == null ) { u = getClass ( ) . getClassLoader ( ) . getResource ( SQLG_APPLICATION_PROPERTIES ) ; } if ( u != null ) { try ( Inp... | get the build version |
124,737 | public String query ( String query ) { try { Connection conn = this . tx ( ) . getConnection ( ) ; ObjectNode result = this . mapper . createObjectNode ( ) ; ArrayNode dataNode = this . mapper . createArrayNode ( ) ; ArrayNode metaNode = this . mapper . createArrayNode ( ) ; Statement statement = conn . createStatement... | This is executes a sql query and returns the result as a json string . |
124,738 | @ SuppressWarnings ( "unchecked" ) private E nextLazy ( ) { List < Emit < SqlgElement > > result = this . elements ; this . elements = null ; return ( E ) result ; } | return the next lazy results |
124,739 | @ SuppressWarnings ( "deprecation" ) private static Time shiftDST ( LocalTime lt ) { Time t = Time . valueOf ( lt ) ; int offset = Calendar . getInstance ( ) . get ( Calendar . DST_OFFSET ) / 1000 ; int m = t . getSeconds ( ) ; t . setSeconds ( m + offset ) ; return t ; } | Postgres gets confused by DST it sets the timezone badly and then reads the wrong value out so we convert the value to winter time |
124,740 | public PropertyType sqlTypeToPropertyType ( SqlgGraph sqlgGraph , String schema , String table , String column , int sqlType , String typeName , ListIterator < Triple < String , Integer , String > > metaDataIter ) { switch ( sqlType ) { case Types . BIT : return PropertyType . BOOLEAN ; case Types . SMALLINT : return P... | This is only used for upgrading from pre sqlg_schema sqlg to a sqlg_schema |
124,741 | private ListIterator < List < Emit < E > > > elements ( SchemaTable schemaTable , SchemaTableTree rootSchemaTableTree ) { this . sqlgGraph . tx ( ) . readWrite ( ) ; if ( this . sqlgGraph . getSqlDialect ( ) . supportsBatchMode ( ) && this . sqlgGraph . tx ( ) . getBatchManager ( ) . isStreaming ( ) ) { throw new Illeg... | Called from SqlgVertexStepCompiler which compiled VertexStep and HasSteps . This is only called when not in BatchMode |
124,742 | void removeColumn ( String schema , String table , String column ) { StringBuilder sql = new StringBuilder ( "ALTER TABLE " ) ; sql . append ( sqlgGraph . getSqlDialect ( ) . maybeWrapInQoutes ( schema ) ) ; sql . append ( "." ) ; sql . append ( sqlgGraph . getSqlDialect ( ) . maybeWrapInQoutes ( table ) ) ; sql . appe... | remove a column from the table |
124,743 | void removeIndex ( Index idx , boolean preserveData ) { this . getSchema ( ) . getTopology ( ) . lock ( ) ; if ( ! uncommittedRemovedIndexes . contains ( idx . getName ( ) ) ) { uncommittedRemovedIndexes . add ( idx . getName ( ) ) ; TopologyManager . removeIndex ( this . sqlgGraph , idx ) ; if ( ! preserveData ) { idx... | remove a given index that was on this label |
124,744 | public static int setKeyValuesAsParameterUsingPropertyColumn ( SqlgGraph sqlgGraph , int i , PreparedStatement preparedStatement , Map < String , Pair < PropertyType , Object > > properties ) throws SQLException { i = setKeyValuesAsParameterUsingPropertyColumn ( sqlgGraph , true , i , preparedStatement , properties . v... | This is called for inserts |
124,745 | public static Triple < Map < String , PropertyType > , Map < String , Object > , Map < String , Object > > validateVertexKeysValues ( SqlDialect sqlDialect , Object [ ] keyValues ) { Map < String , Object > resultAllValues = new LinkedHashMap < > ( ) ; Map < String , Object > resultNotNullValues = new LinkedHashMap < >... | Validates the key values and converts it into a Triple with three maps . The left map is a map of keys together with their PropertyType . The middle map is a map of keys together with their values . The right map is a map of keys with values where the values are guaranteed not to be null . |
124,746 | public SchemaTableTree parse ( SchemaTable schemaTable , ReplacedStepTree replacedStepTree ) { ReplacedStep < ? , ? > rootReplacedStep = replacedStepTree . root ( ) . getReplacedStep ( ) ; Preconditions . checkArgument ( ! rootReplacedStep . isGraphStep ( ) , "Expected VertexStep, found GraphStep" ) ; Set < SchemaTable... | This is only called for vertex steps . Constructs the label paths from the given schemaTable to the leaf vertex labels for the gremlin query . For each path Sqlg will executeRegularQuery a sql query . The union of the queries is the result the gremlin query . The vertex labels can be calculated from the steps . |
124,747 | private void createSchemaOnDb ( ) { StringBuilder sql = new StringBuilder ( ) ; sql . append ( topology . getSqlgGraph ( ) . getSqlDialect ( ) . createSchemaStatement ( this . name ) ) ; if ( this . sqlgGraph . getSqlDialect ( ) . needsSemicolon ( ) ) { sql . append ( ";" ) ; } if ( logger . isDebugEnabled ( ) ) { logg... | Creates a new schema on the database . i . e . CREATE SCHEMA ... sql statement . |
124,748 | Map < String , Map < String , PropertyType > > getAllTables ( ) { Map < String , Map < String , PropertyType > > result = new HashMap < > ( ) ; for ( Map . Entry < String , VertexLabel > vertexLabelEntry : this . vertexLabels . entrySet ( ) ) { String vertexQualifiedName = this . name + "." + VERTEX_PREFIX + vertexLabe... | remove in favour of PropertyColumn |
124,749 | void loadVertexIndices ( GraphTraversalSource traversalSource , Vertex schemaVertex ) { List < Path > indices = traversalSource . V ( schemaVertex ) . out ( SQLG_SCHEMA_SCHEMA_VERTEX_EDGE ) . as ( "vertex" ) . out ( SQLG_SCHEMA_VERTEX_INDEX_EDGE ) . as ( "index" ) . outE ( SQLG_SCHEMA_INDEX_PROPERTY_EDGE ) . order ( ) ... | load indices for all vertices in schema |
124,750 | void removeEdgeLabel ( EdgeLabel edgeLabel , boolean preserveData ) { getTopology ( ) . lock ( ) ; String fn = this . name + "." + EDGE_PREFIX + edgeLabel . getName ( ) ; if ( ! uncommittedRemovedEdgeLabels . contains ( fn ) ) { uncommittedRemovedEdgeLabels . add ( fn ) ; TopologyManager . removeEdgeLabel ( this . sqlg... | remove a given edge label |
124,751 | void removeVertexLabel ( VertexLabel vertexLabel , boolean preserveData ) { getTopology ( ) . lock ( ) ; String fn = this . name + "." + VERTEX_PREFIX + vertexLabel . getName ( ) ; if ( ! uncommittedRemovedVertexLabels . contains ( fn ) ) { uncommittedRemovedVertexLabels . add ( fn ) ; TopologyManager . removeVertexLab... | remove a given vertex label |
124,752 | void removeGlobalUniqueIndex ( GlobalUniqueIndex index , boolean preserveData ) { getTopology ( ) . lock ( ) ; String fn = index . getName ( ) ; if ( ! uncommittedRemovedGlobalUniqueIndexes . contains ( fn ) ) { uncommittedRemovedGlobalUniqueIndexes . add ( fn ) ; TopologyManager . removeGlobalUniqueIndex ( sqlgGraph ,... | remove the given global unique index |
124,753 | void delete ( ) { StringBuilder sql = new StringBuilder ( ) ; sql . append ( "DROP SCHEMA " ) ; sql . append ( this . sqlgGraph . getSqlDialect ( ) . maybeWrapInQoutes ( this . name ) ) ; if ( this . sqlgGraph . getSqlDialect ( ) . supportsCascade ( ) ) { sql . append ( " CASCADE" ) ; } if ( this . sqlgGraph . getSqlDi... | delete schema in DB |
124,754 | public Optional < EdgeLabel > getOutEdgeLabel ( String edgeLabelName ) { EdgeLabel edgeLabel = getOutEdgeLabels ( ) . get ( this . schema . getName ( ) + "." + edgeLabelName ) ; if ( edgeLabel != null ) { return Optional . of ( edgeLabel ) ; } return Optional . empty ( ) ; } | Out EdgeLabels are always in the same schema as the this VertexLabel schema . So the edgeLabelName must not contain the schema prefix |
124,755 | void removeEdgeRole ( EdgeRole er , boolean preserveData ) { if ( er . getVertexLabel ( ) != this ) { throw new IllegalStateException ( "Trying to remove a EdgeRole from a non owner VertexLabel" ) ; } Collection < VertexLabel > ers ; switch ( er . getDirection ( ) ) { case BOTH : throw new IllegalStateException ( "BOTH... | remove a given edge role |
124,756 | protected String escapeQuotes ( Object o ) { if ( o != null ) { return o . toString ( ) . replace ( "'" , "''" ) ; } return null ; } | escape quotes by doubling them when we need a string inside quotes |
124,757 | void delete ( ) { String schema = getSchema ( ) . getName ( ) ; String tableName = EDGE_PREFIX + getLabel ( ) ; SqlDialect sqlDialect = this . sqlgGraph . getSqlDialect ( ) ; sqlDialect . assertTableName ( tableName ) ; StringBuilder sql = new StringBuilder ( "DROP TABLE IF EXISTS " ) ; sql . append ( sqlDialect . mayb... | delete the table |
124,758 | void removeOutVertexLabel ( VertexLabel lbl , boolean preserveData ) { this . uncommittedRemovedOutVertexLabels . add ( lbl ) ; if ( ! preserveData ) { deleteColumn ( lbl . getFullName ( ) + Topology . OUT_VERTEX_COLUMN_END ) ; } } | remove a vertex label from the out collection |
124,759 | void removeInVertexLabel ( VertexLabel lbl , boolean preserveData ) { this . uncommittedRemovedInVertexLabels . add ( lbl ) ; if ( ! preserveData ) { deleteColumn ( lbl . getFullName ( ) + Topology . IN_VERTEX_COLUMN_END ) ; } } | remove a vertex label from the in collection |
124,760 | @ SuppressWarnings ( "unchecked" ) protected boolean doFirst ( ListIterator < Step < ? , ? > > stepIterator , Step < ? , ? > step , MutableInt pathCount ) { if ( step instanceof SelectOneStep ) { if ( stepIterator . hasNext ( ) ) { stepIterator . next ( ) ; return true ; } else { return false ; } } if ( ! ( step instan... | EdgeOtherVertexStep can not be optimized as the direction information is lost . |
124,761 | public Long count ( Criteria < T , T > criteria ) { SingularAttribute < ? super T , PK > id = getEntityManager ( ) . getMetamodel ( ) . entity ( entityClass ) . getId ( entityKey ) ; return criteria . select ( Long . class , countDistinct ( id ) ) . getSingleResult ( ) ; } | Count using a pre populated criteria |
124,762 | public void init ( ) { if ( FacesContext . getCurrentInstance ( ) . getPartialViewContext ( ) . isAjaxRequest ( ) ) { return ; } if ( id != null && ! "" . equals ( id ) ) { entity = crudService . findById ( id ) ; if ( entity == null ) { log . info ( String . format ( "Entity not found with id %s, a new one will be ini... | called via preRenderView or viewAction |
124,763 | public String handle ( final Object value ) { final StringBuilder s = new StringBuilder ( ) ; if ( value instanceof List ) { final List < ? > l = ( List < ? > ) value ; for ( final Object o : l ) { if ( s . length ( ) > 0 ) { s . append ( ',' ) ; } s . append ( o . toString ( ) ) ; } } else { s . append ( value ) ; } r... | Converts the list to a comma separated representation . |
124,764 | void mergeTo ( final NominatimSearchRequest request ) { if ( null == request . getBounded ( ) && null != bounded ) { request . setBounded ( bounded ) ; } if ( null == request . getViewBox ( ) ) { request . setViewBox ( viewBox ) ; } if ( null == request . getPolygonFormat ( ) ) { request . setPolygonFormat ( polygonFor... | Merge this default options to the given request . |
124,765 | private static Object getValue ( final Object o , final Field f ) { try { f . setAccessible ( true ) ; return f . get ( o ) ; } catch ( final IllegalArgumentException e ) { LOGGER . error ( "failure accessing field value {}" , new Object [ ] { f . getName ( ) , e } ) ; } catch ( final IllegalAccessException e ) { LOGGE... | Gets a field value regardless of reflection errors . |
124,766 | public void addExcludedlaceId ( final String placeId ) { if ( null == this . countryCodes ) { this . excludePlaceIds = new ArrayList < String > ( ) ; } this . excludePlaceIds . add ( placeId ) ; } | If you do not want certain openstreetmap objects to appear in the search result give a list of the place_id s you want to skip . |
124,767 | public static ConfigSource parseMainArgs ( String ... args ) { Map < String , String > result ; if ( args == null ) { result = Collections . emptyMap ( ) ; } else { result = new HashMap < > ( ) ; String prefix = System . getProperty ( "main.args.prefix" , "" ) ; String key = null ; for ( String arg : args ) { if ( arg ... | Configure the main arguments herby parsing and mapping the main arguments into configuration properties . |
124,768 | private List < String > addPath ( List < String > filenames , String additionalPath ) { ArrayList < String > newFilenames = new ArrayList < String > ( filenames . size ( ) ) ; for ( String filename : filenames ) { newFilenames . add ( additionalPath + '/' + filename ) ; } return newFilenames ; } | Modifies a String list of filenames to include an additional path . |
124,769 | private List < String > scanFileSet ( File sourceDirectory , FileSet fileSet ) { final String [ ] emptyStringArray = { } ; DirectoryScanner scanner = new DirectoryScanner ( ) ; scanner . setBasedir ( sourceDirectory ) ; if ( fileSet . getIncludes ( ) != null && ! fileSet . getIncludes ( ) . isEmpty ( ) ) { scanner . se... | Scan a fileset and get a list of files which it contains . |
124,770 | public CompletableFuture < Void > open ( ) { CompletableFuture < Void > future = new CompletableFuture < > ( ) ; context . executor ( ) . execute ( ( ) -> register ( new RegisterAttempt ( 1 , future ) ) ) ; return future ; } | Opens the session manager . |
124,771 | public CompletableFuture < Void > expire ( ) { CompletableFuture < Void > future = new CompletableFuture < > ( ) ; context . executor ( ) . execute ( ( ) -> { if ( keepAlive != null ) keepAlive . cancel ( ) ; state . setState ( Session . State . EXPIRED ) ; future . complete ( null ) ; } ) ; return future ; } | Expires the manager . |
124,772 | private void unregister ( boolean retryOnFailure , CompletableFuture < Void > future ) { long sessionId = state . getSessionId ( ) ; if ( state . getState ( ) == Session . State . CLOSED ) { future . complete ( null ) ; return ; } state . getLogger ( ) . debug ( "Unregistering session: {}" , sessionId ) ; if ( keepAliv... | Unregisters the session . |
124,773 | public CompletableFuture < Void > kill ( ) { return CompletableFuture . runAsync ( ( ) -> { if ( keepAlive != null ) keepAlive . cancel ( ) ; state . setState ( Session . State . CLOSED ) ; } , context . executor ( ) ) ; } | Kills the client session manager . |
124,774 | protected AppendResponse handleAppend ( AppendRequest request ) { if ( request . term ( ) < context . getTerm ( ) ) { LOGGER . debug ( "{} - Rejected {}: request term is less than the current term ({})" , context . getCluster ( ) . member ( ) . address ( ) , request , context . getTerm ( ) ) ; return AppendResponse . b... | Handles an append request . |
124,775 | protected AppendResponse checkGlobalIndex ( AppendRequest request ) { long currentGlobalIndex = context . getGlobalIndex ( ) ; long nextGlobalIndex = request . globalIndex ( ) ; if ( currentGlobalIndex > 0 && nextGlobalIndex > currentGlobalIndex && nextGlobalIndex > context . getLog ( ) . lastIndex ( ) ) { context . se... | Checks whether the log needs to be truncated based on the globalIndex . |
124,776 | protected AppendResponse checkPreviousEntry ( AppendRequest request ) { if ( request . logIndex ( ) != 0 && context . getLog ( ) . isEmpty ( ) ) { LOGGER . debug ( "{} - Rejected {}: Previous index ({}) is greater than the local log's last index ({})" , context . getCluster ( ) . member ( ) . address ( ) , request , re... | Checks the previous entry in the append request for consistency . |
124,777 | protected AppendResponse appendEntries ( AppendRequest request ) { long lastEntryIndex = request . logIndex ( ) ; if ( ! request . entries ( ) . isEmpty ( ) ) { lastEntryIndex = request . entries ( ) . get ( request . entries ( ) . size ( ) - 1 ) . getIndex ( ) ; } long commitIndex = Math . max ( context . getCommitInd... | Appends entries to the local log . |
124,778 | protected CompletableFuture < QueryResponse > queryLocal ( QueryEntry entry ) { CompletableFuture < QueryResponse > future = new CompletableFuture < > ( ) ; sequenceQuery ( entry , future ) ; return future ; } | Performs a local query . |
124,779 | public ServerCommit acquire ( OperationEntry entry , ServerSessionContext session , long timestamp ) { ServerCommit commit = pool . poll ( ) ; if ( commit == null ) { commit = new ServerCommit ( this , log ) ; } commit . reset ( entry , session , timestamp ) ; return commit ; } | Acquires a commit from the pool . |
124,780 | List < MemberState > getReserveMemberStates ( Comparator < MemberState > comparator ) { List < MemberState > reserveMembers = new ArrayList < > ( getReserveMemberStates ( ) ) ; Collections . sort ( reserveMembers , comparator ) ; return reserveMembers ; } | Returns a list of reserve members . |
124,781 | CompletableFuture < Void > identify ( ) { Member leader = context . getLeader ( ) ; if ( joinFuture != null && leader != null ) { if ( context . getLeader ( ) . equals ( member ( ) ) ) { if ( context . getState ( ) == CopycatServer . State . LEADER && ! ( ( LeaderState ) context . getServerState ( ) ) . configuring ( )... | Identifies this server to the leader . |
124,782 | private void cancelJoinTimer ( ) { if ( joinTimeout != null ) { LOGGER . trace ( "{} - Cancelling join timeout" , member ( ) . address ( ) ) ; joinTimeout . cancel ( ) ; joinTimeout = null ; } } | Cancels the join timeout . |
124,783 | private void cancelLeaveTimer ( ) { if ( leaveTimeout != null ) { LOGGER . trace ( "{} - Cancelling leave timeout" , member ( ) . address ( ) ) ; leaveTimeout . cancel ( ) ; leaveTimeout = null ; } } | Cancels the leave timeout . |
124,784 | private void reassign ( ) { if ( member . type ( ) == Member . Type . ACTIVE && ! member . equals ( context . getLeader ( ) ) ) { int index = 1 ; for ( MemberState member : getActiveMemberStates ( ( m1 , m2 ) -> m1 . getMember ( ) . id ( ) - m2 . getMember ( ) . id ( ) ) ) { if ( ! member . getMember ( ) . equals ( con... | Rebuilds assigned member states . |
124,785 | private List < MemberState > assignMembers ( int index , List < MemberState > sortedMembers ) { List < MemberState > members = new ArrayList < > ( sortedMembers . size ( ) ) ; for ( int i = 0 ; i < sortedMembers . size ( ) ; i ++ ) { if ( ( i + 1 ) % index == 0 ) { members . add ( sortedMembers . get ( i ) ) ; } } retu... | Assigns members using consistent hashing . |
124,786 | private void copyPredicates ( ) { predicates = new ArrayList < > ( groups . size ( ) ) ; for ( List < Segment > group : groups ) { List < OffsetPredicate > groupPredicates = new ArrayList < > ( group . size ( ) ) ; for ( Segment segment : group ) { groupPredicates . add ( segment . offsetPredicate ( ) . copy ( ) ) ; } ... | Creates a copy of offset predicates prior to compacting segments to prevent race conditions . |
124,787 | private Segment compactGroup ( List < Segment > segments , List < OffsetPredicate > predicates ) { Segment firstSegment = segments . iterator ( ) . next ( ) ; Segment compactSegment = manager . createSegment ( SegmentDescriptor . builder ( ) . withId ( firstSegment . descriptor ( ) . id ( ) ) . withVersion ( firstSegme... | Compacts a group . |
124,788 | private void compactGroup ( List < Segment > segments , List < OffsetPredicate > predicates , Segment compactSegment ) { for ( int i = 0 ; i < segments . size ( ) ; i ++ ) { compactSegment ( segments . get ( i ) , predicates . get ( i ) , compactSegment ) ; } } | Compacts segments in a group sequentially . |
124,789 | private void compactSegment ( Segment segment , OffsetPredicate predicate , Segment compactSegment ) { for ( long i = segment . firstIndex ( ) ; i <= segment . lastIndex ( ) ; i ++ ) { checkEntry ( i , segment , predicate , compactSegment ) ; } } | Compacts the given segment . |
124,790 | private void compactEntry ( long index , Segment segment , Segment compactSegment ) { compactSegment . skip ( 1 ) ; LOGGER . trace ( "Compacted entry {} from segment {}" , index , segment . descriptor ( ) . id ( ) ) ; } | Compacts an entry from the given segment . |
124,791 | private boolean isLive ( long index , Segment segment , OffsetPredicate predicate ) { long offset = segment . offset ( index ) ; return offset != - 1 && predicate . test ( offset ) ; } | Returns a boolean value indicating whether the given index is release . |
124,792 | private void mergeReleased ( List < Segment > segments , List < OffsetPredicate > predicates , Segment compactSegment ) { for ( int i = 0 ; i < segments . size ( ) ; i ++ ) { mergeReleasedEntries ( segments . get ( i ) , predicates . get ( i ) , compactSegment ) ; } } | Updates the new compact segment with entries that were released during compaction . |
124,793 | private void mergeReleasedEntries ( Segment segment , OffsetPredicate predicate , Segment compactSegment ) { for ( long i = segment . firstIndex ( ) ; i <= segment . lastIndex ( ) ; i ++ ) { long offset = segment . offset ( i ) ; if ( offset != - 1 && ! predicate . test ( offset ) ) { compactSegment . release ( i ) ; }... | Updates the new compact segment with entries that were released in the given segment during compaction . |
124,794 | private void deleteGroup ( List < Segment > group ) { for ( Segment oldSegment : group ) { oldSegment . close ( ) ; oldSegment . delete ( ) ; } } | Completes compaction by deleting old segments . |
124,795 | public ClientConnection reset ( Address leader , Collection < Address > servers ) { selector . reset ( leader , servers ) ; return this ; } | Resets the client connection . |
124,796 | private < T extends Request , U > void sendRequest ( T request , BiFunction < Request , Connection , CompletableFuture < U > > sender , Connection connection , Throwable error , CompletableFuture < U > future ) { if ( open ) { if ( error == null ) { if ( connection != null ) { LOGGER . trace ( "{} - Sending {}" , id , ... | Sends the given request attempt to the cluster via the given connection if connected . |
124,797 | private void connect ( CompletableFuture < Connection > future ) { if ( ! selector . hasNext ( ) ) { LOGGER . debug ( "{} - Failed to connect to the cluster" , id ) ; future . complete ( null ) ; } else { Address address = selector . next ( ) ; LOGGER . debug ( "{} - Connecting to {}" , id , address ) ; client . connec... | Attempts to connect to the cluster . |
124,798 | private void handleConnection ( Address address , Connection connection , Throwable error , CompletableFuture < Connection > future ) { if ( open ) { if ( error == null ) { setupConnection ( address , connection , future ) ; } else { LOGGER . debug ( "{} - Failed to connect! Reason: {}" , id , error ) ; connect ( futur... | Handles a connection to a server . |
124,799 | private void handleConnectResponse ( ConnectResponse response , Throwable error , CompletableFuture < Connection > future ) { if ( open ) { if ( error == null ) { LOGGER . trace ( "{} - Received {}" , id , response ) ; if ( response . status ( ) == Response . Status . OK ) { selector . reset ( response . leader ( ) , r... | Handles a connect response . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.