GithubHelp home page GithubHelp logo

Comments (3)

burmanm avatar burmanm commented on August 17, 2024

Well, the original idea was that flipByte() ensures that there's always at least 2 free words in the array (and thus we don't need to call expandCheck inside the writeLong). Since all the longs are at most 64 bits long and we should always have >= 65 bits free in the array. Can you provide a test scenario where this check fails?

from gorilla-tsc.

bsura avatar bsura commented on August 17, 2024

Here's a main method that runs into out of bounds exception.

`
public static void main(String args[]) {

    long now = System.currentTimeMillis();
	LongArrayOutput output = new LongArrayOutput(500);
	GorillaCompressor c = new GorillaCompressor(LocalDateTime.now(ZoneOffset.UTC).truncatedTo(ChronoUnit.HOURS).
			toInstant(ZoneOffset.UTC).toEpochMilli(), output);
	
	Map<Long, Double> dps = new TreeMap<>();
	int n = 3600;
	Random r = new Random();
	for(int i=0; i<n; i++) {
		dps.put(now + (1000 * i) + r.nextInt(100), 100.0);
	}
	
	for(Map.Entry<Long, Double> entry : dps.entrySet()) {
		c.addValue(entry.getKey(), entry.getValue());
	}
	c.close();
	
	LongArrayInput input = new LongArrayInput(output.getLongArray());
	GorillaDecompressor dc = new GorillaDecompressor(input);
	
	while(true) {
		Pair pair = dc.readPair();
		if(pair == null) 
			break;
		
		if(!dps.containsKey(pair.getTimestamp())) {
			System.out.println("There was a mismatch.");
		}
	}
	System.out.println("Done.");
	
}

`

from gorilla-tsc.

burmanm avatar burmanm commented on August 17, 2024

Fixed in 2.0.1

from gorilla-tsc.

Related Issues (15)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.