GVKun编程网logo

FluxInterval实例及解析(flsgetvalue)

14

在本文中,我们将为您详细介绍FluxInterval实例及解析的相关知识,并且为您解答关于flsgetvalue的疑问,此外,我们还会提供一些关于AlluxioLocalCache监控指南Alluxi

在本文中,我们将为您详细介绍FluxInterval实例及解析的相关知识,并且为您解答关于flsgetvalue的疑问,此外,我们还会提供一些关于Alluxio Local Cache 监控指南 Alluxio Alluxio、AngularJs中$ interval和setInterval之间的区别、com.intellij.util.indexing.ValueContainer的实例源码、com.sun.jdi.IntegerValue的实例源码的有用信息。

本文目录一览:

FluxInterval实例及解析(flsgetvalue)

FluxInterval实例及解析(flsgetvalue)

本文主要研究下FluxInterval的机制

FluxInterval

reactor-core-3.1.3.RELEASE-sources.jar!/reactor/core/publisher/FluxInterval.java

/**
 * Periodically emits an ever increasing long value either via a scheduledexecutorservice
 * or a custom async callback function
 * @see <a href="https://github.com/reactor/reactive-streams-commons">Reactive-Streams-Commons</a>
 */
final class FluxInterval extends Flux<Long> {

    final Scheduler timedScheduler;
    
    final long initialDelay;
    
    final long period;
    
    final TimeUnit unit;

    FluxInterval(
            long initialDelay,long period,TimeUnit unit,Scheduler timedScheduler) {
        if (period < 0L) {
            throw new IllegalArgumentException("period >= 0 required but it was " + period);
        }
        this.initialDelay = initialDelay;
        this.period = period;
        this.unit = Objects.requireNonNull(unit,"unit");
        this.timedScheduler = Objects.requireNonNull(timedScheduler,"timedScheduler");
    }
    
    @Override
    public void subscribe(CoreSubscriber<? super Long> actual) {
        Worker w = timedScheduler.createWorker();

        IntervalRunnable r = new IntervalRunnable(actual,w);

        actual.onSubscribe(r);

        try {
            w.schedulePeriodically(r,initialDelay,period,unit);
        }
        catch (RejectedExecutionException ree) {
            if (!r.cancelled) {
                actual.onError(Operators.onRejectedExecution(ree,r,null,actual.currentContext()));
            }
        }
    }
}
可以看到这里利用Scheduler来创建一个定时调度任务IntervalRunnable

IntervalRunnable

static final class IntervalRunnable implements Runnable,Subscription,InnerProducer<Long> {
        final CoreSubscriber<? super Long> actual;
        
        final Worker worker;
        
        volatile long requested;
        static final AtomicLongFieldUpdater<IntervalRunnable> REQUESTED =
                AtomicLongFieldUpdater.newUpdater(IntervalRunnable.class,"requested");
        
        long count;
        
        volatile boolean cancelled;

        IntervalRunnable(CoreSubscriber<? super Long> actual,Worker worker) {
            this.actual = actual;
            this.worker = worker;
        }

        @Override
        public CoreSubscriber<? super Long> actual() {
            return actual;
        }

        @Override
        @Nullable
        public Object scanUnsafe(Attr key) {
            if (key == Attr.CANCELLED) return cancelled;

            return InnerProducer.super.scanUnsafe(key);
        }

        @Override
        public void run() {
            if (!cancelled) {
                if (requested != 0L) {
                    actual.onNext(count++);
                    if (requested != Long.MAX_VALUE) {
                        REQUESTED.decrementAndGet(this);
                    }
                } else {
                    cancel();
                    
                    actual.onError(Exceptions.failWithOverflow("Could not emit tick " + count + " due to lack of requests" +
                            " (interval doesn't support small downstream requests that replenish slower than the ticks)"));
                }
            }
        }
        
        @Override
        public void request(long n) {
            if (Operators.validate(n)) {
                Operators.addCap(REQUESTED,this,n);
            }
        }
        
        @Override
        public void cancel() {
            if (!cancelled) {
                cancelled = true;
                worker.dispose();
            }
        }
    }
这里重点看requested变量,run方法每次判断requested,如果requested为0则销毁worker,否则则每次发射一个元素计数就减一
而subscriber如果有继续request的话,则会增加requested的值

实例1

public static void main(String[] args) throws InterruptedException {
        Flux<Long> flux = Flux.interval(Duration.ofMillis(1))
                .doOnNext(e -> {
                    System.out.println(e);
                }).doOnError(e -> e.printstacktrace());

        System.out.println("begin to subscribe");
        flux.subscribe(e -> {
            System.out.println(e);
            try {
                TimeUnit.MINUTES.sleep(30);
            } catch (InterruptedException e1) {
                e1.printstacktrace();
            }
        });
        TimeUnit.MINUTES.sleep(30);
    }
这个例子requested是Long.MAX_VALUE,但是由于subscribe的线程跟运行interval的线程一样,由于里头执行了sleep操作也导致interval的调度也跟着阻塞住了。

实例2

public static void main(String[] args) throws InterruptedException {
        Flux<Long> flux = Flux.interval(Duration.ofMillis(1))
                .doOnNext(e -> {
                    System.out.println(e);
                })
                //NOTE 这里request prefetch=256个
                .publishOn(Schedulers.newElastic("publish-thread"))
                .doOnError(e -> e.printstacktrace());

        System.out.println("begin to subscribe");
        AtomicInteger count = new AtomicInteger(0);
        //NOTE 得有subscribe才能触发request
        flux.subscribe(e -> {
            LOGGER.info("receive:{}",e);
            try {
                //NOTE 使用publishOn将subscribe与interval的线程分开
                if(count.get() == 0){
                    TimeUnit.MINUTES.sleep(2);
                }
                count.incrementAndGet();
            } catch (InterruptedException e1) {
                e1.printstacktrace();
            }
        });
        TimeUnit.MINUTES.sleep(30);
    }
使用publishOn将subscriber线程与interval线程隔离,使其sleep不阻塞interval
这里publishOn隐含了一个prefetch参数,默认是Queues.SMALL_BUFFER_SIZE即Math.max(16,Integer.parseInt(System.getProperty("reactor.bufferSize.small","256")));
public final Flux<T> publishOn(Scheduler scheduler) {
        return publishOn(scheduler,Queues.SMALL_BUFFER_SIZE);
    }

    final Flux<T> publishOn(Scheduler scheduler,boolean delayError,int prefetch,int lowTide) {
        if (this instanceof Callable) {
            if (this instanceof Fuseable.ScalarCallable) {
                @SuppressWarnings("unchecked")
                Fuseable.ScalarCallable<T> s = (Fuseable.ScalarCallable<T>) this;
                try {
                    return onAssembly(new FluxSubscribeOnValue<>(s.call(),scheduler));
                }
                catch (Exception e) {
                    //leave FluxSubscribeOnCallable defer exception call
                }
            }
            @SuppressWarnings("unchecked")
            Callable<T> c = (Callable<T>)this;
            return onAssembly(new FluxSubscribeOnCallable<>(c,scheduler));
        }

        return onAssembly(new FluxPublishOn<>(this,scheduler,delayError,prefetch,lowTide,Queues.get(prefetch)));
    }
这里使用Queues.get(prefetch)创建一个间接的队列来盛放元素

这个实例最后输出

