Skip to content

Commit

Permalink
Modification on hbase table
Browse files Browse the repository at this point in the history
Change-Id: Ib52121bcda96002048c826012929863f204f8c12
  • Loading branch information
Linary committed Mar 15, 2019
1 parent 7a1ab1c commit 274d28e
Show file tree
Hide file tree
Showing 8 changed files with 17 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -79,16 +79,15 @@ public boolean paging() {

public PageIds fetchNext(String page, long pageSize) {
if (this.exhausted) {
return null;
return PageIds.EMPTY;
}

this.query.page(page);
this.query.limit(pageSize);

PageIds result = this.idsFetcher.get();
if (result == null) {
return null;
}

assert result != null;
this.ids = result.ids();
if (this.ids.size() != this.query.limit() || result.page() == null) {
this.exhausted = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,12 @@
import java.util.Set;

import com.baidu.hugegraph.backend.id.Id;
import com.google.common.collect.ImmutableSet;

public final class PageIds {

public static final PageIds EMPTY = new PageIds(ImmutableSet.of(), null);

private final Set<Id> ids;
private final String page;

Expand All @@ -40,4 +43,8 @@ public Set<Id> ids() {
public String page() {
return this.page;
}

public boolean empty() {
return this.ids.isEmpty();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ public Iterator<BackendEntry> iterator() {
public PageIterator iterator(int index, String page, long pageSize) {
IdHolder holder = this.holders.get(index);
PageIds pageIds = holder.fetchNext(page, pageSize);
if (pageIds == null) {
if (pageIds.empty()) {
return PageIterator.EMPTY;
}
IdQuery query = new IdQuery(parent.resultType(), pageIds.ids());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -748,6 +748,10 @@ private Query writeRangeIndexQuery(ConditionQuery query) {
newQuery = new IdPrefixQuery(query, start, keyMinEq, prefix);
} else {
Id max = formatIndexId(type, index, keyMax);
if (keyMaxEq) {
keyMaxEq = false;
increaseOne(max.asBytes());
}
newQuery = new IdRangeQuery(query, start, keyMinEq, max, keyMaxEq);
}
newQuery.page(query.page());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,6 @@ public HugeGraph graph() {
return this.graph;
}

public HugeConfig config() {
return this.graph().configuration();
}

public BackendStore store() {
E.checkNotNull(this.graph, "store");
return this.store;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -495,7 +495,7 @@ private IdHolder doIndexQueryInPage(IndexLabel indexLabel,
}
// If there is no data, the entries is not a Metadatable object
if (ids.isEmpty()) {
return null;
return PageIds.EMPTY;
}

E.checkState(entries instanceof Metadatable,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
import java.util.Iterator;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;

import org.apache.hadoop.hbase.Cell;
import org.apache.hadoop.hbase.CellScanner;
Expand All @@ -41,7 +40,6 @@
import com.baidu.hugegraph.backend.serializer.BinaryBackendEntry;
import com.baidu.hugegraph.backend.serializer.BinaryEntryIterator;
import com.baidu.hugegraph.backend.serializer.BinaryEntryIterator.PageState;
import com.baidu.hugegraph.backend.serializer.BinarySerializer;
import com.baidu.hugegraph.backend.store.BackendEntry;
import com.baidu.hugegraph.backend.store.BackendEntry.BackendColumn;
import com.baidu.hugegraph.backend.store.BackendEntryIterator;
Expand Down Expand Up @@ -195,11 +193,6 @@ protected RowIterator queryByPrefix(Session session, IdPrefixQuery query) {
protected RowIterator queryByRange(Session session, IdRangeQuery query) {
byte[] start = query.start().asBytes();
byte[] end = query.end() == null ? null : query.end().asBytes();
if (query.inclusiveEnd() && end != null) {
BinarySerializer.increaseOne(end);
return session.scan(this.table(), start, query.inclusiveStart(),
end, false);
}
return session.scan(this.table(), start, query.inclusiveStart(),
end, query.inclusiveEnd());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,7 @@ public void delete(Session session, BackendEntry entry) {
protected BackendEntryIterator newEntryIterator(RowIterator rows,
Query query) {
return new BinaryEntryIterator<>(rows, query, (entry, row) -> {
assert row.size() == 1;
BackendColumn col = BackendColumn.of(row.getRow(), row.value());
entry = new BinaryBackendEntry(query.resultType(), col.name);
entry.columns(col);
Expand Down

0 comments on commit 274d28e

Please sign in to comment.