fix synchronization

getDimvalues can also add to the dimension, protect it properly
This commit is contained in:
nishantmonu51 2014-03-04 11:58:43 +05:30
parent 40aa6ecaef
commit eb7bc28f41
1 changed files with 10 additions and 15 deletions

View File

@ -159,24 +159,19 @@ public class IncrementalIndex implements Iterable<Row>
dimension = dimension.toLowerCase();
List<String> dimensionValues = row.getDimension(dimension);
Integer index = dimensionOrder.get(dimension);
if (index == null) {
synchronized (dimensionOrder) {
index = dimensionOrder.get(dimension);
if (index == null) {
dimensionOrder.put(dimension, dimensionOrder.size());
dimensions.add(dimension);
synchronized (dimensionOrder) {
Integer index = dimensionOrder.get(dimension);
if (index == null) {
dimensionOrder.put(dimension, dimensionOrder.size());
dimensions.add(dimension);
if (overflow == null) {
overflow = Lists.newArrayList();
}
overflow.add(getDimVals(dimValues.add(dimension), dimensionValues));
} else {
dims[index] = getDimVals(dimValues.get(dimension), dimensionValues);
if (overflow == null) {
overflow = Lists.newArrayList();
}
overflow.add(getDimVals(dimValues.add(dimension), dimensionValues));
} else {
dims[index] = getDimVals(dimValues.get(dimension), dimensionValues);
}
} else {
dims[index] = getDimVals(dimValues.get(dimension), dimensionValues);
}
}