use of com.srotya.sidewinder.core.storage.ByteString in project sidewinder by srotya.
the class PersistentMeasurement method loadTimeseriesInMeasurements.
@Override
public void loadTimeseriesInMeasurements() throws IOException {
String fieldFilePath = getFieldMetadataPath();
File file = new File(fieldFilePath);
if (!file.exists()) {
logger.warning("Field file missing for measurement:" + measurementName);
return;
} else {
logger.fine("Field file exists:" + file.getAbsolutePath());
}
List<String> fieldEntries = MiscUtils.readAllLines(file);
loadFieldList(fieldEntries);
String mdFilePath = getMetadataPath();
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) {
e.printStackTrace();
throw new IOException(e);
}
ByteStringCache localCache = ByteStringCache.instance();
Map<ByteString, List<Entry<Integer, BufferObject>>> seriesBuffers = malloc.seriesBufferMap();
for (Entry<ByteString, List<Entry<Integer, BufferObject>>> entry : seriesBuffers.entrySet()) {
ByteString[] split = entry.getKey().split(SERIESID_SEPARATOR);
ByteString seriesId = localCache.get(split[0]);
Integer seriesIndex = seriesMap.get(seriesId);
Series series = seriesList.get(seriesIndex);
if (series.getSeriesId() != seriesId) {
seriesMap.put(seriesId, seriesIndex);
series.setSeriesId(seriesId);
}
List<Entry<Integer, BufferObject>> list = entry.getValue();
if (list != null) {
try {
String fieldName = split[1].toString();
series.loadBuffers(this, fieldName, list, this.getConf());
} 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.ByteString in project sidewinder by srotya.
the class TestDownSamplingIFunction method testBasicSumDownSampling.
@Test
public void testBasicSumDownSampling() throws IOException {
Field tField = new TimeField(measurement, new LinkedByteString().concat(new ByteString("time")), 121213, new HashMap<>());
long ts = 1546755994280L;
for (int i = 0; i < 100; i++) {
tField.addDataPoint(measurement, ts + i * 1000);
}
Field vField = new ValueField(measurement, new LinkedByteString().concat(new ByteString("field1")), 121213, new HashMap<>());
for (int i = 0; i < 100; i++) {
vField.addDataPoint(measurement, i);
}
DataPointIterator itr = new DataPointIterator(tField.queryReader(null, new NoLock()), vField.queryReader(null, new NoLock()));
DownsampleFunction f = new DownsampleFunction(itr, 5, TimeUnit.SECONDS, ((x, y) -> (x + y)));
int c = 0;
while (f.hasNext()) {
DataPoint next = f.next();
if (c < 20) {
assertEquals(ts + c * 1000 * 5, next.getTimestamp());
}
c++;
}
assertEquals(21, c);
itr = new DataPointIterator(tField.queryReader(null, new NoLock()), vField.queryReader(null, new NoLock()));
f = new DownsampleFunction(itr, 10, TimeUnit.SECONDS, ((x, y) -> (x + y) / 2));
c = 0;
while (f.hasNext()) {
DataPoint next = f.next();
if (c < 10) {
assertEquals(ts + c * 1000 * 10, next.getTimestamp());
}
c++;
}
assertEquals(10, c, 1);
}
use of com.srotya.sidewinder.core.storage.ByteString in project sidewinder by srotya.
the class MappedSetTagIndex method searchRowKeysForTagFilter.
@Override
public Set<ByteString> searchRowKeysForTagFilter(TagFilter tagFilterTree) {
Set<ByteString> hexKeys = TagIndex.stringSetToByteSet(evalFilterForTags(tagFilterTree), new HashSet<>());
Set<ByteString> rowKeys = new HashSet<>();
List<Series> list = m.getSeriesList();
for (ByteString val : hexKeys) {
ByteString[] split = val.split(SEPERATOR);
rowKeys.add(new ByteString(list.get(Integer.parseInt(split[split.length - 1].toString(), 16)).getSeriesId().toString()));
}
return rowKeys;
}
use of com.srotya.sidewinder.core.storage.ByteString in project sidewinder by srotya.
the class PersistentMeasurement method appendTimeseriesToMeasurementMetadata.
@Override
public synchronized void appendTimeseriesToMeasurementMetadata(ByteString fieldId, int idx) throws IOException {
String line = fieldId.toString() + MD_SEPARATOR + Integer.toHexString(idx);
DiskStorageEngine.appendLineToFile(line, prMetadata);
}
use of com.srotya.sidewinder.core.storage.ByteString in project sidewinder by srotya.
the class TestBasicSingleFunctions method before.
@Before
public void before() throws IOException {
measurement = new MockMeasurement(32768, 100);
TimeField.compressionClass = CompressionFactory.getTimeClassByName("byzantine");
Field tField = new TimeField(measurement, new LinkedByteString().concat(new ByteString("time")), 121213, new HashMap<>());
long ts = 1546755991280L;
for (int i = 0; i < 200; i++) {
tField.addDataPoint(measurement, ts + i * 1000);
}
Field vField = new ValueField(measurement, new LinkedByteString().concat(new ByteString("field1")), 121213, new HashMap<>());
for (int i = 0; i < 100; i++) {
vField.addDataPoint(measurement, i * 1L);
}
for (int i = 100; i > 0; i--) {
vField.addDataPoint(measurement, i * 1L);
}
itr = new DataPointIterator(tField.queryReader(null, new NoLock()), vField.queryReader(null, new NoLock()));
}
Aggregations