//......
21:06:03.108 [publish-thread-2] INFO com.example.demo.FluxTest - receive:254
21:06:03.108 [publish-thread-2] INFO com.example.demo.FluxTest - receive:255
reactor.core.Exceptions$OverflowException: Could not emit tick 256 due to lack of requests (interval doesn't support small downstream requests that replenish slower than the ticks)
    at reactor.core.Exceptions.failWithOverflow(Exceptions.java:215)
    at reactor.core.publisher.FluxInterval$IntervalRunnable.run(FluxInterval.java:121)
    at reactor.core.scheduler.PeriodicWorkerTask.call(PeriodicWorkerTask.java:59)
    at reactor.core.scheduler.PeriodicWorkerTask.run(PeriodicWorkerTask.java:73)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
    at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:308)
    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:180)
    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:294)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)
由于第一次request默认是256,之后在发射256个元素之后,subscriber没有跟上,导致interval的worker被cancel掉了,于是后续消费完256个元素之后,紧挨着就是OverflowException这个异常

小结

reactor本身并不依赖线程,只有interval,delayElements等方法才会创建线程。而reactor本身是观察者设计模式的扩展,采用push+backpressure模式,一开始调用subscribe方法就触发request N请求推送数据,之后publisher就onNext推送数据,直到complete或cancel。实例1是因为线程阻塞导致interval的onNext阻塞,实例2是interval被cancel掉导致flux关闭。

Alluxio Local Cache 监控指南 Alluxio Alluxio

Alluxio Local Cache 监控指南 Alluxio Alluxio

作者
张策:Alluxio PMC & 联通大数据工程师

01 什么是 Alluxio Local Cache

随着云计算在基础设施领域的市场份额持续上升,主流数据分析引擎纷纷选择独立扩展存储、计算来适配云基础设施,并以此为云提供商降低成本。但是,存储计算分离也为查询延迟带来了新的挑战,因为当网络饱和时,通过网络扫描大量数据将受到 IO 限制。此外,元数据也面临远程网络来检索的性能问题。

数据编排系统 Alluxio 预见到了存算分离的发展趋势,并通过分布式缓存服务为 Presto、Spark 等引擎加速查询性能。为了在存算分离架构中实现亚秒级的查询延迟,Alluxio 和 Presto 的核心团队合作实现了客户端嵌入式缓存库 Alluxio Local Cache,来进一步减少数据分析引擎和 Alluxio 之间的通信开销。

相关博客如下:

Alluxio Data Caching : https://prestodb.io/blog/2020/06/16/alluxio-datacaching

Presto RaptorX : https://prestodb.io/blog/2020/06/16/alluxio-datacaching

02 Alluxio Local Cache 配置与启用

2021 年大部分时间 Local Cache 仅支持 Presto Hive Connector,并已经得到大规模应用。社区于2021年底新增了Local Cache 对 Presto Iceberg Connector 的支持,相关内容将在之后的博客做深入介绍。

如何在 Presto on Hive 场景配置、启用 Local Cache:

1. Presto 配置文件:etc/catalog/hive.properties

hive.node-selection-strategy=SOFT_AFFINITY

2.修改 Presto 配置文件:etc/catalog/hive.properties,缓存路径推荐配置为 Ramdisk 或 SSD 来达到最佳效果。

cache.enabled=true
cache.base-directory=file:///mnt/flash/data
cache.type=ALLUXIO
cache.alluxio.max-cache-size=1600GB

3. 启动 Presto

Tips:除数据缓存(Data cache)外,其他缓存功能为实验特性。

03 如何监控 Local Cache

为了提升 Local Cache 的可观测性,我们可以通过 prometheus jmx exporter 将 Worker 的指标暴露出来,使用 prometheus 采集后做进一步分析。

监控配置与启用

1.新增jmx_prometheus_config.yaml配置文件

global:
  scrape_interval:     15s
  evaluation_interval: 15s

2.下载jmx_prometheus_javaagent-.jar,简称jmx_prometheus_javaagent.jar

3.presto jvm.config 配置中新增

-javaagent://jmx_prometheus_javaagent.jar=://jmx_prometheus_config.yaml

4.重启 Presto

5.访问 http://<presto_worker>:port/ 查询是否配置成功

6.将指标接入 prometheus,在 promethues 配置文件中新增

scrape_configs:
  - job_name: "presto_local_cache"
    scrape_interval: 15s
    static_configs:
      - targets: [":"]
        labels:
          appname: "presto_local_cache"

指标解析

Alluxio Local Cache开放了众多监控指标,以下指标是描述缓存使用情况的基础指标,用户需要重点关注:

缓存命中率

  • com_facebook_alluxio_Client_CacheHitRate_<HOST>_Value

缓存访问量:

  • com_facebook_alluxio_Client_CacheBytesReadCache_<HOST>_OneMinuteRate
  • com_facebook_alluxio_Client_CacheBytesReadCache_<HOST>_FiveMinuteRate
  • com_facebook_alluxio_Client_CacheBytesReadCache_<HOST>_FifteenMinuteRate
  • com_facebook_alluxio_Client_CacheBytesReadCache_<HOST>_Count

缓存未命中后,外部系统访问量

  • com_facebook_alluxio_Client_CacheBytesReadExternal_<HOST>_OneMinuteRate
  • com_facebook_alluxio_Client_CacheBytesReadExternal_<HOST>_FiveMinuteRate
  • com_facebook_alluxio_Client_CacheBytesReadExternal_<HOST>_FifteenMinuteRate
  • com_facebook_alluxio_Client_CacheBytesReadExternal_<HOST>_Count

缓存空间使用量

  • com_facebook_alluxio_Client_CacheSpaceUsed_<HOST>_Number

缓存空间剩余量

  • com_facebook_alluxio_Client_CacheSpaceAvailable_<HOST>_Value

缓存页数目

PS:在LOCAL模式下每个页存储为一个文件,当缓存存储在机械磁盘上时需要重点关注。不推荐使用机械磁盘作为LOCAL模式缓存存储,推荐使用SSD或者Ramdisk

  • com_facebook_alluxio_Client_CachePages_<HOST>_Count

想要获取更多有趣有料的【活动信息】【技术文章】【大咖观点】,请关注[Alluxio智库]:

AngularJs中$ interval和setInterval之间的区别

AngularJs中$ interval和setInterval之间的区别

如何解决AngularJs中$ interval和setInterval之间的区别?

$ interval是Angular对本机Javascript setInterval的包装。

$interval使用时,角意识到由间隔功能所做的任何范围的变化,和双向绑定反映了变化。

setInterval使用时,角不会意识到由setInterval函数所做的任何范围的变化。

简而言之,该$interval函数触发Angular的摘要循环,而setInterval不会触发。

这个笨拙的人展示了差异。

码:

angular.module(''DemoApp'', [])
  .controller(''IntervalCtrl'', function($scope, $interval) {


    var updateExampleText = function() {
      console.log(''Changing exampleText'');
      $scope.exampleText = ''Time: '' + new Date().getSeconds();
    };

    $scope.useInterval = function() {
      //Show current seconds value 5 times after every 1000 ms
      $interval(updateExampleText, 1000, 5);

    };

    $scope.useSetInterval = function() {
      //$scope.exampleText changes are not reflected in the page
      //because Angular is not aware of the changes.
      setInterval(updateExampleText, 1000);
    };
  });

解决方法

我试图了解$ interval和setInterval之间的区别。我有这个测试:

Dashboard.prototype.updateTotalAppointments = function(){
//console.log();
this.appointmentsCount = this.appointmentsCount +1;
console.log(this.appointmentsCount);
};

Dashboard.prototype.start = function(){
    setInterval(function(){
        this.updateTotalAppointments();
    }.bind(this),3000);
}
div><h1>{{dashCtrl.appointmentsCount}}</h1></div>

使用 setInterval 不会更新HTML页面上的值,但实际上该值在浏览器控制台上会更改,但不会在HTML页面上更新。

