Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,11 @@ public interface IQueryFilter
* @return Maximum number of selected records
*/
public long getLimit();


/**
* @return Offset of first record to return (within the matching record set)
*/
public long getOffset();

}
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import org.sensorhub.api.datastore.system.SystemFilter;
import org.sensorhub.utils.FilterUtils;
import org.sensorhub.utils.ObjectUtils;
import org.vast.util.Asserts;
import org.vast.util.BaseBuilder;
import com.google.common.collect.ImmutableSortedSet;

Expand All @@ -50,6 +51,7 @@ public class CommandFilter implements IQueryFilter, Predicate<ICommandData>
protected CommandStatusFilter statusFilter;
protected Predicate<ICommandData> valuePredicate;
protected long limit = Long.MAX_VALUE;
protected long offset = 0;


/*
Expand Down Expand Up @@ -101,6 +103,13 @@ public long getLimit()
}


@Override
public long getOffset()
{
return offset;
}


@Override
public boolean test(ICommandData cmd)
{
Expand Down Expand Up @@ -163,6 +172,9 @@ public CommandFilter intersect(CommandFilter filter) throws EmptyFilterIntersect
if (valuePredicate != null)
builder.withValuePredicate(valuePredicate);

var offset = Math.max(this.offset, filter.offset);
builder.withOffset(offset);

var limit = Math.min(this.limit, filter.limit);
builder.withLimit(limit);

Expand Down Expand Up @@ -250,6 +262,7 @@ public B copyFrom(CommandFilter base)
instance.statusFilter = base.statusFilter;
instance.valuePredicate = base.valuePredicate;
instance.limit = base.limit;
instance.offset = base.offset;
return (B)this;
}

Expand Down Expand Up @@ -505,8 +518,22 @@ public B withValuePredicate(Predicate<ICommandData> valuePredicate)
*/
public B withLimit(long limit)
{
Asserts.checkArgument(limit >= 0, limit);
instance.limit = limit;
return (B)this;
}


