Questions tagged [accumulator]

An accumulator is a register in a computer processor in which intermediate arithmetic and logic results are stored.

253 questions
3
votes
10 answers

Write a method to print out a string "Name" multiple times

I am answering a question for an Intro to Programming class and cannot - after reading through my notes, Big Java book, and looking online - find out where to begin. It seems as though it should be very simple, but I just need to get started. All…
user705447
  • 31
  • 1
  • 1
  • 2
3
votes
2 answers

Comparing Arrays - accumulator in method will not increment

In the methods totalCorrect() and totalIncorrect() , I set up an var accumulator to count how many questions are right or wrong. For some reason, it will not increment properly. The program says that the user got 24, or 40 correct and incorrect...…
Masha
  • 99
  • 4
3
votes
3 answers

accumulator in pyspark with dict as global variable

Just for learning purpose, I tried to set a dictionary as a global variable in accumulator the add function works well, but I ran the code and put dictionary in the map function, it always return empty. But similar code for setting list as a global…
user3341953
  • 159
  • 1
  • 4
  • 12
3
votes
2 answers

Problem with accumulators in prolog

While learning Prolog, I'm trying to solve the following problem, using accumulators: Write a predicate addone2/ whose first argument is a list of integers, and whose second argument is the list of integers obtained by adding 1 to each integer in…
André
  • 313
  • 4
  • 17
3
votes
1 answer

Is immutability a "must" or "should" for custom accumulators?

I would like to create custom accumulators and I can't feel safe when using them since I can only test them locally for now. My question is: Is immutability a "must" or "should" when creating accumulators? Although I can't find the link/reference…
Erel
  • 31
  • 3
3
votes
1 answer

How to access accumulators in object outside the place where they were defined?

I'm defining helper map function as a separate def in helper object and it does not "see" the accumulator defined earlier in code. Spark docs seams to be recommending to keep "remote" functions inside object, but how do I make it all work with those…
Michael Zeltser
  • 349
  • 1
  • 3
  • 7
3
votes
1 answer

How to ensure garbage collection of unused accumulators?

I meet a problem that Accumulator on Spark can not be GC. def newIteration (lastParams: Accumulable[Params, (Int, Int, Int)], lastChosens: RDD[Document], i: Int): Params = { if (i == maxIteration) return lastParams.value val size1:…
superhan
  • 137
  • 1
  • 1
  • 6
3
votes
1 answer

Spark Task not Serializable with simple accumulator?

I am running this simple code: val accum = sc.accumulator(0, "Progress"); listFilesPar.foreach { filepath => accum += 1 } listFilesPar is an RDD[String] which throws the following error: org.apache.spark.SparkException: Task not…
Stephane
  • 4,462
  • 5
  • 38
  • 77
3
votes
1 answer

Spark accumulableCollection does not work with mutable.Map

I am using Spark to do employee record accumulation and for that I use Spark's accumulator. I am using Map[empId, emp] as accumulableCollection so that I can search employee by their ids. I have tried everything but it does not work. Can someone…
smishra
  • 2,322
  • 22
  • 24
3
votes
1 answer

Haskell Recursion using an Accumulator

I'm trying to make a function that will look for 3 identical and adjacent numbers given a list, for a solver I am trying to implement. Then, if there are 3 identical and adjacent numbers, it will mark the 1st and 3rd identical numbers to '0' and set…
user1670032
  • 720
  • 1
  • 10
  • 27
2
votes
2 answers

Coldfusion counting based on patterns matching

I am reading numbers off a database and create a 4 digits patterns such as: 1, 2, 2, 1 0, 2, 2, 2 4, 0, 2, 0 1, 2, 2, 1 2, 1, 1, 2 Each digit can only be from 0-6. The second step is where my problem is. I need to tally each pattern. For example,…
Jack
  • 737
  • 1
  • 5
  • 16
2
votes
1 answer

Using tail recursion to duplicate items on a list

I have a homework problem that asks us to write a predicate that creates a duplicate of every item on a list, first using linear recursion and then using tail recursion. We can't use built-in predicates. I could solve it using linear recursion, but…
user94647
  • 21
  • 2
2
votes
1 answer

Accumulators not showing up in Spark UI

I have implemented Accumulators to see counts of events in my code. But I cannot see them in the Spark UI. I am using the following things : val count_Of_2317508_1 = sc.longAccumulator("count_Of_2317508_1") count_Of_2317508_1.add(1) on some…
Puja Roy
  • 61
  • 6
2
votes
2 answers

accumulator register 8086 microprocessor family

Accumulator register is a register that holds temporary values. Only EAX, AX, AL registers are accumulators. As I know BX, CX, DX and extended versions can hold permanent values. So, why do we use EAX, AX, AL registers as accumulators? What is an…
2
votes
2 answers

Rewriting Ruby #inject (#reduce) using recursion?

New to coding and have gone through some of the more commonly used methods in Ruby, monkey patching them to gain a better understanding of how each works (which btw has helped a massive amount). Now I'm again doing the same, but for ones that I…
Zezuz
  • 53
  • 7
1 2
3
16 17