但是如果我这样做:

Dashboard.prototype.start = function(){
$interval(function(){//using $interval seems to work fine
    this.updateTotalAppointments();
}.bind(this),3000);

}

这似乎工作得很好,所以我真的不知道为什么后者不起作用,但是我真的很想知道。

同样,从后台不断请求数据的最佳方法是每隔n分钟说一次并通过其控制器更新页面。

com.intellij.util.indexing.ValueContainer的实例源码

com.intellij.util.indexing.ValueContainer的实例源码

项目:tools-idea    文件:MethodCallingLocationIndex.java   
public List<CallingLocation> getAllLocations(final MethodNameAndQualifier methodNameAndQualifier) {
  try {
    final List<CallingLocation> result = new ArrayList<CallingLocation>();
    myIndex.getData(methodNameAndQualifier).forEach(new ValueContainer.ContainerAction<List<CallingLocation>>() {
      @Override
      public boolean perform(final int id,final List<CallingLocation> values) {
        result.addAll(values);
        return true;
      }
    });
    return result;
  }
  catch (StorageException e) {
    throw new RuntimeException(e);
  }
}
项目:tools-idea    文件:MethodCallingLocationIndex.java   
public Multiset<MethodIncompleteSignature> getLocationsAsParam(final MethodNameAndQualifier methodNameAndQualifier) {
  final Multiset<MethodIncompleteSignature> result = HashMultiset.create();
  try {
    myIndex.getData(methodNameAndQualifier).forEach(new ValueContainer.ContainerAction<List<CallingLocation>>() {
      @Override
      public boolean perform(final int id,final List<CallingLocation> values) {
        for (final CallingLocation value : values) {
          if (value.getvariableType().equals(VariableType.METHOD_ParaMETER)) {
            result.add(value.getmethodIncompleteSignature());
          }
        }
        return true;
      }
    });
  }
  catch (StorageException e) {
    throw new RuntimeException(e);
  }
  return result;
}
项目:tools-idea    文件:QuickInheritanceIndex.java   
protected Set<String> getSupers(final String classQName) {
  try {
    final ValueContainer<Set<String>> valueContainer = myIndex.getData(classQName);
    final Ref<Set<String>> setRef = Ref.create();
    valueContainer.forEach(new ValueContainer.ContainerAction<Set<String>>() {
      @Override
      public boolean perform(final int id,final Set<String> value) {
        setRef.set(value);
        return false;
      }
    });
    final Set<String> supers = setRef.get();
    if (supers == null) {
      return Collections.emptySet();
    }
    return supers;
  }
  catch (StorageException e) {
    throw new RuntimeException(e);
  }
}
项目:tools-idea    文件:QuickMethodsIndex.java   
protected Set<String> getmethodsNames(final String classQName) {
  final Ref<Set<String>> methodsRef = Ref.create();
  try {
    myIndex.getData(classQName).forEach(new ValueContainer.ContainerAction<Set<String>>() {
      @Override
      public boolean perform(final int id,final Set<String> value) {
        methodsRef.set(value);
        return true;
      }
    });
    final Set<String> methods = methodsRef.get();
    return methods == null ? Collections.<String>emptySet() : methods;
  }
  catch (StorageException e) {
    throw new RuntimeException(e);
  }
}
项目:tools-idea    文件:CompilerOutputBaseGramsIndex.java   
public TreeSet<UsageIndexValue> getValues(final K key) {
  try {
    final ValueContainer<Multiset<MethodIncompleteSignature>> valueContainer = myIndex.getData(key);
    final Multiset<MethodIncompleteSignature> rawValues = HashMultiset.create();
    valueContainer.forEach(new ValueContainer.ContainerAction<Multiset<MethodIncompleteSignature>>() {
      @Override
      public boolean perform(final int id,final Multiset<MethodIncompleteSignature> values) {
        for (final Multiset.Entry<MethodIncompleteSignature> entry : values.entrySet()) {
          rawValues.add(entry.getElement(),entry.getCount());
        }
        return true;
      }
    });
    return rawValuesTovalues(rawValues);
  } catch (StorageException e) {
    throw new RuntimeException();
  }
}
项目:tools-idea    文件:TwinVariablesIndex.java   
@NotNull
public List<Integer> getTwinInfo(final String typeQName) {
  try {
    final ValueContainer<List<Integer>> valueContainer = myIndex.getData(typeQName);
    final List<Integer> result = new ArrayList<Integer>(valueContainer.size());
    valueContainer.forEach(new ValueContainer.ContainerAction<List<Integer>>() {
      @Override
      public boolean perform(final int id,final List<Integer> value) {
        result.addAll(value);
        return true;
      }
    });
    return result;
  }
  catch (StorageException e) {
    throw new RuntimeException(e);
  }
}
项目:intellij-ce-playground    文件:IdBitSet.java   
public IdBitSet(RandomAccessIntContainer set,int additionalCount) {
  this(calcMax(set),additionalCount);
  ValueContainer.IntIterator iterator = set.intIterator();
  while(iterator.hasNext()) {
    add(iterator.next());
  }
}
项目:intellij-ce-playground    文件:IdBitSet.java   
private static int[] calcMax(RandomAccessIntContainer set) {
  int min = Integer.MAX_VALUE;
  int max = Integer.MIN_VALUE;
  ValueContainer.IntIterator iterator = set.intIterator();
  while(iterator.hasNext()) {
    int next = iterator.next();
    min = Math.min(min,next);
    max = Math.max(max,next);
  }

  return new int[] {min,max};
}
项目:intellij-ce-playground    文件:IdBitSet.java   
@Override
public ValueContainer.IntPredicate intPredicate() {
  return new ValueContainer.IntPredicate() {
    @Override
    public boolean contains(int id) {
      return IdBitSet.this.contains(id);
    }
  };
}
项目:intellij-ce-playground    文件:SortedIdSet.java   
@Override
public ValueContainer.IntPredicate intPredicate() {
  return new ValueContainer.IntPredicate() {

    @Override
    public boolean contains(int id) {
      return SortedIdSet.this.contains(id);
    }
  };
}
项目:intellij-ce-playground    文件:IdSet.java   
@Override
public ValueContainer.IntPredicate intPredicate() {
  return new ValueContainer.IntPredicate() {
    @Override
    public boolean contains(int id) {
      return IdSet.this.contains(id);
    }
  };
}
项目:intellij-ce-playground    文件:SortedFileIdSetIterator.java   
public static ValueContainer.IntIterator getTransientIterator(ValueContainer.IntIterator intIterator) {
  final ValueContainer.IntIterator intIteratorConed = intIterator.createcopyInInitialState();
  int max = 0,min = Integer.MAX_VALUE;

  while(intIterator.hasNext()) {
    int nextInt = intIterator.next();
    max = Math.max(max,nextInt);
    min = Math.min(min,nextInt);
  }

  assert min > 0;

  final int offset = (min >> INT_BITS_SHIFT) << INT_BITS_SHIFT;
  final int bitsLength = ((max - offset) >> INT_BITS_SHIFT) + 1;
  final int[] bits = ourSpareBuffer.getBuffer(bitsLength);
  for(int i = 0; i < bitsLength; ++i) bits[i] = 0;

  intIterator = intIteratorConed;
  int size = 0;
  while(intIterator.hasNext()) {
    final int id = intIterator.next() - offset;
    bits[id >> INT_BITS_SHIFT] |= (1 << (id));
    ++size;
  }

  return new SortedFileIdSetIterator(bits,bitsLength,offset,size);
}
项目:intellij-ce-playground    文件:ChangeBufferingList.java   
private void mergeChangesRemovingDupes() { // duplicated ids can be present for some index due to cancellation of indexing for next index
  int[] currentChanges = changes;
  ValueContainer.IntIterator sorted = SortedFileIdSetIterator.getTransientIterator(new ChangesIterator(currentChanges,length));
  int lastIndex = 0;
  while(sorted.hasNext()) {
    currentChanges[lastIndex++] = sorted.next();
  }

  length = (short)lastIndex;
  mayHaveDupes = false;
}
项目:intellij-ce-playground    文件:ChangeBufferingList.java   
public ValueContainer.IntPredicate intPredicate() {
  final ValueContainer.IntPredicate predicate = getRandomAccessContainer().intPredicate();
  if (checkSet != null) {
    return new ValueContainer.IntPredicate() {
      @Override
      public boolean contains(int id) {
        boolean answer = predicate.contains(id);
        DebugAssertions.assertTrue(answer == checkSet.contains(id));
        return answer;
      }
    };
  }
  return predicate;
}
项目:intellij-ce-playground    文件:ChangeBufferingList.java   
public ValueContainer.IntIterator intIterator() {
  RandomAccessIntContainer intContainer = randomAccessContainer;
  if (intContainer == null && !hasRemovals) {
    int[] currentChanges = changes;
    if (currentChanges != null) {
      if (mayHaveDupes) {
        synchronized (currentChanges) {
          if (mayHaveDupes) mergeChangesRemovingDupes();
        }
      }
      return new ChangesIterator(currentChanges,length);
    }
  }
  return getRandomAccessContainer().intIterator();
}
项目:intellij-ce-playground    文件:ChangeBufferingList.java   
public ValueContainer.IntIterator rawIntIterator() {
  RandomAccessIntContainer intContainer = randomAccessContainer;
  if (intContainer == null && !hasRemovals) {
    return new ChangesIterator(changes,length); // dupes are possible
  }
  return getRandomAccessContainer().intIterator();
}
项目:consulo    文件:IdBitSet.java   
public IdBitSet(RandomAccessIntContainer set,additionalCount);
  ValueContainer.IntIterator iterator = set.intIterator();
  while(iterator.hasNext()) {
    add(iterator.next());
  }
}
项目:consulo    文件:IdBitSet.java   
private static int[] calcMax(RandomAccessIntContainer set) {
  int min = Integer.MAX_VALUE;
  int max = Integer.MIN_VALUE;
  ValueContainer.IntIterator iterator = set.intIterator();
  while(iterator.hasNext()) {
    int next = iterator.next();
    min = Math.min(min,max};
}
项目:consulo    文件:IdBitSet.java   
@Override
public ValueContainer.IntPredicate intPredicate() {
  return new ValueContainer.IntPredicate() {
    @Override
    public boolean contains(int id) {
      return IdBitSet.this.contains(id);
    }
  };
}
项目:consulo    文件:SortedIdSet.java   
@Override
public ValueContainer.IntPredicate intPredicate() {
  return new ValueContainer.IntPredicate() {

    @Override
    public boolean contains(int id) {
      return SortedIdSet.this.contains(id);
    }
  };
}
项目:consulo    文件:IdSet.java   
@Override
public ValueContainer.IntPredicate intPredicate() {
  return new ValueContainer.IntPredicate() {
    @Override
    public boolean contains(int id) {
      return IdSet.this.contains(id);
    }
  };
}
项目:consulo    文件:ChangeBufferingList.java   
private void removingDupesAndSort() { // duplicated ids can be present for some index due to cancellation of indexing for next index
  final int[] currentChanges = changes;
  final int intLength = length;

  if (intLength < 250) { // Plain sorting in Arrays works without allocations for small number of elements (see DualPivotQuicksort.QUICKSORT_THRESHOLD)
    Arrays.sort(currentChanges,intLength);
    boolean hasDupes = false;

    for(int i = 0,max = intLength - 1; i < max; ++i) {
      if (currentChanges[i] == currentChanges[i + 1]) {
        hasDupes = true;
        break;
      }
    }

    if (hasDupes) {
      int ptr = 0;
      for(int i = 1; i < intLength; ++i) {
        if (currentChanges[i] != currentChanges[ptr]) {
          currentChanges[++ptr] = currentChanges[i];
        }
      }
      length = (short)(ptr + 1);
    }
  } else {
    ValueContainer.IntIterator sorted =
            SortedFileIdSetIterator.getTransientIterator(new ChangesIterator(currentChanges,length,false));
    int lastIndex = 0;
    while (sorted.hasNext()) {
      currentChanges[lastIndex++] = sorted.next();
    }

    length = (short)lastIndex;
  }
  mayHaveDupes = false;
}
项目:consulo    文件:ChangeBufferingList.java   
public ValueContainer.IntPredicate intPredicate() {
  final ValueContainer.IntPredicate predicate = getRandomAccessContainer().intPredicate();
  if (checkSet != null) {
    return new ValueContainer.IntPredicate() {
      @Override
      public boolean contains(int id) {
        boolean answer = predicate.contains(id);
        DebugAssertions.assertTrue(answer == checkSet.contains(id));
        return answer;
      }
    };
  }
  return predicate;
}
项目:consulo    文件:ValueContainerImpl.java   
private static @Nonnull
ValueContainer.IntIterator getIntIteratorOutOfFileSetobject(@Nullable Object input) {
  if (input == null) return EMPTY_IteraTOR;
  if (input instanceof Integer){
    return new SingleValueIterator(((Integer)input).intValue());
  } else {
    return ((ChangeBufferingList)input).intIterator();
  }
}
项目:consulo    文件:FileId2ValueMapping.java   
FileId2ValueMapping(ValueContainerImpl<Value> _valueContainer) {
  id2ValueMap = new TIntObjectHashMap<Value>();
  valueContainer = _valueContainer;

  TIntArrayList removedFileIdList = null;
  List<Value> removedValueList = null;

  for (final ValueContainer.ValueIterator<Value> valueIterator = _valueContainer.getValueIterator(); valueIterator.hasNext();) {
    final Value value = valueIterator.next();

    for (final ValueContainer.IntIterator intIterator = valueIterator.getInputIdsIterator(); intIterator.hasNext();) {
      int id = intIterator.next();
      Value prevIoUsValue = id2ValueMap.put(id,value);
      if (prevIoUsValue != null) {  // delay removal of duplicated id -> value mapping since it will affect valueIterator we are using
        if (removedFileIdList == null) {
          removedFileIdList = new TIntArrayList();
          removedValueList = new SmartList<Value>();
        }
        removedFileIdList.add(id);
        removedValueList.add(prevIoUsValue);
      }
    }
  }

  if (removedFileIdList != null) {
    for(int i = 0,size = removedFileIdList.size(); i < size; ++i) {
      valueContainer.removeValue(removedFileIdList.get(i),removedValueList.get(i));
    }
  }
}
项目:intellij-ce-playground    文件:IdBitSet.java   
@Override
public ValueContainer.IntIterator intIterator() {
  return new Iterator();
}
项目:intellij-ce-playground    文件:IdBitSet.java   
@Override
public ValueContainer.IntIterator createcopyInInitialState() {
  return new Iterator();
}
项目:intellij-ce-playground    文件:SortedIdSet.java   
@Override
public ValueContainer.IntIterator intIterator() {
  return new Iterator();
}
项目:intellij-ce-playground    文件:SortedIdSet.java   
@Override
public ValueContainer.IntIterator createcopyInInitialState() {
  return new Iterator();
}
项目:intellij-ce-playground    文件:IdSet.java   
@Override
public ValueContainer.IntIterator intIterator() {
  return new IntSetIterator();
}
项目:intellij-ce-playground    文件:IdSet.java   
@Override
public ValueContainer.IntIterator createcopyInInitialState() {
  return new IntSetIterator();
}
项目:intellij-ce-playground    文件:SortedFileIdSetIterator.java   
@Override
public ValueContainer.IntIterator createcopyInInitialState() {
  return new SortedFileIdSetIterator(myBits,myBitsLength,myOffset,mySize);
}
项目:intellij-ce-playground    文件:ChangeBufferingList.java   
@Override
public ValueContainer.IntIterator createcopyInInitialState() {
  return new ChangesIterator(changes,length);
}
项目:consulo    文件:ChangeTrackingValueContainer.java   
@Nonnull
@Override
public ValueContainer.ValueIterator<Value> getValueIterator() {
  return getMergedData().getValueIterator();
}
项目:consulo    文件:ValueContainerImpl.java   
@Nonnull
@Override
public ValueContainer.IntIterator getInputIdsIterator() {
  throw new IllegalStateException();
}
项目:consulo    文件:IndexStorage.java   
@Nonnull
ValueContainer<Value> read(Key key) throws StorageException;
项目:consulo    文件:InvertedindexValueIterator.java   
@Override
@Nonnull
ValueContainer.IntPredicate getValueAssociationPredicate();
项目:consulo    文件:MapIndexStorage.java   
protected void initMapAndCache() throws IOException {
  final ValueContainerMap<Key,Value> map;
  PersistentHashMapValueStorage.CreationTimeOptions.EXCEPTIONAL_IO_CANCELLATION.set(new PersistentHashMapValueStorage.ExceptionalIOCancellationCallback() {
    @Override
    public void checkCancellation() {
      checkCanceled();
    }
  });
  PersistentHashMapValueStorage.CreationTimeOptions.COMPACT_CHUNKS_WITH_VALUE_DESERIALIZATION.set(Boolean.TRUE);
  try {
    map = new ValueContainerMap<Key,Value>(getStorageFile(),myKeyDescriptor,myDataExternalizer,myKeyIsUniqueForIndexedFile);
  }
  finally {
    PersistentHashMapValueStorage.CreationTimeOptions.EXCEPTIONAL_IO_CANCELLATION.set(null);
    PersistentHashMapValueStorage.CreationTimeOptions.COMPACT_CHUNKS_WITH_VALUE_DESERIALIZATION.set(null);
  }
  myCache = new SLRUCache<Key,ChangeTrackingValueContainer<Value>>(myCacheSize,(int)(Math.ceil(myCacheSize * 0.25)) /* 25% from the main cache size*/) {
    @Override
    @Nonnull
    public ChangeTrackingValueContainer<Value> createValue(final Key key) {
      return new ChangeTrackingValueContainer<Value>(new ChangeTrackingValueContainer.Initializer<Value>() {
        @Nonnull
        @Override
        public Object getLock() {
          return map.getDataAccessLock();
        }

        @Nullable
        @Override
        public ValueContainer<Value> compute() {
          ValueContainer<Value> value;
          try {
            value = map.get(key);
            if (value == null) {
              value = new ValueContainerImpl<Value>();
            }
          }
          catch (IOException e) {
            throw new RuntimeException(e);
          }
          return value;
        }
      });
    }

    @Override
    protected void onDropFromCache(final Key key,@Nonnull final ChangeTrackingValueContainer<Value> valueContainer) {
      if (valueContainer.isDirty()) {
        try {
          map.put(key,valueContainer);
        }
        catch (IOException e) {
          throw new RuntimeException(e);
        }
      }
    }
  };

  myMap = map;
}
项目:intellij-ce-playground    文件:RandomAccessIntContainer.java   
ValueContainer.IntIterator intIterator();
项目:intellij-ce-playground    文件:RandomAccessIntContainer.java   
ValueContainer.IntPredicate intPredicate();

com.sun.jdi.IntegerValue的实例源码

com.sun.jdi.IntegerValue的实例源码

项目:openjdk-jdk10    文件:PacketStream.java   
void writeUntaggedValueChecked(Value val) throws InvalidTypeException {
    byte tag = ValueImpl.typeValueKey(val);
    if (isObjectTag(tag)) {
        if (val == null) {
             writeObjectRef(0);
        } else {
            if (!(val instanceof ObjectReference)) {
                throw new InvalidTypeException();
            }
            writeObjectRef(((ObjectReferenceImpl)val).ref());
        }
    } else {
        switch (tag) {
            case JDWP.Tag.BYTE:
                if(!(val instanceof ByteValue))
                    throw new InvalidTypeException();

                writeByte(((PrimitiveValue)val).byteValue());
                break;

            case JDWP.Tag.CHAR:
                if(!(val instanceof CharValue))
                    throw new InvalidTypeException();

                writeChar(((PrimitiveValue)val).charValue());
                break;

            case JDWP.Tag.FLOAT:
                if(!(val instanceof FloatValue))
                    throw new InvalidTypeException();

                writeFloat(((PrimitiveValue)val).floatValue());
                break;

            case JDWP.Tag.DOUBLE:
                if(!(val instanceof DoubleValue))
                    throw new InvalidTypeException();

                writeDouble(((PrimitiveValue)val).doubleValue());
                break;

            case JDWP.Tag.INT:
                if(!(val instanceof IntegerValue))
                    throw new InvalidTypeException();

                writeInt(((PrimitiveValue)val).intValue());
                break;

            case JDWP.Tag.LONG:
                if(!(val instanceof LongValue))
                    throw new InvalidTypeException();

                writeLong(((PrimitiveValue)val).longValue());
                break;

            case JDWP.Tag.SHORT:
                if(!(val instanceof ShortValue))
                    throw new InvalidTypeException();

                writeShort(((PrimitiveValue)val).shortValue());
                break;

            case JDWP.Tag.BOOLEAN:
                if(!(val instanceof BooleanValue))
                    throw new InvalidTypeException();

                writeBoolean(((PrimitiveValue)val).booleanValue());
                break;
        }
    }
}
项目:gravel    文件:VMTargetRemoteTest.java   
@Test
public void testEvaluate() throws Throwable {
    ObjectReference promise = remote.evaluateForked("3+4");
    ThreadReference thread = ((ThreadReference) remote.invokeMethod(
            promise,"thread"));
    Value result1 = remote.invokeMethod(promise,"result");
    Value ex = remote.invokeMethod(promise,"throwable");
    printThreadState();
    VMTargetStarter.sleep(100);
    printThreadState();

    boolean isFinished = ((BooleanValue) remote.invokeMethod(promise,"isFinished")).booleanValue();

    assertTrue(isFinished);
    ObjectReference result = (ObjectReference) remote.invokeMethod(promise,"result");
    IntegerValue intValue = (IntegerValue) remote.invokeMethod(result,"intValue");
    assertEquals(7,intValue.intValue());
}
项目:JavaTracer    文件:ClassUtils.java   
private Data getPrimitiveObject(String name,Value value) {
    Data object = null;
    if (value instanceof BooleanValue)
        object = new SimpleData(name,((BooleanValue) value).booleanValue());
    else if (value instanceof ByteValue)
        object = new SimpleData(name,((ByteValue) value).byteValue());
    else if (value instanceof CharValue)
        object = new SimpleData(name,((CharValue) value).charValue());
    else if (value instanceof DoubleValue)
        object = new SimpleData(name,((DoubleValue) value).doubleValue());
    else if (value instanceof FloatValue)
        object = new SimpleData(name,((FloatValue) value).floatValue());
    else if (value instanceof IntegerValue)
        object = new SimpleData(name,((IntegerValue) value).intValue());
    else if (value instanceof LongValue)
        object = new SimpleData(name,((LongValue) value).longValue());
    else if (value instanceof ShortValue)
        object = new SimpleData(name,((ShortValue)value).shortValue());
    return object;
}
项目:incubator-netbeans    文件:AWTGrabHandler.java   
private void ungrabWindowFX(Classtype WindowClass,ObjectReference w,ThreadReference tr) throws Exception {
    // javafx.stage.Window w
    // w.focusGrabCounter
    // while (focusGrabCounter-- > 0) {
    //     w.impl_getPeer().ungrabFocus(); OR: w.impl_peer.ungrabFocus();
    // }
    Field focusGrabCounterField = WindowClass.fieldByName("focusGrabCounter");
    if (focusGrabCounterField == null) {
        logger.info("Unable to release FX X grab,no focusGrabCounter field in "+w);
        return ;
    }
    Value focusGrabCounterValue = w.getValue(focusGrabCounterField);
    if (!(focusGrabCounterValue instanceof IntegerValue)) {
        logger.info("Unable to release FX X grab,focusGrabCounter does not have an integer value in "+w);
        return ;
    }
    int focusGrabCounter = ((IntegerValue) focusGrabCounterValue).intValue();
    if (logger.isLoggable(Level.FINE)) {
        logger.fine("Focus grab counter of "+w+" is: "+focusGrabCounter);
    }
    while (focusGrabCounter-- > 0) {
        //Method impl_getPeerMethod = WindowClass.concreteMethodByName("impl_getPeer","");
        Field impl_peerField = WindowClass.fieldByName("impl_peer");
        if (impl_peerField == null) {
            logger.info("Unable to release FX X grab,no impl_peer field in "+w);
            return ;
        }
        ObjectReference impl_peer = (ObjectReference) w.getValue(impl_peerField);
        if (impl_peer == null) {
            continue;
        }
        InterfaceType TKStageClass = (InterfaceType) w.virtualMachine().classesByName("com.sun.javafx.tk.TKStage").get(0);
        Method ungrabFocusMethod = TKStageClass.methodsByName("ungrabFocus","()V").get(0);
        impl_peer.invokeMethod(tr,ungrabFocusMethod,Collections.EMPTY_LIST,ObjectReference.INVOKE_SINGLE_THREADED);
        if (logger.isLoggable(Level.FINE)) {
            logger.fine("FX Window "+w+" was successfully ungrabbed.");
        }
    }
}
项目:incubator-netbeans    文件:MirrorValuesTest.java   
public void testTargetMirrors() throws Exception {
    try {
        Utils.BreakPositions bp = Utils.getBreakPositions(System.getProperty ("test.dir.src") + 
                "org/netbeans/api/debugger/jpda/testapps/MirrorValuesApp.java");
        LineBreakpoint lb = bp.getLineBreakpoints().get(0);
        dm.addBreakpoint (lb);

        support = JPDASupport.attach (CLASS_NAME);

        support.waitState (JPDADebugger.STATE_STOPPED);  // breakpoint hit

        JPDADebugger debugger = support.getDebugger();

        Variable mirrorVar = debugger.createMirrorVar("Test");
        Value v = ((jdiVariable) mirrorVar).getjdiValue();
        assertTrue("Value "+v+" should be a String",v instanceof StringReference);
        assertEquals("Test",((StringReference) v).value());

        Point p = new Point(-1,1);
        mirrorVar = debugger.createMirrorVar(p);
        Object mp = mirrorVar.createMirrorObject();
        assertTrue("Correct point was created: "+mp,p.equals(mp));

        mirrorVar = debugger.createMirrorVar(1);
        v = ((jdiVariable) mirrorVar).getjdiValue();
        assertTrue("Value "+v+" should be an Integer object.",(v.type() instanceof Classtype) && Integer.class.getName().equals(((Classtype) v.type()).name()));

        mirrorVar = debugger.createMirrorVar(1,true);
        v = ((jdiVariable) mirrorVar).getjdiValue();
        assertTrue("Value "+v+" should be an int.",v instanceof IntegerValue);
        assertEquals(((IntegerValue) v).value(),1);
    } finally {
        support.doFinish ();
    }
}
项目:openjdk-jdk10    文件:IntegerValueImpl.java   
public boolean equals(Object obj) {
    if ((obj != null) && (obj instanceof IntegerValue)) {
        return (value == ((IntegerValue)obj).value()) &&
               super.equals(obj);
    } else {
        return false;
    }
}
项目:acdebugger    文件:BreakpointProcessor.java   
private void extractFilePermActions(ObjectReference permission,StringBuilder sb) {
  IntegerValue value =
      (IntegerValue) permission.getValue(permission.referenceType().fieldByName("mask"));
  Integer mask = value.value();

  try {
    Method meth = FilePermission.class.getDeclaredMethod("getActions",int.class);
    meth.setAccessible(true);
    String actions = (String) meth.invoke(null,mask);

    sb.append(actions);
  } catch (NoSuchMethodException | illegalaccessexception | InvocationTargetException e) {
    sb.append("FILEPERMS ACTIONS UNKNowN");
  }
}
项目:intellij-ce-playground    文件:ResolveTypedIntegerCommand.java   
@Override
public void action() {
  // Todo: see if it is possible to cache this evaluation
  // if (myIsEvaluated) return;

  DebugProcess debugProcess = myEvaluationContext.getDebugProcess();
  if (!(debugProcess instanceof DebugProcessImpl)) {
    return;
  }

  final DebuggerContextImpl debuggerContext = ((DebugProcessImpl)debugProcess).getDebuggerContext();
  PsiAnnotation annotation = ApplicationManager.getApplication().runReadAction(new Computable<PsiAnnotation>() {
    @Override
    public PsiAnnotation compute() {
      PsiElement context = PositionUtil.getContextElement(debuggerContext);
      if (context == null) {
        return null;
      }

      if (myDescriptor instanceof LocalVariableDescriptor) {
        return AndroidResolveHelper.getAnnotationForLocal(context,myDescriptor.getName());
      }
      else if (myDescriptor instanceof FieldDescriptor) {
        String className = ((FieldDescriptor)myDescriptor).getField().declaringType().name();
        return AndroidResolveHelper.getAnnotationForField(context,className,myDescriptor.getName());
      }
      else {
        return null;
      }
    }
  });

  if (annotation != null) {
    ResourceIdResolver resolver = ServiceManager.getService(myEvaluationContext.getProject(),ResourceIdResolver.class);
    DynamicResourceIdResolver resolver1 = new DynamicResourceIdResolver(myEvaluationContext,resolver);
    myResult = AnnotationsRenderer.render(resolver1,annotation,((IntegerValue)myValue).value());
  }

  evaluationResult("");
}
项目:form-follows-function    文件:F3Wrapper.java   
public static F3Value wrap(F3VirtualMachine f3vm,Value value) {
    if (value == null) {
        return null;
    }

    if (value instanceof PrimitiveValue) {
        if (value instanceof BooleanValue) {
            return f3vm.booleanValue((BooleanValue)value);
        } else if (value instanceof CharValue) {
            return f3vm.charValue((CharValue)value);
        } else if (value instanceof ByteValue) {
            return f3vm.byteValue((ByteValue)value);
        } else if (value instanceof ShortValue) {
            return f3vm.shortValue((ShortValue)value);
        } else if (value instanceof IntegerValue) {
            return f3vm.integerValue((IntegerValue)value);
        } else if (value instanceof LongValue) {
            return f3vm.longValue((LongValue)value);
        } else if (value instanceof FloatValue) {
            return f3vm.floatValue((FloatValue)value);
        } else if (value instanceof DoubleValue) {
            return f3vm.doubleValue((DoubleValue)value);
        } else {
            throw new IllegalArgumentException("illegal primitive value : " + value);
        }
    } else if (value instanceof VoidValue) {
        return f3vm.voidValue();
    } else if (value instanceof ObjectReference) {
        return  wrap(f3vm,(ObjectReference)value);
    } else {
        throw new IllegalArgumentException("illegal value: " + value);
    }
}
项目:form-follows-function    文件:F3SequenceReference.java   
/**
 * Replace a sequence element with another value.
 *
 * Object values must be assignment compatible with the element type.
 * (This implies that the component type must be loaded through the
 * declaring class's class loader). Primitive values must be
 * assignment compatible with the component type.
 *
 * @param value the new value
 * @param index the index of the component to set.  If this is beyond the 
 * end of the sequence,the new value is appended to the sequence.
 *
 * @throws InvalidTypeException if the type of <CODE><I>value</I></CODE>
 * is not compatible with the declared type of sequence elements.
 * @throws ClassNotLoadedException if the sequence element type
 * has not yet been loaded through the appropriate class loader.
 * @throws VMCannotBeModifiedException if the VirtualMachine is read-only - see {@link com.sun.jdi.VirtualMachine#canBeModified()}.
 * @return a new sequence with the specified element replaced/added.
 */
public F3SequenceReference setValue(int index,Value value) {
    Types type = getElementType();
    switch (type) {
        case INT:
            return setIntValue(index,(IntegerValue)value);
        case FLOAT:
            return setFloatValue(index,(FloatValue)value);
        case OBJECT:
            return setobjectValue(index,(ObjectReference)value);
        case DOUBLE:
            return setDoubleValue(index,(DoubleValue)value);
        case BOOLEAN:
            return setBooleanValue(index,(BooleanValue)value);
        case LONG:
            return setLongValue(index,(LongValue)value);
        case SHORT:
            return setShortValue(index,(ShortValue)value);
        case BYTE:
            return setByteValue(index,(ByteValue)value);
        case CHAR:
            return setCharValue(index,(CharValue)value);
        case OTHER:
            return setobjectValue(index,(ObjectReference)value);
        default:
            throw new IllegalArgumentException("Invalid sequence element type");
    }
}
项目:form-follows-function    文件:F3VirtualMachine.java   
private int getFlagMask(String maskName) {
    int flagMask = 0;
    // we only work with underlying jdi objects here
    List<ReferenceType> rtx =  this.underlying().classesByName("org.f3.runtime.F3Object");
    if (rtx.size() != 1) {
        System.out.println("Can't find the ReferenceType for org.f3.runtime.F3Object");
        return 0;
    }
    ReferenceType f3ObjectRefType = rtx.get(0);
    Field fieldx = f3ObjectRefType.fieldByName(maskName);
    Value flagValue = f3ObjectRefType.getValue(fieldx);
    return ((IntegerValue)flagValue).value();
}
项目:incubator-netbeans    文件:EvaluatorVisitor.java   
public static Value unBox(ObjectReference val,PrimitiveType type,ThreadReference thread,EvaluationContext context) throws InvalidTypeException,ClassNotLoadedException,IncompatibleThreadStateException,InvocationException {
    ReferenceType rt = val.referenceType();
    String classtype = rt.name();
    PrimitiveValue pv;
    if (classtype.equals("java.lang.Boolean")) {
        pv = invokeUnBoxingMethod(val,"booleanValue",thread,context);
    } else if (classtype.equals("java.lang.Byte")) {
        pv = invokeUnBoxingMethod(val,"byteValue",context);
    } else if (classtype.equals("java.lang.Character")) {
        pv = invokeUnBoxingMethod(val,"charValue",context);
    } else if (classtype.equals("java.lang.Short")) {
        pv = invokeUnBoxingMethod(val,"shortValue",context);
    } else if (classtype.equals("java.lang.Integer")) {
        pv = invokeUnBoxingMethod(val,"intValue",context);
    } else if (classtype.equals("java.lang.Long")) {
        pv = invokeUnBoxingMethod(val,"longValue",context);
    } else if (classtype.equals("java.lang.Float")) {
        pv = invokeUnBoxingMethod(val,"floatValue",context);
    } else if (classtype.equals("java.lang.Double")) {
        pv = invokeUnBoxingMethod(val,"doubleValue",context);
    //throw new RuntimeException("Invalid type while unBoxing: " + type.signature());    // never happens
    } else {
        return val;
    }
    VirtualMachine vm = pv.virtualMachine();
    if (type instanceof BooleanType && !(pv instanceof BooleanValue)) {
        return vm.mirrorOf(pv.booleanValue());
    }
    if (type instanceof ByteType && !(pv instanceof ByteValue)) {
        return vm.mirrorOf(pv.byteValue());
    }
    if (type instanceof CharType && !(pv instanceof CharValue)) {
        return vm.mirrorOf(pv.charValue());
    }
    if (type instanceof ShortType && !(pv instanceof ShortValue)) {
        return vm.mirrorOf(pv.shortValue());
    }
    if (type instanceof IntegerType && !(pv instanceof IntegerValue)) {
        return vm.mirrorOf(pv.intValue());
    }
    if (type instanceof LongType && !(pv instanceof LongValue)) {
        return vm.mirrorOf(pv.longValue());
    }
    if (type instanceof FloatType && !(pv instanceof FloatValue)) {
        return vm.mirrorOf(pv.floatValue());
    }
    if (type instanceof DoubleType && !(pv instanceof DoubleValue)) {
        return vm.mirrorOf(pv.doubleValue());
    }
    return pv;
}
项目:incubator-netbeans    文件:EvaluatorVisitor.java   
@Override
public int compareto(IntegerValue o) {
    return value - ((IntegerValue)o).value();
}
项目:openjdk-jdk10    文件:IntegerValueImpl.java   
public int compareto(IntegerValue obj) {
    int other = obj.value();
    return (value()<other ? -1 : (value()==other ? 0 : 1));
}
项目:openjdk-jdk10    文件:VirtualMachineImpl.java   
public IntegerValue mirrorOf(int value) {
    validateVM();
    return new IntegerValueImpl(this,value);
}
项目:intellij-ce-playground    文件:IntegerValueImpl.java   
@Override
public int compareto(IntegerValue o) {
  return value() - o.value();
}
项目:form-follows-function    文件:F3IntegerValue.java   
public F3IntegerValue(F3VirtualMachine f3vm,IntegerValue underlying) {
    super(f3vm,underlying);
}
项目:form-follows-function    文件:F3IntegerValue.java   
public int compareto(IntegerValue o) {
    return underlying().compareto((IntegerValue)F3Wrapper.unwrap(o));
}
项目:form-follows-function    文件:F3IntegerValue.java   
@Override
protected IntegerValue underlying() {
    return (IntegerValue) super.underlying();
}
项目:form-follows-function    文件:F3SequenceReference.java   
private IntegerValue getValueAsInt(int index) {
    Method getAsIntMethod = virtualMachine().f3SequenceType().getAsIntMethod();
    return (IntegerValue) getElement(getAsIntMethod,index);
}
项目:form-follows-function    文件:F3SequenceReference.java   
private F3SequenceReference setIntValue(int index,IntegerValue value) {
    Method setIntElementMethod = virtualMachine().f3SequencesType().setIntElementMethod();
    return setElement(setIntElementMethod,index,value);
}
项目:form-follows-function    文件:F3VirtualMachine.java   
protected F3IntegerValue integerValue(IntegerValue value) {
    return new F3IntegerValue(this,value);
}
项目:form-follows-function    文件:SequenceTest.java   
protected void runTests() throws Exception {
    startToMain();

    // break into function printSeq(arg: Integer[])
    BreakpointEvent bpe = resumeto(targetClassName,"printSeq","(Lorg/f3/runtime/sequence/Sequence;)V");

    mainThread = bpe.thread();

    // get the top frame
    StackFrame frame = mainThread.frame(0);
    // get first argument which is Integer[]
    Value value = frame.getArgumentValues().get(0);
    Assert.assertEquals(true,value instanceof F3SequenceReference);
    F3SequenceReference seq = (F3SequenceReference) value;
    Assert.assertEquals(2,seq.size());
    Assert.assertEquals(2,seq.length());
    Assert.assertEquals(F3SequenceReference.Types.INT,seq.getElementType());
    Value zerothElementAsVal = seq.getValue(0);
    Assert.assertEquals(true,zerothElementAsVal instanceof IntegerValue);
    Assert.assertEquals(1729,((IntegerValue)zerothElementAsVal).intValue());
    Value firstElementAsVal = seq.getValue(1);
    Assert.assertEquals(true,firstElementAsVal instanceof IntegerValue);
    Assert.assertEquals(9999,((IntegerValue)firstElementAsVal).intValue());

    // sequence element set
    seq.setValue(0,vm().mirrorOf(1111));
    seq.setValue(1,vm().mirrorOf(2222));
    Assert.assertEquals(1111,((IntegerValue)seq.getValue(0)).intValue());
    Assert.assertEquals(2222,((IntegerValue)seq.getValue(1)).intValue());

    // sequence setValues 
    List<Value> newValues = new ArrayList<Value>(2);
    newValues.add(vm().mirrorOf(1234));
    newValues.add(vm().mirrorOf(5678));
    seq.setValues(newValues);
    Assert.assertEquals(1234,((IntegerValue)seq.getValue(0)).intValue());
    Assert.assertEquals(5678,((IntegerValue)seq.getValue(1)).intValue());

    // sequence getValues
    List<Value> values = seq.getValues(0,2);
    Assert.assertEquals(1234,((IntegerValue)values.get(0)).intValue());
    Assert.assertEquals(5678,((IntegerValue)values.get(1)).intValue());


    /*
     * resume until end
     */
    listenUntilVMdisconnect();
}
项目:gravel    文件:VMRemoteTarget.java   
public int add(int x,int y) throws Throwable {
    Value resultMirror = invokeMethod("add",vm.mirrorOf(x),vm.mirrorOf(y));
    return ((IntegerValue) resultMirror).intValue();
}
项目:java-debug    文件:NumericFormatterTest.java   
@Test
public void testValueOf() throws Exception {

    Value i = this.getLocalValue("i");
    Map<String,Object> options = formatter.getDefaultOptions();
    Value newValue = formatter.valueOf(formatter.toString(i,options),i.type(),options);
    assertNotNull("NumericFormatter should be able to create integer by string.",newValue);
    assertTrue("Should create an integer value.",newValue instanceof IntegerValue);
    assertEquals("Should create an integer with right value.","111",newValue.toString());

    options.put(NUMERIC_FORMAT_OPTION,NumericFormatEnum.HEX);

    newValue = formatter.valueOf(formatter.toString(i,NumericFormatEnum.OCT);
    newValue = formatter.valueOf(formatter.toString(i,newValue.toString());


    newValue = formatter.valueOf("-12121212","-12121212",newValue.toString());

    newValue = formatter.valueOf("0","0",newValue.toString());

    VirtualMachine vm = getVM();

    newValue = formatter.valueOf("0",vm.mirrorOf(10.0f).type(),options);
    assertNotNull("NumericFormatter should be able to create float by string.",newValue);
    assertTrue("Should create an float value.",newValue instanceof FloatValue);
    assertEquals("Should create an float with right value.","0.0",newValue.toString());

    newValue = formatter.valueOf("10.0",vm.mirrorOf(10.0).type(),options);
    assertNotNull("NumericFormatter should be able to create double by string.",newValue);
    assertTrue("Should create an double value.",newValue instanceof DoubleValue);
    assertEquals("Should create an double with right value.","10.0",newValue.toString());

    newValue = formatter.valueOf("10",vm.mirrorOf((short)10).type(),options);
    assertNotNull("NumericFormatter should be able to create short by string.",newValue);
    assertTrue("Should create an short value.",newValue instanceof ShortValue);
    assertEquals("Should create an short with right value.","10",vm.mirrorOf(10L).type(),options);
    assertNotNull("NumericFormatter should be able to create long by string.",newValue);
    assertTrue("Should create an long value.",newValue instanceof LongValue);
    assertEquals("Should create an long with right value.",vm.mirrorOf((byte) 10).type(),options);
    assertNotNull("NumericFormatter should be able to create byte by string.",newValue);
    assertTrue("Should create an byte value.",newValue instanceof ByteValue);
    assertEquals("Should create an byte with right value.",newValue.toString());
}
项目:EclipseTracer    文件:NumericHistoryController.java   
/**
 * Draws the axis of the view and displays the minimum and maximum values on
 * each axis
 * 
 * @param g
 *            - the graphics context
 * @param to
 *            - the index of the last drawn point
 */
private void drawAxis(GC g,int to) {
    String strMaxX;
    String strMinX;
    if (properties.scaleByTime) {
        strMaxX = "" + getMaxTimeStamp();
        strMinX = "" + getMinTimeStamp();
    } else {
        strMaxX = "" + getValuesCount();
        strMinX = "" + 1;
    }
    Rectangle lineArea = new Rectangle(properties.border,properties.border,view.getSize().x - properties.border * 2,view.getSize().y - properties.border * 2);
    String strMaxY = ""
            + ((IntegerValue) getHistory().getMaxValue().getValue())
                    .value();
    String strMinY = ""
            + ((IntegerValue) getHistory().getMinValue().getValue())
                    .value();
    g.setForeground(new Color(view.getdisplay(),new RGB(0,0)));
    g.setLinestyle(SWT.LINE_SOLID);
    g.setlinewidth(1);
    g.drawLine(lineArea.x,lineArea.y,lineArea.x,lineArea.y
            + lineArea.height);
    g.drawLine(lineArea.x,lineArea.y + lineArea.height,lineArea.x
            + lineArea.width,lineArea.y + lineArea.height);
    g.drawString(
            strMaxY,lineArea.x - g.stringExtent(strMaxY).x
                    - g.stringExtent(strMaxY).y / 2,lineArea.y - g.stringExtent(strMaxY).y / 2);
    g.drawString(
            strMinY,lineArea.x - g.stringExtent(strMinY).x
                    - g.stringExtent(strMinY).y / 2,lineArea.y
                    + lineArea.height - g.stringExtent(strMinY).y / 2);
    g.drawString(strMinX,lineArea.x - g.stringExtent(strMinX).x / 2,lineArea.y + lineArea.height + g.stringExtent(strMinX).y / 2);
    g.drawString(strMaxX,getItemX(this.getValuesCount() - 1) - g.stringExtent(strMaxX).x
                    / 2,lineArea.y + lineArea.height + g.stringExtent(strMaxX).y / 2);

}

关于FluxInterval实例及解析flsgetvalue的介绍现已完结,谢谢您的耐心阅读,如果想了解更多关于Alluxio Local Cache 监控指南 Alluxio Alluxio、AngularJs中$ interval和setInterval之间的区别、com.intellij.util.indexing.ValueContainer的实例源码、com.sun.jdi.IntegerValue的实例源码的相关知识,请在本站寻找。

本文标签: