idx int64 0 41.2k | question stringlengths 83 4.15k | target stringlengths 5 715 |
|---|---|---|
1,000 | public VersionDiff diff ( Semver version ) { if ( ! Objects . equals ( this . major , version . getMajor ( ) ) ) return VersionDiff . MAJOR ; if ( ! Objects . equals ( this . minor , version . getMinor ( ) ) ) return VersionDiff . MINOR ; if ( ! Objects . equals ( this . patch , version . getPatch ( ) ) ) return Versio... | Returns the greatest difference between 2 versions . For example if the current version is 1 . 2 . 3 and compared version is 1 . 3 . 0 the biggest difference is the MINOR number . |
1,001 | public static Requirement buildNPM ( String requirement ) { if ( requirement . isEmpty ( ) ) { requirement = "*" ; } return buildWithTokenizer ( requirement , Semver . SemverType . NPM ) ; } | Builds a requirement following the rules of NPM . |
1,002 | private static List < Token > addParentheses ( List < Token > tokens ) { List < Token > result = new ArrayList < Token > ( ) ; result . add ( new Token ( TokenType . OPENING , "(" ) ) ; for ( Token token : tokens ) { if ( token . type == TokenType . OR ) { result . add ( new Token ( TokenType . CLOSING , ")" ) ) ; resu... | Return parenthesized expression giving lowest priority to OR operator |
1,003 | private static List < Tokenizer . Token > toReversePolishNotation ( List < Tokenizer . Token > tokens ) { LinkedList < Tokenizer . Token > queue = new LinkedList < Tokenizer . Token > ( ) ; Stack < Tokenizer . Token > stack = new Stack < Tokenizer . Token > ( ) ; for ( int i = 0 ; i < tokens . size ( ) ; i ++ ) { Token... | Adaptation of the shutting yard algorithm |
1,004 | private static Requirement evaluateReversePolishNotation ( Iterator < Tokenizer . Token > iterator , Semver . SemverType type ) { try { Tokenizer . Token token = iterator . next ( ) ; if ( token . type == Tokenizer . TokenType . VERSION ) { if ( "*" . equals ( token . value ) || ( type == Semver . SemverType . NPM && "... | Evaluates a reverse polish notation token list |
1,005 | protected static Requirement hyphenRequirement ( String lowerVersion , String upperVersion , Semver . SemverType type ) { if ( type != Semver . SemverType . NPM ) { throw new SemverException ( "The hyphen requirements are only compatible with NPM." ) ; } Semver lower = extrapolateVersion ( new Semver ( lowerVersion , t... | Creates a requirement that satisfies x1 . y1 . z1 - x2 . y2 . z2 . |
1,006 | private static Semver extrapolateVersion ( Semver semver ) { StringBuilder sb = new StringBuilder ( ) . append ( semver . getMajor ( ) ) . append ( "." ) . append ( semver . getMinor ( ) == null ? 0 : semver . getMinor ( ) ) . append ( "." ) . append ( semver . getPatch ( ) == null ? 0 : semver . getPatch ( ) ) ; boole... | Extrapolates the optional minor and patch numbers . - 1 = 1 . 0 . 0 - 1 . 2 = 1 . 2 . 0 - 1 . 2 . 3 = 1 . 2 . 3 |
1,007 | public boolean isSatisfiedBy ( Semver version ) { if ( this . range != null ) { return this . range . isSatisfiedBy ( version ) ; } else { switch ( this . op ) { case AND : try { List < Range > set = getAllRanges ( this , new ArrayList < Range > ( ) ) ; for ( Range range : set ) { if ( ! range . isSatisfiedBy ( version... | Checks if the requirement is satisfied by a version . |
1,008 | public JSONObject toJSON ( ) throws JSONException { JSONObject json = new JSONObject ( ) ; json . put ( JSON_TYPE , this . getType ( ) ) ; return json ; } | Formats the object s attributes as GeoJSON . |
1,009 | public void setFeatures ( List < Feature > features ) { this . mFeatures . clear ( ) ; if ( features != null ) { this . mFeatures . addAll ( features ) ; } } | Sets the list of features contained within this feature collection . All previously existing features are removed as a result of setting this property . |
1,010 | 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 . |
1,011 | 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 . |
1,012 | 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 . |
1,013 | 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 . |
1,014 | 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 . |
1,015 | 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 . |
1,016 | 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 . |
1,017 | public void write ( ByteBuffer buffer ) { if ( obj != null ) buffer . put ( getSerialized ( ) ) ; tmpBuffer = null ; } | This method is not thread safe! |
1,018 | 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 |
1,019 | 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 |
1,020 | 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 |
1,021 | 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 . |
1,022 | 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! |
1,023 | 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 . |
1,024 | 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 |
1,025 | 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! |
1,026 | 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 . |
1,027 | 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 |
1,028 | 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 . |
1,029 | 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... |
1,030 | 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 . |
1,031 | 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 . |
1,032 | 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 . |
1,033 | @ 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 |
1,034 | 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? |
1,035 | 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 |
1,036 | 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 . |
1,037 | 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 . |
1,038 | 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 |
1,039 | 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 . |
1,040 | 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 . |
1,041 | 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 |
1,042 | 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 . |
1,043 | 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 |
1,044 | 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 |
1,045 | 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 |
1,046 | 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 |
1,047 | 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 . |
1,048 | @ SuppressWarnings ( "unchecked" ) private E nextLazy ( ) { List < Emit < SqlgElement > > result = this . elements ; this . elements = null ; return ( E ) result ; } | return the next lazy results |
1,049 | @ 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 |
1,050 | 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 |
1,051 | 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 |
1,052 | 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 |
1,053 | 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 |
1,054 | 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 |
1,055 | 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 . |
1,056 | 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 . |
1,057 | 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 . |
1,058 | 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 |
1,059 | 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 |
1,060 | 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 |
1,061 | 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 |
1,062 | 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 |
1,063 | 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 |
1,064 | 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 |
1,065 | 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 |
1,066 | 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 |
1,067 | 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 |
1,068 | 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 |
1,069 | 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 |
1,070 | @ 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 . |
1,071 | 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 |
1,072 | 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 |
1,073 | 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 . |
1,074 | 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 . |
1,075 | 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 . |
1,076 | 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 . |
1,077 | 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 . |
1,078 | 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 . |
1,079 | 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 . |
1,080 | public CompletableFuture < Void > open ( ) { CompletableFuture < Void > future = new CompletableFuture < > ( ) ; context . executor ( ) . execute ( ( ) -> register ( new RegisterAttempt ( 1 , future ) ) ) ; return future ; } | Opens the session manager . |
1,081 | 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 . |
1,082 | 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 . |
1,083 | public CompletableFuture < Void > kill ( ) { return CompletableFuture . runAsync ( ( ) -> { if ( keepAlive != null ) keepAlive . cancel ( ) ; state . setState ( Session . State . CLOSED ) ; } , context . executor ( ) ) ; } | Kills the client session manager . |
1,084 | 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 . |
1,085 | 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 . |
1,086 | 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 . |
1,087 | 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 . |
1,088 | protected CompletableFuture < QueryResponse > queryLocal ( QueryEntry entry ) { CompletableFuture < QueryResponse > future = new CompletableFuture < > ( ) ; sequenceQuery ( entry , future ) ; return future ; } | Performs a local query . |
1,089 | 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 . |
1,090 | List < MemberState > getReserveMemberStates ( Comparator < MemberState > comparator ) { List < MemberState > reserveMembers = new ArrayList < > ( getReserveMemberStates ( ) ) ; Collections . sort ( reserveMembers , comparator ) ; return reserveMembers ; } | Returns a list of reserve members . |
1,091 | 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 . |
1,092 | private void cancelJoinTimer ( ) { if ( joinTimeout != null ) { LOGGER . trace ( "{} - Cancelling join timeout" , member ( ) . address ( ) ) ; joinTimeout . cancel ( ) ; joinTimeout = null ; } } | Cancels the join timeout . |
1,093 | private void cancelLeaveTimer ( ) { if ( leaveTimeout != null ) { LOGGER . trace ( "{} - Cancelling leave timeout" , member ( ) . address ( ) ) ; leaveTimeout . cancel ( ) ; leaveTimeout = null ; } } | Cancels the leave timeout . |
1,094 | 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 . |
1,095 | 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 . |
1,096 | 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 . |
1,097 | 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 . |
1,098 | 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 . |
1,099 | 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 . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.