idx int64 0 41.2k | question stringlengths 73 5.81k | target stringlengths 5 918 |
|---|---|---|
6,100 | public static final String formatInstructionName ( String project , String instruction ) { return INSTRUCTION_PATH_TEMPLATE . instantiate ( "project" , project , "instruction" , instruction ) ; } | Formats a string containing the fully - qualified path to represent a instruction resource . |
6,101 | public final ListDatasetsPagedResponse listDatasets ( String parent , String filter ) { PROJECT_PATH_TEMPLATE . validate ( parent , "listDatasets" ) ; ListDatasetsRequest request = ListDatasetsRequest . newBuilder ( ) . setParent ( parent ) . setFilter ( filter ) . build ( ) ; return listDatasets ( request ) ; } | Lists datasets under a project . Pagination is supported . |
6,102 | public final void deleteDataset ( String name ) { DATASET_PATH_TEMPLATE . validate ( name , "deleteDataset" ) ; DeleteDatasetRequest request = DeleteDatasetRequest . newBuilder ( ) . setName ( name ) . build ( ) ; deleteDataset ( request ) ; } | Deletes a dataset by resource name . |
6,103 | public final DataItem getDataItem ( String name ) { DATA_ITEM_PATH_TEMPLATE . validate ( name , "getDataItem" ) ; GetDataItemRequest request = GetDataItemRequest . newBuilder ( ) . setName ( name ) . build ( ) ; return getDataItem ( request ) ; } | Gets a data item in a dataset by resource name . This API can be called after data are imported into dataset . |
6,104 | public final ListDataItemsPagedResponse listDataItems ( String parent , String filter ) { DATASET_PATH_TEMPLATE . validate ( parent , "listDataItems" ) ; ListDataItemsRequest request = ListDataItemsRequest . newBuilder ( ) . setParent ( parent ) . setFilter ( filter ) . build ( ) ; return listDataItems ( request ) ; } | Lists data items in a dataset . This API can be called after data are imported into dataset . Pagination is supported . |
6,105 | public final AnnotatedDataset getAnnotatedDataset ( String name ) { ANNOTATED_DATASET_PATH_TEMPLATE . validate ( name , "getAnnotatedDataset" ) ; GetAnnotatedDatasetRequest request = GetAnnotatedDatasetRequest . newBuilder ( ) . setName ( name ) . build ( ) ; return getAnnotatedDataset ( request ) ; } | Gets an annotated dataset by resource name . |
6,106 | public final ListAnnotatedDatasetsPagedResponse listAnnotatedDatasets ( String parent , String filter ) { DATASET_PATH_TEMPLATE . validate ( parent , "listAnnotatedDatasets" ) ; ListAnnotatedDatasetsRequest request = ListAnnotatedDatasetsRequest . newBuilder ( ) . setParent ( parent ) . setFilter ( filter ) . build ( ) ; return listAnnotatedDatasets ( request ) ; } | Lists annotated datasets for a dataset . Pagination is supported . |
6,107 | public final Example getExample ( String name , String filter ) { EXAMPLE_PATH_TEMPLATE . validate ( name , "getExample" ) ; GetExampleRequest request = GetExampleRequest . newBuilder ( ) . setName ( name ) . setFilter ( filter ) . build ( ) ; return getExample ( request ) ; } | Gets an example by resource name including both data and annotation . |
6,108 | public final ListExamplesPagedResponse listExamples ( String parent , String filter ) { ANNOTATED_DATASET_PATH_TEMPLATE . validate ( parent , "listExamples" ) ; ListExamplesRequest request = ListExamplesRequest . newBuilder ( ) . setParent ( parent ) . setFilter ( filter ) . build ( ) ; return listExamples ( request ) ; } | Lists examples in an annotated dataset . Pagination is supported . |
6,109 | public final AnnotationSpecSet createAnnotationSpecSet ( String parent , AnnotationSpecSet annotationSpecSet ) { PROJECT_PATH_TEMPLATE . validate ( parent , "createAnnotationSpecSet" ) ; CreateAnnotationSpecSetRequest request = CreateAnnotationSpecSetRequest . newBuilder ( ) . setParent ( parent ) . setAnnotationSpecSet ( annotationSpecSet ) . build ( ) ; return createAnnotationSpecSet ( request ) ; } | Creates an annotation spec set by providing a set of labels . |
6,110 | public final AnnotationSpecSet getAnnotationSpecSet ( String name ) { ANNOTATION_SPEC_SET_PATH_TEMPLATE . validate ( name , "getAnnotationSpecSet" ) ; GetAnnotationSpecSetRequest request = GetAnnotationSpecSetRequest . newBuilder ( ) . setName ( name ) . build ( ) ; return getAnnotationSpecSet ( request ) ; } | Gets an annotation spec set by resource name . |
6,111 | public final ListAnnotationSpecSetsPagedResponse listAnnotationSpecSets ( String parent , String filter ) { PROJECT_PATH_TEMPLATE . validate ( parent , "listAnnotationSpecSets" ) ; ListAnnotationSpecSetsRequest request = ListAnnotationSpecSetsRequest . newBuilder ( ) . setParent ( parent ) . setFilter ( filter ) . build ( ) ; return listAnnotationSpecSets ( request ) ; } | Lists annotation spec sets for a project . Pagination is supported . |
6,112 | public final void deleteAnnotationSpecSet ( String name ) { ANNOTATION_SPEC_SET_PATH_TEMPLATE . validate ( name , "deleteAnnotationSpecSet" ) ; DeleteAnnotationSpecSetRequest request = DeleteAnnotationSpecSetRequest . newBuilder ( ) . setName ( name ) . build ( ) ; deleteAnnotationSpecSet ( request ) ; } | Deletes an annotation spec set by resource name . |
6,113 | public final Instruction getInstruction ( String name ) { INSTRUCTION_PATH_TEMPLATE . validate ( name , "getInstruction" ) ; GetInstructionRequest request = GetInstructionRequest . newBuilder ( ) . setName ( name ) . build ( ) ; return getInstruction ( request ) ; } | Gets an instruction by resource name . |
6,114 | public final ListInstructionsPagedResponse listInstructions ( String parent , String filter ) { PROJECT_PATH_TEMPLATE . validate ( parent , "listInstructions" ) ; ListInstructionsRequest request = ListInstructionsRequest . newBuilder ( ) . setParent ( parent ) . setFilter ( filter ) . build ( ) ; return listInstructions ( request ) ; } | Lists instructions for a project . Pagination is supported . |
6,115 | public final void deleteInstruction ( String name ) { INSTRUCTION_PATH_TEMPLATE . validate ( name , "deleteInstruction" ) ; DeleteInstructionRequest request = DeleteInstructionRequest . newBuilder ( ) . setName ( name ) . build ( ) ; deleteInstruction ( request ) ; } | Deletes an instruction object by resource name . |
6,116 | static DnsException translateAndThrow ( RetryHelperException ex ) { BaseServiceException . translate ( ex ) ; throw new DnsException ( UNKNOWN_CODE , ex . getMessage ( ) , ex . getCause ( ) ) ; } | Translate RetryHelperException to the DnsException that caused the error . This method will always throw an exception . |
6,117 | public void close ( Duration duration ) throws InterruptedException , TimeoutException { closed = true ; long deadlineMs = System . currentTimeMillis ( ) + duration . toMillis ( ) ; synchronized ( lock ) { while ( numOutstanding . get ( ) > 0 ) { long waitMs = deadlineMs - System . currentTimeMillis ( ) ; if ( waitMs <= 0 ) { throw new TimeoutException ( "Timed out waiting outstanding mutations to finish" ) ; } lock . wait ( waitMs ) ; } if ( numFailures > 0 ) { throw new BulkMutationFailure ( numFailures ) ; } } } | Prevents further mutations and waits for all outstanding mutations to complete . |
6,118 | public ApiFuture < Void > add ( final RowMutation rowMutation ) { Preconditions . checkState ( ! closed , "BulkMutations has been closed" ) ; numOutstanding . incrementAndGet ( ) ; ApiFuture < Void > future = callable . futureCall ( rowMutation ) ; ApiFutures . addCallback ( future , new ApiFutureCallback < Void > ( ) { public void onFailure ( Throwable throwable ) { onMutationComplete ( false ) ; } public void onSuccess ( Void aVoid ) { onMutationComplete ( true ) ; } } , MoreExecutors . directExecutor ( ) ) ; return future ; } | Queues the mutation to be batched and sent . Please note that the order of mutations is not guaranteed . |
6,119 | public final Operation patchHealthCheck ( ProjectGlobalHealthCheckName healthCheck , HealthCheck healthCheckResource , List < String > fieldMask ) { PatchHealthCheckHttpRequest request = PatchHealthCheckHttpRequest . newBuilder ( ) . setHealthCheck ( healthCheck == null ? null : healthCheck . toString ( ) ) . setHealthCheckResource ( healthCheckResource ) . addAllFieldMask ( fieldMask ) . build ( ) ; return patchHealthCheck ( request ) ; } | Updates a HealthCheck resource in the specified project using the data included in the request . This method supports PATCH semantics and uses the JSON merge patch format and processing rules . |
6,120 | public Map < String , Object > getNamedBindings ( ) { ImmutableMap . Builder < String , Object > builder = ImmutableSortedMap . naturalOrder ( ) ; for ( Map . Entry < String , Binding > binding : namedBindings . entrySet ( ) ) { builder . put ( binding . getKey ( ) , binding . getValue ( ) . getCursorOrValue ( ) ) ; } return builder . build ( ) ; } | Returns an immutable map of named bindings . |
6,121 | public void createTable ( ) { if ( ! adminClient . exists ( tableId ) ) { System . out . println ( "Table does not exist, creating table: " + tableId ) ; CreateTableRequest createTableRequest = CreateTableRequest . of ( tableId ) . addFamily ( "cf" ) ; Table table = adminClient . createTable ( createTableRequest ) ; System . out . printf ( "Table: %s created successfully%n" , table . getId ( ) ) ; } } | Demonstrates how to create a table with the specified configuration . |
6,122 | public void listAllTables ( ) { System . out . println ( "\nListing tables in current instance" ) ; try { List < String > tableIds = adminClient . listTables ( ) ; for ( String tableId : tableIds ) { System . out . println ( tableId ) ; } } catch ( NotFoundException e ) { System . err . println ( "Failed to list tables from a non-existent instance: " + e . getMessage ( ) ) ; } } | Demonstrates how to list all tables within an instance . |
6,123 | public void addFamilyWithMaxAgeRule ( ) { System . out . printf ( "%nCreating column family %s with max age GC rule%n" , COLUMN_FAMILY_1 ) ; DurationRule maxAgeRule = GCRULES . maxAge ( 5 , TimeUnit . DAYS ) ; try { ModifyColumnFamiliesRequest columnFamiliesRequest = ModifyColumnFamiliesRequest . of ( tableId ) . addFamily ( COLUMN_FAMILY_1 , maxAgeRule ) ; adminClient . modifyFamilies ( columnFamiliesRequest ) ; System . out . println ( "Created column family: " + COLUMN_FAMILY_1 ) ; } catch ( AlreadyExistsException e ) { System . err . println ( "Failed to create column family with rule, already exists: " + e . getMessage ( ) ) ; } } | Demonstrates how to create a new instance of the DurationRule . |
6,124 | public void addFamilyWithMaxVersionsRule ( ) { System . out . printf ( "%nCreating column family %s with max versions GC rule%n" , COLUMN_FAMILY_2 ) ; VersionRule versionRule = GCRULES . maxVersions ( 2 ) ; try { ModifyColumnFamiliesRequest columnFamiliesRequest = ModifyColumnFamiliesRequest . of ( tableId ) . addFamily ( COLUMN_FAMILY_2 , versionRule ) ; adminClient . modifyFamilies ( columnFamiliesRequest ) ; System . out . println ( "Created column family: " + COLUMN_FAMILY_2 ) ; } catch ( AlreadyExistsException e ) { System . err . println ( "Failed to create column family with rule, already exists: " + e . getMessage ( ) ) ; } } | Demonstrates how to create a new instance of the VersionRule . |
6,125 | public void addFamilyWithUnionRule ( ) { System . out . printf ( "%nCreating column family %s with union GC rule%n" , COLUMN_FAMILY_3 ) ; UnionRule unionRule = GCRULES . union ( ) . rule ( GCRULES . maxAge ( 5 , TimeUnit . DAYS ) ) . rule ( GCRULES . maxVersions ( 1 ) ) ; try { ModifyColumnFamiliesRequest columnFamiliesRequest = ModifyColumnFamiliesRequest . of ( tableId ) . addFamily ( COLUMN_FAMILY_3 , unionRule ) ; adminClient . modifyFamilies ( columnFamiliesRequest ) ; System . out . println ( "Created column family: " + COLUMN_FAMILY_3 ) ; } catch ( AlreadyExistsException e ) { System . err . println ( "Failed to create column family with rule, already exists: " + e . getMessage ( ) ) ; } } | Demonstrates how to create a new instance of the UnionRule . |
6,126 | public void addFamilyWithIntersectionRule ( ) { System . out . printf ( "%nCreating column family %s with intersection GC rule%n" , COLUMN_FAMILY_4 ) ; DurationRule maxAgeRule = GCRULES . maxAge ( 5 , TimeUnit . DAYS ) ; VersionRule versionRule = GCRULES . maxVersions ( 2 ) ; IntersectionRule intersectionRule = GCRULES . intersection ( ) . rule ( maxAgeRule ) . rule ( versionRule ) ; try { ModifyColumnFamiliesRequest columnFamiliesRequest = ModifyColumnFamiliesRequest . of ( tableId ) . addFamily ( COLUMN_FAMILY_4 , intersectionRule ) ; adminClient . modifyFamilies ( columnFamiliesRequest ) ; System . out . println ( "Created column family: " + COLUMN_FAMILY_4 ) ; } catch ( AlreadyExistsException e ) { System . err . println ( "Failed to create column family with rule, already exists: " + e . getMessage ( ) ) ; } } | Demonstrates how to create a new instance of the IntersectionRule . |
6,127 | public void addFamilyWithNestedRule ( ) { System . out . printf ( "%nCreating column family %s with a nested GC rule%n" , COLUMN_FAMILY_5 ) ; VersionRule versionRule1 = GCRULES . maxVersions ( 10 ) ; VersionRule versionRule2 = GCRULES . maxVersions ( 2 ) ; DurationRule maxAgeRule = GCRULES . maxAge ( 30 , TimeUnit . DAYS ) ; IntersectionRule intersectionRule = GCRULES . intersection ( ) . rule ( maxAgeRule ) . rule ( versionRule2 ) ; UnionRule unionRule = GCRULES . union ( ) . rule ( intersectionRule ) . rule ( versionRule1 ) ; try { ModifyColumnFamiliesRequest columnFamiliesRequest = ModifyColumnFamiliesRequest . of ( tableId ) . addFamily ( COLUMN_FAMILY_5 , unionRule ) ; adminClient . modifyFamilies ( columnFamiliesRequest ) ; System . out . println ( "Created column family: " + COLUMN_FAMILY_5 ) ; } catch ( AlreadyExistsException e ) { System . err . println ( "Failed to create column family with rule, already exists: " + e . getMessage ( ) ) ; } } | Demonstrates how to create a nested rule using the IntersectionRule and UnionRule . |
6,128 | public void modifyColumnFamilyRule ( ) { System . out . printf ( "%nUpdating column family %s GC rule%n" , COLUMN_FAMILY_1 ) ; VersionRule versionRule = GCRULES . maxVersions ( 1 ) ; try { ModifyColumnFamiliesRequest updateRequest = ModifyColumnFamiliesRequest . of ( tableId ) . updateFamily ( COLUMN_FAMILY_1 , versionRule ) ; adminClient . modifyFamilies ( updateRequest ) ; System . out . printf ( "Column family %s GC rule updated%n" , COLUMN_FAMILY_1 ) ; } catch ( NotFoundException e ) { System . err . println ( "Failed to modify a non-existent column family: " + e . getMessage ( ) ) ; } } | Demonstrates how to modify a column family s rule . |
6,129 | public void printModifiedColumnFamily ( ) { System . out . printf ( "%nPrint updated GC rule for column family %s%n" , COLUMN_FAMILY_1 ) ; try { Table table = adminClient . getTable ( tableId ) ; Collection < ColumnFamily > columnFamilies = table . getColumnFamilies ( ) ; for ( ColumnFamily columnFamily : columnFamilies ) { if ( columnFamily . getId ( ) . equals ( COLUMN_FAMILY_1 ) ) { System . out . printf ( "Column family: %s%nGC Rule: %s%n" , columnFamily . getId ( ) , columnFamily . getGCRule ( ) . toString ( ) ) ; } } } catch ( NotFoundException e ) { System . err . println ( "Failed to print a non-existent column family: " + e . getMessage ( ) ) ; } } | Demonstrates how to print the modified column family . |
6,130 | public void deleteColumnFamily ( ) { System . out . println ( "\nDelete column family: " + COLUMN_FAMILY_2 ) ; try { ModifyColumnFamiliesRequest deleted = ModifyColumnFamiliesRequest . of ( tableId ) . dropFamily ( COLUMN_FAMILY_2 ) ; adminClient . modifyFamilies ( deleted ) ; System . out . printf ( "Column family %s deleted successfully%n" , COLUMN_FAMILY_2 ) ; } catch ( NotFoundException e ) { System . err . println ( "Failed to delete a non-existent column family: " + e . getMessage ( ) ) ; } } | Demonstrates how to delete a column family . |
6,131 | public void deleteTable ( ) { System . out . println ( "\nDelete table: " + tableId ) ; try { adminClient . deleteTable ( tableId ) ; System . out . printf ( "Table: %s deleted successfully%n" , tableId ) ; } catch ( NotFoundException e ) { System . err . println ( "Failed to delete a non-existent table: " + e . getMessage ( ) ) ; } } | Demonstrates how to delete a table . |
6,132 | static Watch forDocument ( DocumentReference documentReference ) { Target . Builder target = Target . newBuilder ( ) ; target . getDocumentsBuilder ( ) . addDocuments ( documentReference . getName ( ) ) ; target . setTargetId ( WATCH_TARGET_ID ) ; return new Watch ( ( FirestoreImpl ) documentReference . getFirestore ( ) , documentReference . getParent ( ) , target . build ( ) ) ; } | Creates a new Watch instance that listens on DocumentReferences . |
6,133 | static Watch forQuery ( Query query ) { Target . Builder target = Target . newBuilder ( ) ; target . setQuery ( QueryTarget . newBuilder ( ) . setStructuredQuery ( query . buildQuery ( ) ) . setParent ( query . getResourcePath ( ) . getParent ( ) . getName ( ) ) . build ( ) ) ; target . setTargetId ( WATCH_TARGET_ID ) ; return new Watch ( ( FirestoreImpl ) query . getFirestore ( ) , query , target . build ( ) ) ; } | Creates a new Watch instance that listens on Queries . |
6,134 | ListenerRegistration runWatch ( final Executor userCallbackExecutor , EventListener < QuerySnapshot > listener ) { boolean watchStarted = isActive . compareAndSet ( false , true ) ; Preconditions . checkState ( watchStarted , "Can't restart an already active watch" ) ; this . userCallbackExecutor = userCallbackExecutor ; this . listener = listener ; this . stream = null ; this . documentSet = DocumentSet . emptySet ( comparator ) ; this . changeMap = new HashMap < > ( ) ; this . resumeToken = null ; this . current = false ; initStream ( ) ; return new ListenerRegistration ( ) { public void remove ( ) { isActive . set ( false ) ; firestore . getClient ( ) . getExecutor ( ) . execute ( new Runnable ( ) { public void run ( ) { synchronized ( Watch . this ) { stream . onCompleted ( ) ; stream = null ; } } } ) ; } } ; } | API entry point that starts the Watch stream . |
6,135 | private int currentSize ( ) { ChangeSet changeSet = extractChanges ( Timestamp . now ( ) ) ; return documentSet . size ( ) + changeSet . adds . size ( ) - changeSet . deletes . size ( ) ; } | Returns the current count of all documents including the changes from the current changeMap . |
6,136 | private void resetDocs ( ) { changeMap . clear ( ) ; resumeToken = null ; for ( DocumentSnapshot snapshot : documentSet ) { changeMap . put ( snapshot . getReference ( ) . getResourcePath ( ) , null ) ; } current = false ; } | Helper to clear the docs on RESET or filter mismatch . |
6,137 | private void maybeReopenStream ( Throwable throwable ) { if ( isActive . get ( ) && ! isPermanentError ( throwable ) ) { if ( isResourceExhaustedError ( throwable ) ) { nextAttempt = backoff . createNextAttempt ( nextAttempt ) ; } changeMap . clear ( ) ; resetStream ( ) ; } else { closeStream ( throwable ) ; } } | Re - opens the stream unless the specified error is considered permanent . Clears the change map . |
6,138 | private void initStream ( ) { firestoreExecutor . schedule ( new Runnable ( ) { public void run ( ) { if ( ! isActive . get ( ) ) { return ; } synchronized ( Watch . this ) { if ( ! isActive . get ( ) ) { return ; } Preconditions . checkState ( stream == null ) ; current = false ; nextAttempt = backoff . createNextAttempt ( nextAttempt ) ; stream = firestore . streamRequest ( Watch . this , firestore . getClient ( ) . listenCallable ( ) ) ; ListenRequest . Builder request = ListenRequest . newBuilder ( ) ; request . setDatabase ( firestore . getDatabaseName ( ) ) ; request . setAddTarget ( target ) ; if ( resumeToken != null ) { request . getAddTargetBuilder ( ) . setResumeToken ( resumeToken ) ; } stream . onNext ( request . build ( ) ) ; } } } , nextAttempt . getRandomizedRetryDelay ( ) . toMillis ( ) , TimeUnit . MILLISECONDS ) ; } | Initializes a new stream to the backend with backoff . |
6,139 | private boolean affectsTarget ( List < Integer > targetIds , int currentId ) { return targetIds == null || targetIds . isEmpty ( ) || targetIds . contains ( currentId ) ; } | Checks if the current target id is included in the list of target ids . Returns true if no targetIds are provided . |
6,140 | private ChangeSet extractChanges ( Timestamp readTime ) { ChangeSet changeSet = new ChangeSet ( ) ; for ( Entry < ResourcePath , Document > change : changeMap . entrySet ( ) ) { if ( change . getValue ( ) == null ) { if ( documentSet . contains ( change . getKey ( ) ) ) { changeSet . deletes . add ( documentSet . getDocument ( change . getKey ( ) ) ) ; } continue ; } QueryDocumentSnapshot snapshot = QueryDocumentSnapshot . fromDocument ( firestore , readTime , change . getValue ( ) ) ; if ( documentSet . contains ( change . getKey ( ) ) ) { changeSet . updates . add ( snapshot ) ; } else { changeSet . adds . add ( snapshot ) ; } } return changeSet ; } | Splits up document changes into removals additions and updates . |
6,141 | private void pushSnapshot ( final Timestamp readTime , ByteString nextResumeToken ) { final List < DocumentChange > changes = computeSnapshot ( readTime ) ; if ( ! hasPushed || ! changes . isEmpty ( ) ) { final QuerySnapshot querySnapshot = QuerySnapshot . withChanges ( query , readTime , documentSet , changes ) ; userCallbackExecutor . execute ( new Runnable ( ) { public void run ( ) { listener . onEvent ( querySnapshot , null ) ; } } ) ; hasPushed = true ; } changeMap . clear ( ) ; resumeToken = nextResumeToken ; } | Assembles a new snapshot from the current set of changes and invokes the user s callback . Clears the current changes on completion . |
6,142 | private DocumentChange deleteDoc ( QueryDocumentSnapshot oldDocument ) { ResourcePath resourcePath = oldDocument . getReference ( ) . getResourcePath ( ) ; int oldIndex = documentSet . indexOf ( resourcePath ) ; documentSet = documentSet . remove ( resourcePath ) ; return new DocumentChange ( oldDocument , Type . REMOVED , oldIndex , - 1 ) ; } | Applies a document delete to the document tree . Returns the corresponding DocumentChange event . |
6,143 | private DocumentChange addDoc ( QueryDocumentSnapshot newDocument ) { ResourcePath resourcePath = newDocument . getReference ( ) . getResourcePath ( ) ; documentSet = documentSet . add ( newDocument ) ; int newIndex = documentSet . indexOf ( resourcePath ) ; return new DocumentChange ( newDocument , Type . ADDED , - 1 , newIndex ) ; } | Applies a document add to the document tree . Returns the corresponding DocumentChange event . |
6,144 | private DocumentChange modifyDoc ( QueryDocumentSnapshot newDocument ) { ResourcePath resourcePath = newDocument . getReference ( ) . getResourcePath ( ) ; DocumentSnapshot oldDocument = documentSet . getDocument ( resourcePath ) ; if ( ! oldDocument . getUpdateTime ( ) . equals ( newDocument . getUpdateTime ( ) ) ) { int oldIndex = documentSet . indexOf ( resourcePath ) ; documentSet = documentSet . remove ( resourcePath ) ; documentSet = documentSet . add ( newDocument ) ; int newIndex = documentSet . indexOf ( resourcePath ) ; return new DocumentChange ( newDocument , Type . MODIFIED , oldIndex , newIndex ) ; } return null ; } | Applies a document modification to the document tree . Returns the DocumentChange event for successful modifications . |
6,145 | private List < DocumentChange > computeSnapshot ( Timestamp readTime ) { List < DocumentChange > appliedChanges = new ArrayList < > ( ) ; ChangeSet changeSet = extractChanges ( readTime ) ; Collections . sort ( changeSet . deletes , comparator ) ; for ( QueryDocumentSnapshot delete : changeSet . deletes ) { appliedChanges . add ( deleteDoc ( delete ) ) ; } Collections . sort ( changeSet . adds , comparator ) ; for ( QueryDocumentSnapshot add : changeSet . adds ) { appliedChanges . add ( addDoc ( add ) ) ; } Collections . sort ( changeSet . updates , comparator ) ; for ( QueryDocumentSnapshot update : changeSet . updates ) { DocumentChange change = modifyDoc ( update ) ; if ( change != null ) { appliedChanges . add ( change ) ; } } return appliedChanges ; } | Applies the mutations in changeMap to the document tree . Modified documentSet in - place and returns the changed documents . |
6,146 | private static boolean isPermanentError ( Throwable throwable ) { Status status = getStatus ( throwable ) ; switch ( status . getCode ( ) ) { case CANCELLED : case UNKNOWN : case DEADLINE_EXCEEDED : case RESOURCE_EXHAUSTED : case INTERNAL : case UNAVAILABLE : case UNAUTHENTICATED : return false ; default : return true ; } } | Determines whether a GRPC Error is considered permanent and should not be retried . |
6,147 | private static Status getStatus ( Throwable throwable ) { Status status = Status . UNKNOWN ; if ( throwable instanceof StatusRuntimeException ) { status = ( ( StatusRuntimeException ) throwable ) . getStatus ( ) ; } else if ( throwable instanceof StatusException ) { status = ( ( StatusException ) throwable ) . getStatus ( ) ; } return status ; } | Extracts the GRPC status code if available . Returns UNKNOWN for non - GRPC exceptions . |
6,148 | public final Operation patchFirewall ( ProjectGlobalFirewallName firewall , Firewall firewallResource , List < String > fieldMask ) { PatchFirewallHttpRequest request = PatchFirewallHttpRequest . newBuilder ( ) . setFirewall ( firewall == null ? null : firewall . toString ( ) ) . setFirewallResource ( firewallResource ) . addAllFieldMask ( fieldMask ) . build ( ) ; return patchFirewall ( request ) ; } | Updates the specified firewall rule with the data included in the request . This method supports PATCH semantics and uses the JSON merge patch format and processing rules . |
6,149 | public static CloudStorageOption . OpenCopy withUserMetadata ( String key , String value ) { return OptionUserMetadata . create ( key , value ) ; } | Sets an unmodifiable piece of user metadata on a Cloud Storage object . |
6,150 | @ BetaApi ( "The surface for long-running operations is not stable yet and may change in the future." ) public final OperationFuture < Cluster , ClusterOperationMetadata > createClusterAsync ( String projectId , String region , Cluster cluster ) { CreateClusterRequest request = CreateClusterRequest . newBuilder ( ) . setProjectId ( projectId ) . setRegion ( region ) . setCluster ( cluster ) . build ( ) ; return createClusterAsync ( request ) ; } | Creates a cluster in a project . |
6,151 | public final Cluster getCluster ( String projectId , String region , String clusterName ) { GetClusterRequest request = GetClusterRequest . newBuilder ( ) . setProjectId ( projectId ) . setRegion ( region ) . setClusterName ( clusterName ) . build ( ) ; return getCluster ( request ) ; } | Gets the resource representation for a cluster in a project . |
6,152 | @ SuppressWarnings ( "unchecked" ) public String getString ( String name ) { return ( ( Value < String > ) getValue ( name ) ) . get ( ) ; } | Returns the property value as a string . |
6,153 | @ SuppressWarnings ( "unchecked" ) public Timestamp getTimestamp ( String name ) { return ( ( Value < Timestamp > ) getValue ( name ) ) . get ( ) ; } | Returns the property value as a Timestamp . |
6,154 | @ SuppressWarnings ( "unchecked" ) public LatLng getLatLng ( String name ) { return ( ( Value < LatLng > ) getValue ( name ) ) . get ( ) ; } | Returns the property value as a LatLng . |
6,155 | @ SuppressWarnings ( "unchecked" ) public Key getKey ( String name ) { return ( ( Value < Key > ) getValue ( name ) ) . get ( ) ; } | Returns the property value as a Key . |
6,156 | @ SuppressWarnings ( "unchecked" ) public < K extends IncompleteKey > FullEntity < K > getEntity ( String name ) { return ( ( Value < FullEntity < K > > ) getValue ( name ) ) . get ( ) ; } | Returns the property value as an entity . |
6,157 | @ SuppressWarnings ( "unchecked" ) public < T extends Value < ? > > List < T > getList ( String name ) { return ( List < T > ) getValue ( name ) . get ( ) ; } | Returns the property value as a list of values . |
6,158 | @ SuppressWarnings ( "unchecked" ) public Blob getBlob ( String name ) { return ( ( Value < Blob > ) getValue ( name ) ) . get ( ) ; } | Returns the property value as a blob . |
6,159 | public Operation addAccessConfig ( String networkInterface , AccessConfig accessConfig , OperationOption ... options ) { return compute . addAccessConfig ( getInstanceId ( ) , networkInterface , accessConfig , options ) ; } | Adds an access configuration to the provided network interface for this instance . |
6,160 | public Operation attachDisk ( PersistentDiskConfiguration configuration , OperationOption ... options ) { return compute . attachDisk ( getInstanceId ( ) , configuration , options ) ; } | Attaches a persistent disk to this instance given its configuration . |
6,161 | public Operation deleteAccessConfig ( String networkInterface , String accessConfig , OperationOption ... options ) { return compute . deleteAccessConfig ( getInstanceId ( ) , networkInterface , accessConfig , options ) ; } | Deletes an access configuration from the provided network interface for this instance . |
6,162 | public Operation detachDisk ( String deviceName , OperationOption ... options ) { return compute . detachDisk ( getInstanceId ( ) , deviceName , options ) ; } | Detaches a disk from this instance . |
6,163 | public Operation setDiskAutoDelete ( String deviceName , boolean autoDelete , OperationOption ... options ) { return compute . setDiskAutoDelete ( getInstanceId ( ) , deviceName , autoDelete , options ) ; } | Sets the auto - delete flag for a disk attached to this instance . |
6,164 | public Operation setMetadata ( Metadata metadata , OperationOption ... options ) { return compute . setMetadata ( getInstanceId ( ) , metadata , options ) ; } | Sets the metadata for this instance . |
6,165 | public Operation setSchedulingOptions ( SchedulingOptions scheduling , OperationOption ... options ) { return compute . setSchedulingOptions ( getInstanceId ( ) , scheduling , options ) ; } | Sets the scheduling options for this instance . |
6,166 | public Operation setTags ( Tags tags , OperationOption ... options ) { return compute . setTags ( getInstanceId ( ) , tags , options ) ; } | Sets the tags for this instance . |
6,167 | private Logging getLogging ( ) { if ( logging == null ) { synchronized ( this ) { if ( logging == null ) { logging = loggingOptions . getService ( ) ; } } } return logging ; } | Returns an instance of the logging service . |
6,168 | public static ByteString literalRegex ( ByteString value ) { ByteString . Output output = ByteString . newOutput ( value . size ( ) * 2 ) ; ByteIterator it = value . iterator ( ) ; writeLiteralRegex ( it , output ) ; return output . toByteString ( ) ; } | Converts the value to a quoted regular expression . |
6,169 | public final Table createTable ( InstanceName parent , String tableId , Table table ) { CreateTableRequest request = CreateTableRequest . newBuilder ( ) . setParent ( parent == null ? null : parent . toString ( ) ) . setTableId ( tableId ) . setTable ( table ) . build ( ) ; return createTable ( request ) ; } | Creates a new table in the specified instance . The table can be created with a full set of initial column families specified in the request . |
6,170 | static DocumentSet emptySet ( final Comparator < QueryDocumentSnapshot > comparator ) { return new DocumentSet ( EMPTY_DOCUMENT_MAP , new ImmutableSortedSet < > ( Collections . < QueryDocumentSnapshot > emptyList ( ) , comparator ) ) ; } | Returns an empty DocumentSet sorted by the given comparator then by keys . |
6,171 | int indexOf ( ResourcePath key ) { QueryDocumentSnapshot document = keyIndex . get ( key ) ; if ( document == null ) { return - 1 ; } return sortedSet . indexOf ( document ) ; } | Returns the index of the provided key in the document set or - 1 if the document key is not present in the set ; |
6,172 | DocumentSet add ( QueryDocumentSnapshot document ) { DocumentSet removed = remove ( document . getReference ( ) . getResourcePath ( ) ) ; ImmutableSortedMap < ResourcePath , QueryDocumentSnapshot > newKeyIndex = removed . keyIndex . insert ( document . getReference ( ) . getResourcePath ( ) , document ) ; ImmutableSortedSet < QueryDocumentSnapshot > newSortedSet = removed . sortedSet . insert ( document ) ; return new DocumentSet ( newKeyIndex , newSortedSet ) ; } | Returns a new DocumentSet that contains the given document replacing any old document with the same key . |
6,173 | DocumentSet remove ( ResourcePath key ) { QueryDocumentSnapshot document = keyIndex . get ( key ) ; if ( document == null ) { return this ; } ImmutableSortedMap < ResourcePath , QueryDocumentSnapshot > newKeyIndex = keyIndex . remove ( key ) ; ImmutableSortedSet < QueryDocumentSnapshot > newSortedSet = sortedSet . remove ( document ) ; return new DocumentSet ( newKeyIndex , newSortedSet ) ; } | Returns a new DocumentSet with the document for the provided key removed . |
6,174 | public static BigtableDataClient create ( String projectId , String instanceId ) throws IOException { BigtableDataSettings settings = BigtableDataSettings . newBuilder ( ) . setProjectId ( projectId ) . setInstanceId ( instanceId ) . build ( ) ; return create ( settings ) ; } | Constructs an instance of BigtableDataClient with default settings . |
6,175 | public static BigtableDataClient create ( BigtableDataSettings settings ) throws IOException { EnhancedBigtableStub stub = EnhancedBigtableStub . create ( settings . getStubSettings ( ) ) ; return new BigtableDataClient ( stub ) ; } | Constructs an instance of BigtableDataClient using the given settings . The channels are created based on the settings passed in or defaults for any settings that are not set . |
6,176 | public < RowT > UnaryCallable < Query , RowT > readRowCallable ( RowAdapter < RowT > rowAdapter ) { return stub . createReadRowCallable ( rowAdapter ) ; } | Reads a single row . This callable allows for customization of the logical representation of a row . It s meant for advanced use cases . |
6,177 | public < RowT > ServerStreamingCallable < Query , RowT > readRowsCallable ( RowAdapter < RowT > rowAdapter ) { return stub . createReadRowsCallable ( rowAdapter ) ; } | Streams back the results of the query . This callable allows for customization of the logical representation of a row . It s meant for advanced use cases . |
6,178 | public InstanceConfig getInstanceConfig ( final String my_config_id ) { final String configId = my_config_id ; InstanceConfig instanceConfig = instanceAdminClient . getInstanceConfig ( configId ) ; return instanceConfig ; } | Example to get instance config . |
6,179 | public List < InstanceConfig > listInstanceConfigs ( ) { List < InstanceConfig > configs = Lists . newArrayList ( instanceAdminClient . listInstanceConfigs ( Options . pageSize ( 1 ) ) . iterateAll ( ) ) ; return configs ; } | Example to list instance configs . |
6,180 | public void createInstance ( final String my_instance_id , final String my_config_id , final String my_client_project ) { final String instanceId = my_instance_id ; final String configId = my_config_id ; final String clientProject = my_client_project ; OperationFuture < Instance , CreateInstanceMetadata > op = instanceAdminClient . createInstance ( InstanceInfo . newBuilder ( InstanceId . of ( clientProject , instanceId ) ) . setInstanceConfigId ( InstanceConfigId . of ( clientProject , configId ) ) . setDisplayName ( instanceId ) . setNodeCount ( 1 ) . build ( ) ) ; try { op . get ( ) ; } catch ( ExecutionException e ) { throw ( SpannerException ) e . getCause ( ) ; } catch ( InterruptedException e ) { throw SpannerExceptionFactory . propagateInterrupt ( e ) ; } } | Example to create an instance . |
6,181 | public Instance getInstance ( final String my_instance_id ) { final String instanceId = my_instance_id ; Instance ins = instanceAdminClient . getInstance ( instanceId ) ; return ins ; } | Example to get an instance . |
6,182 | public List < Instance > listInstances ( ) { List < Instance > instances = Lists . newArrayList ( instanceAdminClient . listInstances ( Options . pageSize ( 1 ) ) . iterateAll ( ) ) ; return instances ; } | Example to list instances . |
6,183 | public void updateInstance ( Instance my_instance , final String my_client_project , final String my_instance_id , final String my_display_name ) { Instance instance = my_instance ; final String clientProject = my_client_project ; final String instanceId = my_instance_id ; final String newDisplayName = my_display_name ; InstanceInfo toUpdate = InstanceInfo . newBuilder ( InstanceId . of ( clientProject , instanceId ) ) . setDisplayName ( newDisplayName ) . setNodeCount ( instance . getNodeCount ( ) + 1 ) . build ( ) ; OperationFuture < Instance , UpdateInstanceMetadata > op = instanceAdminClient . updateInstance ( toUpdate , InstanceInfo . InstanceField . DISPLAY_NAME ) ; try { op . get ( ) ; } catch ( ExecutionException e ) { throw ( SpannerException ) e . getCause ( ) ; } catch ( InterruptedException e ) { throw SpannerExceptionFactory . propagateInterrupt ( e ) ; } } | Example to update an instance . |
6,184 | @ SuppressWarnings ( "WeakerAccess" ) public String getId ( ) { ClusterName fullName = Verify . verifyNotNull ( ClusterName . parse ( stateProto . getName ( ) ) , "Name can never be null" ) ; return fullName . getCluster ( ) ; } | Gets the cluster s id . |
6,185 | @ SuppressWarnings ( "WeakerAccess" ) public String getInstanceId ( ) { ClusterName fullName = Verify . verifyNotNull ( ClusterName . parse ( stateProto . getName ( ) ) , "Name can never be null" ) ; return fullName . getInstance ( ) ; } | Gets the instance id . |
6,186 | @ SuppressWarnings ( "WeakerAccess" ) public String getZone ( ) { LocationName location = Verify . verifyNotNull ( LocationName . parse ( stateProto . getLocation ( ) ) ) ; return location . getLocation ( ) ; } | Get the zone where this cluster is located . |
6,187 | public final Operation patchAutoscaler ( String autoscaler , ProjectZoneName zone , Autoscaler autoscalerResource , List < String > fieldMask ) { PatchAutoscalerHttpRequest request = PatchAutoscalerHttpRequest . newBuilder ( ) . setAutoscaler ( autoscaler ) . setZone ( zone == null ? null : zone . toString ( ) ) . setAutoscalerResource ( autoscalerResource ) . addAllFieldMask ( fieldMask ) . build ( ) ; return patchAutoscaler ( request ) ; } | Updates an autoscaler in the specified project using the data included in the request . This method supports PATCH semantics and uses the JSON merge patch format and processing rules . |
6,188 | public final Operation patchRegionInstanceGroupManager ( String instanceGroupManager , InstanceGroupManager instanceGroupManagerResource , List < String > fieldMask ) { PatchRegionInstanceGroupManagerHttpRequest request = PatchRegionInstanceGroupManagerHttpRequest . newBuilder ( ) . setInstanceGroupManager ( instanceGroupManager ) . setInstanceGroupManagerResource ( instanceGroupManagerResource ) . addAllFieldMask ( fieldMask ) . build ( ) ; return patchRegionInstanceGroupManager ( request ) ; } | Updates a managed instance group using the information that you specify in the request . This operation is marked as DONE when the group is patched even if the instances in the group are still in the process of being patched . You must separately verify the status of the individual instances with the listmanagedinstances method . This method supports PATCH semantics and uses the JSON merge patch format and processing rules . |
6,189 | private < T > ApiFuture < T > extractFirst ( ApiFuture < List < T > > results ) { return ApiFutures . transform ( results , new ApiFunction < List < T > , T > ( ) { public T apply ( List < T > results ) { return results . isEmpty ( ) ? null : results . get ( 0 ) ; } } ) ; } | Extracts the first result from an ApiFuture with list of results . |
6,190 | public Iterable < CollectionReference > listCollections ( ) { ListCollectionIdsRequest . Builder request = ListCollectionIdsRequest . newBuilder ( ) ; request . setParent ( path . toString ( ) ) ; final ListCollectionIdsPagedResponse response ; try { response = ApiExceptions . callAndTranslateApiException ( firestore . sendRequest ( request . build ( ) , firestore . getClient ( ) . listCollectionIdsPagedCallable ( ) ) ) ; } catch ( ApiException exception ) { throw FirestoreException . apiException ( exception ) ; } return new Iterable < CollectionReference > ( ) { public Iterator < CollectionReference > iterator ( ) { final Iterator < String > iterator = response . iterateAll ( ) . iterator ( ) ; return new Iterator < CollectionReference > ( ) { public boolean hasNext ( ) { return iterator . hasNext ( ) ; } public CollectionReference next ( ) { return DocumentReference . this . collection ( iterator . next ( ) ) ; } public void remove ( ) { throw new UnsupportedOperationException ( "remove" ) ; } } ; } } ; } | Fetches the subcollections that are direct children of this document . |
6,191 | public static final String formatEntryName ( String project , String location , String entryGroup , String entry ) { return ENTRY_PATH_TEMPLATE . instantiate ( "project" , project , "location" , location , "entry_group" , entryGroup , "entry" , entry ) ; } | Formats a string containing the fully - qualified path to represent a entry resource . |
6,192 | public final AlertPolicy updateAlertPolicy ( FieldMask updateMask , AlertPolicy alertPolicy ) { UpdateAlertPolicyRequest request = UpdateAlertPolicyRequest . newBuilder ( ) . setUpdateMask ( updateMask ) . setAlertPolicy ( alertPolicy ) . build ( ) ; return updateAlertPolicy ( request ) ; } | Updates an alerting policy . You can either replace the entire policy with a new one or replace only certain fields in the current alerting policy by specifying the fields to be updated via updateMask . Returns the updated alerting policy . |
6,193 | public final ComputeThreatListDiffResponse computeThreatListDiff ( ThreatType threatType , ByteString versionToken , ComputeThreatListDiffRequest . Constraints constraints ) { ComputeThreatListDiffRequest request = ComputeThreatListDiffRequest . newBuilder ( ) . setThreatType ( threatType ) . setVersionToken ( versionToken ) . setConstraints ( constraints ) . build ( ) ; return computeThreatListDiff ( request ) ; } | Gets the most recent threat list diffs . |
6,194 | public final SearchUrisResponse searchUris ( String uri , List < ThreatType > threatTypes ) { SearchUrisRequest request = SearchUrisRequest . newBuilder ( ) . setUri ( uri ) . addAllThreatTypes ( threatTypes ) . build ( ) ; return searchUris ( request ) ; } | This method is used to check whether a URI is on a given threatList . |
6,195 | public final SearchHashesResponse searchHashes ( ByteString hashPrefix , List < ThreatType > threatTypes ) { SearchHashesRequest request = SearchHashesRequest . newBuilder ( ) . setHashPrefix ( hashPrefix ) . addAllThreatTypes ( threatTypes ) . build ( ) ; return searchHashes ( request ) ; } | Gets the full hashes that match the requested hash prefix . This is used after a hash prefix is looked up in a threatList and there is a match . The client side threatList only holds partial hashes so the client must query this method to determine if there is a full hash match of a threat . |
6,196 | public final Operation patchInterconnectAttachment ( ProjectRegionInterconnectAttachmentName interconnectAttachment , InterconnectAttachment interconnectAttachmentResource , List < String > fieldMask ) { PatchInterconnectAttachmentHttpRequest request = PatchInterconnectAttachmentHttpRequest . newBuilder ( ) . setInterconnectAttachment ( interconnectAttachment == null ? null : interconnectAttachment . toString ( ) ) . setInterconnectAttachmentResource ( interconnectAttachmentResource ) . addAllFieldMask ( fieldMask ) . build ( ) ; return patchInterconnectAttachment ( request ) ; } | Updates the specified interconnect attachment with the data included in the request . This method supports PATCH semantics and uses the JSON merge patch format and processing rules . |
6,197 | public KeyFactory reset ( ) { setProjectId ( pi ) ; setNamespace ( ns ) ; kind = null ; ancestors . clear ( ) ; return this ; } | Resets the KeyFactory to its initial state . |
6,198 | public Builder toBuilder ( ) { return newBuilder ( ) . setMaxAgeSeconds ( maxAgeSeconds ) . setMethods ( methods ) . setOrigins ( origins ) . setResponseHeaders ( responseHeaders ) ; } | Returns a builder for this CORS configuration . |
6,199 | public final Operation deleteSignedUrlKeyBackendBucket ( ProjectGlobalBackendBucketName backendBucket , String keyName ) { DeleteSignedUrlKeyBackendBucketHttpRequest request = DeleteSignedUrlKeyBackendBucketHttpRequest . newBuilder ( ) . setBackendBucket ( backendBucket == null ? null : backendBucket . toString ( ) ) . setKeyName ( keyName ) . build ( ) ; return deleteSignedUrlKeyBackendBucket ( request ) ; } | Deletes a key for validating requests with signed URLs for this backend bucket . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.