-
-
Notifications
You must be signed in to change notification settings - Fork 211
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
change around vacuum so that we ask ES for all the 'state' ctids (in …
…a binary blob), validate them with PG, and then delete them. This ensures we don't try to delete docs that don't exist in our ES index and it removes the need for ZDB to copy in the LVRelStats struct from 3 different versions of PG.
- Loading branch information
1 parent
1584099
commit f16d705
Showing
7 changed files
with
157 additions
and
106 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
64 changes: 64 additions & 0 deletions
64
elasticsearch/src/main/java/com/tcdi/zombodb/postgres/ZombodbVacuumSupport.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,64 @@ | ||
/* | ||
* Copyright 2015-2016 ZomboDB, LLC | ||
* | ||
* Licensed 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.tcdi.zombodb.postgres; | ||
|
||
import com.tcdi.zombodb.query_parser.utils.Utils; | ||
import org.elasticsearch.action.search.SearchRequestBuilder; | ||
import org.elasticsearch.action.search.SearchResponse; | ||
import org.elasticsearch.client.Client; | ||
import org.elasticsearch.common.inject.Inject; | ||
import org.elasticsearch.common.settings.Settings; | ||
import org.elasticsearch.rest.*; | ||
import org.elasticsearch.search.SearchHit; | ||
|
||
import static org.elasticsearch.rest.RestRequest.Method.GET; | ||
|
||
public class ZombodbVacuumSupport extends BaseRestHandler { | ||
|
||
@Inject | ||
protected ZombodbVacuumSupport(Settings settings, RestController controller, Client client) { | ||
super(settings, controller, client); | ||
|
||
controller.registerHandler(GET, "/{index}/_zdbvacsup", this); | ||
} | ||
|
||
@Override | ||
protected void handleRequest(RestRequest request, RestChannel channel, Client client) throws Exception { | ||
SearchRequestBuilder builder = new SearchRequestBuilder(client) | ||
.setIndices(request.param("index")) | ||
.setTypes("state") | ||
.setSize(Integer.MAX_VALUE); | ||
|
||
SearchResponse response = client.search(builder.request()).actionGet(); | ||
int many = response.getHits().getHits().length; | ||
byte[] buffer = new byte[1 + 4 + 6*many]; | ||
int offset = 0; | ||
|
||
buffer[0] = 0; | ||
offset++; | ||
|
||
offset += Utils.encodeInteger(many, buffer, offset); | ||
for (SearchHit hit : response.getHits().getHits()) { | ||
String id = hit.id(); | ||
String[] parts = id.split("[-]"); | ||
|
||
offset += Utils.encodeInteger(Integer.parseInt(parts[0]), buffer, offset); | ||
offset += Utils.encodeCharacter((char) Integer.parseInt(parts[1]), buffer, offset); | ||
} | ||
|
||
channel.sendResponse(new BytesRestResponse(RestStatus.OK, "application/data", buffer)); | ||
} | ||
} |
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