2011-03-13 23:10:15 +00:00
|
|
|
/*
|
|
|
|
Copyright 2011 Google Inc.
|
|
|
|
|
|
|
|
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 search
|
|
|
|
|
|
|
|
import (
|
|
|
|
"camli/blobref"
|
2011-03-14 02:27:59 +00:00
|
|
|
|
2011-03-13 23:10:15 +00:00
|
|
|
"os"
|
2011-03-14 02:27:59 +00:00
|
|
|
"time"
|
2011-03-13 23:10:15 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
type Result struct {
|
|
|
|
BlobRef *blobref.BlobRef
|
2011-03-14 02:27:59 +00:00
|
|
|
Signer *blobref.BlobRef // may be nil
|
|
|
|
LastModTime int64 // seconds since epoch
|
|
|
|
}
|
|
|
|
|
|
|
|
// TODO: move this to schema or something?
|
|
|
|
type Claim struct {
|
|
|
|
BlobRef, Signer, Permanode *blobref.BlobRef
|
|
|
|
|
|
|
|
Date *time.Time
|
|
|
|
Type string // "set-attribute", "add-attribute", etc
|
|
|
|
|
|
|
|
// If an attribute modification
|
|
|
|
Attr, Value string
|
2011-03-13 23:10:15 +00:00
|
|
|
}
|
|
|
|
|
2011-03-14 03:51:58 +00:00
|
|
|
type ClaimList []*Claim
|
|
|
|
|
|
|
|
func (cl ClaimList) Len() int {
|
|
|
|
return len(cl)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (cl ClaimList) Less(i, j int) bool {
|
|
|
|
// TODO: memoize Seconds in unexported Claim field
|
|
|
|
return cl[i].Date.Seconds() < cl[j].Date.Seconds()
|
|
|
|
}
|
|
|
|
|
|
|
|
func (cl ClaimList) Swap(i, j int) {
|
|
|
|
cl[i], cl[j] = cl[j], cl[i]
|
|
|
|
}
|
|
|
|
|
2011-06-12 07:20:57 +00:00
|
|
|
type FileInfo struct {
|
|
|
|
Size int64
|
|
|
|
FileName string
|
|
|
|
MimeType string
|
|
|
|
}
|
|
|
|
|
2011-03-13 23:10:15 +00:00
|
|
|
type Index interface {
|
|
|
|
// dest is closed
|
|
|
|
// limit is <= 0 for default. smallest possible default is 0
|
|
|
|
GetRecentPermanodes(dest chan *Result,
|
|
|
|
owner []*blobref.BlobRef,
|
|
|
|
limit int) os.Error
|
2011-03-14 02:27:59 +00:00
|
|
|
|
2011-03-14 03:51:58 +00:00
|
|
|
GetOwnerClaims(permaNode, owner *blobref.BlobRef) (ClaimList, os.Error)
|
|
|
|
|
2011-05-30 22:44:25 +00:00
|
|
|
GetBlobMimeType(blob *blobref.BlobRef) (mime string, size int64, err os.Error)
|
2011-06-09 19:55:38 +00:00
|
|
|
|
|
|
|
// ExistingFileSchemas returns 0 or more blobrefs of file
|
|
|
|
// schema blobs that represent the bytes of a file given in
|
|
|
|
// bytesRef. The file schema blobs returned are not
|
|
|
|
// guaranteed to reference chunks that still exist on the
|
|
|
|
// blobservers, though. It's purely a hint for clients to
|
|
|
|
// avoid uploads if possible. Before re-using any returned
|
|
|
|
// blobref they should be checked.
|
|
|
|
ExistingFileSchemas(bytesRef *blobref.BlobRef) ([]*blobref.BlobRef, os.Error)
|
2011-06-12 07:20:57 +00:00
|
|
|
|
|
|
|
GetFileInfo(fileRef *blobref.BlobRef) (*FileInfo, os.Error)
|
2011-03-13 23:10:15 +00:00
|
|
|
}
|