/**
* Sets the offset of the first command to retrieve, among the ones matching the filter
* @param offset Offset of first command
* @return This builder for chaining
*/
public B withOffset(long offset)
{
Asserts.checkArgument(offset >= 0, offset);
instance.offset = offset;
return (B)this;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import java.time.Duration;
import org.sensorhub.api.datastore.IQueryFilter;
import org.sensorhub.utils.ObjectUtils;
import org.vast.util.Asserts;
import org.vast.util.BaseBuilder;


Expand All @@ -33,6 +34,7 @@ public class CommandStatsQuery implements IQueryFilter
protected CommandFilter commandFilter = new CommandFilter.Builder().build();
protected Duration histogramBinSize;
protected long limit = Long.MAX_VALUE;
protected long offset = 0;


/*
Expand Down Expand Up @@ -60,6 +62,13 @@ public long getLimit()
}


@Override
public long getOffset()
{
return offset;
}


@Override
public String toString()
{
Expand Down Expand Up @@ -98,6 +107,7 @@ protected B copyFrom(CommandStatsQuery base)
instance.commandFilter = base.commandFilter;
instance.histogramBinSize = base.histogramBinSize;
instance.limit = base.limit;
instance.offset = base.offset;
return (B)this;
}

Expand Down Expand Up @@ -131,8 +141,16 @@ public B withHistogramBinSize(Duration size)

public B withLimit(int limit)
{
Asserts.checkArgument(limit >= 0, limit);
instance.limit = limit;
return (B)this;
}


public B withOffset(long offset)
{
instance.offset = offset;
return (B)this;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import org.sensorhub.api.datastore.TemporalFilter;
import org.sensorhub.utils.FilterUtils;
import org.sensorhub.utils.ObjectUtils;
import org.vast.util.Asserts;
import org.vast.util.BaseBuilder;
import com.google.common.collect.ImmutableSortedSet;

Expand All @@ -48,6 +49,7 @@ public class CommandStatusFilter implements IQueryFilter, Predicate<ICommandStat
protected SortedSet<CommandStatusCode> statusCodes;
protected Predicate<ICommandStatus> valuePredicate;
protected long limit = Long.MAX_VALUE;
protected long offset = 0;


/*
Expand Down Expand Up @@ -93,6 +95,13 @@ public long getLimit()
}


@Override
public long getOffset()
{
return offset;
}


@Override
public boolean test(ICommandStatus status)
{
Expand Down Expand Up @@ -164,6 +173,9 @@ public CommandStatusFilter intersect(CommandStatusFilter filter) throws EmptyFil
if (valuePredicate != null)
builder.withValuePredicate(valuePredicate);

var offset = Math.max(this.offset, filter.offset);
builder.withOffset(offset);

var limit = Math.min(this.limit, filter.limit);
builder.withLimit(limit);

Expand Down Expand Up @@ -251,6 +263,7 @@ public B copyFrom(CommandStatusFilter base)
instance.statusCodes = base.statusCodes;
instance.valuePredicate = base.valuePredicate;
instance.limit = base.limit;
instance.offset = base.offset;
return (B)this;
}

Expand Down Expand Up @@ -319,7 +332,7 @@ public B withExecutionTimeDuring(Instant begin, Instant end)


/**
* Keep only commands with specific status.
* Keep only status reports with specific status codes.
* @param statusCodes One or more status codes
* @return This builder for chaining
*/
Expand All @@ -330,7 +343,7 @@ public B withStatus(CommandStatusCode... statusCodes)


/**
* Keep only commands with specific status.
* Keep only status reports with specific status codes.
* @param statusCodes One or more status codes
* @return This builder for chaining
*/
Expand Down Expand Up @@ -384,7 +397,7 @@ public B withCommands(BigId... ids)

/**
* Keep only status from commands with the given IDs.
* @param ids Collection of commands internal IDs
* @param ids Collection of status report internal IDs
* @return This builder for chaining
*/
public B withCommands(Collection<BigId> ids)
Expand All @@ -397,7 +410,7 @@ public B withCommands(Collection<BigId> ids)

/**
* Keep only the status messages that matches the predicate
* @param valuePredicate The predicate to test the command data
* @param valuePredicate The predicate to test the status data
* @return This builder for chaining
*/
public B withValuePredicate(Predicate<ICommandStatus> valuePredicate)
Expand All @@ -408,14 +421,28 @@ public B withValuePredicate(Predicate<ICommandStatus> valuePredicate)


/**
* Sets the maximum number of commands to retrieve
* @param limit Max command count
* Sets the maximum number of status reports to retrieve
* @param limit Max status report count
* @return This builder for chaining
*/
public B withLimit(long limit)
{
Asserts.checkArgument(limit >= 0, limit);
instance.limit = limit;
return (B)this;
}


/**
* Sets the offset of the first status report to retrieve, among the ones matching the filter
* @param offset Offset of first status report
* @return This builder for chaining
*/
public B withOffset(long offset)
{
Asserts.checkArgument(offset >= 0, offset);
instance.offset = offset;
return (B)this;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import org.sensorhub.api.datastore.system.SystemFilter;
import org.sensorhub.utils.FilterUtils;
import org.sensorhub.utils.ObjectUtils;
import org.vast.util.Asserts;
import org.vast.util.BaseBuilder;
import com.google.common.collect.ImmutableSortedSet;

Expand All @@ -52,6 +53,7 @@ public class ObsFilter implements IQueryFilter, Predicate<IObsData>
protected FoiFilter foiFilter;
protected Predicate<IObsData> valuePredicate;
protected long limit = Long.MAX_VALUE;
protected long offset = 0;


/*
Expand Down Expand Up @@ -109,6 +111,13 @@ public long getLimit()
}


@Override
public long getOffset()
{
return offset;
}


@Override
public boolean test(IObsData obs)
{
Expand Down Expand Up @@ -189,6 +198,9 @@ public ObsFilter intersect(ObsFilter filter) throws EmptyFilterIntersection
if (valuePredicate != null)
builder.withValuePredicate(valuePredicate);

var offset = Math.max(this.offset, filter.offset);
builder.withOffset(offset);

var limit = Math.min(this.limit, filter.limit);
builder.withLimit(limit);

Expand Down Expand Up @@ -278,6 +290,7 @@ public B copyFrom(ObsFilter base)
instance.foiFilter = base.foiFilter;
instance.valuePredicate = base.valuePredicate;
instance.limit = base.limit;
instance.offset = base.offset;
return (B)this;
}

Expand Down Expand Up @@ -603,8 +616,22 @@ public B withValuePredicate(Predicate<IObsData> valuePredicate)
*/
public B withLimit(long limit)
{
Asserts.checkArgument(limit >= 0, limit);
instance.limit = limit;
return (B)this;
}


/**
* Sets the offset of the first observation to retrieve, among the ones matching the filter
* @param offset Offset of first observation
* @return This builder for chaining
*/
public B withOffset(long offset)
{
Asserts.checkArgument(offset >= 0, offset);
instance.offset = offset;
return (B)this;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import java.time.Duration;
import org.sensorhub.api.datastore.IQueryFilter;
import org.sensorhub.utils.ObjectUtils;
import org.vast.util.Asserts;
import org.vast.util.BaseBuilder;


Expand All @@ -34,6 +35,7 @@ public class ObsStatsQuery implements IQueryFilter
protected boolean aggregateFois = false;
protected Duration histogramBinSize;
protected long limit = Long.MAX_VALUE;
protected long offset = 0;


/*
Expand Down Expand Up @@ -67,6 +69,13 @@ public long getLimit()
}


@Override
public long getOffset()
{
return offset;
}


@Override
public String toString()
{
Expand Down Expand Up @@ -106,6 +115,7 @@ protected B copyFrom(ObsStatsQuery base)
instance.aggregateFois = base.aggregateFois;
instance.histogramBinSize = base.histogramBinSize;
instance.limit = base.limit;
instance.offset = base.offset;
return (B)this;
}

Expand Down Expand Up @@ -146,8 +156,17 @@ public B withHistogramBinSize(Duration size)

public B withLimit(long limit)
{
Asserts.checkArgument(limit >= 0, limit);
instance.limit = limit;
return (B)this;
}


public B withOffset(long offset)
{
Asserts.checkArgument(offset >= 0, offset);
instance.offset = offset;
return (B)this;
}
}
}
Loading
Loading