-
Notifications
You must be signed in to change notification settings - Fork 529
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support pagination when single index query
Change-Id: I15c10c702078ff4a998378633e5cbb68cf2ac5fa
- Loading branch information
Showing
25 changed files
with
895 additions
and
299 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
83 changes: 83 additions & 0 deletions
83
hugegraph-core/src/main/java/com/baidu/hugegraph/backend/serializer/PageState.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
/* | ||
* Copyright 2017 HugeGraph Authors | ||
* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with this | ||
* work for additional information regarding copyright ownership. The ASF | ||
* licenses this file to You under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||
* License for the specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
package com.baidu.hugegraph.backend.serializer; | ||
|
||
import java.util.Base64; | ||
|
||
import com.baidu.hugegraph.backend.BackendException; | ||
import com.baidu.hugegraph.util.Bytes; | ||
import com.baidu.hugegraph.util.E; | ||
|
||
public class PageState { | ||
|
||
private final byte[] position; | ||
private final int offset; | ||
|
||
public PageState(byte[] position, int offset) { | ||
E.checkNotNull(position, "position"); | ||
this.position = position; | ||
this.offset = offset; | ||
} | ||
|
||
public byte[] position() { | ||
return this.position; | ||
} | ||
|
||
public int offset() { | ||
return this.offset; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return Base64.getEncoder().encodeToString(this.toBytes()); | ||
} | ||
|
||
public byte[] toBytes() { | ||
int length = 2 + this.position.length + BytesBuffer.INT_LEN; | ||
BytesBuffer buffer = BytesBuffer.allocate(length); | ||
buffer.writeBytes(this.position); | ||
buffer.writeInt(this.offset); | ||
return buffer.bytes(); | ||
} | ||
|
||
public static PageState fromString(String page) { | ||
byte[] bytes; | ||
try { | ||
bytes = Base64.getDecoder().decode(page); | ||
} catch (Exception e) { | ||
throw new BackendException("Invalid page: '%s'", e, page); | ||
} | ||
return fromBytes(bytes); | ||
} | ||
|
||
public static PageState fromBytes(byte[] bytes) { | ||
if (bytes.length == 0) { | ||
// The first page | ||
return new PageState(new byte[0], 0); | ||
} | ||
try { | ||
BytesBuffer buffer = BytesBuffer.wrap(bytes); | ||
return new PageState(buffer.readBytes(), buffer.readInt()); | ||
} catch (Exception e) { | ||
throw new BackendException("Invalid page: '0x%s'", | ||
e, Bytes.toHex(bytes)); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
hugegraph-core/src/main/java/com/baidu/hugegraph/backend/tx/EntireIds.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
/* | ||
* Copyright 2017 HugeGraph Authors | ||
* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with this | ||
* work for additional information regarding copyright ownership. The ASF | ||
* licenses this file to You under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||
* License for the specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
package com.baidu.hugegraph.backend.tx; | ||
|
||
import java.util.Collection; | ||
import java.util.Set; | ||
|
||
import com.baidu.hugegraph.backend.id.Id; | ||
import com.baidu.hugegraph.util.E; | ||
|
||
public class EntireIds implements Ids { | ||
|
||
private final Set<Id> ids; | ||
|
||
public EntireIds(Collection<Id> ids) { | ||
E.checkArgument(ids instanceof Set, | ||
"The ids of EntireIds must be Set, but got '%s'", | ||
ids.getClass().getName()); | ||
this.ids = (Set<Id>) ids; | ||
} | ||
|
||
public EntireIds(Set<Id> ids) { | ||
this.ids = ids; | ||
} | ||
|
||
public Set<Id> ids() { | ||
return this.ids; | ||
} | ||
} |
Oops, something went wrong.