code
stringlengths
73
34.1k
label
stringclasses
1 value
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( "--------------...
java
public static Class<?> loadClass(ClassLoader classLoader, String className) { try { // If input classLoader is null, use current thread's ClassLoader, if that is null, use // default (calling class') ClassLoader. ClassLoader cl = classLoader != null ? classLoader : Thread.currentThread()...
java
public static <ComponentT> Optional<ComponentT> buildFromConfig( InternalDriverContext context, DriverOption classNameOption, Class<ComponentT> expectedSuperType, String... defaultPackages) { return buildFromConfig(context, null, classNameOption, expectedSuperType, defaultPackages); }
java
public static <ComponentT> Map<String, ComponentT> buildFromConfigProfiles( InternalDriverContext context, DriverOption rootOption, Class<ComponentT> expectedSuperType, String... defaultPackages) { // Find out how many distinct configurations we have ListMultimap<Object, String> profile...
java
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, ...
java
public CompletionStage<Void> init( boolean listenToClusterEvents, boolean reconnectOnFailure, boolean useInitialReconnectionSchedule) { RunOrSchedule.on( adminExecutor, () -> singleThreaded.init( listenToClusterEvents, reconnectOnFailure, useInitialRecon...
java
public CompletionStage<Void> setKeyspace(CqlIdentifier newKeyspaceName) { return RunOrSchedule.on(adminExecutor, () -> singleThreaded.setKeyspace(newKeyspaceName)); }
java
public List<String> getPreReleaseLabels() { return preReleases == null ? null : Collections.unmodifiableList(Arrays.asList(preReleases)); }
java
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; // ignore case RUNNING: for (LoadBalancingPolic...
java
@VisibleForTesting static String reverse(InetAddress address) { byte[] bytes = address.getAddress(); if (bytes.length == 4) return reverseIpv4(bytes); else return reverseIpv6(bytes); }
java
public int firstIndexOf(CqlIdentifier id) { Integer index = byId.get(id); return (index == null) ? -1 : index; }
java
private static void insertWithCoreApi(CqlSession session) { // Bind in a simple statement: session.execute( SimpleStatement.newInstance( "INSERT INTO examples.querybuilder_json JSON ?", "{ \"id\": 1, \"name\": \"Mouse\", \"specs\": { \"color\": \"silver\" } }")); // Bind in ...
java
private static void selectWithCoreApi(CqlSession session) { // Reading the whole row as a JSON object: Row row = session .execute( SimpleStatement.newInstance( "SELECT JSON * FROM examples.querybuilder_json WHERE id = ?", 1)) .one(); assert...
java
public UserDefinedTypeBuilder withField(CqlIdentifier name, DataType type) { fieldNames.add(name); fieldTypes.add(type); return this; }
java
public DefaultMetadata withNodes( Map<UUID, Node> newNodes, boolean tokenMapEnabled, boolean tokensChanged, TokenFactory tokenFactory, InternalDriverContext context) { // Force a rebuild if at least one node has different tokens, or there are new or removed nodes. boolean forceFul...
java
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 = se...
java
private static void selectJsonRow(CqlSession session) { // Reading the whole row as a JSON object Statement stmt = selectFrom("examples", "json_jsr353_row") .json() .all() .whereColumn("id") .in(literal(1), literal(2)) .build(); ResultSet...
java
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 b...
java
public static int minimumRequestSize(Request request) { // Header and payload are common inside a Frame at the protocol level // Frame header has a fixed size of 9 for protocol version >= V3, which includes Frame flags // size int size = FrameCodec.headerEncodedSize(); if (!request.getCustomPaylo...
java
public static int sizeOfSimpleStatementValues( SimpleStatement simpleStatement, ProtocolVersion protocolVersion, CodecRegistry codecRegistry) { int size = 0; if (!simpleStatement.getPositionalValues().isEmpty()) { List<ByteBuffer> positionalValues = new ArrayList<>(simpleStat...
java
public static Integer sizeOfInnerBatchStatementInBytes( BatchableStatement statement, ProtocolVersion protocolVersion, CodecRegistry codecRegistry) { int size = 0; size += PrimitiveSizes .BYTE; // for each inner statement, there is one byte for the "kind": prepared or string if (...
java
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<Vert...
java
public void cancel(ResponseCallback responseCallback) { // To avoid creating an extra message, we adopt the convention that writing the callback // directly means cancellation writeCoalescer.writeAndFlush(channel, responseCallback).addListener(UncaughtExceptions::log); }
java
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.a...
java
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); ...
java
@NonNull public CompletionStage<SessionT> buildAsync() { CompletionStage<CqlSession> buildStage = buildDefaultSessionAsync(); CompletionStage<SessionT> wrapStage = buildStage.thenApply(this::wrap); // thenApply does not propagate cancellation (!) CompletableFutures.propagateCancellation(wrapStage, bui...
java
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 Parse...
java
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.ge...
java
private Supplier getFormatterForType(String type) { switch(type) { case "s": //string stored in shared table if (!lastContents.isEmpty()) { int idx = Integer.parseInt(lastContents); return new StringSupplier(new XSSFRichTextString(sst.getEntryAt(idx)).toString()); ...
java
String unformattedContents() { switch(currentCell.getType()) { case "s": //string stored in shared table if (!lastContents.isEmpty()) { int idx = Integer.parseInt(lastContents); return new XSSFRichTextString(sst.getEntryAt(idx)).toString(); } return la...
java
@Override 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)...
java
@Override public String getStringCellValue() { Object c = contentsSupplier.getContent(); return c == null ? "" : c.toString(); }
java
@Override 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); }
java
@Override 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(); defa...
java
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...
java
@Override 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".eq...
java
@Override public void close() throws IOException { try { workbook.close(); } finally { if(tmp != null) { if (log.isDebugEnabled()) { log.debug("Deleting tmp file [" + tmp.getAbsolutePath() + "]"); } tmp.delete(); } } }
java
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)) { ...
java
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)); }
java
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); ...
java
private void drawPart(Canvas canvas, PagePart part) { // Can seem strange, but avoid lot of calls RectF pageRelativeBounds = part.getPageRelativeBounds(); Bitmap renderedBitmap = part.getRenderedBitmap(); // Move to the target page float localTranslationX = 0; flo...
java
public void loadPages() { if (optimalPageWidth == 0 || optimalPageHeight == 0) { return; } // Cancel all current tasks renderingAsyncTask.removeAllTasks(); cacheManager.makeANewSet(); // Find current index in filtered user pages int index =...
java
public void loadComplete(DecodeService decodeService) { this.decodeService = decodeService; this.documentPageCount = decodeService.getPageCount(); // We assume all the pages are the same size this.pageWidth = decodeService.getPageWidth(0); this.pageHeight = decodeService.g...
java
public void onBitmapRendered(PagePart part) { if (part.isThumbnail()) { cacheManager.cacheThumbnail(part); } else { cacheManager.cachePart(part); } invalidate(); }
java
private int determineValidPageNumberFrom(int userPage) { if (userPage <= 0) { return 0; } if (originalUserPages != null) { if (userPage >= originalUserPages.length) { return originalUserPages.length - 1; } } else { ...
java
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 = (floa...
java
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 = o...
java
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()); }
java
public void moveTo(float offsetX, float offsetY) { if (swipeVertical) { // Check X offset if (toCurrentScale(optimalPageWidth) < getWidth()) { offsetX = getWidth() / 2 - toCurrentScale(optimalPageWidth) / 2; } else { if (offsetX > 0) { offse...
java
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); } }
java
public Configurator fromFile(File file) { if (!file.exists()) throw new FileNotFoundException(file.getAbsolutePath() + "does not exist."); return new Configurator(Uri.fromFile(file)); }
java
@Benchmark @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; }
java
@Benchmark @BenchmarkMode(Mode.AverageTime) @OutputTimeUnit(TimeUnit.NANOSECONDS) public Span putAttributes(Data data) { Span span = data.attributeSpan; span.putAttributes(data.attributeMap); return span; }
java
@Benchmark @BenchmarkMode(Mode.AverageTime) @OutputTimeUnit(TimeUnit.NANOSECONDS) public Span addAnnotationEmpty(Data data) { Span span = data.annotationSpanEmpty; span.addAnnotation(ANNOTATION_DESCRIPTION); return span; }
java
@Benchmark @BenchmarkMode(Mode.AverageTime) @OutputTimeUnit(TimeUnit.NANOSECONDS) public Span addAnnotationWithAttributes(Data data) { Span span = data.annotationSpanAttributes; span.addAnnotation(ANNOTATION_DESCRIPTION, data.attributeMap); return span; }
java
@Benchmark @BenchmarkMode(Mode.AverageTime) @OutputTimeUnit(TimeUnit.NANOSECONDS) public Span addAnnotationWithAnnotation(Data data) { Span span = data.annotationSpanAnnotation; Annotation annotation = Annotation.fromDescriptionAndAttributes(ANNOTATION_DESCRIPTION, data.attributeMap); span.add...
java
@Benchmark @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; }
java
@Benchmark @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; }
java
@Override public <V> Callable<V> wrap(Callable<V> callable) { if (isTracing()) { return new SpanContinuingTraceCallable<V>(this, this.traceKeys, this.spanNamer, callable); } return callable; }
java
@Override public Runnable wrap(Runnable runnable) { if (isTracing()) { return new SpanContinuingTraceRunnable(this, this.traceKeys, this.spanNamer, runnable); } return runnable; }
java
public static void premain(String agentArgs, Instrumentation instrumentation) throws Exception { checkNotNull(instrumentation, "instrumentation"); logger.fine("Initializing."); // The classes in bootstrap.jar, such as ContextManger and ContextStrategy, will be referenced // from classes loaded by the ...
java
private static TraceServiceGrpc.TraceServiceStub getTraceServiceStub( String endPoint, Boolean useInsecure, SslContext sslContext) { ManagedChannelBuilder<?> channelBuilder; if (useInsecure) { channelBuilder = ManagedChannelBuilder.forTarget(endPoint).usePlaintext(); } else { channelBuilde...
java
@Benchmark @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) i); ...
java
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, os)...
java
public static void createAndRegister(DatadogTraceConfiguration configuration) throws MalformedURLException { synchronized (monitor) { checkState(handler == null, "Datadog exporter is already registered."); String agentEndpoint = configuration.getAgentEndpoint(); String service = configurati...
java
@Deprecated public static void createAndRegisterWithCredentialsAndProjectId( Credentials credentials, String projectId, Duration exportInterval) throws IOException { checkNotNull(credentials, "credentials"); checkNotNull(projectId, "projectId"); checkNotNull(exportInterval, "exportInterval"); cr...
java
@Deprecated public static void createAndRegisterWithProjectId(String projectId, Duration exportInterval) throws IOException { checkNotNull(projectId, "projectId"); checkNotNull(exportInterval, "exportInterval"); createInternal( null, projectId, exportInterval, DEFAULT_RESOURCE, null, DEFAULT...
java
@Deprecated 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, expo...
java
@Deprecated public static void createAndRegisterWithProjectIdAndMonitoredResource( String projectId, Duration exportInterval, MonitoredResource monitoredResource) throws IOException { checkNotNull(projectId, "projectId"); checkNotNull(exportInterval, "exportInterval"); checkNotNull(monitoredRe...
java
@Deprecated public static void createAndRegisterWithMonitoredResource( Duration exportInterval, MonitoredResource monitoredResource) throws IOException { checkNotNull(exportInterval, "exportInterval"); checkNotNull(monitoredResource, "monitoredResource"); checkArgument( !DEFAULT_PROJECT_ID.i...
java
@VisibleForTesting static void unsafeResetExporter() { synchronized (monitor) { if (instance != null) { instance.intervalMetricReader.stop(); } instance = null; } }
java
private void export() { if (exportRpcHandler == null || exportRpcHandler.isCompleted()) { return; } ArrayList<Metric> metricsList = Lists.newArrayList(); for (MetricProducer metricProducer : metricProducerManager.getAllMetricProducer()) { metricsList.addAll(metricProducer.getMetrics()); ...
java
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.traceStrat...
java
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); }...
java
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); } }
java
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 + ": " + val...
java
private boolean registerMetricDescriptor( io.opencensus.metrics.export.MetricDescriptor metricDescriptor) { String metricName = metricDescriptor.getName(); io.opencensus.metrics.export.MetricDescriptor existingMetricDescriptor = registeredMetricDescriptors.get(metricName); if (existingMetricDe...
java
static String generateFullMetricName(String name, String type) { return SOURCE + DELIMITER + name + DELIMITER + type; }
java
static String generateFullMetricDescription(String metricName, Metric metric) { return "Collected from " + SOURCE + " (metric=" + metricName + ", type=" + metric.getClass().getName() + ")"; }
java
public static void setContextStrategy(ContextStrategy contextStrategy) { if (ContextTrampoline.contextStrategy != null) { throw new IllegalStateException("contextStrategy was already set"); } if (contextStrategy == null) { throw new NullPointerException("contextStrategy"); } ContextTra...
java
private static Attributes toAttributesProto( io.opencensus.trace.export.SpanData.Attributes attributes, Map<String, AttributeValue> resourceLabels, Map<String, AttributeValue> fixedAttributes) { Attributes.Builder attributesBuilder = toAttributesBuilderProto( attributes.getAttr...
java
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(T...
java
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; }
java
public final void handleMessageSent(HttpRequestContext context, long bytes) { checkNotNull(context, "context"); context.sentMessageSize.addAndGet(bytes); if (context.span.getOptions().contains(Options.RECORD_EVENTS)) { // record compressed size recordMessageEvent(context.span, context.sentSeqId....
java
public final void handleMessageReceived(HttpRequestContext context, long bytes) { checkNotNull(context, "context"); context.receiveMessageSize.addAndGet(bytes); if (context.span.getOptions().contains(Options.RECORD_EVENTS)) { // record compressed size recordMessageEvent( context.span, ...
java
@GuardedBy("monitor") private /*@Nullable*/ TreeNode findNode(/*@Nullable*/ String path) { if (Strings.isNullOrEmpty(path) || "/".equals(path)) { // Go back to the root directory. return root; } else { List<String> dirs = PATH_SPLITTER.splitToList(path); TreeNode node = root; for (int ...
java
void record( List</*@Nullable*/ TagValue> tagValues, double value, Map<String, AttachmentValue> attachments, Timestamp timestamp) { if (!tagValueAggregationMap.containsKey(tagValues)) { tagValueAggregationMap.put( tagValues, RecordUtils.createMutableAggregation(aggregation, m...
java
static MetricDescriptor createMetricDescriptor( io.opencensus.metrics.export.MetricDescriptor metricDescriptor, String projectId, String domain, String displayNamePrefix, Map<LabelKey, LabelValue> constantLabels) { MetricDescriptor.Builder builder = MetricDescriptor.newBuilder(); ...
java
@VisibleForTesting static LabelDescriptor createLabelDescriptor(LabelKey labelKey) { LabelDescriptor.Builder builder = LabelDescriptor.newBuilder(); builder.setKey(labelKey.getKey()); builder.setDescription(labelKey.getDescription()); // Now we only support String tags builder.setValueType(ValueTy...
java
@VisibleForTesting 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 Metr...
java
@VisibleForTesting 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.I...
java
@VisibleForTesting 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(metricDescr...
java
@VisibleForTesting static TypedValue createTypedValue(Value value) { return value.match( typedValueDoubleFunction, typedValueLongFunction, typedValueDistributionFunction, typedValueSummaryFunction, Functions.<TypedValue>throwIllegalArgumentException()); }
java
@VisibleForTesting static Distribution createDistribution(io.opencensus.metrics.export.Distribution distribution) { Distribution.Builder builder = Distribution.newBuilder() .setBucketOptions(createBucketOptions(distribution.getBucketOptions())) .setCount(distribution.getCount()) ...
java
@VisibleForTesting static Timestamp convertTimestamp(io.opencensus.common.Timestamp censusTimestamp) { if (censusTimestamp.getSeconds() < 0) { // StackDriver doesn't handle negative timestamps. return Timestamp.newBuilder().build(); } return Timestamp.newBuilder() .setSeconds(censusTim...
java
@Benchmark @BenchmarkMode(Mode.AverageTime) @OutputTimeUnit(TimeUnit.NANOSECONDS) public TagContext tagContextCreation(Data data) { return TagsBenchmarksUtil.createTagContext(data.tagger.emptyBuilder(), data.numTags); }
java
@BenchmarkMode(Mode.AverageTime) @OutputTimeUnit(TimeUnit.NANOSECONDS) public Scope scopeTagContext(Data data) { Scope scope = data.tagger.withTagContext(data.tagContext); scope.close(); return scope; }
java
@Benchmark @BenchmarkMode(Mode.AverageTime) @OutputTimeUnit(TimeUnit.NANOSECONDS) public TagContext getCurrentTagContext(Data data) { return data.tagger.getCurrentTagContext(); }
java
@Benchmark @BenchmarkMode(Mode.AverageTime) @OutputTimeUnit(TimeUnit.NANOSECONDS) public byte[] serializeTagContext(Data data) throws Exception { return data.serializer.toByteArray(data.tagContext); }
java
@Benchmark @BenchmarkMode(Mode.AverageTime) @OutputTimeUnit(TimeUnit.NANOSECONDS) public TagContext deserializeTagContext(Data data) throws Exception { return data.serializer.fromByteArray(data.serializedTagContext); }
java