HBase过滤器继承咨询
我需要一个有点像 TimestampsFilter 的过滤器,只不过它需要一个时间帧并在该帧内应用带有时间戳的每一行。 这是我的实现:
public class TimeFilter extends TimestampsFilter {
private long from;
private long to;
public TimeFilter(long from, long to) {
this.from = from;
this.to = to;
}
@Override
public ReturnCode filterKeyValue(KeyValue v) {
long timestamp = v.getTimestamp();
if (from <= timestamp && to >= timestamp) {
return ReturnCode.INCLUDE;
}
return ReturnCode.SKIP;
}
}
这个实现足够好吗? 我找不到适合我需要的现有过滤器。 有什么意见吗?
I need a filter which is a bit like TimestampsFilter except that it takes a time frame and applies every row with timestamp within this frame.
This is my implementation:
public class TimeFilter extends TimestampsFilter {
private long from;
private long to;
public TimeFilter(long from, long to) {
this.from = from;
this.to = to;
}
@Override
public ReturnCode filterKeyValue(KeyValue v) {
long timestamp = v.getTimestamp();
if (from <= timestamp && to >= timestamp) {
return ReturnCode.INCLUDE;
}
return ReturnCode.SKIP;
}
}
Is this implementation good enough?
I couldn't find an existing filter that suites my need.
Any input?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
你不能使用
Can't you use a setTimeRange on the Scan?