This question is regarding Chronicle-Values
One example found in the site is:
interface SomeStats {
@Array(length=100)
long getPercentFreqAt(int index);
void setPercentFreqAt(int index, long percentFreq);
long addPercentFreqAt(int index, long addition);
}
Here the annotation is only applied to the one of the methods. Does this imply all methods afterwards are treated as working on the array data?
In one of the test cases I found
package net.openhft.chronicle.values;
public interface HasArraysInterface {
@Array(length = 4)
void setFlagAt(int idx, boolean flag);
boolean getFlagAt(int idx);
@Array(length = 4)
void setByteAt(int idx, byte b);
byte getByteAt(int idx);
@Array(length = 4)
void setShortAt(int idx, short s);
short getShortAt(int idx);
@Array(length = 4)
void setCharAt(int idx, char ch);
char getCharAt(int idx);
@Array(length = 4)
void setIntAt(int idx, int i);
int getIntAt(int idx);
@Array(length = 4)
void setFloatAt(int idx, float f);
float getFloatAt(int idx);
@Array(length = 4)
void setLongAt(int idx, long l);
long getLongAt(int idx);
@Array(length = 4)
void setDoubleAt(int idx, double d);
double getDoubleAt(int idx);
@Array(length = 4)
void setStringAt(int idx, @MaxUtf8Length(8) String s);
String getStringAt(int idx);
}
What I understood from this is that you can have multiple arrays within this interface where @Array(length = 4)
applies to methods ending with At
until the next annotation. Is this right?
In addition can you have something like the following to simulate an array of 4 double and array of 8 strings:
@Array(length = 4)
void setDoubleAt(int idx, double d);
double getDoubleAt(int idx);
@Array(length = 8)
void setStringAt(int idx, @MaxUtf8Length(8) String s);
String getStringAt(int idx);
What is the memory layout of multiple arrays allocated with multiple @Array(length= ?)
within one interface? Can you choose between column oriented or row oriented layout? How will the layouts be handled if the length
is different?
Also instead of:
interface SomeStats {
@Array(length=100)
long getPercentFreqAt(int index);
void setPercentFreqAt(int index, long percentFreq);
long addPercentFreqAt(int index, long addition);
}
can you write it as:
@Array(length=100)
interface SomeStats {
long getPercentFreqAt(int index);
void setPercentFreqAt(int index, long percentFreq);
long addPercentFreqAt(int index, long addition);
}
implying @Array(length=100)
applies to the whole interface.
Also can you defer specifying the length until the point of creation?