Search in sources :

Example 11 with SeriesFieldMap

use of com.srotya.sidewinder.core.storage.SeriesFieldMap in project sidewinder by srotya.

the class MemStorageEngine method isMeasurementFieldFP.

@Override
public boolean isMeasurementFieldFP(String dbName, String measurementName, String valueFieldName) throws IOException {
    if (!checkIfExists(dbName, measurementName)) {
        throw NOT_FOUND_EXCEPTION;
    }
    Map<String, Measurement> dbMap = getOrCreateDatabase(dbName);
    // check and create measurement map
    Measurement measurement = getOrCreateMeasurement(dbMap, dbName, measurementName);
    for (String entry : measurement.getSeriesKeys()) {
        SeriesFieldMap seriesFromKey = measurement.getSeriesFromKey(entry);
        if (seriesFromKey.get(valueFieldName) != null) {
            return seriesFromKey.get(valueFieldName).isFp();
        }
    }
    throw NOT_FOUND_EXCEPTION;
}
Also used : Measurement(com.srotya.sidewinder.core.storage.Measurement) SeriesFieldMap(com.srotya.sidewinder.core.storage.SeriesFieldMap)

Example 12 with SeriesFieldMap

use of com.srotya.sidewinder.core.storage.SeriesFieldMap in project sidewinder by srotya.

the class MemoryMeasurement method getOrCreateTimeSeries.

@Override
public TimeSeries getOrCreateTimeSeries(String valueFieldName, List<String> tags, int timeBucketSize, boolean fp, Map<String, String> conf) throws IOException {
    Collections.sort(tags);
    String seriesId = constructSeriesId(tags, tagIndex);
    SeriesFieldMap seriesFieldMap = getSeriesFromKey(seriesId);
    if (seriesFieldMap == null) {
        lock.lock();
        if ((seriesFieldMap = getSeriesFromKey(seriesId)) == null) {
            Measurement.indexRowKey(tagIndex, seriesId, tags);
            seriesFieldMap = new SeriesFieldMap(seriesId);
            seriesMap.put(seriesId, seriesFieldMap);
        }
        lock.unlock();
    }
    TimeSeries series = seriesFieldMap.get(valueFieldName);
    if (series == null) {
        lock.lock();
        if ((series = seriesFieldMap.get(valueFieldName)) == null) {
            String seriesId2 = seriesId + SERIESID_SEPARATOR + valueFieldName;
            series = new TimeSeries(this, compressionCodec, compactionCodec, seriesId2, timeBucketSize, metadata, fp, conf);
            seriesFieldMap.addSeries(valueFieldName, series);
            logger.fine("Created new timeseries:" + seriesFieldMap + " for measurement:" + measurementName + "\t" + seriesId + "\t" + metadata.getRetentionHours() + "\t" + seriesMap.size());
        }
        lock.unlock();
    }
    return series;
}
Also used : TimeSeries(com.srotya.sidewinder.core.storage.TimeSeries) SeriesFieldMap(com.srotya.sidewinder.core.storage.SeriesFieldMap)

Aggregations

SeriesFieldMap (com.srotya.sidewinder.core.storage.SeriesFieldMap)12 File (java.io.File)7 SimpleTagFilter (com.srotya.sidewinder.core.filters.SimpleTagFilter)6 DBMetadata (com.srotya.sidewinder.core.storage.DBMetadata)6 HashMap (java.util.HashMap)6 Test (org.junit.Test)6 ComplexTagFilter (com.srotya.sidewinder.core.filters.ComplexTagFilter)4 TagFilter (com.srotya.sidewinder.core.filters.TagFilter)4 TimeSeries (com.srotya.sidewinder.core.storage.TimeSeries)3 Measurement (com.srotya.sidewinder.core.storage.Measurement)2 IOException (java.io.IOException)2 BufferObject (com.srotya.sidewinder.core.storage.BufferObject)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 Entry (java.util.Map.Entry)1