use of com.srotya.sidewinder.core.storage.BufferObject in project sidewinder by srotya.
the class MemMalloc method createNewBuffer.
public BufferObject createNewBuffer(LinkedByteString seriesId, Integer tsBucket, int newSize) throws IOException {
ByteBuffer allocateDirect = ByteBuffer.allocateDirect(newSize);
LinkedByteString str = new LinkedByteString().concat(seriesId);
str.concat(STR2).concat(String.valueOf(tsBucket));
return new BufferObject(str, allocateDirect);
}
use of com.srotya.sidewinder.core.storage.BufferObject in project sidewinder by srotya.
the class PersistentMeasurement method loadTimeseriesFromMeasurements.
@Override
public void loadTimeseriesFromMeasurements() throws IOException {
String mdFilePath = getMetadataPath();
File file = new File(mdFilePath);
if (!file.exists()) {
logger.warning("Metadata file missing for measurement:" + measurementName);
return;
} else {
logger.fine("Metadata file exists:" + file.getAbsolutePath());
}
List<String> seriesEntries = MiscUtils.readAllLines(file);
try {
loadSeriesEntries(seriesEntries);
} catch (Exception e) {
throw new IOException(e);
}
Map<String, List<Entry<String, BufferObject>>> seriesBuffers = malloc.seriesBufferMap();
for (Entry<String, List<Entry<String, BufferObject>>> entry : seriesBuffers.entrySet()) {
String[] split = entry.getKey().split(SERIESID_SEPARATOR);
Integer seriesId = seriesMap.get(split[0]);
SeriesFieldMap ts = seriesList.get(seriesId);
List<Entry<String, BufferObject>> list = entry.getValue();
if (list != null) {
try {
ts.get(split[1]).loadBucketMap(list);
} catch (Exception e) {
logger.log(Level.SEVERE, "Failed to load bucket map for:" + entry.getKey() + ":" + measurementName, e);
}
}
}
if (compactOnStart) {
compact();
}
logger.info("Loaded measurement:" + measurementName);
}
use of com.srotya.sidewinder.core.storage.BufferObject in project sidewinder by srotya.
the class DiskMalloc method sliceMappedBuffersForBuckets.
private void sliceMappedBuffersForBuckets(Map<String, MappedByteBuffer> bufferMap, Map<ByteString, List<Entry<Integer, BufferObject>>> seriesBuffers) throws IOException {
ptrCounter = 0;
initializePtrFile();
for (int i = 0; i < ptrCounter; i++) {
String line = MiscUtils.getStringFromBuffer(ptrBuf).trim();
String[] splits = line.split("\\" + SEPARATOR);
logger.finer("Reading line:" + Arrays.toString(splits));
String fileName = splits[1];
int positionOffset = Integer.parseInt(splits[3]);
String seriesIdStr = splits[0];
int pointer = Integer.parseInt(splits[2]);
int size = Integer.parseInt(splits[4]);
MappedByteBuffer buf = bufferMap.get(fileName);
int position = positionOffset + pointer;
buf.position(position);
String tsBucket = splits[5];
ByteBuffer slice = buf.slice();
slice.limit(size);
ByteString seriesId = new ByteString(seriesIdStr);
LinkedByteString bsLine = new LinkedByteString(BUF_PARTS_LENGTH);
bsLine.concat(seriesId).concat(SEPARATOR).concat(cache.get(new ByteString(splits[1]))).concat(SEPARATOR).concat(new ByteString(splits[2])).concat(SEPARATOR).concat(new ByteString(splits[3])).concat(SEPARATOR).concat(new ByteString(splits[4]));
List<Entry<Integer, BufferObject>> list = seriesBuffers.get(seriesId);
if (list == null) {
list = new ArrayList<>();
seriesBuffers.put(seriesId, list);
}
list.add(new AbstractMap.SimpleEntry<>(Integer.parseInt(tsBucket, 16), new BufferObject(bsLine, slice)));
}
}
Aggregations