idx int64 0 165k | question stringlengths 73 5.81k | target stringlengths 5 918 |
|---|---|---|
158,900 | public void querySchema ( ) { ResultSet results = session . execute ( "SELECT * FROM simplex.playlists " + "WHERE id = 2cc9ccb7-6221-4ccb-8387-f22b6a1b354d;" ) ; System . out . printf ( "%-30s\t%-20s\t%-20s%n" , "title" , "album" , "artist" ) ; System . out . println ( "-------------------------------+-----------------... | Queries and displays data . |
158,901 | public static Class < ? > loadClass ( ClassLoader classLoader , String className ) { try { ClassLoader cl = classLoader != null ? classLoader : Thread . currentThread ( ) . getContextClassLoader ( ) ; if ( cl != null ) { return Class . forName ( className , true , cl ) ; } else { return Class . forName ( className ) ; ... | Loads a class by name . |
158,902 | public static < ComponentT > Optional < ComponentT > buildFromConfig ( InternalDriverContext context , DriverOption classNameOption , Class < ComponentT > expectedSuperType , String ... defaultPackages ) { return buildFromConfig ( context , null , classNameOption , expectedSuperType , defaultPackages ) ; } | Tries to create an instance of a class given an option defined in the driver configuration . |
158,903 | public static < ComponentT > Map < String , ComponentT > buildFromConfigProfiles ( InternalDriverContext context , DriverOption rootOption , Class < ComponentT > expectedSuperType , String ... defaultPackages ) { ListMultimap < Object , String > profilesByConfig = MultimapBuilder . hashKeys ( ) . arrayListValues ( ) . ... | Tries to create multiple instances of a class given options defined in the driver configuration and possibly overridden in profiles . |
158,904 | public Map < CqlIdentifier , UserDefinedType > parse ( Collection < AdminRow > typeRows , CqlIdentifier keyspaceId ) { if ( typeRows . isEmpty ( ) ) { return Collections . emptyMap ( ) ; } else { Map < CqlIdentifier , UserDefinedType > types = new LinkedHashMap < > ( ) ; for ( AdminRow row : topologicalSort ( typeRows ... | Contrary to other element parsers this one processes all the types of a keyspace in one go . UDTs can depend on each other but the system table returns them in alphabetical order . In order to properly build the definitions we need to do a topological sort of the rows first so that each type is parsed after its depende... |
158,905 | public CompletionStage < Void > init ( boolean listenToClusterEvents , boolean reconnectOnFailure , boolean useInitialReconnectionSchedule ) { RunOrSchedule . on ( adminExecutor , ( ) -> singleThreaded . init ( listenToClusterEvents , reconnectOnFailure , useInitialReconnectionSchedule ) ) ; return singleThreaded . ini... | Initializes the control connection . If it is already initialized this is a no - op and all parameters are ignored . |
158,906 | public CompletionStage < Void > setKeyspace ( CqlIdentifier newKeyspaceName ) { return RunOrSchedule . on ( adminExecutor , ( ) -> singleThreaded . setKeyspace ( newKeyspaceName ) ) ; } | Changes the keyspace name on all the channels in this pool . |
158,907 | public List < String > getPreReleaseLabels ( ) { return preReleases == null ? null : Collections . unmodifiableList ( Arrays . asList ( preReleases ) ) ; } | The pre - release labels if relevant i . e . label1 and label2 in X . Y . Z - label1 - lable2 . |
158,908 | private void processNodeStateEvent ( NodeStateEvent event ) { switch ( stateRef . get ( ) ) { case BEFORE_INIT : case DURING_INIT : throw new AssertionError ( "Filter should not be marked ready until LBP init" ) ; case CLOSING : return ; case RUNNING : for ( LoadBalancingPolicy policy : policies ) { if ( event . newSta... | once it has gone through the filter |
158,909 | static String reverse ( InetAddress address ) { byte [ ] bytes = address . getAddress ( ) ; if ( bytes . length == 4 ) return reverseIpv4 ( bytes ) ; else return reverseIpv6 ( bytes ) ; } | Builds the reversed domain name in the ARPA domain to perform the reverse lookup |
158,910 | public int firstIndexOf ( CqlIdentifier id ) { Integer index = byId . get ( id ) ; return ( index == null ) ? - 1 : index ; } | Returns the first occurrence of a given identifier or - 1 if it s not in the list . |
158,911 | private static void insertWithCoreApi ( CqlSession session ) { session . execute ( SimpleStatement . newInstance ( "INSERT INTO examples.querybuilder_json JSON ?" , "{ \"id\": 1, \"name\": \"Mouse\", \"specs\": { \"color\": \"silver\" } }" ) ) ; PreparedStatement pst = session . prepare ( "INSERT INTO examples.querybui... | Demonstrates data insertion with the core API i . e . providing the full query strings . |
158,912 | private static void selectWithCoreApi ( CqlSession session ) { Row row = session . execute ( SimpleStatement . newInstance ( "SELECT JSON * FROM examples.querybuilder_json WHERE id = ?" , 1 ) ) . one ( ) ; assert row != null ; System . out . printf ( "Entry #1 as JSON: %s%n" , row . getString ( "[json]" ) ) ; row = ses... | Demonstrates data retrieval with the core API i . e . providing the full query strings . |
158,913 | public UserDefinedTypeBuilder withField ( CqlIdentifier name , DataType type ) { fieldNames . add ( name ) ; fieldTypes . add ( type ) ; return this ; } | Adds a new field . The fields in the resulting type will be in the order of the calls to this method . |
158,914 | public DefaultMetadata withNodes ( Map < UUID , Node > newNodes , boolean tokenMapEnabled , boolean tokensChanged , TokenFactory tokenFactory , InternalDriverContext context ) { boolean forceFullRebuild = tokensChanged || ! newNodes . equals ( nodes ) ; return new DefaultMetadata ( ImmutableMap . copyOf ( newNodes ) , ... | Refreshes the current metadata with the given list of nodes . |
158,915 | private void sendRequest ( Node retriedNode , Queue < Node > queryPlan , int currentExecutionIndex , int retryCount , boolean scheduleNextExecution ) { if ( result . isDone ( ) ) { return ; } Node node = retriedNode ; DriverChannel channel = null ; if ( node == null || ( channel = session . getChannel ( node , logPrefi... | Sends the request to the next available node . |
158,916 | private static void selectJsonRow ( CqlSession session ) { Statement stmt = selectFrom ( "examples" , "json_jsr353_row" ) . json ( ) . all ( ) . whereColumn ( "id" ) . in ( literal ( 1 ) , literal ( 2 ) ) . build ( ) ; ResultSet rows = session . execute ( stmt ) ; for ( Row row : rows ) { JsonObject user = ( JsonObject... | Retrieving User instances from table rows using SELECT JSON |
158,917 | private static ByteBuffer readAll ( File file ) throws IOException { try ( FileInputStream inputStream = new FileInputStream ( file ) ) { FileChannel channel = inputStream . getChannel ( ) ; ByteBuffer buffer = ByteBuffer . allocate ( ( int ) channel . size ( ) ) ; channel . read ( buffer ) ; buffer . flip ( ) ; return... | probably not insert it into Cassandra either ; ) |
158,918 | public static int minimumRequestSize ( Request request ) { int size = FrameCodec . headerEncodedSize ( ) ; if ( ! request . getCustomPayload ( ) . isEmpty ( ) ) { size += PrimitiveSizes . sizeOfBytesMap ( request . getCustomPayload ( ) ) ; } return size ; } | Returns a common size for all kinds of Request implementations . |
158,919 | public static int sizeOfSimpleStatementValues ( SimpleStatement simpleStatement , ProtocolVersion protocolVersion , CodecRegistry codecRegistry ) { int size = 0 ; if ( ! simpleStatement . getPositionalValues ( ) . isEmpty ( ) ) { List < ByteBuffer > positionalValues = new ArrayList < > ( simpleStatement . getPositional... | Returns the size in bytes of a simple statement s values depending on whether the values are named or positional . |
158,920 | public static Integer sizeOfInnerBatchStatementInBytes ( BatchableStatement statement , ProtocolVersion protocolVersion , CodecRegistry codecRegistry ) { int size = 0 ; size += PrimitiveSizes . BYTE ; if ( statement instanceof SimpleStatement ) { size += PrimitiveSizes . sizeOfLongString ( ( ( SimpleStatement ) stateme... | The size of a statement inside a batch query is different from the size of a complete Statement . The inner batch statements only include the query or prepared ID and the values of the statement . |
158,921 | public List < VertexT > topologicalSort ( ) { Preconditions . checkState ( ! wasSorted ) ; wasSorted = true ; Queue < VertexT > queue = new ArrayDeque < > ( ) ; for ( Map . Entry < VertexT , Integer > entry : vertices . entrySet ( ) ) { if ( entry . getValue ( ) == 0 ) { queue . add ( entry . getKey ( ) ) ; } } List < ... | one - time use only calling this multiple times on the same graph won t work |
158,922 | public void cancel ( ResponseCallback responseCallback ) { writeCoalescer . writeAndFlush ( channel , responseCallback ) . addListener ( UncaughtExceptions :: log ) ; } | Cancels a callback indicating that the client that wrote it is no longer interested in the answer . |
158,923 | private void computeEvents ( KeyspaceMetadata oldKeyspace , KeyspaceMetadata newKeyspace , ImmutableList . Builder < Object > events ) { if ( oldKeyspace == null ) { events . add ( KeyspaceChangeEvent . created ( newKeyspace ) ) ; } else { if ( ! shallowEquals ( oldKeyspace , newKeyspace ) ) { events . add ( KeyspaceCh... | Computes the exact set of events to emit when a keyspace has changed . |
158,924 | public void receive ( IncomingT element ) { assert adminExecutor . inEventLoop ( ) ; if ( stopped ) { return ; } if ( window . isZero ( ) || maxEvents == 1 ) { LOG . debug ( "Received {}, flushing immediately (window = {}, maxEvents = {})" , element , window , maxEvents ) ; onFlush . accept ( coalescer . apply ( Immuta... | This must be called on eventExecutor too . |
158,925 | public CompletionStage < SessionT > buildAsync ( ) { CompletionStage < CqlSession > buildStage = buildDefaultSessionAsync ( ) ; CompletionStage < SessionT > wrapStage = buildStage . thenApply ( this :: wrap ) ; CompletableFutures . propagateCancellation ( wrapStage , buildStage ) ; return wrapStage ; } | Creates the session with the options set by this builder . |
158,926 | private boolean getRow ( ) { try { rowCache . clear ( ) ; while ( rowCache . size ( ) < rowCacheSize && parser . hasNext ( ) ) { handleEvent ( parser . nextEvent ( ) ) ; } rowCacheIterator = rowCache . iterator ( ) ; return rowCacheIterator . hasNext ( ) ; } catch ( XMLStreamException e ) { throw new ParseException ( "... | Read through a number of rows equal to the rowCacheSize field or until there is no more data to read |
158,927 | void setFormatString ( StartElement startElement , StreamingCell cell ) { Attribute cellStyle = startElement . getAttributeByName ( new QName ( "s" ) ) ; String cellStyleString = ( cellStyle != null ) ? cellStyle . getValue ( ) : null ; XSSFCellStyle style = null ; if ( cellStyleString != null ) { style = stylesTable .... | Read the numeric format string out of the styles table for this cell . Stores the result in the Cell . |
158,928 | private Supplier getFormatterForType ( String type ) { switch ( type ) { case "s" : if ( ! lastContents . isEmpty ( ) ) { int idx = Integer . parseInt ( lastContents ) ; return new StringSupplier ( new XSSFRichTextString ( sst . getEntryAt ( idx ) ) . toString ( ) ) ; } return new StringSupplier ( lastContents ) ; case... | Tries to format the contents of the last contents appropriately based on the provided type and the discovered numeric format . |
158,929 | String unformattedContents ( ) { switch ( currentCell . getType ( ) ) { case "s" : if ( ! lastContents . isEmpty ( ) ) { int idx = Integer . parseInt ( lastContents ) ; return new XSSFRichTextString ( sst . getEntryAt ( idx ) ) . toString ( ) ; } return lastContents ; case "inlineStr" : return new XSSFRichTextString ( ... | Returns the contents of the cell with no formatting applied |
158,930 | public CellType getCellType ( ) { if ( formulaType ) { return CellType . FORMULA ; } else if ( contentsSupplier . getContent ( ) == null || type == null ) { return CellType . BLANK ; } else if ( "n" . equals ( type ) ) { return CellType . NUMERIC ; } else if ( "s" . equals ( type ) || "inlineStr" . equals ( type ) || "... | Return the cell type . |
158,931 | public String getStringCellValue ( ) { Object c = contentsSupplier . getContent ( ) ; return c == null ? "" : c . toString ( ) ; } | Get the value of the cell as a string . For blank cells we return an empty string . |
158,932 | public Date getDateCellValue ( ) { if ( getCellType ( ) == CellType . STRING ) { throw new IllegalStateException ( "Cell type cannot be CELL_TYPE_STRING" ) ; } return rawContents == null ? null : HSSFDateUtil . getJavaDate ( getNumericCellValue ( ) , use1904Dates ) ; } | Get the value of the cell as a date . For strings we throw an exception . For blank cells we return a null . |
158,933 | public boolean getBooleanCellValue ( ) { CellType cellType = getCellType ( ) ; switch ( cellType ) { case BLANK : return false ; case BOOLEAN : return rawContents != null && TRUE_AS_STRING . equals ( rawContents ) ; case FORMULA : throw new NotSupportedException ( ) ; default : throw typeMismatch ( CellType . BOOLEAN ,... | Get the value of the cell as a boolean . For strings we throw an exception . For blank cells we return a false . |
158,934 | private static String getCellTypeName ( CellType cellType ) { switch ( cellType ) { case BLANK : return "blank" ; case STRING : return "text" ; case BOOLEAN : return "boolean" ; case ERROR : return "error" ; case NUMERIC : return "numeric" ; case FORMULA : return "formula" ; } return "#unknown cell type (" + cellType +... | Used to help format error messages |
158,935 | public CellType getCachedFormulaResultType ( ) { if ( formulaType ) { if ( contentsSupplier . getContent ( ) == null || type == null ) { return CellType . BLANK ; } else if ( "n" . equals ( type ) ) { return CellType . NUMERIC ; } else if ( "s" . equals ( type ) || "inlineStr" . equals ( type ) || "str" . equals ( type... | Only valid for formula cells |
158,936 | public void close ( ) throws IOException { try { workbook . close ( ) ; } finally { if ( tmp != null ) { if ( log . isDebugEnabled ( ) ) { log . debug ( "Deleting tmp file [" + tmp . getAbsolutePath ( ) + "]" ) ; } tmp . delete ( ) ; } } } | Closes the streaming resource attempting to clean up any temporary files created . |
158,937 | public boolean containsThumbnail ( int userPage , int page , float width , float height , RectF pageRelativeBounds ) { PagePart fakePart = new PagePart ( userPage , page , null , width , height , pageRelativeBounds , true , 0 ) ; for ( PagePart part : thumbnails ) { if ( part . equals ( fakePart ) ) { return true ; } }... | Return true if already contains the described PagePart |
158,938 | private float distance ( MotionEvent event ) { if ( event . getPointerCount ( ) < 2 ) { return 0 ; } return PointF . length ( event . getX ( POINTER1 ) - event . getX ( POINTER2 ) , event . getY ( POINTER1 ) - event . getY ( POINTER2 ) ) ; } | Calculates the distance between the 2 current pointers |
158,939 | private boolean isClick ( MotionEvent upEvent , float xDown , float yDown , float xUp , float yUp ) { if ( upEvent == null ) return false ; long time = upEvent . getEventTime ( ) - upEvent . getDownTime ( ) ; float distance = PointF . length ( xDown - xUp , yDown - yUp ) ; return time < MAX_CLICK_TIME && distance < MAX... | Test if a MotionEvent with the given start and end offsets can be considered as a click . |
158,940 | private void drawPart ( Canvas canvas , PagePart part ) { RectF pageRelativeBounds = part . getPageRelativeBounds ( ) ; Bitmap renderedBitmap = part . getRenderedBitmap ( ) ; float localTranslationX = 0 ; float localTranslationY = 0 ; if ( swipeVertical ) localTranslationY = toCurrentScale ( part . getUserPage ( ) * op... | Draw a given PagePart on the canvas |
158,941 | public void loadPages ( ) { if ( optimalPageWidth == 0 || optimalPageHeight == 0 ) { return ; } renderingAsyncTask . removeAllTasks ( ) ; cacheManager . makeANewSet ( ) ; int index = currentPage ; if ( filteredUserPageIndexes != null ) { index = filteredUserPageIndexes [ currentPage ] ; } int parts = 0 ; for ( int i = ... | Load all the parts around the center of the screen taking into account X and Y offsets zoom level and the current page displayed |
158,942 | public void loadComplete ( DecodeService decodeService ) { this . decodeService = decodeService ; this . documentPageCount = decodeService . getPageCount ( ) ; this . pageWidth = decodeService . getPageWidth ( 0 ) ; this . pageHeight = decodeService . getPageHeight ( 0 ) ; state = State . LOADED ; calculateOptimalWidth... | Called when the PDF is loaded |
158,943 | public void onBitmapRendered ( PagePart part ) { if ( part . isThumbnail ( ) ) { cacheManager . cacheThumbnail ( part ) ; } else { cacheManager . cachePart ( part ) ; } invalidate ( ) ; } | Called when a rendering task is over and a PagePart has been freshly created . |
158,944 | private int determineValidPageNumberFrom ( int userPage ) { if ( userPage <= 0 ) { return 0 ; } if ( originalUserPages != null ) { if ( userPage >= originalUserPages . length ) { return originalUserPages . length - 1 ; } } else { if ( userPage >= documentPageCount ) { return documentPageCount - 1 ; } } return userPage ... | Given the UserPage number this method restrict it to be sure it s an existing page . It takes care of using the user defined pages if any . |
158,945 | private void calculateOptimalWidthAndHeight ( ) { if ( state == State . DEFAULT || getWidth ( ) == 0 ) { return ; } float maxWidth = getWidth ( ) , maxHeight = getHeight ( ) ; float w = pageWidth , h = pageHeight ; float ratio = w / h ; w = maxWidth ; h = ( float ) Math . floor ( maxWidth / ratio ) ; if ( h > maxHeight... | Calculate the optimal width and height of a page considering the area width and height |
158,946 | private void calculateMinimapBounds ( ) { float ratioX = Constants . MINIMAP_MAX_SIZE / optimalPageWidth ; float ratioY = Constants . MINIMAP_MAX_SIZE / optimalPageHeight ; float ratio = Math . min ( ratioX , ratioY ) ; float minimapWidth = optimalPageWidth * ratio ; float minimapHeight = optimalPageHeight * ratio ; mi... | Place the minimap background considering the optimal width and height and the MINIMAP_MAX_SIZE . |
158,947 | private void calculateMasksBounds ( ) { leftMask = new RectF ( 0 , 0 , getWidth ( ) / 2 - toCurrentScale ( optimalPageWidth ) / 2 , getHeight ( ) ) ; rightMask = new RectF ( getWidth ( ) / 2 + toCurrentScale ( optimalPageWidth ) / 2 , 0 , getWidth ( ) , getHeight ( ) ) ; } | Place the left and right masks around the current page . |
158,948 | public void moveTo ( float offsetX , float offsetY ) { if ( swipeVertical ) { if ( toCurrentScale ( optimalPageWidth ) < getWidth ( ) ) { offsetX = getWidth ( ) / 2 - toCurrentScale ( optimalPageWidth ) / 2 ; } else { if ( offsetX > 0 ) { offsetX = 0 ; } else if ( offsetX + toCurrentScale ( optimalPageWidth ) < getWidt... | Move to the given X and Y offsets but check them ahead of time to be sure not to go outside the the big strip . |
158,949 | public Configurator fromAsset ( String assetName ) { try { File pdfFile = FileUtils . fileFromAsset ( getContext ( ) , assetName ) ; return fromFile ( pdfFile ) ; } catch ( IOException e ) { throw new FileNotFoundException ( assetName + " does not exist." , e ) ; } } | Use an asset file as the pdf source |
158,950 | public Configurator fromFile ( File file ) { if ( ! file . exists ( ) ) throw new FileNotFoundException ( file . getAbsolutePath ( ) + "does not exist." ) ; return new Configurator ( Uri . fromFile ( file ) ) ; } | Use a file as the pdf source |
158,951 | @ BenchmarkMode ( Mode . AverageTime ) @ OutputTimeUnit ( TimeUnit . NANOSECONDS ) public Span putAttribute ( Data data ) { Span span = data . attributeSpan ; for ( int i = 0 ; i < data . size ; i ++ ) { span . putAttribute ( data . attributeKeys [ i ] , data . attributeValues [ i ] ) ; } return span ; } | Add attributes individually . |
158,952 | @ BenchmarkMode ( Mode . AverageTime ) @ OutputTimeUnit ( TimeUnit . NANOSECONDS ) public Span putAttributes ( Data data ) { Span span = data . attributeSpan ; span . putAttributes ( data . attributeMap ) ; return span ; } | Add attributes as a map . |
158,953 | @ BenchmarkMode ( Mode . AverageTime ) @ OutputTimeUnit ( TimeUnit . NANOSECONDS ) public Span addAnnotationEmpty ( Data data ) { Span span = data . annotationSpanEmpty ; span . addAnnotation ( ANNOTATION_DESCRIPTION ) ; return span ; } | Add an annotation as description only . |
158,954 | @ BenchmarkMode ( Mode . AverageTime ) @ OutputTimeUnit ( TimeUnit . NANOSECONDS ) public Span addAnnotationWithAttributes ( Data data ) { Span span = data . annotationSpanAttributes ; span . addAnnotation ( ANNOTATION_DESCRIPTION , data . attributeMap ) ; return span ; } | Add an annotation with attributes . |
158,955 | @ BenchmarkMode ( Mode . AverageTime ) @ OutputTimeUnit ( TimeUnit . NANOSECONDS ) public Span addAnnotationWithAnnotation ( Data data ) { Span span = data . annotationSpanAnnotation ; Annotation annotation = Annotation . fromDescriptionAndAttributes ( ANNOTATION_DESCRIPTION , data . attributeMap ) ; span . addAnnotati... | Add an annotation with an annotation . |
158,956 | @ BenchmarkMode ( Mode . AverageTime ) @ OutputTimeUnit ( TimeUnit . NANOSECONDS ) public Span addMessageEvent ( Data data ) { Span span = data . messageEventSpan ; for ( int i = 0 ; i < data . size ; i ++ ) { span . addMessageEvent ( data . messageEvents [ i ] ) ; } return span ; } | Add message events . |
158,957 | @ BenchmarkMode ( Mode . AverageTime ) @ OutputTimeUnit ( TimeUnit . NANOSECONDS ) public Span addLink ( Data data ) { Span span = data . linkSpan ; for ( int i = 0 ; i < data . size ; i ++ ) { span . addLink ( data . links [ i ] ) ; } return span ; } | Add links . |
158,958 | public < V > Callable < V > wrap ( Callable < V > callable ) { if ( isTracing ( ) ) { return new SpanContinuingTraceCallable < V > ( this , this . traceKeys , this . spanNamer , callable ) ; } return callable ; } | Wrap the callable in a TraceCallable if tracing . |
158,959 | public Runnable wrap ( Runnable runnable ) { if ( isTracing ( ) ) { return new SpanContinuingTraceRunnable ( this , this . traceKeys , this . spanNamer , runnable ) ; } return runnable ; } | Wrap the runnable in a TraceRunnable if tracing . |
158,960 | public static void premain ( String agentArgs , Instrumentation instrumentation ) throws Exception { checkNotNull ( instrumentation , "instrumentation" ) ; logger . fine ( "Initializing." ) ; instrumentation . appendToBootstrapClassLoaderSearch ( new JarFile ( Resources . getResourceAsTempFile ( "bootstrap.jar" ) ) ) ;... | Initializes the OpenCensus Agent for Java . |
158,961 | private static TraceServiceGrpc . TraceServiceStub getTraceServiceStub ( String endPoint , Boolean useInsecure , SslContext sslContext ) { ManagedChannelBuilder < ? > channelBuilder ; if ( useInsecure ) { channelBuilder = ManagedChannelBuilder . forTarget ( endPoint ) . usePlaintext ( ) ; } else { channelBuilder = Nett... | One stub can be used for both Export RPC and Config RPC . |
158,962 | @ BenchmarkMode ( Mode . AverageTime ) @ OutputTimeUnit ( TimeUnit . NANOSECONDS ) public MeasureMap recordBatchedDoubleCount ( Data data ) { MeasureMap map = data . recorder . newMeasureMap ( ) ; for ( int i = 0 ; i < data . numValues ; i ++ ) { map . put ( StatsBenchmarksUtil . DOUBLE_COUNT_MEASURES [ i ] , ( double ... | Record batched double count measures . |
158,963 | static File getResourceAsTempFile ( String resourceName ) throws IOException { checkArgument ( ! Strings . isNullOrEmpty ( resourceName ) , "resourceName" ) ; File file = File . createTempFile ( resourceName , ".tmp" ) ; OutputStream os = new FileOutputStream ( file ) ; try { getResourceAsTempFile ( resourceName , file... | Returns a resource of the given name as a temporary file . |
158,964 | public static void createAndRegister ( DatadogTraceConfiguration configuration ) throws MalformedURLException { synchronized ( monitor ) { checkState ( handler == null , "Datadog exporter is already registered." ) ; String agentEndpoint = configuration . getAgentEndpoint ( ) ; String service = configuration . getServic... | Creates and registers the Datadog Trace exporter to the OpenCensus library . Only one Datadog exporter can be registered at any point . |
158,965 | public static void createAndRegisterWithCredentialsAndProjectId ( Credentials credentials , String projectId , Duration exportInterval ) throws IOException { checkNotNull ( credentials , "credentials" ) ; checkNotNull ( projectId , "projectId" ) ; checkNotNull ( exportInterval , "exportInterval" ) ; createInternal ( cr... | Creates a StackdriverStatsExporter for an explicit project ID and using explicit credentials with default Monitored Resource . |
158,966 | public static void createAndRegisterWithProjectId ( String projectId , Duration exportInterval ) throws IOException { checkNotNull ( projectId , "projectId" ) ; checkNotNull ( exportInterval , "exportInterval" ) ; createInternal ( null , projectId , exportInterval , DEFAULT_RESOURCE , null , DEFAULT_CONSTANT_LABELS ) ;... | Creates a Stackdriver Stats exporter for an explicit project ID with default Monitored Resource . |
158,967 | public static void createAndRegister ( Duration exportInterval ) throws IOException { checkNotNull ( exportInterval , "exportInterval" ) ; checkArgument ( ! DEFAULT_PROJECT_ID . isEmpty ( ) , "Cannot find a project ID from application default." ) ; createInternal ( null , DEFAULT_PROJECT_ID , exportInterval , DEFAULT_R... | Creates a Stackdriver Stats exporter with default Monitored Resource . |
158,968 | public static void createAndRegisterWithProjectIdAndMonitoredResource ( String projectId , Duration exportInterval , MonitoredResource monitoredResource ) throws IOException { checkNotNull ( projectId , "projectId" ) ; checkNotNull ( exportInterval , "exportInterval" ) ; checkNotNull ( monitoredResource , "monitoredRes... | Creates a Stackdriver Stats exporter with an explicit project ID and a custom Monitored Resource . |
158,969 | public static void createAndRegisterWithMonitoredResource ( Duration exportInterval , MonitoredResource monitoredResource ) throws IOException { checkNotNull ( exportInterval , "exportInterval" ) ; checkNotNull ( monitoredResource , "monitoredResource" ) ; checkArgument ( ! DEFAULT_PROJECT_ID . isEmpty ( ) , "Cannot fi... | Creates a Stackdriver Stats exporter with a custom Monitored Resource . |
158,970 | static void unsafeResetExporter ( ) { synchronized ( monitor ) { if ( instance != null ) { instance . intervalMetricReader . stop ( ) ; } instance = null ; } } | Resets exporter to null . Used only for unit tests . |
158,971 | private void export ( ) { if ( exportRpcHandler == null || exportRpcHandler . isCompleted ( ) ) { return ; } ArrayList < Metric > metricsList = Lists . newArrayList ( ) ; for ( MetricProducer metricProducer : metricProducerManager . getAllMetricProducer ( ) ) { metricsList . addAll ( metricProducer . getMetrics ( ) ) ;... | converts them to proto then exports them to OC - Agent . |
158,972 | public static void setTraceStrategy ( TraceStrategy traceStrategy ) { if ( TraceTrampoline . traceStrategy != null ) { throw new IllegalStateException ( "traceStrategy was already set" ) ; } if ( traceStrategy == null ) { throw new NullPointerException ( "traceStrategy" ) ; } TraceTrampoline . traceStrategy = traceStra... | Sets the concrete strategy for creating and manipulating trace spans . |
158,973 | public static < T > T createInstance ( Class < ? > rawClass , Class < T > superclass ) { try { return rawClass . asSubclass ( superclass ) . getConstructor ( ) . newInstance ( ) ; } catch ( Exception e ) { throw new ServiceConfigurationError ( "Provider " + rawClass . getName ( ) + " could not be instantiated." , e ) ;... | Tries to create an instance of the given rawClass as a subclass of the given superclass . |
158,974 | private static final TagKey createTagKey ( String name ) throws TagContextDeserializationException { try { return TagKey . create ( name ) ; } catch ( IllegalArgumentException e ) { throw new TagContextDeserializationException ( "Invalid tag key: " + name , e ) ; } } | IllegalArgumentException here . |
158,975 | private static final TagValue createTagValue ( TagKey key , String value ) throws TagContextDeserializationException { try { return TagValue . create ( value ) ; } catch ( IllegalArgumentException e ) { throw new TagContextDeserializationException ( "Invalid tag value for key " + key + ": " + value , e ) ; } } | an IllegalArgumentException here . |
158,976 | private boolean registerMetricDescriptor ( io . opencensus . metrics . export . MetricDescriptor metricDescriptor ) { String metricName = metricDescriptor . getName ( ) ; io . opencensus . metrics . export . MetricDescriptor existingMetricDescriptor = registeredMetricDescriptors . get ( metricName ) ; if ( existingMetr... | exact same metric has already been registered . Returns false otherwise . |
158,977 | static String generateFullMetricName ( String name , String type ) { return SOURCE + DELIMITER + name + DELIMITER + type ; } | Returns the metric name . |
158,978 | static String generateFullMetricDescription ( String metricName , Metric metric ) { return "Collected from " + SOURCE + " (metric=" + metricName + ", type=" + metric . getClass ( ) . getName ( ) + ")" ; } | Returns the metric description . |
158,979 | public static void setContextStrategy ( ContextStrategy contextStrategy ) { if ( ContextTrampoline . contextStrategy != null ) { throw new IllegalStateException ( "contextStrategy was already set" ) ; } if ( contextStrategy == null ) { throw new NullPointerException ( "contextStrategy" ) ; } ContextTrampoline . context... | Sets the concrete strategy for accessing and manipulating the context . |
158,980 | private static Attributes toAttributesProto ( io . opencensus . trace . export . SpanData . Attributes attributes , Map < String , AttributeValue > resourceLabels , Map < String , AttributeValue > fixedAttributes ) { Attributes . Builder attributesBuilder = toAttributesBuilderProto ( attributes . getAttributeMap ( ) , ... | These are the attributes of the Span where usually we may add more attributes like the agent . |
158,981 | public static void createAndRegister ( String agentEndpoint ) throws MalformedURLException { synchronized ( monitor ) { checkState ( handler == null , "Instana exporter is already registered." ) ; Handler newHandler = new InstanaExporterHandler ( new URL ( agentEndpoint ) ) ; handler = newHandler ; register ( Tracing .... | Creates and registers the Instana Trace exporter to the OpenCensus library . Only one Instana exporter can be registered at any point . |
158,982 | public synchronized Collection < T > getAll ( ) { List < T > all = new ArrayList < T > ( size ) ; for ( T e = head ; e != null ; e = e . getNext ( ) ) { all . add ( e ) ; } return all ; } | Returns all the elements from this list . |
158,983 | public final void handleMessageSent ( HttpRequestContext context , long bytes ) { checkNotNull ( context , "context" ) ; context . sentMessageSize . addAndGet ( bytes ) ; if ( context . span . getOptions ( ) . contains ( Options . RECORD_EVENTS ) ) { recordMessageEvent ( context . span , context . sentSeqId . addAndGet... | Instrument an HTTP span after a message is sent . Typically called for every chunk of request or response is sent . |
158,984 | public final void handleMessageReceived ( HttpRequestContext context , long bytes ) { checkNotNull ( context , "context" ) ; context . receiveMessageSize . addAndGet ( bytes ) ; if ( context . span . getOptions ( ) . contains ( Options . RECORD_EVENTS ) ) { recordMessageEvent ( context . span , context . receviedSeqId ... | Instrument an HTTP span after a message is received . Typically called for every chunk of request or response is received . |
158,985 | @ GuardedBy ( "monitor" ) private TreeNode findNode ( String path ) { if ( Strings . isNullOrEmpty ( path ) || "/" . equals ( path ) ) { return root ; } else { List < String > dirs = PATH_SPLITTER . splitToList ( path ) ; TreeNode node = root ; for ( int i = 0 ; i < dirs . size ( ) ; i ++ ) { String dir = dirs . get ( ... | Returns null if such a TreeNode doesn t exist . |
158,986 | void record ( List < TagValue > tagValues , double value , Map < String , AttachmentValue > attachments , Timestamp timestamp ) { if ( ! tagValueAggregationMap . containsKey ( tagValues ) ) { tagValueAggregationMap . put ( tagValues , RecordUtils . createMutableAggregation ( aggregation , measure ) ) ; } tagValueAggreg... | Puts a new value into the internal MutableAggregations based on the TagValues . |
158,987 | static MetricDescriptor createMetricDescriptor ( io . opencensus . metrics . export . MetricDescriptor metricDescriptor , String projectId , String domain , String displayNamePrefix , Map < LabelKey , LabelValue > constantLabels ) { MetricDescriptor . Builder builder = MetricDescriptor . newBuilder ( ) ; String type = ... | Convert a OpenCensus MetricDescriptor to a StackDriver MetricDescriptor |
158,988 | static LabelDescriptor createLabelDescriptor ( LabelKey labelKey ) { LabelDescriptor . Builder builder = LabelDescriptor . newBuilder ( ) ; builder . setKey ( labelKey . getKey ( ) ) ; builder . setDescription ( labelKey . getDescription ( ) ) ; builder . setValueType ( ValueType . STRING ) ; return builder . build ( )... | Construct a LabelDescriptor from a LabelKey |
158,989 | static MetricKind createMetricKind ( Type type ) { if ( type == Type . GAUGE_INT64 || type == Type . GAUGE_DOUBLE ) { return MetricKind . GAUGE ; } else if ( type == Type . CUMULATIVE_INT64 || type == Type . CUMULATIVE_DOUBLE || type == Type . CUMULATIVE_DISTRIBUTION ) { return MetricKind . CUMULATIVE ; } return Metric... | Convert a OpenCensus Type to a StackDriver MetricKind |
158,990 | static MetricDescriptor . ValueType createValueType ( Type type ) { if ( type == Type . CUMULATIVE_DOUBLE || type == Type . GAUGE_DOUBLE ) { return MetricDescriptor . ValueType . DOUBLE ; } else if ( type == Type . GAUGE_INT64 || type == Type . CUMULATIVE_INT64 ) { return MetricDescriptor . ValueType . INT64 ; } else i... | Convert a OpenCensus Type to a StackDriver ValueType |
158,991 | static Metric createMetric ( io . opencensus . metrics . export . MetricDescriptor metricDescriptor , List < LabelValue > labelValues , String domain , Map < LabelKey , LabelValue > constantLabels ) { Metric . Builder builder = Metric . newBuilder ( ) ; builder . setType ( generateType ( metricDescriptor . getName ( ) ... | Create a Metric using the LabelKeys and LabelValues . |
158,992 | static TypedValue createTypedValue ( Value value ) { return value . match ( typedValueDoubleFunction , typedValueLongFunction , typedValueDistributionFunction , typedValueSummaryFunction , Functions . < TypedValue > throwIllegalArgumentException ( ) ) ; } | Note TypedValue is A single strongly - typed value i . e only one field should be set . |
158,993 | static Distribution createDistribution ( io . opencensus . metrics . export . Distribution distribution ) { Distribution . Builder builder = Distribution . newBuilder ( ) . setBucketOptions ( createBucketOptions ( distribution . getBucketOptions ( ) ) ) . setCount ( distribution . getCount ( ) ) . setMean ( distributio... | Convert a OpenCensus Distribution to a StackDriver Distribution |
158,994 | static Timestamp convertTimestamp ( io . opencensus . common . Timestamp censusTimestamp ) { if ( censusTimestamp . getSeconds ( ) < 0 ) { return Timestamp . newBuilder ( ) . build ( ) ; } return Timestamp . newBuilder ( ) . setSeconds ( censusTimestamp . getSeconds ( ) ) . setNanos ( censusTimestamp . getNanos ( ) ) .... | Convert a OpenCensus Timestamp to a StackDriver Timestamp |
158,995 | @ BenchmarkMode ( Mode . AverageTime ) @ OutputTimeUnit ( TimeUnit . NANOSECONDS ) public TagContext tagContextCreation ( Data data ) { return TagsBenchmarksUtil . createTagContext ( data . tagger . emptyBuilder ( ) , data . numTags ) ; } | Create a tag context . |
158,996 | @ BenchmarkMode ( Mode . AverageTime ) @ OutputTimeUnit ( TimeUnit . NANOSECONDS ) public Scope scopeTagContext ( Data data ) { Scope scope = data . tagger . withTagContext ( data . tagContext ) ; scope . close ( ) ; return scope ; } | Open and close a tag context scope . |
158,997 | @ BenchmarkMode ( Mode . AverageTime ) @ OutputTimeUnit ( TimeUnit . NANOSECONDS ) public TagContext getCurrentTagContext ( Data data ) { return data . tagger . getCurrentTagContext ( ) ; } | Get the current tag context . |
158,998 | @ BenchmarkMode ( Mode . AverageTime ) @ OutputTimeUnit ( TimeUnit . NANOSECONDS ) public byte [ ] serializeTagContext ( Data data ) throws Exception { return data . serializer . toByteArray ( data . tagContext ) ; } | Serialize a tag context . |
158,999 | @ BenchmarkMode ( Mode . AverageTime ) @ OutputTimeUnit ( TimeUnit . NANOSECONDS ) public TagContext deserializeTagContext ( Data data ) throws Exception { return data . serializer . fromByteArray ( data . serializedTagContext ) ; } | Deserialize a tag context . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.