id
int32
0
167k
repo
stringlengths
5
54
path
stringlengths
4
155
func_name
stringlengths
1
118
original_string
stringlengths
52
85.5k
language
stringclasses
1 value
code
stringlengths
52
85.5k
code_tokens
listlengths
21
1.41k
docstring
stringlengths
6
2.61k
docstring_tokens
listlengths
3
215
sha
stringlengths
40
40
url
stringlengths
85
252
8,200
contiv/netplugin
netmaster/objApi/apiController.go
NetworkGetOper
func (ac *APIController) NetworkGetOper(network *contivModel.NetworkInspect) error { log.Infof("Received NetworkInspect: %+v", network) // Get the state driver stateDriver, err := utils.GetStateDriver() if err != nil { return err } nwCfg := &mastercfg.CfgNetworkState{} nwCfg.StateDriver = stateDriver networ...
go
func (ac *APIController) NetworkGetOper(network *contivModel.NetworkInspect) error { log.Infof("Received NetworkInspect: %+v", network) // Get the state driver stateDriver, err := utils.GetStateDriver() if err != nil { return err } nwCfg := &mastercfg.CfgNetworkState{} nwCfg.StateDriver = stateDriver networ...
[ "func", "(", "ac", "*", "APIController", ")", "NetworkGetOper", "(", "network", "*", "contivModel", ".", "NetworkInspect", ")", "error", "{", "log", ".", "Infof", "(", "\"", "\"", ",", "network", ")", "\n\n", "// Get the state driver", "stateDriver", ",", "e...
// NetworkGetOper inspects network
[ "NetworkGetOper", "inspects", "network" ]
965773066d2b8ebed3514979949061a03d46fd20
https://github.com/contiv/netplugin/blob/965773066d2b8ebed3514979949061a03d46fd20/netmaster/objApi/apiController.go#L1142-L1193
8,201
contiv/netplugin
netmaster/objApi/apiController.go
NetworkUpdate
func (ac *APIController) NetworkUpdate(network, params *contivModel.Network) error { log.Infof("Received NetworkUpdate: %+v, params: %+v", network, params) return core.Errorf("Cant change network parameters after its created") }
go
func (ac *APIController) NetworkUpdate(network, params *contivModel.Network) error { log.Infof("Received NetworkUpdate: %+v, params: %+v", network, params) return core.Errorf("Cant change network parameters after its created") }
[ "func", "(", "ac", "*", "APIController", ")", "NetworkUpdate", "(", "network", ",", "params", "*", "contivModel", ".", "Network", ")", "error", "{", "log", ".", "Infof", "(", "\"", "\"", ",", "network", ",", "params", ")", "\n", "return", "core", ".", ...
// NetworkUpdate updates network
[ "NetworkUpdate", "updates", "network" ]
965773066d2b8ebed3514979949061a03d46fd20
https://github.com/contiv/netplugin/blob/965773066d2b8ebed3514979949061a03d46fd20/netmaster/objApi/apiController.go#L1196-L1199
8,202
contiv/netplugin
netmaster/objApi/apiController.go
NetworkDelete
func (ac *APIController) NetworkDelete(network *contivModel.Network) error { log.Infof("Received NetworkDelete: %+v", network) // Find the tenant tenant := contivModel.FindTenant(network.TenantName) if tenant == nil { return core.Errorf("Tenant not found") } // if the network has associated epgs, fail the del...
go
func (ac *APIController) NetworkDelete(network *contivModel.Network) error { log.Infof("Received NetworkDelete: %+v", network) // Find the tenant tenant := contivModel.FindTenant(network.TenantName) if tenant == nil { return core.Errorf("Tenant not found") } // if the network has associated epgs, fail the del...
[ "func", "(", "ac", "*", "APIController", ")", "NetworkDelete", "(", "network", "*", "contivModel", ".", "Network", ")", "error", "{", "log", ".", "Infof", "(", "\"", "\"", ",", "network", ")", "\n\n", "// Find the tenant", "tenant", ":=", "contivModel", "....
// NetworkDelete deletes network
[ "NetworkDelete", "deletes", "network" ]
965773066d2b8ebed3514979949061a03d46fd20
https://github.com/contiv/netplugin/blob/965773066d2b8ebed3514979949061a03d46fd20/netmaster/objApi/apiController.go#L1202-L1259
8,203
contiv/netplugin
netmaster/objApi/apiController.go
NetprofileCreate
func (ac *APIController) NetprofileCreate(netProfile *contivModel.Netprofile) error { log.Infof("Received NetprofileCreate: %+v", netProfile) // Check if the tenant exists if netProfile.TenantName == "" { return core.Errorf("Invalid tenant name") } if netProfile.Burst > 0 && netProfile.Burst < 2 { return cor...
go
func (ac *APIController) NetprofileCreate(netProfile *contivModel.Netprofile) error { log.Infof("Received NetprofileCreate: %+v", netProfile) // Check if the tenant exists if netProfile.TenantName == "" { return core.Errorf("Invalid tenant name") } if netProfile.Burst > 0 && netProfile.Burst < 2 { return cor...
[ "func", "(", "ac", "*", "APIController", ")", "NetprofileCreate", "(", "netProfile", "*", "contivModel", ".", "Netprofile", ")", "error", "{", "log", ".", "Infof", "(", "\"", "\"", ",", "netProfile", ")", "\n\n", "// Check if the tenant exists", "if", "netProf...
// NetprofileCreate creates the network rule
[ "NetprofileCreate", "creates", "the", "network", "rule" ]
965773066d2b8ebed3514979949061a03d46fd20
https://github.com/contiv/netplugin/blob/965773066d2b8ebed3514979949061a03d46fd20/netmaster/objApi/apiController.go#L1262-L1291
8,204
contiv/netplugin
netmaster/objApi/apiController.go
NetprofileUpdate
func (ac *APIController) NetprofileUpdate(profile, params *contivModel.Netprofile) error { log.Infof("Received NetprofileUpdate: %+v, params: %+v", profile, params) if params.Burst > 0 && params.Burst < 2 { return core.Errorf("Invalid Burst size. burst size must be > 1500 bytes") } profile.Bandwidth = params.Ban...
go
func (ac *APIController) NetprofileUpdate(profile, params *contivModel.Netprofile) error { log.Infof("Received NetprofileUpdate: %+v, params: %+v", profile, params) if params.Burst > 0 && params.Burst < 2 { return core.Errorf("Invalid Burst size. burst size must be > 1500 bytes") } profile.Bandwidth = params.Ban...
[ "func", "(", "ac", "*", "APIController", ")", "NetprofileUpdate", "(", "profile", ",", "params", "*", "contivModel", ".", "Netprofile", ")", "error", "{", "log", ".", "Infof", "(", "\"", "\"", ",", "profile", ",", "params", ")", "\n\n", "if", "params", ...
// NetprofileUpdate updates the netprofile
[ "NetprofileUpdate", "updates", "the", "netprofile" ]
965773066d2b8ebed3514979949061a03d46fd20
https://github.com/contiv/netplugin/blob/965773066d2b8ebed3514979949061a03d46fd20/netmaster/objApi/apiController.go#L1294-L1317
8,205
contiv/netplugin
netmaster/objApi/apiController.go
NetprofileDelete
func (ac *APIController) NetprofileDelete(netProfile *contivModel.Netprofile) error { log.Infof("Deleting Netprofile:%s", netProfile.ProfileName) // Find Tenant tenant := contivModel.FindTenant(netProfile.TenantName) if tenant == nil { return core.Errorf("Tenant %s not found", netProfile.TenantName) } // Check...
go
func (ac *APIController) NetprofileDelete(netProfile *contivModel.Netprofile) error { log.Infof("Deleting Netprofile:%s", netProfile.ProfileName) // Find Tenant tenant := contivModel.FindTenant(netProfile.TenantName) if tenant == nil { return core.Errorf("Tenant %s not found", netProfile.TenantName) } // Check...
[ "func", "(", "ac", "*", "APIController", ")", "NetprofileDelete", "(", "netProfile", "*", "contivModel", ".", "Netprofile", ")", "error", "{", "log", ".", "Infof", "(", "\"", "\"", ",", "netProfile", ".", "ProfileName", ")", "\n\n", "// Find Tenant", "tenant...
// NetprofileDelete deletes netprofile
[ "NetprofileDelete", "deletes", "netprofile" ]
965773066d2b8ebed3514979949061a03d46fd20
https://github.com/contiv/netplugin/blob/965773066d2b8ebed3514979949061a03d46fd20/netmaster/objApi/apiController.go#L1320-L1335
8,206
contiv/netplugin
netmaster/objApi/apiController.go
PolicyCreate
func (ac *APIController) PolicyCreate(policy *contivModel.Policy) error { log.Infof("Received PolicyCreate: %+v", policy) // Make sure tenant exists if policy.TenantName == "" { return core.Errorf("Invalid tenant name") } tenant := contivModel.FindTenant(policy.TenantName) if tenant == nil { return core.Err...
go
func (ac *APIController) PolicyCreate(policy *contivModel.Policy) error { log.Infof("Received PolicyCreate: %+v", policy) // Make sure tenant exists if policy.TenantName == "" { return core.Errorf("Invalid tenant name") } tenant := contivModel.FindTenant(policy.TenantName) if tenant == nil { return core.Err...
[ "func", "(", "ac", "*", "APIController", ")", "PolicyCreate", "(", "policy", "*", "contivModel", ".", "Policy", ")", "error", "{", "log", ".", "Infof", "(", "\"", "\"", ",", "policy", ")", "\n\n", "// Make sure tenant exists", "if", "policy", ".", "TenantN...
// PolicyCreate creates policy
[ "PolicyCreate", "creates", "policy" ]
965773066d2b8ebed3514979949061a03d46fd20
https://github.com/contiv/netplugin/blob/965773066d2b8ebed3514979949061a03d46fd20/netmaster/objApi/apiController.go#L1338-L1363
8,207
contiv/netplugin
netmaster/objApi/apiController.go
PolicyGetOper
func (ac *APIController) PolicyGetOper(policy *contivModel.PolicyInspect) error { log.Infof("Received PolicyInspect: %+v", policy) // Get the state driver stateDriver, err := utils.GetStateDriver() if err != nil { return err } // To hold total number of Endpoint count var policyEPCount int policyCfg := &ma...
go
func (ac *APIController) PolicyGetOper(policy *contivModel.PolicyInspect) error { log.Infof("Received PolicyInspect: %+v", policy) // Get the state driver stateDriver, err := utils.GetStateDriver() if err != nil { return err } // To hold total number of Endpoint count var policyEPCount int policyCfg := &ma...
[ "func", "(", "ac", "*", "APIController", ")", "PolicyGetOper", "(", "policy", "*", "contivModel", ".", "PolicyInspect", ")", "error", "{", "log", ".", "Infof", "(", "\"", "\"", ",", "policy", ")", "\n\n", "// Get the state driver", "stateDriver", ",", "err",...
// PolicyGetOper inspects policy
[ "PolicyGetOper", "inspects", "policy" ]
965773066d2b8ebed3514979949061a03d46fd20
https://github.com/contiv/netplugin/blob/965773066d2b8ebed3514979949061a03d46fd20/netmaster/objApi/apiController.go#L1366-L1441
8,208
contiv/netplugin
netmaster/objApi/apiController.go
PolicyUpdate
func (ac *APIController) PolicyUpdate(policy, params *contivModel.Policy) error { log.Infof("Received PolicyUpdate: %+v, params: %+v", policy, params) return nil }
go
func (ac *APIController) PolicyUpdate(policy, params *contivModel.Policy) error { log.Infof("Received PolicyUpdate: %+v, params: %+v", policy, params) return nil }
[ "func", "(", "ac", "*", "APIController", ")", "PolicyUpdate", "(", "policy", ",", "params", "*", "contivModel", ".", "Policy", ")", "error", "{", "log", ".", "Infof", "(", "\"", "\"", ",", "policy", ",", "params", ")", "\n", "return", "nil", "\n", "}...
// PolicyUpdate updates policy
[ "PolicyUpdate", "updates", "policy" ]
965773066d2b8ebed3514979949061a03d46fd20
https://github.com/contiv/netplugin/blob/965773066d2b8ebed3514979949061a03d46fd20/netmaster/objApi/apiController.go#L1444-L1447
8,209
contiv/netplugin
netmaster/objApi/apiController.go
PolicyDelete
func (ac *APIController) PolicyDelete(policy *contivModel.Policy) error { log.Infof("Received PolicyDelete: %+v", policy) // Find Tenant tenant := contivModel.FindTenant(policy.TenantName) if tenant == nil { return core.Errorf("Tenant %s not found", policy.TenantName) } // Check if any endpoint group is using...
go
func (ac *APIController) PolicyDelete(policy *contivModel.Policy) error { log.Infof("Received PolicyDelete: %+v", policy) // Find Tenant tenant := contivModel.FindTenant(policy.TenantName) if tenant == nil { return core.Errorf("Tenant %s not found", policy.TenantName) } // Check if any endpoint group is using...
[ "func", "(", "ac", "*", "APIController", ")", "PolicyDelete", "(", "policy", "*", "contivModel", ".", "Policy", ")", "error", "{", "log", ".", "Infof", "(", "\"", "\"", ",", "policy", ")", "\n\n", "// Find Tenant", "tenant", ":=", "contivModel", ".", "Fi...
// PolicyDelete deletes policy
[ "PolicyDelete", "deletes", "policy" ]
965773066d2b8ebed3514979949061a03d46fd20
https://github.com/contiv/netplugin/blob/965773066d2b8ebed3514979949061a03d46fd20/netmaster/objApi/apiController.go#L1450-L1484
8,210
contiv/netplugin
netmaster/objApi/apiController.go
RuleUpdate
func (ac *APIController) RuleUpdate(rule, params *contivModel.Rule) error { log.Infof("Received RuleUpdate: %+v, params: %+v", rule, params) return errors.New("can not update a rule after its created") }
go
func (ac *APIController) RuleUpdate(rule, params *contivModel.Rule) error { log.Infof("Received RuleUpdate: %+v, params: %+v", rule, params) return errors.New("can not update a rule after its created") }
[ "func", "(", "ac", "*", "APIController", ")", "RuleUpdate", "(", "rule", ",", "params", "*", "contivModel", ".", "Rule", ")", "error", "{", "log", ".", "Infof", "(", "\"", "\"", ",", "rule", ",", "params", ")", "\n", "return", "errors", ".", "New", ...
// RuleUpdate updates the rule within a policy
[ "RuleUpdate", "updates", "the", "rule", "within", "a", "policy" ]
965773066d2b8ebed3514979949061a03d46fd20
https://github.com/contiv/netplugin/blob/965773066d2b8ebed3514979949061a03d46fd20/netmaster/objApi/apiController.go#L1688-L1691
8,211
contiv/netplugin
netmaster/objApi/apiController.go
RuleDelete
func (ac *APIController) RuleDelete(rule *contivModel.Rule) error { var epg *contivModel.EndpointGroup epg = nil log.Infof("Received RuleDelete: %+v", rule) policyKey := GetpolicyKey(rule.TenantName, rule.PolicyName) // find the policy policy := contivModel.FindPolicy(policyKey) if policy == nil { log.Error...
go
func (ac *APIController) RuleDelete(rule *contivModel.Rule) error { var epg *contivModel.EndpointGroup epg = nil log.Infof("Received RuleDelete: %+v", rule) policyKey := GetpolicyKey(rule.TenantName, rule.PolicyName) // find the policy policy := contivModel.FindPolicy(policyKey) if policy == nil { log.Error...
[ "func", "(", "ac", "*", "APIController", ")", "RuleDelete", "(", "rule", "*", "contivModel", ".", "Rule", ")", "error", "{", "var", "epg", "*", "contivModel", ".", "EndpointGroup", "\n\n", "epg", "=", "nil", "\n", "log", ".", "Infof", "(", "\"", "\"", ...
// RuleDelete deletes the rule within a policy
[ "RuleDelete", "deletes", "the", "rule", "within", "a", "policy" ]
965773066d2b8ebed3514979949061a03d46fd20
https://github.com/contiv/netplugin/blob/965773066d2b8ebed3514979949061a03d46fd20/netmaster/objApi/apiController.go#L1694-L1737
8,212
contiv/netplugin
netmaster/objApi/apiController.go
TenantCreate
func (ac *APIController) TenantCreate(tenant *contivModel.Tenant) error { log.Infof("Received TenantCreate: %+v", tenant) if tenant.TenantName == "" { return core.Errorf("Invalid tenant name") } // Get the state driver stateDriver, err := utils.GetStateDriver() if err != nil { return err } // Build tenan...
go
func (ac *APIController) TenantCreate(tenant *contivModel.Tenant) error { log.Infof("Received TenantCreate: %+v", tenant) if tenant.TenantName == "" { return core.Errorf("Invalid tenant name") } // Get the state driver stateDriver, err := utils.GetStateDriver() if err != nil { return err } // Build tenan...
[ "func", "(", "ac", "*", "APIController", ")", "TenantCreate", "(", "tenant", "*", "contivModel", ".", "Tenant", ")", "error", "{", "log", ".", "Infof", "(", "\"", "\"", ",", "tenant", ")", "\n\n", "if", "tenant", ".", "TenantName", "==", "\"", "\"", ...
// TenantCreate creates a tenant
[ "TenantCreate", "creates", "a", "tenant" ]
965773066d2b8ebed3514979949061a03d46fd20
https://github.com/contiv/netplugin/blob/965773066d2b8ebed3514979949061a03d46fd20/netmaster/objApi/apiController.go#L1740-L1767
8,213
contiv/netplugin
netmaster/objApi/apiController.go
getTenantNetworks
func getTenantNetworks(tenant *contivModel.TenantInspect) error { // Get the state driver stateDriver, err := utils.GetStateDriver() if err != nil { return err } tenantID := tenant.Config.TenantName numEPs := 0 s := []string{} networkID := "" for _, net := range tenant.Config.LinkSets.Networks { networkI...
go
func getTenantNetworks(tenant *contivModel.TenantInspect) error { // Get the state driver stateDriver, err := utils.GetStateDriver() if err != nil { return err } tenantID := tenant.Config.TenantName numEPs := 0 s := []string{} networkID := "" for _, net := range tenant.Config.LinkSets.Networks { networkI...
[ "func", "getTenantNetworks", "(", "tenant", "*", "contivModel", ".", "TenantInspect", ")", "error", "{", "// Get the state driver", "stateDriver", ",", "err", ":=", "utils", ".", "GetStateDriver", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err",...
// Get all the networks inside tenant
[ "Get", "all", "the", "networks", "inside", "tenant" ]
965773066d2b8ebed3514979949061a03d46fd20
https://github.com/contiv/netplugin/blob/965773066d2b8ebed3514979949061a03d46fd20/netmaster/objApi/apiController.go#L1770-L1833
8,214
contiv/netplugin
netmaster/objApi/apiController.go
getTenantEPGs
func getTenantEPGs(tenant *contivModel.TenantInspect) error { // Get the state driver stateDriver, err := utils.GetStateDriver() if err != nil { return err } tenantID := tenant.Config.TenantName s := []string{} epgID := "" for _, epg := range tenant.Config.LinkSets.EndpointGroups { epgID = epg.ObjKey lo...
go
func getTenantEPGs(tenant *contivModel.TenantInspect) error { // Get the state driver stateDriver, err := utils.GetStateDriver() if err != nil { return err } tenantID := tenant.Config.TenantName s := []string{} epgID := "" for _, epg := range tenant.Config.LinkSets.EndpointGroups { epgID = epg.ObjKey lo...
[ "func", "getTenantEPGs", "(", "tenant", "*", "contivModel", ".", "TenantInspect", ")", "error", "{", "// Get the state driver", "stateDriver", ",", "err", ":=", "utils", ".", "GetStateDriver", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "...
// Get all the EPGs inside tenant
[ "Get", "all", "the", "EPGs", "inside", "tenant" ]
965773066d2b8ebed3514979949061a03d46fd20
https://github.com/contiv/netplugin/blob/965773066d2b8ebed3514979949061a03d46fd20/netmaster/objApi/apiController.go#L1836-L1895
8,215
contiv/netplugin
netmaster/objApi/apiController.go
TenantGetOper
func (ac *APIController) TenantGetOper(tenant *contivModel.TenantInspect) error { log.Infof("Received TenantInspect: %+v", tenant) tenant.Oper.TotalNetworks = len(tenant.Config.LinkSets.Networks) tenant.Oper.TotalEPGs = len(tenant.Config.LinkSets.EndpointGroups) tenant.Oper.TotalNetprofiles = len(tenant.Config.Lin...
go
func (ac *APIController) TenantGetOper(tenant *contivModel.TenantInspect) error { log.Infof("Received TenantInspect: %+v", tenant) tenant.Oper.TotalNetworks = len(tenant.Config.LinkSets.Networks) tenant.Oper.TotalEPGs = len(tenant.Config.LinkSets.EndpointGroups) tenant.Oper.TotalNetprofiles = len(tenant.Config.Lin...
[ "func", "(", "ac", "*", "APIController", ")", "TenantGetOper", "(", "tenant", "*", "contivModel", ".", "TenantInspect", ")", "error", "{", "log", ".", "Infof", "(", "\"", "\"", ",", "tenant", ")", "\n\n", "tenant", ".", "Oper", ".", "TotalNetworks", "=",...
// TenantGetOper inspects tenant
[ "TenantGetOper", "inspects", "tenant" ]
965773066d2b8ebed3514979949061a03d46fd20
https://github.com/contiv/netplugin/blob/965773066d2b8ebed3514979949061a03d46fd20/netmaster/objApi/apiController.go#L1898-L1916
8,216
contiv/netplugin
netmaster/objApi/apiController.go
TenantUpdate
func (ac *APIController) TenantUpdate(tenant, params *contivModel.Tenant) error { log.Infof("Received TenantUpdate: %+v, params: %+v", tenant, params) return core.Errorf("Cant change tenant parameters after its created") }
go
func (ac *APIController) TenantUpdate(tenant, params *contivModel.Tenant) error { log.Infof("Received TenantUpdate: %+v, params: %+v", tenant, params) return core.Errorf("Cant change tenant parameters after its created") }
[ "func", "(", "ac", "*", "APIController", ")", "TenantUpdate", "(", "tenant", ",", "params", "*", "contivModel", ".", "Tenant", ")", "error", "{", "log", ".", "Infof", "(", "\"", "\"", ",", "tenant", ",", "params", ")", "\n\n", "return", "core", ".", ...
// TenantUpdate updates a tenant
[ "TenantUpdate", "updates", "a", "tenant" ]
965773066d2b8ebed3514979949061a03d46fd20
https://github.com/contiv/netplugin/blob/965773066d2b8ebed3514979949061a03d46fd20/netmaster/objApi/apiController.go#L1919-L1923
8,217
contiv/netplugin
netmaster/objApi/apiController.go
TenantDelete
func (ac *APIController) TenantDelete(tenant *contivModel.Tenant) error { log.Infof("Received TenantDelete: %+v", tenant) // Get the state driver stateDriver, err := utils.GetStateDriver() if err != nil { return err } // if the tenant has associated app profiles, fail the delete profCount := len(tenant.LinkS...
go
func (ac *APIController) TenantDelete(tenant *contivModel.Tenant) error { log.Infof("Received TenantDelete: %+v", tenant) // Get the state driver stateDriver, err := utils.GetStateDriver() if err != nil { return err } // if the tenant has associated app profiles, fail the delete profCount := len(tenant.LinkS...
[ "func", "(", "ac", "*", "APIController", ")", "TenantDelete", "(", "tenant", "*", "contivModel", ".", "Tenant", ")", "error", "{", "log", ".", "Infof", "(", "\"", "\"", ",", "tenant", ")", "\n\n", "// Get the state driver", "stateDriver", ",", "err", ":=",...
// TenantDelete deletes a tenant
[ "TenantDelete", "deletes", "a", "tenant" ]
965773066d2b8ebed3514979949061a03d46fd20
https://github.com/contiv/netplugin/blob/965773066d2b8ebed3514979949061a03d46fd20/netmaster/objApi/apiController.go#L1926-L1977
8,218
contiv/netplugin
netmaster/objApi/apiController.go
BgpCreate
func (ac *APIController) BgpCreate(bgpCfg *contivModel.Bgp) error { log.Infof("Received BgpCreate: %+v", bgpCfg) if bgpCfg.Hostname == "" { return core.Errorf("Invalid host name") } // Get the state driver stateDriver, err := utils.GetStateDriver() if err != nil { return err } // Build bgp config bgpInt...
go
func (ac *APIController) BgpCreate(bgpCfg *contivModel.Bgp) error { log.Infof("Received BgpCreate: %+v", bgpCfg) if bgpCfg.Hostname == "" { return core.Errorf("Invalid host name") } // Get the state driver stateDriver, err := utils.GetStateDriver() if err != nil { return err } // Build bgp config bgpInt...
[ "func", "(", "ac", "*", "APIController", ")", "BgpCreate", "(", "bgpCfg", "*", "contivModel", ".", "Bgp", ")", "error", "{", "log", ".", "Infof", "(", "\"", "\"", ",", "bgpCfg", ")", "\n\n", "if", "bgpCfg", ".", "Hostname", "==", "\"", "\"", "{", "...
//BgpCreate add bgp neighbor
[ "BgpCreate", "add", "bgp", "neighbor" ]
965773066d2b8ebed3514979949061a03d46fd20
https://github.com/contiv/netplugin/blob/965773066d2b8ebed3514979949061a03d46fd20/netmaster/objApi/apiController.go#L1980-L2009
8,219
contiv/netplugin
netmaster/objApi/apiController.go
BgpDelete
func (ac *APIController) BgpDelete(bgpCfg *contivModel.Bgp) error { log.Infof("Received delete for Bgp config on {%+v} ", bgpCfg.Hostname) // Get the state driver stateDriver, err := utils.GetStateDriver() if err != nil { return err } err = master.DeleteBgp(stateDriver, bgpCfg.Hostname) if err != nil { log...
go
func (ac *APIController) BgpDelete(bgpCfg *contivModel.Bgp) error { log.Infof("Received delete for Bgp config on {%+v} ", bgpCfg.Hostname) // Get the state driver stateDriver, err := utils.GetStateDriver() if err != nil { return err } err = master.DeleteBgp(stateDriver, bgpCfg.Hostname) if err != nil { log...
[ "func", "(", "ac", "*", "APIController", ")", "BgpDelete", "(", "bgpCfg", "*", "contivModel", ".", "Bgp", ")", "error", "{", "log", ".", "Infof", "(", "\"", "\"", ",", "bgpCfg", ".", "Hostname", ")", "\n", "// Get the state driver", "stateDriver", ",", "...
//BgpDelete deletes bgp neighbor
[ "BgpDelete", "deletes", "bgp", "neighbor" ]
965773066d2b8ebed3514979949061a03d46fd20
https://github.com/contiv/netplugin/blob/965773066d2b8ebed3514979949061a03d46fd20/netmaster/objApi/apiController.go#L2012-L2027
8,220
contiv/netplugin
netmaster/objApi/apiController.go
BgpUpdate
func (ac *APIController) BgpUpdate(oldbgpCfg *contivModel.Bgp, NewbgpCfg *contivModel.Bgp) error { log.Infof("Received BgpUpdate: %+v", NewbgpCfg) if NewbgpCfg.Hostname == "" { return core.Errorf("Invalid host name") } // Get the state driver stateDriver, err := utils.GetStateDriver() if err != nil { return...
go
func (ac *APIController) BgpUpdate(oldbgpCfg *contivModel.Bgp, NewbgpCfg *contivModel.Bgp) error { log.Infof("Received BgpUpdate: %+v", NewbgpCfg) if NewbgpCfg.Hostname == "" { return core.Errorf("Invalid host name") } // Get the state driver stateDriver, err := utils.GetStateDriver() if err != nil { return...
[ "func", "(", "ac", "*", "APIController", ")", "BgpUpdate", "(", "oldbgpCfg", "*", "contivModel", ".", "Bgp", ",", "NewbgpCfg", "*", "contivModel", ".", "Bgp", ")", "error", "{", "log", ".", "Infof", "(", "\"", "\"", ",", "NewbgpCfg", ")", "\n\n", "if",...
//BgpUpdate updates bgp config
[ "BgpUpdate", "updates", "bgp", "config" ]
965773066d2b8ebed3514979949061a03d46fd20
https://github.com/contiv/netplugin/blob/965773066d2b8ebed3514979949061a03d46fd20/netmaster/objApi/apiController.go#L2030-L2068
8,221
contiv/netplugin
netmaster/objApi/apiController.go
BgpGetOper
func (ac *APIController) BgpGetOper(bgp *contivModel.BgpInspect) error { var obj BgpInspect var host string srvList, err := ac.objdbClient.GetService("netplugin") if err != nil { log.Errorf("Error getting netplugin nodes. Err: %v", err) return err } for _, srv := range srvList { if srv.Hostname == bgp.Con...
go
func (ac *APIController) BgpGetOper(bgp *contivModel.BgpInspect) error { var obj BgpInspect var host string srvList, err := ac.objdbClient.GetService("netplugin") if err != nil { log.Errorf("Error getting netplugin nodes. Err: %v", err) return err } for _, srv := range srvList { if srv.Hostname == bgp.Con...
[ "func", "(", "ac", "*", "APIController", ")", "BgpGetOper", "(", "bgp", "*", "contivModel", ".", "BgpInspect", ")", "error", "{", "var", "obj", "BgpInspect", "\n", "var", "host", "string", "\n\n", "srvList", ",", "err", ":=", "ac", ".", "objdbClient", "....
//BgpGetOper inspects the oper state of bgp object
[ "BgpGetOper", "inspects", "the", "oper", "state", "of", "bgp", "object" ]
965773066d2b8ebed3514979949061a03d46fd20
https://github.com/contiv/netplugin/blob/965773066d2b8ebed3514979949061a03d46fd20/netmaster/objApi/apiController.go#L2071-L2133
8,222
contiv/netplugin
netmaster/objApi/apiController.go
ServiceLBCreate
func (ac *APIController) ServiceLBCreate(serviceCfg *contivModel.ServiceLB) error { log.Infof("Received Service Load Balancer create: %+v", serviceCfg) if serviceCfg.ServiceName == "" { return core.Errorf("Invalid service name") } if len(serviceCfg.Selectors) == 0 { return core.Errorf("Invalid selector optio...
go
func (ac *APIController) ServiceLBCreate(serviceCfg *contivModel.ServiceLB) error { log.Infof("Received Service Load Balancer create: %+v", serviceCfg) if serviceCfg.ServiceName == "" { return core.Errorf("Invalid service name") } if len(serviceCfg.Selectors) == 0 { return core.Errorf("Invalid selector optio...
[ "func", "(", "ac", "*", "APIController", ")", "ServiceLBCreate", "(", "serviceCfg", "*", "contivModel", ".", "ServiceLB", ")", "error", "{", "log", ".", "Infof", "(", "\"", "\"", ",", "serviceCfg", ")", "\n\n", "if", "serviceCfg", ".", "ServiceName", "==",...
//ServiceLBCreate creates service object
[ "ServiceLBCreate", "creates", "service", "object" ]
965773066d2b8ebed3514979949061a03d46fd20
https://github.com/contiv/netplugin/blob/965773066d2b8ebed3514979949061a03d46fd20/netmaster/objApi/apiController.go#L2136-L2213
8,223
contiv/netplugin
netmaster/objApi/apiController.go
ServiceLBUpdate
func (ac *APIController) ServiceLBUpdate(oldServiceCfg *contivModel.ServiceLB, serviceCfg *contivModel.ServiceLB) error { log.Infof("Received Service Load Balancer update: %+v", serviceCfg) err := ac.ServiceLBCreate(serviceCfg) if err != nil { return err } oldServiceCfg.ServiceName = serviceCfg.ServiceName oldS...
go
func (ac *APIController) ServiceLBUpdate(oldServiceCfg *contivModel.ServiceLB, serviceCfg *contivModel.ServiceLB) error { log.Infof("Received Service Load Balancer update: %+v", serviceCfg) err := ac.ServiceLBCreate(serviceCfg) if err != nil { return err } oldServiceCfg.ServiceName = serviceCfg.ServiceName oldS...
[ "func", "(", "ac", "*", "APIController", ")", "ServiceLBUpdate", "(", "oldServiceCfg", "*", "contivModel", ".", "ServiceLB", ",", "serviceCfg", "*", "contivModel", ".", "ServiceLB", ")", "error", "{", "log", ".", "Infof", "(", "\"", "\"", ",", "serviceCfg", ...
//ServiceLBUpdate updates service object
[ "ServiceLBUpdate", "updates", "service", "object" ]
965773066d2b8ebed3514979949061a03d46fd20
https://github.com/contiv/netplugin/blob/965773066d2b8ebed3514979949061a03d46fd20/netmaster/objApi/apiController.go#L2216-L2231
8,224
contiv/netplugin
netmaster/objApi/apiController.go
ServiceLBDelete
func (ac *APIController) ServiceLBDelete(serviceCfg *contivModel.ServiceLB) error { log.Info("Received Service Load Balancer delete : {%+v}", serviceCfg) if serviceCfg.ServiceName == "" { return core.Errorf("Invalid service name") } // Get the state driver stateDriver, err := utils.GetStateDriver() if err !=...
go
func (ac *APIController) ServiceLBDelete(serviceCfg *contivModel.ServiceLB) error { log.Info("Received Service Load Balancer delete : {%+v}", serviceCfg) if serviceCfg.ServiceName == "" { return core.Errorf("Invalid service name") } // Get the state driver stateDriver, err := utils.GetStateDriver() if err !=...
[ "func", "(", "ac", "*", "APIController", ")", "ServiceLBDelete", "(", "serviceCfg", "*", "contivModel", ".", "ServiceLB", ")", "error", "{", "log", ".", "Info", "(", "\"", "\"", ",", "serviceCfg", ")", "\n\n", "if", "serviceCfg", ".", "ServiceName", "==", ...
//ServiceLBDelete deletes service object
[ "ServiceLBDelete", "deletes", "service", "object" ]
965773066d2b8ebed3514979949061a03d46fd20
https://github.com/contiv/netplugin/blob/965773066d2b8ebed3514979949061a03d46fd20/netmaster/objApi/apiController.go#L2234-L2273
8,225
contiv/netplugin
netmaster/objApi/apiController.go
ServiceLBGetOper
func (ac *APIController) ServiceLBGetOper(serviceLB *contivModel.ServiceLBInspect) error { log.Infof("Received Service load balancer inspect : %+v", serviceLB) // Get the state driver stateDriver, err := utils.GetStateDriver() if err != nil { return err } serviceID := master.GetServiceID(serviceLB.Config.Servi...
go
func (ac *APIController) ServiceLBGetOper(serviceLB *contivModel.ServiceLBInspect) error { log.Infof("Received Service load balancer inspect : %+v", serviceLB) // Get the state driver stateDriver, err := utils.GetStateDriver() if err != nil { return err } serviceID := master.GetServiceID(serviceLB.Config.Servi...
[ "func", "(", "ac", "*", "APIController", ")", "ServiceLBGetOper", "(", "serviceLB", "*", "contivModel", ".", "ServiceLBInspect", ")", "error", "{", "log", ".", "Infof", "(", "\"", "\"", ",", "serviceLB", ")", "\n\n", "// Get the state driver", "stateDriver", "...
//ServiceLBGetOper inspects the oper state of service lb object
[ "ServiceLBGetOper", "inspects", "the", "oper", "state", "of", "service", "lb", "object" ]
965773066d2b8ebed3514979949061a03d46fd20
https://github.com/contiv/netplugin/blob/965773066d2b8ebed3514979949061a03d46fd20/netmaster/objApi/apiController.go#L2276-L2320
8,226
contiv/netplugin
netplugin/plugin/netplugin.go
Init
func (p *NetPlugin) Init(pluginConfig Config) error { var err error if pluginConfig.Instance.HostLabel == "" { return core.Errorf("empty host-label passed") } // initialize state driver p.StateDriver, err = utils.GetStateDriver() if err != nil { p.StateDriver, err = utils.NewStateDriver(pluginConfig.Drivers....
go
func (p *NetPlugin) Init(pluginConfig Config) error { var err error if pluginConfig.Instance.HostLabel == "" { return core.Errorf("empty host-label passed") } // initialize state driver p.StateDriver, err = utils.GetStateDriver() if err != nil { p.StateDriver, err = utils.NewStateDriver(pluginConfig.Drivers....
[ "func", "(", "p", "*", "NetPlugin", ")", "Init", "(", "pluginConfig", "Config", ")", "error", "{", "var", "err", "error", "\n", "if", "pluginConfig", ".", "Instance", ".", "HostLabel", "==", "\"", "\"", "{", "return", "core", ".", "Errorf", "(", "\"", ...
// Init initializes the NetPlugin instance via the configuration string passed.
[ "Init", "initializes", "the", "NetPlugin", "instance", "via", "the", "configuration", "string", "passed", "." ]
965773066d2b8ebed3514979949061a03d46fd20
https://github.com/contiv/netplugin/blob/965773066d2b8ebed3514979949061a03d46fd20/netplugin/plugin/netplugin.go#L56-L97
8,227
contiv/netplugin
netplugin/plugin/netplugin.go
Deinit
func (p *NetPlugin) Deinit() { p.Lock() defer p.Unlock() if p.NetworkDriver != nil { p.NetworkDriver.Deinit() p.NetworkDriver = nil } if p.StateDriver != nil { utils.ReleaseStateDriver() p.StateDriver = nil } }
go
func (p *NetPlugin) Deinit() { p.Lock() defer p.Unlock() if p.NetworkDriver != nil { p.NetworkDriver.Deinit() p.NetworkDriver = nil } if p.StateDriver != nil { utils.ReleaseStateDriver() p.StateDriver = nil } }
[ "func", "(", "p", "*", "NetPlugin", ")", "Deinit", "(", ")", "{", "p", ".", "Lock", "(", ")", "\n", "defer", "p", ".", "Unlock", "(", ")", "\n\n", "if", "p", ".", "NetworkDriver", "!=", "nil", "{", "p", ".", "NetworkDriver", ".", "Deinit", "(", ...
// Deinit is a destructor for the NetPlugin configuration.
[ "Deinit", "is", "a", "destructor", "for", "the", "NetPlugin", "configuration", "." ]
965773066d2b8ebed3514979949061a03d46fd20
https://github.com/contiv/netplugin/blob/965773066d2b8ebed3514979949061a03d46fd20/netplugin/plugin/netplugin.go#L100-L112
8,228
contiv/netplugin
netplugin/plugin/netplugin.go
DeleteNetwork
func (p *NetPlugin) DeleteNetwork(id, subnet, nwType, encap string, pktTag, extPktTag int, Gw string, tenant string) error { p.Lock() defer p.Unlock() return p.NetworkDriver.DeleteNetwork(id, subnet, nwType, encap, pktTag, extPktTag, Gw, tenant) }
go
func (p *NetPlugin) DeleteNetwork(id, subnet, nwType, encap string, pktTag, extPktTag int, Gw string, tenant string) error { p.Lock() defer p.Unlock() return p.NetworkDriver.DeleteNetwork(id, subnet, nwType, encap, pktTag, extPktTag, Gw, tenant) }
[ "func", "(", "p", "*", "NetPlugin", ")", "DeleteNetwork", "(", "id", ",", "subnet", ",", "nwType", ",", "encap", "string", ",", "pktTag", ",", "extPktTag", "int", ",", "Gw", "string", ",", "tenant", "string", ")", "error", "{", "p", ".", "Lock", "(",...
// DeleteNetwork deletes a network provided by the ID.
[ "DeleteNetwork", "deletes", "a", "network", "provided", "by", "the", "ID", "." ]
965773066d2b8ebed3514979949061a03d46fd20
https://github.com/contiv/netplugin/blob/965773066d2b8ebed3514979949061a03d46fd20/netplugin/plugin/netplugin.go#L122-L126
8,229
contiv/netplugin
netplugin/plugin/netplugin.go
FetchNetwork
func (p *NetPlugin) FetchNetwork(id string) (core.State, error) { return nil, core.Errorf("Not implemented") }
go
func (p *NetPlugin) FetchNetwork(id string) (core.State, error) { return nil, core.Errorf("Not implemented") }
[ "func", "(", "p", "*", "NetPlugin", ")", "FetchNetwork", "(", "id", "string", ")", "(", "core", ".", "State", ",", "error", ")", "{", "return", "nil", ",", "core", ".", "Errorf", "(", "\"", "\"", ")", "\n", "}" ]
// FetchNetwork retrieves a network's state given an ID.
[ "FetchNetwork", "retrieves", "a", "network", "s", "state", "given", "an", "ID", "." ]
965773066d2b8ebed3514979949061a03d46fd20
https://github.com/contiv/netplugin/blob/965773066d2b8ebed3514979949061a03d46fd20/netplugin/plugin/netplugin.go#L129-L131
8,230
contiv/netplugin
netplugin/plugin/netplugin.go
CreateHostAccPort
func (p *NetPlugin) CreateHostAccPort(portName, globalIP string) (string, error) { p.Lock() defer p.Unlock() return p.NetworkDriver.CreateHostAccPort(portName, globalIP, p.PluginConfig.Instance.HostPvtNW) }
go
func (p *NetPlugin) CreateHostAccPort(portName, globalIP string) (string, error) { p.Lock() defer p.Unlock() return p.NetworkDriver.CreateHostAccPort(portName, globalIP, p.PluginConfig.Instance.HostPvtNW) }
[ "func", "(", "p", "*", "NetPlugin", ")", "CreateHostAccPort", "(", "portName", ",", "globalIP", "string", ")", "(", "string", ",", "error", ")", "{", "p", ".", "Lock", "(", ")", "\n", "defer", "p", ".", "Unlock", "(", ")", "\n", "return", "p", ".",...
// CreateHostAccPort creates a host access port
[ "CreateHostAccPort", "creates", "a", "host", "access", "port" ]
965773066d2b8ebed3514979949061a03d46fd20
https://github.com/contiv/netplugin/blob/965773066d2b8ebed3514979949061a03d46fd20/netplugin/plugin/netplugin.go#L169-L173
8,231
contiv/netplugin
netplugin/plugin/netplugin.go
DeleteHostAccPort
func (p *NetPlugin) DeleteHostAccPort(portName string) error { p.Lock() defer p.Unlock() return p.NetworkDriver.DeleteHostAccPort(portName) }
go
func (p *NetPlugin) DeleteHostAccPort(portName string) error { p.Lock() defer p.Unlock() return p.NetworkDriver.DeleteHostAccPort(portName) }
[ "func", "(", "p", "*", "NetPlugin", ")", "DeleteHostAccPort", "(", "portName", "string", ")", "error", "{", "p", ".", "Lock", "(", ")", "\n", "defer", "p", ".", "Unlock", "(", ")", "\n", "return", "p", ".", "NetworkDriver", ".", "DeleteHostAccPort", "(...
// DeleteHostAccPort creates a host access port
[ "DeleteHostAccPort", "creates", "a", "host", "access", "port" ]
965773066d2b8ebed3514979949061a03d46fd20
https://github.com/contiv/netplugin/blob/965773066d2b8ebed3514979949061a03d46fd20/netplugin/plugin/netplugin.go#L176-L180
8,232
contiv/netplugin
netplugin/plugin/netplugin.go
DeletePeerHost
func (p *NetPlugin) DeletePeerHost(node core.ServiceInfo) error { p.Lock() defer p.Unlock() return p.NetworkDriver.DeletePeerHost(node) }
go
func (p *NetPlugin) DeletePeerHost(node core.ServiceInfo) error { p.Lock() defer p.Unlock() return p.NetworkDriver.DeletePeerHost(node) }
[ "func", "(", "p", "*", "NetPlugin", ")", "DeletePeerHost", "(", "node", "core", ".", "ServiceInfo", ")", "error", "{", "p", ".", "Lock", "(", ")", "\n", "defer", "p", ".", "Unlock", "(", ")", "\n", "return", "p", ".", "NetworkDriver", ".", "DeletePee...
// DeletePeerHost removes a peer host.
[ "DeletePeerHost", "removes", "a", "peer", "host", "." ]
965773066d2b8ebed3514979949061a03d46fd20
https://github.com/contiv/netplugin/blob/965773066d2b8ebed3514979949061a03d46fd20/netplugin/plugin/netplugin.go#L195-L199
8,233
contiv/netplugin
netplugin/plugin/netplugin.go
AddServiceLB
func (p *NetPlugin) AddServiceLB(servicename string, spec *core.ServiceSpec) error { p.Lock() defer p.Unlock() return p.NetworkDriver.AddSvcSpec(servicename, spec) }
go
func (p *NetPlugin) AddServiceLB(servicename string, spec *core.ServiceSpec) error { p.Lock() defer p.Unlock() return p.NetworkDriver.AddSvcSpec(servicename, spec) }
[ "func", "(", "p", "*", "NetPlugin", ")", "AddServiceLB", "(", "servicename", "string", ",", "spec", "*", "core", ".", "ServiceSpec", ")", "error", "{", "p", ".", "Lock", "(", ")", "\n", "defer", "p", ".", "Unlock", "(", ")", "\n", "return", "p", "....
//AddServiceLB adds service
[ "AddServiceLB", "adds", "service" ]
965773066d2b8ebed3514979949061a03d46fd20
https://github.com/contiv/netplugin/blob/965773066d2b8ebed3514979949061a03d46fd20/netplugin/plugin/netplugin.go#L230-L234
8,234
contiv/netplugin
netplugin/plugin/netplugin.go
DeleteServiceLB
func (p *NetPlugin) DeleteServiceLB(servicename string, spec *core.ServiceSpec) error { p.Lock() defer p.Unlock() return p.NetworkDriver.DelSvcSpec(servicename, spec) }
go
func (p *NetPlugin) DeleteServiceLB(servicename string, spec *core.ServiceSpec) error { p.Lock() defer p.Unlock() return p.NetworkDriver.DelSvcSpec(servicename, spec) }
[ "func", "(", "p", "*", "NetPlugin", ")", "DeleteServiceLB", "(", "servicename", "string", ",", "spec", "*", "core", ".", "ServiceSpec", ")", "error", "{", "p", ".", "Lock", "(", ")", "\n", "defer", "p", ".", "Unlock", "(", ")", "\n", "return", "p", ...
//DeleteServiceLB deletes service
[ "DeleteServiceLB", "deletes", "service" ]
965773066d2b8ebed3514979949061a03d46fd20
https://github.com/contiv/netplugin/blob/965773066d2b8ebed3514979949061a03d46fd20/netplugin/plugin/netplugin.go#L237-L241
8,235
contiv/netplugin
netplugin/plugin/netplugin.go
GetEndpointStats
func (p *NetPlugin) GetEndpointStats() ([]byte, error) { p.Lock() defer p.Unlock() return p.NetworkDriver.GetEndpointStats() }
go
func (p *NetPlugin) GetEndpointStats() ([]byte, error) { p.Lock() defer p.Unlock() return p.NetworkDriver.GetEndpointStats() }
[ "func", "(", "p", "*", "NetPlugin", ")", "GetEndpointStats", "(", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "p", ".", "Lock", "(", ")", "\n", "defer", "p", ".", "Unlock", "(", ")", "\n", "return", "p", ".", "NetworkDriver", ".", "GetEnd...
// GetEndpointStats returns all endpoint stats
[ "GetEndpointStats", "returns", "all", "endpoint", "stats" ]
965773066d2b8ebed3514979949061a03d46fd20
https://github.com/contiv/netplugin/blob/965773066d2b8ebed3514979949061a03d46fd20/netplugin/plugin/netplugin.go#L251-L255
8,236
contiv/netplugin
netplugin/plugin/netplugin.go
InspectState
func (p *NetPlugin) InspectState() ([]byte, error) { p.Lock() defer p.Unlock() return p.NetworkDriver.InspectState() }
go
func (p *NetPlugin) InspectState() ([]byte, error) { p.Lock() defer p.Unlock() return p.NetworkDriver.InspectState() }
[ "func", "(", "p", "*", "NetPlugin", ")", "InspectState", "(", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "p", ".", "Lock", "(", ")", "\n", "defer", "p", ".", "Unlock", "(", ")", "\n", "return", "p", ".", "NetworkDriver", ".", "InspectSta...
// InspectState returns current state of the plugin
[ "InspectState", "returns", "current", "state", "of", "the", "plugin" ]
965773066d2b8ebed3514979949061a03d46fd20
https://github.com/contiv/netplugin/blob/965773066d2b8ebed3514979949061a03d46fd20/netplugin/plugin/netplugin.go#L258-L262
8,237
contiv/netplugin
netplugin/plugin/netplugin.go
InspectBgp
func (p *NetPlugin) InspectBgp() ([]byte, error) { p.Lock() defer p.Unlock() return p.NetworkDriver.InspectBgp() }
go
func (p *NetPlugin) InspectBgp() ([]byte, error) { p.Lock() defer p.Unlock() return p.NetworkDriver.InspectBgp() }
[ "func", "(", "p", "*", "NetPlugin", ")", "InspectBgp", "(", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "p", ".", "Lock", "(", ")", "\n", "defer", "p", ".", "Unlock", "(", ")", "\n", "return", "p", ".", "NetworkDriver", ".", "InspectBgp",...
// InspectBgp returns current state of the plugin
[ "InspectBgp", "returns", "current", "state", "of", "the", "plugin" ]
965773066d2b8ebed3514979949061a03d46fd20
https://github.com/contiv/netplugin/blob/965773066d2b8ebed3514979949061a03d46fd20/netplugin/plugin/netplugin.go#L265-L269
8,238
contiv/netplugin
netplugin/plugin/netplugin.go
InspectNameserver
func (p *NetPlugin) InspectNameserver() ([]byte, error) { p.Lock() defer p.Unlock() return p.NetworkDriver.InspectNameserver() }
go
func (p *NetPlugin) InspectNameserver() ([]byte, error) { p.Lock() defer p.Unlock() return p.NetworkDriver.InspectNameserver() }
[ "func", "(", "p", "*", "NetPlugin", ")", "InspectNameserver", "(", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "p", ".", "Lock", "(", ")", "\n", "defer", "p", ".", "Unlock", "(", ")", "\n", "return", "p", ".", "NetworkDriver", ".", "Inspe...
// InspectNameserver returns current state of the nameserver
[ "InspectNameserver", "returns", "current", "state", "of", "the", "nameserver" ]
965773066d2b8ebed3514979949061a03d46fd20
https://github.com/contiv/netplugin/blob/965773066d2b8ebed3514979949061a03d46fd20/netplugin/plugin/netplugin.go#L272-L276
8,239
contiv/netplugin
netplugin/plugin/netplugin.go
GlobalConfigUpdate
func (p *NetPlugin) GlobalConfigUpdate(cfg Config) error { p.Lock() defer p.Unlock() return p.NetworkDriver.GlobalConfigUpdate(cfg.Instance) }
go
func (p *NetPlugin) GlobalConfigUpdate(cfg Config) error { p.Lock() defer p.Unlock() return p.NetworkDriver.GlobalConfigUpdate(cfg.Instance) }
[ "func", "(", "p", "*", "NetPlugin", ")", "GlobalConfigUpdate", "(", "cfg", "Config", ")", "error", "{", "p", ".", "Lock", "(", ")", "\n", "defer", "p", ".", "Unlock", "(", ")", "\n", "return", "p", ".", "NetworkDriver", ".", "GlobalConfigUpdate", "(", ...
//GlobalConfigUpdate update global config
[ "GlobalConfigUpdate", "update", "global", "config" ]
965773066d2b8ebed3514979949061a03d46fd20
https://github.com/contiv/netplugin/blob/965773066d2b8ebed3514979949061a03d46fd20/netplugin/plugin/netplugin.go#L279-L283
8,240
contiv/netplugin
netplugin/plugin/netplugin.go
Reinit
func (p *NetPlugin) Reinit(cfg Config) { var err error p.Lock() defer p.Unlock() if p.NetworkDriver != nil { logrus.Infof("Reinit de-initializing NetworkDriver") p.NetworkDriver.Deinit() p.NetworkDriver = nil } cfg.Instance.StateDriver, _ = utils.GetStateDriver() p.NetworkDriver, err = utils.NewNetworkDr...
go
func (p *NetPlugin) Reinit(cfg Config) { var err error p.Lock() defer p.Unlock() if p.NetworkDriver != nil { logrus.Infof("Reinit de-initializing NetworkDriver") p.NetworkDriver.Deinit() p.NetworkDriver = nil } cfg.Instance.StateDriver, _ = utils.GetStateDriver() p.NetworkDriver, err = utils.NewNetworkDr...
[ "func", "(", "p", "*", "NetPlugin", ")", "Reinit", "(", "cfg", "Config", ")", "{", "var", "err", "error", "\n\n", "p", ".", "Lock", "(", ")", "\n", "defer", "p", ".", "Unlock", "(", ")", "\n", "if", "p", ".", "NetworkDriver", "!=", "nil", "{", ...
//Reinit reinitialize the network driver
[ "Reinit", "reinitialize", "the", "network", "driver" ]
965773066d2b8ebed3514979949061a03d46fd20
https://github.com/contiv/netplugin/blob/965773066d2b8ebed3514979949061a03d46fd20/netplugin/plugin/netplugin.go#L286-L305
8,241
contiv/netplugin
netplugin/plugin/netplugin.go
DelSvcSpec
func (p *NetPlugin) DelSvcSpec(svcName string, spec *core.ServiceSpec) { p.Lock() defer p.Unlock() p.NetworkDriver.DelSvcSpec(svcName, spec) }
go
func (p *NetPlugin) DelSvcSpec(svcName string, spec *core.ServiceSpec) { p.Lock() defer p.Unlock() p.NetworkDriver.DelSvcSpec(svcName, spec) }
[ "func", "(", "p", "*", "NetPlugin", ")", "DelSvcSpec", "(", "svcName", "string", ",", "spec", "*", "core", ".", "ServiceSpec", ")", "{", "p", ".", "Lock", "(", ")", "\n", "defer", "p", ".", "Unlock", "(", ")", "\n", "p", ".", "NetworkDriver", ".", ...
//DelSvcSpec deletes k8 service spec
[ "DelSvcSpec", "deletes", "k8", "service", "spec" ]
965773066d2b8ebed3514979949061a03d46fd20
https://github.com/contiv/netplugin/blob/965773066d2b8ebed3514979949061a03d46fd20/netplugin/plugin/netplugin.go#L371-L375
8,242
contiv/netplugin
netplugin/plugin/netplugin.go
AddPolicyRule
func (p *NetPlugin) AddPolicyRule(id string) error { p.Lock() defer p.Unlock() return p.NetworkDriver.AddPolicyRule(id) }
go
func (p *NetPlugin) AddPolicyRule(id string) error { p.Lock() defer p.Unlock() return p.NetworkDriver.AddPolicyRule(id) }
[ "func", "(", "p", "*", "NetPlugin", ")", "AddPolicyRule", "(", "id", "string", ")", "error", "{", "p", ".", "Lock", "(", ")", "\n", "defer", "p", ".", "Unlock", "(", ")", "\n", "return", "p", ".", "NetworkDriver", ".", "AddPolicyRule", "(", "id", "...
// AddPolicyRule creates a policy rule
[ "AddPolicyRule", "creates", "a", "policy", "rule" ]
965773066d2b8ebed3514979949061a03d46fd20
https://github.com/contiv/netplugin/blob/965773066d2b8ebed3514979949061a03d46fd20/netplugin/plugin/netplugin.go#L378-L382
8,243
contiv/netplugin
netmaster/k8snetwork/networkpolicy.go
InitK8SServiceWatch
func InitK8SServiceWatch(listenAddr string, isLeader func() bool) error { npLog = log.WithField("k8s", "netpolicy") npLog.Infof("Create contiv client at http://%s", listenAddr) contivClient, err := client.NewContivClient("http://" + listenAddr) if err != nil { npLog.Errorf("failed to create contivclient %s", err...
go
func InitK8SServiceWatch(listenAddr string, isLeader func() bool) error { npLog = log.WithField("k8s", "netpolicy") npLog.Infof("Create contiv client at http://%s", listenAddr) contivClient, err := client.NewContivClient("http://" + listenAddr) if err != nil { npLog.Errorf("failed to create contivclient %s", err...
[ "func", "InitK8SServiceWatch", "(", "listenAddr", "string", ",", "isLeader", "func", "(", ")", "bool", ")", "error", "{", "npLog", "=", "log", ".", "WithField", "(", "\"", "\"", ",", "\"", "\"", ")", "\n\n", "npLog", ".", "Infof", "(", "\"", "\"", ",...
// InitK8SServiceWatch monitor k8s services
[ "InitK8SServiceWatch", "monitor", "k8s", "services" ]
965773066d2b8ebed3514979949061a03d46fd20
https://github.com/contiv/netplugin/blob/965773066d2b8ebed3514979949061a03d46fd20/netmaster/k8snetwork/networkpolicy.go#L376-L395
8,244
kellydunn/golang-geo
point.go
MarshalBinary
func (p *Point) MarshalBinary() ([]byte, error) { var buf bytes.Buffer err := binary.Write(&buf, binary.LittleEndian, p.lat) if err != nil { return nil, fmt.Errorf("unable to encode lat %v: %v", p.lat, err) } err = binary.Write(&buf, binary.LittleEndian, p.lng) if err != nil { return nil, fmt.Errorf("unable t...
go
func (p *Point) MarshalBinary() ([]byte, error) { var buf bytes.Buffer err := binary.Write(&buf, binary.LittleEndian, p.lat) if err != nil { return nil, fmt.Errorf("unable to encode lat %v: %v", p.lat, err) } err = binary.Write(&buf, binary.LittleEndian, p.lng) if err != nil { return nil, fmt.Errorf("unable t...
[ "func", "(", "p", "*", "Point", ")", "MarshalBinary", "(", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "var", "buf", "bytes", ".", "Buffer", "\n", "err", ":=", "binary", ".", "Write", "(", "&", "buf", ",", "binary", ".", "LittleEndian", "...
// MarshalBinary renders the current point to a byte slice. // Implements the encoding.BinaryMarshaler Interface.
[ "MarshalBinary", "renders", "the", "current", "point", "to", "a", "byte", "slice", ".", "Implements", "the", "encoding", ".", "BinaryMarshaler", "Interface", "." ]
2c6d5d781da2b42e60f1d7507c1055ef625d8652
https://github.com/kellydunn/golang-geo/blob/2c6d5d781da2b42e60f1d7507c1055ef625d8652/point.go#L130-L142
8,245
kellydunn/golang-geo
point.go
MarshalJSON
func (p *Point) MarshalJSON() ([]byte, error) { res := fmt.Sprintf(`{"lat":%v, "lng":%v}`, p.lat, p.lng) return []byte(res), nil }
go
func (p *Point) MarshalJSON() ([]byte, error) { res := fmt.Sprintf(`{"lat":%v, "lng":%v}`, p.lat, p.lng) return []byte(res), nil }
[ "func", "(", "p", "*", "Point", ")", "MarshalJSON", "(", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "res", ":=", "fmt", ".", "Sprintf", "(", "`{\"lat\":%v, \"lng\":%v}`", ",", "p", ".", "lat", ",", "p", ".", "lng", ")", "\n", "return", "...
// MarshalJSON renders the current Point to valid JSON. // Implements the json.Marshaller Interface.
[ "MarshalJSON", "renders", "the", "current", "Point", "to", "valid", "JSON", ".", "Implements", "the", "json", ".", "Marshaller", "Interface", "." ]
2c6d5d781da2b42e60f1d7507c1055ef625d8652
https://github.com/kellydunn/golang-geo/blob/2c6d5d781da2b42e60f1d7507c1055ef625d8652/point.go#L166-L169
8,246
kellydunn/golang-geo
point.go
UnmarshalJSON
func (p *Point) UnmarshalJSON(data []byte) error { // TODO throw an error if there is an issue parsing the body. dec := json.NewDecoder(bytes.NewReader(data)) var values map[string]float64 err := dec.Decode(&values) if err != nil { log.Print(err) return err } *p = *NewPoint(values["lat"], values["lng"]) ...
go
func (p *Point) UnmarshalJSON(data []byte) error { // TODO throw an error if there is an issue parsing the body. dec := json.NewDecoder(bytes.NewReader(data)) var values map[string]float64 err := dec.Decode(&values) if err != nil { log.Print(err) return err } *p = *NewPoint(values["lat"], values["lng"]) ...
[ "func", "(", "p", "*", "Point", ")", "UnmarshalJSON", "(", "data", "[", "]", "byte", ")", "error", "{", "// TODO throw an error if there is an issue parsing the body.", "dec", ":=", "json", ".", "NewDecoder", "(", "bytes", ".", "NewReader", "(", "data", ")", "...
// UnmarshalJSON decodes the current Point from a JSON body. // Throws an error if the body of the point cannot be interpreted by the JSON body
[ "UnmarshalJSON", "decodes", "the", "current", "Point", "from", "a", "JSON", "body", ".", "Throws", "an", "error", "if", "the", "body", "of", "the", "point", "cannot", "be", "interpreted", "by", "the", "JSON", "body" ]
2c6d5d781da2b42e60f1d7507c1055ef625d8652
https://github.com/kellydunn/golang-geo/blob/2c6d5d781da2b42e60f1d7507c1055ef625d8652/point.go#L173-L187
8,247
kellydunn/golang-geo
geo.go
HandleWithSQL
func HandleWithSQL() (*SQLMapper, error) { sqlConf, sqlConfErr := GetSQLConf() if sqlConfErr == nil { s := &SQLMapper{conf: sqlConf} db, err := sql.Open(s.conf.driver, s.conf.openStr) if err != nil { panic(err) } s.sqlConn = db return s, err } return nil, sqlConfErr }
go
func HandleWithSQL() (*SQLMapper, error) { sqlConf, sqlConfErr := GetSQLConf() if sqlConfErr == nil { s := &SQLMapper{conf: sqlConf} db, err := sql.Open(s.conf.driver, s.conf.openStr) if err != nil { panic(err) } s.sqlConn = db return s, err } return nil, sqlConfErr }
[ "func", "HandleWithSQL", "(", ")", "(", "*", "SQLMapper", ",", "error", ")", "{", "sqlConf", ",", "sqlConfErr", ":=", "GetSQLConf", "(", ")", "\n", "if", "sqlConfErr", "==", "nil", "{", "s", ":=", "&", "SQLMapper", "{", "conf", ":", "sqlConf", "}", "...
// HandleWithSQL retrieves the SQL configuration specified in config.yml // that resides at the root level of the project. // Returns a pointer to a SQLMapper if successful, or an error // if there is an issue opening a database connection.
[ "HandleWithSQL", "retrieves", "the", "SQL", "configuration", "specified", "in", "config", ".", "yml", "that", "resides", "at", "the", "root", "level", "of", "the", "project", ".", "Returns", "a", "pointer", "to", "a", "SQLMapper", "if", "successful", "or", "...
2c6d5d781da2b42e60f1d7507c1055ef625d8652
https://github.com/kellydunn/golang-geo/blob/2c6d5d781da2b42e60f1d7507c1055ef625d8652/geo.go#L14-L29
8,248
kellydunn/golang-geo
opencage_geocoder.go
Geocode
func (g *OpenCageGeocoder) Geocode(address string) (*Point, error) { queryStr, err := opencageGeocodeQueryStr(address) if err != nil { return nil, err } data, err := g.Request(queryStr) if err != nil { return nil, err } res := &opencageGeocodeResponse{} json.Unmarshal(data, res) if len(res.Results) == ...
go
func (g *OpenCageGeocoder) Geocode(address string) (*Point, error) { queryStr, err := opencageGeocodeQueryStr(address) if err != nil { return nil, err } data, err := g.Request(queryStr) if err != nil { return nil, err } res := &opencageGeocodeResponse{} json.Unmarshal(data, res) if len(res.Results) == ...
[ "func", "(", "g", "*", "OpenCageGeocoder", ")", "Geocode", "(", "address", "string", ")", "(", "*", "Point", ",", "error", ")", "{", "queryStr", ",", "err", ":=", "opencageGeocodeQueryStr", "(", "address", ")", "\n", "if", "err", "!=", "nil", "{", "ret...
// Geocode returns the first point returned by OpenCage's geocoding service or an error // if one occurs during the geocoding request.
[ "Geocode", "returns", "the", "first", "point", "returned", "by", "OpenCage", "s", "geocoding", "service", "or", "an", "error", "if", "one", "occurs", "during", "the", "geocoding", "request", "." ]
2c6d5d781da2b42e60f1d7507c1055ef625d8652
https://github.com/kellydunn/golang-geo/blob/2c6d5d781da2b42e60f1d7507c1055ef625d8652/opencage_geocoder.go#L84-L112
8,249
kellydunn/golang-geo
mapquest_geocoder.go
Geocode
func (g *MapQuestGeocoder) Geocode(address string) (*Point, error) { queryStr, err := mapquestGeocodeQueryStr(address) if err != nil { return nil, err } data, err := g.Request(queryStr) if err != nil { return nil, err } res := []*mapQuestGeocodeResponse{} json.Unmarshal(data, &res) if len(res) == 0 { ...
go
func (g *MapQuestGeocoder) Geocode(address string) (*Point, error) { queryStr, err := mapquestGeocodeQueryStr(address) if err != nil { return nil, err } data, err := g.Request(queryStr) if err != nil { return nil, err } res := []*mapQuestGeocodeResponse{} json.Unmarshal(data, &res) if len(res) == 0 { ...
[ "func", "(", "g", "*", "MapQuestGeocoder", ")", "Geocode", "(", "address", "string", ")", "(", "*", "Point", ",", "error", ")", "{", "queryStr", ",", "err", ":=", "mapquestGeocodeQueryStr", "(", "address", ")", "\n", "if", "err", "!=", "nil", "{", "ret...
// Geocode returns the first point returned by MapQuest's geocoding service or an error // if one occurs during the geocoding request.
[ "Geocode", "returns", "the", "first", "point", "returned", "by", "MapQuest", "s", "geocoding", "service", "or", "an", "error", "if", "one", "occurs", "during", "the", "geocoding", "request", "." ]
2c6d5d781da2b42e60f1d7507c1055ef625d8652
https://github.com/kellydunn/golang-geo/blob/2c6d5d781da2b42e60f1d7507c1055ef625d8652/mapquest_geocoder.go#L84-L119
8,250
kellydunn/golang-geo
sql_conf.go
confFromYamlFile
func confFromYamlFile(config *yaml.File, goEnv string) (*SQLConf, error) { // TODO Refactor this into a more generic method of retrieving info // Get driver driver, driveError := config.Get(fmt.Sprintf("%s.driver", goEnv)) if driveError != nil { return nil, driveError } // Get openStr openStr, openStrError ...
go
func confFromYamlFile(config *yaml.File, goEnv string) (*SQLConf, error) { // TODO Refactor this into a more generic method of retrieving info // Get driver driver, driveError := config.Get(fmt.Sprintf("%s.driver", goEnv)) if driveError != nil { return nil, driveError } // Get openStr openStr, openStrError ...
[ "func", "confFromYamlFile", "(", "config", "*", "yaml", ".", "File", ",", "goEnv", "string", ")", "(", "*", "SQLConf", ",", "error", ")", "{", "// TODO Refactor this into a more generic method of retrieving info", "// Get driver", "driver", ",", "driveError", ":=", ...
// Creates a new SQLConf and returns a pointer to it. // If it encounters an error during parsing the file, // it will return an error instead.
[ "Creates", "a", "new", "SQLConf", "and", "returns", "a", "pointer", "to", "it", ".", "If", "it", "encounters", "an", "error", "during", "parsing", "the", "file", "it", "will", "return", "an", "error", "instead", "." ]
2c6d5d781da2b42e60f1d7507c1055ef625d8652
https://github.com/kellydunn/golang-geo/blob/2c6d5d781da2b42e60f1d7507c1055ef625d8652/sql_conf.go#L84-L121
8,251
kellydunn/golang-geo
polygon.go
Contains
func (p *Polygon) Contains(point *Point) bool { if !p.IsClosed() { return false } start := len(p.points) - 1 end := 0 contains := p.intersectsWithRaycast(point, p.points[start], p.points[end]) for i := 1; i < len(p.points); i++ { if p.intersectsWithRaycast(point, p.points[i-1], p.points[i]) { contains =...
go
func (p *Polygon) Contains(point *Point) bool { if !p.IsClosed() { return false } start := len(p.points) - 1 end := 0 contains := p.intersectsWithRaycast(point, p.points[start], p.points[end]) for i := 1; i < len(p.points); i++ { if p.intersectsWithRaycast(point, p.points[i-1], p.points[i]) { contains =...
[ "func", "(", "p", "*", "Polygon", ")", "Contains", "(", "point", "*", "Point", ")", "bool", "{", "if", "!", "p", ".", "IsClosed", "(", ")", "{", "return", "false", "\n", "}", "\n\n", "start", ":=", "len", "(", "p", ".", "points", ")", "-", "1",...
// Contains returns whether or not the current Polygon contains the passed in Point.
[ "Contains", "returns", "whether", "or", "not", "the", "current", "Polygon", "contains", "the", "passed", "in", "Point", "." ]
2c6d5d781da2b42e60f1d7507c1055ef625d8652
https://github.com/kellydunn/golang-geo/blob/2c6d5d781da2b42e60f1d7507c1055ef625d8652/polygon.go#L46-L63
8,252
remeh/sizedwaitgroup
sizedwaitgroup.go
New
func New(limit int) SizedWaitGroup { size := math.MaxInt32 // 2^32 - 1 if limit > 0 { size = limit } return SizedWaitGroup{ Size: size, current: make(chan struct{}, size), wg: sync.WaitGroup{}, } }
go
func New(limit int) SizedWaitGroup { size := math.MaxInt32 // 2^32 - 1 if limit > 0 { size = limit } return SizedWaitGroup{ Size: size, current: make(chan struct{}, size), wg: sync.WaitGroup{}, } }
[ "func", "New", "(", "limit", "int", ")", "SizedWaitGroup", "{", "size", ":=", "math", ".", "MaxInt32", "// 2^32 - 1", "\n", "if", "limit", ">", "0", "{", "size", "=", "limit", "\n", "}", "\n", "return", "SizedWaitGroup", "{", "Size", ":", "size", ",", ...
// New creates a SizedWaitGroup. // The limit parameter is the maximum amount of // goroutines which can be started concurrently.
[ "New", "creates", "a", "SizedWaitGroup", ".", "The", "limit", "parameter", "is", "the", "maximum", "amount", "of", "goroutines", "which", "can", "be", "started", "concurrently", "." ]
5e7302b12ccef91dce9fde2f5bda6d5c7ea5d2eb
https://github.com/remeh/sizedwaitgroup/blob/5e7302b12ccef91dce9fde2f5bda6d5c7ea5d2eb/sizedwaitgroup.go#L31-L42
8,253
remeh/sizedwaitgroup
sizedwaitgroup.go
AddWithContext
func (s *SizedWaitGroup) AddWithContext(ctx context.Context) error { select { case <-ctx.Done(): return ctx.Err() case s.current <- struct{}{}: break } s.wg.Add(1) return nil }
go
func (s *SizedWaitGroup) AddWithContext(ctx context.Context) error { select { case <-ctx.Done(): return ctx.Err() case s.current <- struct{}{}: break } s.wg.Add(1) return nil }
[ "func", "(", "s", "*", "SizedWaitGroup", ")", "AddWithContext", "(", "ctx", "context", ".", "Context", ")", "error", "{", "select", "{", "case", "<-", "ctx", ".", "Done", "(", ")", ":", "return", "ctx", ".", "Err", "(", ")", "\n", "case", "s", ".",...
// AddWithContext increments the internal WaitGroup counter. // It can be blocking if the limit of spawned goroutines // has been reached. It will stop blocking when Done is // been called, or when the context is canceled. Returns nil on // success or an error if the context is canceled before the lock // is acquired. ...
[ "AddWithContext", "increments", "the", "internal", "WaitGroup", "counter", ".", "It", "can", "be", "blocking", "if", "the", "limit", "of", "spawned", "goroutines", "has", "been", "reached", ".", "It", "will", "stop", "blocking", "when", "Done", "is", "been", ...
5e7302b12ccef91dce9fde2f5bda6d5c7ea5d2eb
https://github.com/remeh/sizedwaitgroup/blob/5e7302b12ccef91dce9fde2f5bda6d5c7ea5d2eb/sizedwaitgroup.go#L62-L71
8,254
tidwall/pretty
pretty.go
PrettyOptions
func PrettyOptions(json []byte, opts *Options) []byte { if opts == nil { opts = DefaultOptions } buf := make([]byte, 0, len(json)) if len(opts.Prefix) != 0 { buf = append(buf, opts.Prefix...) } buf, _, _, _ = appendPrettyAny(buf, json, 0, true, opts.Width, opts.Prefix, opts.Indent, opts.SortKeys, 0, 0, -1...
go
func PrettyOptions(json []byte, opts *Options) []byte { if opts == nil { opts = DefaultOptions } buf := make([]byte, 0, len(json)) if len(opts.Prefix) != 0 { buf = append(buf, opts.Prefix...) } buf, _, _, _ = appendPrettyAny(buf, json, 0, true, opts.Width, opts.Prefix, opts.Indent, opts.SortKeys, 0, 0, -1...
[ "func", "PrettyOptions", "(", "json", "[", "]", "byte", ",", "opts", "*", "Options", ")", "[", "]", "byte", "{", "if", "opts", "==", "nil", "{", "opts", "=", "DefaultOptions", "\n", "}", "\n", "buf", ":=", "make", "(", "[", "]", "byte", ",", "0",...
// PrettyOptions is like Pretty but with customized options.
[ "PrettyOptions", "is", "like", "Pretty", "but", "with", "customized", "options", "." ]
1166b9ac2b65e46a43d8618d30d1554f4652d49b
https://github.com/tidwall/pretty/blob/1166b9ac2b65e46a43d8618d30d1554f4652d49b/pretty.go#L31-L46
8,255
tidwall/pretty
pretty.go
Ugly
func Ugly(json []byte) []byte { buf := make([]byte, 0, len(json)) return ugly(buf, json) }
go
func Ugly(json []byte) []byte { buf := make([]byte, 0, len(json)) return ugly(buf, json) }
[ "func", "Ugly", "(", "json", "[", "]", "byte", ")", "[", "]", "byte", "{", "buf", ":=", "make", "(", "[", "]", "byte", ",", "0", ",", "len", "(", "json", ")", ")", "\n", "return", "ugly", "(", "buf", ",", "json", ")", "\n", "}" ]
// Ugly removes insignificant space characters from the input json byte slice // and returns the compacted result.
[ "Ugly", "removes", "insignificant", "space", "characters", "from", "the", "input", "json", "byte", "slice", "and", "returns", "the", "compacted", "result", "." ]
1166b9ac2b65e46a43d8618d30d1554f4652d49b
https://github.com/tidwall/pretty/blob/1166b9ac2b65e46a43d8618d30d1554f4652d49b/pretty.go#L50-L53
8,256
klauspost/compress
flate/deflate.go
writeBlockSkip
func (d *compressor) writeBlockSkip(tok tokens, index int, eof bool) error { if index > 0 || eof { if d.blockStart <= index { window := d.window[d.blockStart:index] // If we removed less than a 64th of all literals // we huffman compress the block. if int(tok.n) > len(window)-int(tok.n>>6) { d.w.writ...
go
func (d *compressor) writeBlockSkip(tok tokens, index int, eof bool) error { if index > 0 || eof { if d.blockStart <= index { window := d.window[d.blockStart:index] // If we removed less than a 64th of all literals // we huffman compress the block. if int(tok.n) > len(window)-int(tok.n>>6) { d.w.writ...
[ "func", "(", "d", "*", "compressor", ")", "writeBlockSkip", "(", "tok", "tokens", ",", "index", "int", ",", "eof", "bool", ")", "error", "{", "if", "index", ">", "0", "||", "eof", "{", "if", "d", ".", "blockStart", "<=", "index", "{", "window", ":=...
// writeBlockSkip writes the current block and uses the number of tokens // to determine if the block should be stored on no matches, or // only huffman encoded.
[ "writeBlockSkip", "writes", "the", "current", "block", "and", "uses", "the", "number", "of", "tokens", "to", "determine", "if", "the", "block", "should", "be", "stored", "on", "no", "matches", "or", "only", "huffman", "encoded", "." ]
ae52aff18558bd92cbe681549bfe9e8cbffd5903
https://github.com/klauspost/compress/blob/ae52aff18558bd92cbe681549bfe9e8cbffd5903/flate/deflate.go#L178-L197
8,257
klauspost/compress
flate/deflate.go
findMatch
func (d *compressor) findMatch(pos int, prevHead int, prevLength int, lookahead int) (length, offset int, ok bool) { minMatchLook := maxMatchLength if lookahead < minMatchLook { minMatchLook = lookahead } win := d.window[0 : pos+minMatchLook] // We quit when we get a match that's at least nice long nice := le...
go
func (d *compressor) findMatch(pos int, prevHead int, prevLength int, lookahead int) (length, offset int, ok bool) { minMatchLook := maxMatchLength if lookahead < minMatchLook { minMatchLook = lookahead } win := d.window[0 : pos+minMatchLook] // We quit when we get a match that's at least nice long nice := le...
[ "func", "(", "d", "*", "compressor", ")", "findMatch", "(", "pos", "int", ",", "prevHead", "int", ",", "prevLength", "int", ",", "lookahead", "int", ")", "(", "length", ",", "offset", "int", ",", "ok", "bool", ")", "{", "minMatchLook", ":=", "maxMatchL...
// Try to find a match starting at index whose length is greater than prevSize. // We only look at chainCount possibilities before giving up. // pos = d.index, prevHead = d.chainHead-d.hashOffset, prevLength=minMatchLength-1, lookahead
[ "Try", "to", "find", "a", "match", "starting", "at", "index", "whose", "length", "is", "greater", "than", "prevSize", ".", "We", "only", "look", "at", "chainCount", "possibilities", "before", "giving", "up", ".", "pos", "=", "d", ".", "index", "prevHead", ...
ae52aff18558bd92cbe681549bfe9e8cbffd5903
https://github.com/klauspost/compress/blob/ae52aff18558bd92cbe681549bfe9e8cbffd5903/flate/deflate.go#L254-L304
8,258
klauspost/compress
flate/deflate.go
bulkHash4
func bulkHash4(b []byte, dst []uint32) { if len(b) < minMatchLength { return } hb := uint32(b[3]) | uint32(b[2])<<8 | uint32(b[1])<<16 | uint32(b[0])<<24 dst[0] = (hb * hashmul) >> (32 - hashBits) end := len(b) - minMatchLength + 1 for i := 1; i < end; i++ { hb = (hb << 8) | uint32(b[i+3]) dst[i] = (hb * ha...
go
func bulkHash4(b []byte, dst []uint32) { if len(b) < minMatchLength { return } hb := uint32(b[3]) | uint32(b[2])<<8 | uint32(b[1])<<16 | uint32(b[0])<<24 dst[0] = (hb * hashmul) >> (32 - hashBits) end := len(b) - minMatchLength + 1 for i := 1; i < end; i++ { hb = (hb << 8) | uint32(b[i+3]) dst[i] = (hb * ha...
[ "func", "bulkHash4", "(", "b", "[", "]", "byte", ",", "dst", "[", "]", "uint32", ")", "{", "if", "len", "(", "b", ")", "<", "minMatchLength", "{", "return", "\n", "}", "\n", "hb", ":=", "uint32", "(", "b", "[", "3", "]", ")", "|", "uint32", "...
// bulkHash4 will compute hashes using the same // algorithm as hash4
[ "bulkHash4", "will", "compute", "hashes", "using", "the", "same", "algorithm", "as", "hash4" ]
ae52aff18558bd92cbe681549bfe9e8cbffd5903
https://github.com/klauspost/compress/blob/ae52aff18558bd92cbe681549bfe9e8cbffd5903/flate/deflate.go#L380-L391
8,259
klauspost/compress
flate/deflate.go
matchLen
func matchLen(a, b []byte, max int) int { a = a[:max] b = b[:len(a)] for i, av := range a { if b[i] != av { return i } } return max }
go
func matchLen(a, b []byte, max int) int { a = a[:max] b = b[:len(a)] for i, av := range a { if b[i] != av { return i } } return max }
[ "func", "matchLen", "(", "a", ",", "b", "[", "]", "byte", ",", "max", "int", ")", "int", "{", "a", "=", "a", "[", ":", "max", "]", "\n", "b", "=", "b", "[", ":", "len", "(", "a", ")", "]", "\n", "for", "i", ",", "av", ":=", "range", "a"...
// matchLen returns the number of matching bytes in a and b // up to length 'max'. Both slices must be at least 'max' // bytes in size.
[ "matchLen", "returns", "the", "number", "of", "matching", "bytes", "in", "a", "and", "b", "up", "to", "length", "max", ".", "Both", "slices", "must", "be", "at", "least", "max", "bytes", "in", "size", "." ]
ae52aff18558bd92cbe681549bfe9e8cbffd5903
https://github.com/klauspost/compress/blob/ae52aff18558bd92cbe681549bfe9e8cbffd5903/flate/deflate.go#L396-L405
8,260
klauspost/compress
flate/deflate.go
fillBlock
func (d *compressor) fillBlock(b []byte) int { n := copy(d.window[d.windowEnd:], b) d.windowEnd += n return n }
go
func (d *compressor) fillBlock(b []byte) int { n := copy(d.window[d.windowEnd:], b) d.windowEnd += n return n }
[ "func", "(", "d", "*", "compressor", ")", "fillBlock", "(", "b", "[", "]", "byte", ")", "int", "{", "n", ":=", "copy", "(", "d", ".", "window", "[", "d", ".", "windowEnd", ":", "]", ",", "b", ")", "\n", "d", ".", "windowEnd", "+=", "n", "\n",...
// fillWindow will fill the buffer with data for huffman-only compression. // The number of bytes copied is returned.
[ "fillWindow", "will", "fill", "the", "buffer", "with", "data", "for", "huffman", "-", "only", "compression", ".", "The", "number", "of", "bytes", "copied", "is", "returned", "." ]
ae52aff18558bd92cbe681549bfe9e8cbffd5903
https://github.com/klauspost/compress/blob/ae52aff18558bd92cbe681549bfe9e8cbffd5903/flate/deflate.go#L1062-L1066
8,261
klauspost/compress
flate/deflate.go
write
func (d *compressor) write(b []byte) (n int, err error) { if d.err != nil { return 0, d.err } n = len(b) for len(b) > 0 { d.step(d) b = b[d.fill(d, b):] if d.err != nil { return 0, d.err } } return n, d.err }
go
func (d *compressor) write(b []byte) (n int, err error) { if d.err != nil { return 0, d.err } n = len(b) for len(b) > 0 { d.step(d) b = b[d.fill(d, b):] if d.err != nil { return 0, d.err } } return n, d.err }
[ "func", "(", "d", "*", "compressor", ")", "write", "(", "b", "[", "]", "byte", ")", "(", "n", "int", ",", "err", "error", ")", "{", "if", "d", ".", "err", "!=", "nil", "{", "return", "0", ",", "d", ".", "err", "\n", "}", "\n", "n", "=", "...
// write will add input byte to the stream. // Unless an error occurs all bytes will be consumed.
[ "write", "will", "add", "input", "byte", "to", "the", "stream", ".", "Unless", "an", "error", "occurs", "all", "bytes", "will", "be", "consumed", "." ]
ae52aff18558bd92cbe681549bfe9e8cbffd5903
https://github.com/klauspost/compress/blob/ae52aff18558bd92cbe681549bfe9e8cbffd5903/flate/deflate.go#L1127-L1140
8,262
klauspost/compress
flate/deflate.go
reset
func (d *compressor) reset(w io.Writer) { d.w.reset(w) d.sync = false d.err = nil // We only need to reset a few things for Snappy. if d.snap != nil { d.snap.Reset() d.windowEnd = 0 d.tokens.n = 0 return } switch d.compressionLevel.chain { case 0: // level was NoCompression or ConstantCompresssion. ...
go
func (d *compressor) reset(w io.Writer) { d.w.reset(w) d.sync = false d.err = nil // We only need to reset a few things for Snappy. if d.snap != nil { d.snap.Reset() d.windowEnd = 0 d.tokens.n = 0 return } switch d.compressionLevel.chain { case 0: // level was NoCompression or ConstantCompresssion. ...
[ "func", "(", "d", "*", "compressor", ")", "reset", "(", "w", "io", ".", "Writer", ")", "{", "d", ".", "w", ".", "reset", "(", "w", ")", "\n", "d", ".", "sync", "=", "false", "\n", "d", ".", "err", "=", "nil", "\n", "// We only need to reset a few...
// reset the state of the compressor.
[ "reset", "the", "state", "of", "the", "compressor", "." ]
ae52aff18558bd92cbe681549bfe9e8cbffd5903
https://github.com/klauspost/compress/blob/ae52aff18558bd92cbe681549bfe9e8cbffd5903/flate/deflate.go#L1202-L1235
8,263
klauspost/compress
flate/deflate.go
NewWriterDict
func NewWriterDict(w io.Writer, level int, dict []byte) (*Writer, error) { dw := &dictWriter{w} zw, err := NewWriter(dw, level) if err != nil { return nil, err } zw.d.fillWindow(dict) zw.dict = append(zw.dict, dict...) // duplicate dictionary for Reset method. return zw, err }
go
func NewWriterDict(w io.Writer, level int, dict []byte) (*Writer, error) { dw := &dictWriter{w} zw, err := NewWriter(dw, level) if err != nil { return nil, err } zw.d.fillWindow(dict) zw.dict = append(zw.dict, dict...) // duplicate dictionary for Reset method. return zw, err }
[ "func", "NewWriterDict", "(", "w", "io", ".", "Writer", ",", "level", "int", ",", "dict", "[", "]", "byte", ")", "(", "*", "Writer", ",", "error", ")", "{", "dw", ":=", "&", "dictWriter", "{", "w", "}", "\n", "zw", ",", "err", ":=", "NewWriter", ...
// NewWriterDict is like NewWriter but initializes the new // Writer with a preset dictionary. The returned Writer behaves // as if the dictionary had been written to it without producing // any compressed output. The compressed data written to w // can only be decompressed by a Reader initialized with the // same di...
[ "NewWriterDict", "is", "like", "NewWriter", "but", "initializes", "the", "new", "Writer", "with", "a", "preset", "dictionary", ".", "The", "returned", "Writer", "behaves", "as", "if", "the", "dictionary", "had", "been", "written", "to", "it", "without", "produ...
ae52aff18558bd92cbe681549bfe9e8cbffd5903
https://github.com/klauspost/compress/blob/ae52aff18558bd92cbe681549bfe9e8cbffd5903/flate/deflate.go#L1279-L1288
8,264
klauspost/compress
flate/deflate.go
Write
func (w *Writer) Write(data []byte) (n int, err error) { return w.d.write(data) }
go
func (w *Writer) Write(data []byte) (n int, err error) { return w.d.write(data) }
[ "func", "(", "w", "*", "Writer", ")", "Write", "(", "data", "[", "]", "byte", ")", "(", "n", "int", ",", "err", "error", ")", "{", "return", "w", ".", "d", ".", "write", "(", "data", ")", "\n", "}" ]
// Write writes data to w, which will eventually write the // compressed form of data to its underlying writer.
[ "Write", "writes", "data", "to", "w", "which", "will", "eventually", "write", "the", "compressed", "form", "of", "data", "to", "its", "underlying", "writer", "." ]
ae52aff18558bd92cbe681549bfe9e8cbffd5903
https://github.com/klauspost/compress/blob/ae52aff18558bd92cbe681549bfe9e8cbffd5903/flate/deflate.go#L1307-L1309
8,265
klauspost/compress
flate/deflate.go
Reset
func (w *Writer) Reset(dst io.Writer) { if dw, ok := w.d.w.writer.(*dictWriter); ok { // w was created with NewWriterDict dw.w = dst w.d.reset(dw) w.d.fillWindow(w.dict) } else { // w was created with NewWriter w.d.reset(dst) } }
go
func (w *Writer) Reset(dst io.Writer) { if dw, ok := w.d.w.writer.(*dictWriter); ok { // w was created with NewWriterDict dw.w = dst w.d.reset(dw) w.d.fillWindow(w.dict) } else { // w was created with NewWriter w.d.reset(dst) } }
[ "func", "(", "w", "*", "Writer", ")", "Reset", "(", "dst", "io", ".", "Writer", ")", "{", "if", "dw", ",", "ok", ":=", "w", ".", "d", ".", "w", ".", "writer", ".", "(", "*", "dictWriter", ")", ";", "ok", "{", "// w was created with NewWriterDict", ...
// Reset discards the writer's state and makes it equivalent to // the result of NewWriter or NewWriterDict called with dst // and w's level and dictionary.
[ "Reset", "discards", "the", "writer", "s", "state", "and", "makes", "it", "equivalent", "to", "the", "result", "of", "NewWriter", "or", "NewWriterDict", "called", "with", "dst", "and", "w", "s", "level", "and", "dictionary", "." ]
ae52aff18558bd92cbe681549bfe9e8cbffd5903
https://github.com/klauspost/compress/blob/ae52aff18558bd92cbe681549bfe9e8cbffd5903/flate/deflate.go#L1334-L1344
8,266
klauspost/compress
flate/deflate.go
ResetDict
func (w *Writer) ResetDict(dst io.Writer, dict []byte) { w.dict = dict w.d.reset(dst) w.d.fillWindow(w.dict) }
go
func (w *Writer) ResetDict(dst io.Writer, dict []byte) { w.dict = dict w.d.reset(dst) w.d.fillWindow(w.dict) }
[ "func", "(", "w", "*", "Writer", ")", "ResetDict", "(", "dst", "io", ".", "Writer", ",", "dict", "[", "]", "byte", ")", "{", "w", ".", "dict", "=", "dict", "\n", "w", ".", "d", ".", "reset", "(", "dst", ")", "\n", "w", ".", "d", ".", "fillW...
// ResetDict discards the writer's state and makes it equivalent to // the result of NewWriter or NewWriterDict called with dst // and w's level, but sets a specific dictionary.
[ "ResetDict", "discards", "the", "writer", "s", "state", "and", "makes", "it", "equivalent", "to", "the", "result", "of", "NewWriter", "or", "NewWriterDict", "called", "with", "dst", "and", "w", "s", "level", "but", "sets", "a", "specific", "dictionary", "." ...
ae52aff18558bd92cbe681549bfe9e8cbffd5903
https://github.com/klauspost/compress/blob/ae52aff18558bd92cbe681549bfe9e8cbffd5903/flate/deflate.go#L1349-L1353
8,267
klauspost/compress
gzip/gunzip.go
noEOF
func noEOF(err error) error { if err == io.EOF { return io.ErrUnexpectedEOF } return err }
go
func noEOF(err error) error { if err == io.EOF { return io.ErrUnexpectedEOF } return err }
[ "func", "noEOF", "(", "err", "error", ")", "error", "{", "if", "err", "==", "io", ".", "EOF", "{", "return", "io", ".", "ErrUnexpectedEOF", "\n", "}", "\n", "return", "err", "\n", "}" ]
// noEOF converts io.EOF to io.ErrUnexpectedEOF.
[ "noEOF", "converts", "io", ".", "EOF", "to", "io", ".", "ErrUnexpectedEOF", "." ]
ae52aff18558bd92cbe681549bfe9e8cbffd5903
https://github.com/klauspost/compress/blob/ae52aff18558bd92cbe681549bfe9e8cbffd5903/gzip/gunzip.go#L41-L46
8,268
klauspost/compress
gzip/gunzip.go
NewReader
func NewReader(r io.Reader) (*Reader, error) { z := new(Reader) if err := z.Reset(r); err != nil { return nil, err } return z, nil }
go
func NewReader(r io.Reader) (*Reader, error) { z := new(Reader) if err := z.Reset(r); err != nil { return nil, err } return z, nil }
[ "func", "NewReader", "(", "r", "io", ".", "Reader", ")", "(", "*", "Reader", ",", "error", ")", "{", "z", ":=", "new", "(", "Reader", ")", "\n", "if", "err", ":=", "z", ".", "Reset", "(", "r", ")", ";", "err", "!=", "nil", "{", "return", "nil...
// NewReader creates a new Reader reading the given reader. // If r does not also implement io.ByteReader, // the decompressor may read more data than necessary from r. // // It is the caller's responsibility to call Close on the Reader when done. // // The Reader.Header fields will be valid in the Reader returned.
[ "NewReader", "creates", "a", "new", "Reader", "reading", "the", "given", "reader", ".", "If", "r", "does", "not", "also", "implement", "io", ".", "ByteReader", "the", "decompressor", "may", "read", "more", "data", "than", "necessary", "from", "r", ".", "It...
ae52aff18558bd92cbe681549bfe9e8cbffd5903
https://github.com/klauspost/compress/blob/ae52aff18558bd92cbe681549bfe9e8cbffd5903/gzip/gunzip.go#L93-L99
8,269
klauspost/compress
gzip/gunzip.go
Reset
func (z *Reader) Reset(r io.Reader) error { *z = Reader{ decompressor: z.decompressor, multistream: true, } if rr, ok := r.(flate.Reader); ok { z.r = rr } else { z.r = bufio.NewReader(r) } z.Header, z.err = z.readHeader() return z.err }
go
func (z *Reader) Reset(r io.Reader) error { *z = Reader{ decompressor: z.decompressor, multistream: true, } if rr, ok := r.(flate.Reader); ok { z.r = rr } else { z.r = bufio.NewReader(r) } z.Header, z.err = z.readHeader() return z.err }
[ "func", "(", "z", "*", "Reader", ")", "Reset", "(", "r", "io", ".", "Reader", ")", "error", "{", "*", "z", "=", "Reader", "{", "decompressor", ":", "z", ".", "decompressor", ",", "multistream", ":", "true", ",", "}", "\n", "if", "rr", ",", "ok", ...
// Reset discards the Reader z's state and makes it equivalent to the // result of its original state from NewReader, but reading from r instead. // This permits reusing a Reader rather than allocating a new one.
[ "Reset", "discards", "the", "Reader", "z", "s", "state", "and", "makes", "it", "equivalent", "to", "the", "result", "of", "its", "original", "state", "from", "NewReader", "but", "reading", "from", "r", "instead", ".", "This", "permits", "reusing", "a", "Re...
ae52aff18558bd92cbe681549bfe9e8cbffd5903
https://github.com/klauspost/compress/blob/ae52aff18558bd92cbe681549bfe9e8cbffd5903/gzip/gunzip.go#L104-L116
8,270
klauspost/compress
gzip/gunzip.go
readHeader
func (z *Reader) readHeader() (hdr Header, err error) { if _, err = io.ReadFull(z.r, z.buf[:10]); err != nil { // RFC 1952, section 2.2, says the following: // A gzip file consists of a series of "members" (compressed data sets). // // Other than this, the specification does not clarify whether a // "series"...
go
func (z *Reader) readHeader() (hdr Header, err error) { if _, err = io.ReadFull(z.r, z.buf[:10]); err != nil { // RFC 1952, section 2.2, says the following: // A gzip file consists of a series of "members" (compressed data sets). // // Other than this, the specification does not clarify whether a // "series"...
[ "func", "(", "z", "*", "Reader", ")", "readHeader", "(", ")", "(", "hdr", "Header", ",", "err", "error", ")", "{", "if", "_", ",", "err", "=", "io", ".", "ReadFull", "(", "z", ".", "r", ",", "z", ".", "buf", "[", ":", "10", "]", ")", ";", ...
// readHeader reads the GZIP header according to section 2.3.1. // This method does not set z.err.
[ "readHeader", "reads", "the", "GZIP", "header", "according", "to", "section", "2", ".", "3", ".", "1", ".", "This", "method", "does", "not", "set", "z", ".", "err", "." ]
ae52aff18558bd92cbe681549bfe9e8cbffd5903
https://github.com/klauspost/compress/blob/ae52aff18558bd92cbe681549bfe9e8cbffd5903/gzip/gunzip.go#L175-L240
8,271
klauspost/compress
gzip/gunzip.go
Read
func (z *Reader) Read(p []byte) (n int, err error) { if z.err != nil { return 0, z.err } n, z.err = z.decompressor.Read(p) z.digest = crc32.Update(z.digest, crc32.IEEETable, p[:n]) z.size += uint32(n) if z.err != io.EOF { // In the normal case we return here. return n, z.err } // Finished file; check ch...
go
func (z *Reader) Read(p []byte) (n int, err error) { if z.err != nil { return 0, z.err } n, z.err = z.decompressor.Read(p) z.digest = crc32.Update(z.digest, crc32.IEEETable, p[:n]) z.size += uint32(n) if z.err != io.EOF { // In the normal case we return here. return n, z.err } // Finished file; check ch...
[ "func", "(", "z", "*", "Reader", ")", "Read", "(", "p", "[", "]", "byte", ")", "(", "n", "int", ",", "err", "error", ")", "{", "if", "z", ".", "err", "!=", "nil", "{", "return", "0", ",", "z", ".", "err", "\n", "}", "\n\n", "n", ",", "z",...
// Read implements io.Reader, reading uncompressed bytes from its underlying Reader.
[ "Read", "implements", "io", ".", "Reader", "reading", "uncompressed", "bytes", "from", "its", "underlying", "Reader", "." ]
ae52aff18558bd92cbe681549bfe9e8cbffd5903
https://github.com/klauspost/compress/blob/ae52aff18558bd92cbe681549bfe9e8cbffd5903/gzip/gunzip.go#L243-L284
8,272
klauspost/compress
huff0/bitwriter.go
addBits16NC
func (b *bitWriter) addBits16NC(value uint16, bits uint8) { b.bitContainer |= uint64(value&bitMask16[bits&31]) << (b.nBits & 63) b.nBits += bits }
go
func (b *bitWriter) addBits16NC(value uint16, bits uint8) { b.bitContainer |= uint64(value&bitMask16[bits&31]) << (b.nBits & 63) b.nBits += bits }
[ "func", "(", "b", "*", "bitWriter", ")", "addBits16NC", "(", "value", "uint16", ",", "bits", "uint8", ")", "{", "b", ".", "bitContainer", "|=", "uint64", "(", "value", "&", "bitMask16", "[", "bits", "&", "31", "]", ")", "<<", "(", "b", ".", "nBits"...
// addBits16NC will add up to 16 bits. // It will not check if there is space for them, // so the caller must ensure that it has flushed recently.
[ "addBits16NC", "will", "add", "up", "to", "16", "bits", ".", "It", "will", "not", "check", "if", "there", "is", "space", "for", "them", "so", "the", "caller", "must", "ensure", "that", "it", "has", "flushed", "recently", "." ]
ae52aff18558bd92cbe681549bfe9e8cbffd5903
https://github.com/klauspost/compress/blob/ae52aff18558bd92cbe681549bfe9e8cbffd5903/huff0/bitwriter.go#L29-L32
8,273
klauspost/compress
huff0/bitwriter.go
addBits16ZeroNC
func (b *bitWriter) addBits16ZeroNC(value uint16, bits uint8) { if bits == 0 { return } value <<= (16 - bits) & 15 value >>= (16 - bits) & 15 b.bitContainer |= uint64(value) << (b.nBits & 63) b.nBits += bits }
go
func (b *bitWriter) addBits16ZeroNC(value uint16, bits uint8) { if bits == 0 { return } value <<= (16 - bits) & 15 value >>= (16 - bits) & 15 b.bitContainer |= uint64(value) << (b.nBits & 63) b.nBits += bits }
[ "func", "(", "b", "*", "bitWriter", ")", "addBits16ZeroNC", "(", "value", "uint16", ",", "bits", "uint8", ")", "{", "if", "bits", "==", "0", "{", "return", "\n", "}", "\n", "value", "<<=", "(", "16", "-", "bits", ")", "&", "15", "\n", "value", ">...
// addBits16ZeroNC will add up to 16 bits. // It will not check if there is space for them, // so the caller must ensure that it has flushed recently. // This is fastest if bits can be zero.
[ "addBits16ZeroNC", "will", "add", "up", "to", "16", "bits", ".", "It", "will", "not", "check", "if", "there", "is", "space", "for", "them", "so", "the", "caller", "must", "ensure", "that", "it", "has", "flushed", "recently", ".", "This", "is", "fastest",...
ae52aff18558bd92cbe681549bfe9e8cbffd5903
https://github.com/klauspost/compress/blob/ae52aff18558bd92cbe681549bfe9e8cbffd5903/huff0/bitwriter.go#L53-L61
8,274
klauspost/compress
huff0/bitwriter.go
flush32
func (b *bitWriter) flush32() { if b.nBits < 32 { return } b.out = append(b.out, byte(b.bitContainer), byte(b.bitContainer>>8), byte(b.bitContainer>>16), byte(b.bitContainer>>24)) b.nBits -= 32 b.bitContainer >>= 32 }
go
func (b *bitWriter) flush32() { if b.nBits < 32 { return } b.out = append(b.out, byte(b.bitContainer), byte(b.bitContainer>>8), byte(b.bitContainer>>16), byte(b.bitContainer>>24)) b.nBits -= 32 b.bitContainer >>= 32 }
[ "func", "(", "b", "*", "bitWriter", ")", "flush32", "(", ")", "{", "if", "b", ".", "nBits", "<", "32", "{", "return", "\n", "}", "\n", "b", ".", "out", "=", "append", "(", "b", ".", "out", ",", "byte", "(", "b", ".", "bitContainer", ")", ",",...
// flush32 will flush out, so there are at least 32 bits available for writing.
[ "flush32", "will", "flush", "out", "so", "there", "are", "at", "least", "32", "bits", "available", "for", "writing", "." ]
ae52aff18558bd92cbe681549bfe9e8cbffd5903
https://github.com/klauspost/compress/blob/ae52aff18558bd92cbe681549bfe9e8cbffd5903/huff0/bitwriter.go#L148-L159
8,275
klauspost/compress
huff0/bitwriter.go
flushAlign
func (b *bitWriter) flushAlign() { nbBytes := (b.nBits + 7) >> 3 for i := uint8(0); i < nbBytes; i++ { b.out = append(b.out, byte(b.bitContainer>>(i*8))) } b.nBits = 0 b.bitContainer = 0 }
go
func (b *bitWriter) flushAlign() { nbBytes := (b.nBits + 7) >> 3 for i := uint8(0); i < nbBytes; i++ { b.out = append(b.out, byte(b.bitContainer>>(i*8))) } b.nBits = 0 b.bitContainer = 0 }
[ "func", "(", "b", "*", "bitWriter", ")", "flushAlign", "(", ")", "{", "nbBytes", ":=", "(", "b", ".", "nBits", "+", "7", ")", ">>", "3", "\n", "for", "i", ":=", "uint8", "(", "0", ")", ";", "i", "<", "nbBytes", ";", "i", "++", "{", "b", "."...
// flushAlign will flush remaining full bytes and align to next byte boundary.
[ "flushAlign", "will", "flush", "remaining", "full", "bytes", "and", "align", "to", "next", "byte", "boundary", "." ]
ae52aff18558bd92cbe681549bfe9e8cbffd5903
https://github.com/klauspost/compress/blob/ae52aff18558bd92cbe681549bfe9e8cbffd5903/huff0/bitwriter.go#L162-L169
8,276
klauspost/compress
huff0/bitwriter.go
reset
func (b *bitWriter) reset(out []byte) { b.bitContainer = 0 b.nBits = 0 b.out = out }
go
func (b *bitWriter) reset(out []byte) { b.bitContainer = 0 b.nBits = 0 b.out = out }
[ "func", "(", "b", "*", "bitWriter", ")", "reset", "(", "out", "[", "]", "byte", ")", "{", "b", ".", "bitContainer", "=", "0", "\n", "b", ".", "nBits", "=", "0", "\n", "b", ".", "out", "=", "out", "\n", "}" ]
// reset and continue writing by appending to out.
[ "reset", "and", "continue", "writing", "by", "appending", "to", "out", "." ]
ae52aff18558bd92cbe681549bfe9e8cbffd5903
https://github.com/klauspost/compress/blob/ae52aff18558bd92cbe681549bfe9e8cbffd5903/huff0/bitwriter.go#L182-L186
8,277
klauspost/compress
gzip/gzip.go
NewWriter
func NewWriter(w io.Writer) *Writer { z, _ := NewWriterLevel(w, DefaultCompression) return z }
go
func NewWriter(w io.Writer) *Writer { z, _ := NewWriterLevel(w, DefaultCompression) return z }
[ "func", "NewWriter", "(", "w", "io", ".", "Writer", ")", "*", "Writer", "{", "z", ",", "_", ":=", "NewWriterLevel", "(", "w", ",", "DefaultCompression", ")", "\n", "return", "z", "\n", "}" ]
// NewWriter returns a new Writer. // Writes to the returned writer are compressed and written to w. // // It is the caller's responsibility to call Close on the WriteCloser when done. // Writes may be buffered and not flushed until Close. // // Callers that wish to set the fields in Writer.Header must do so before // ...
[ "NewWriter", "returns", "a", "new", "Writer", ".", "Writes", "to", "the", "returned", "writer", "are", "compressed", "and", "written", "to", "w", ".", "It", "is", "the", "caller", "s", "responsibility", "to", "call", "Close", "on", "the", "WriteCloser", "w...
ae52aff18558bd92cbe681549bfe9e8cbffd5903
https://github.com/klauspost/compress/blob/ae52aff18558bd92cbe681549bfe9e8cbffd5903/gzip/gzip.go#L50-L53
8,278
klauspost/compress
gzip/gzip.go
NewWriterLevel
func NewWriterLevel(w io.Writer, level int) (*Writer, error) { if level < HuffmanOnly || level > BestCompression { return nil, fmt.Errorf("gzip: invalid compression level: %d", level) } z := new(Writer) z.init(w, level) return z, nil }
go
func NewWriterLevel(w io.Writer, level int) (*Writer, error) { if level < HuffmanOnly || level > BestCompression { return nil, fmt.Errorf("gzip: invalid compression level: %d", level) } z := new(Writer) z.init(w, level) return z, nil }
[ "func", "NewWriterLevel", "(", "w", "io", ".", "Writer", ",", "level", "int", ")", "(", "*", "Writer", ",", "error", ")", "{", "if", "level", "<", "HuffmanOnly", "||", "level", ">", "BestCompression", "{", "return", "nil", ",", "fmt", ".", "Errorf", ...
// NewWriterLevel is like NewWriter but specifies the compression level instead // of assuming DefaultCompression. // // The compression level can be DefaultCompression, NoCompression, or any // integer value between BestSpeed and BestCompression inclusive. The error // returned will be nil if the level is valid.
[ "NewWriterLevel", "is", "like", "NewWriter", "but", "specifies", "the", "compression", "level", "instead", "of", "assuming", "DefaultCompression", ".", "The", "compression", "level", "can", "be", "DefaultCompression", "NoCompression", "or", "any", "integer", "value", ...
ae52aff18558bd92cbe681549bfe9e8cbffd5903
https://github.com/klauspost/compress/blob/ae52aff18558bd92cbe681549bfe9e8cbffd5903/gzip/gzip.go#L61-L68
8,279
klauspost/compress
gzip/gzip.go
Reset
func (z *Writer) Reset(w io.Writer) { z.init(w, z.level) }
go
func (z *Writer) Reset(w io.Writer) { z.init(w, z.level) }
[ "func", "(", "z", "*", "Writer", ")", "Reset", "(", "w", "io", ".", "Writer", ")", "{", "z", ".", "init", "(", "w", ",", "z", ".", "level", ")", "\n", "}" ]
// Reset discards the Writer z's state and makes it equivalent to the // result of its original state from NewWriter or NewWriterLevel, but // writing to w instead. This permits reusing a Writer rather than // allocating a new one.
[ "Reset", "discards", "the", "Writer", "z", "s", "state", "and", "makes", "it", "equivalent", "to", "the", "result", "of", "its", "original", "state", "from", "NewWriter", "or", "NewWriterLevel", "but", "writing", "to", "w", "instead", ".", "This", "permits",...
ae52aff18558bd92cbe681549bfe9e8cbffd5903
https://github.com/klauspost/compress/blob/ae52aff18558bd92cbe681549bfe9e8cbffd5903/gzip/gzip.go#L89-L91
8,280
klauspost/compress
gzip/gzip.go
writeBytes
func (z *Writer) writeBytes(b []byte) error { if len(b) > 0xffff { return errors.New("gzip.Write: Extra data is too large") } le.PutUint16(z.buf[:2], uint16(len(b))) _, err := z.w.Write(z.buf[:2]) if err != nil { return err } _, err = z.w.Write(b) return err }
go
func (z *Writer) writeBytes(b []byte) error { if len(b) > 0xffff { return errors.New("gzip.Write: Extra data is too large") } le.PutUint16(z.buf[:2], uint16(len(b))) _, err := z.w.Write(z.buf[:2]) if err != nil { return err } _, err = z.w.Write(b) return err }
[ "func", "(", "z", "*", "Writer", ")", "writeBytes", "(", "b", "[", "]", "byte", ")", "error", "{", "if", "len", "(", "b", ")", ">", "0xffff", "{", "return", "errors", ".", "New", "(", "\"", "\"", ")", "\n", "}", "\n", "le", ".", "PutUint16", ...
// writeBytes writes a length-prefixed byte slice to z.w.
[ "writeBytes", "writes", "a", "length", "-", "prefixed", "byte", "slice", "to", "z", ".", "w", "." ]
ae52aff18558bd92cbe681549bfe9e8cbffd5903
https://github.com/klauspost/compress/blob/ae52aff18558bd92cbe681549bfe9e8cbffd5903/gzip/gzip.go#L94-L105
8,281
klauspost/compress
gzip/gzip.go
Write
func (z *Writer) Write(p []byte) (int, error) { if z.err != nil { return 0, z.err } var n int // Write the GZIP header lazily. if !z.wroteHeader { z.wroteHeader = true z.buf[0] = gzipID1 z.buf[1] = gzipID2 z.buf[2] = gzipDeflate z.buf[3] = 0 if z.Extra != nil { z.buf[3] |= 0x04 } if z.Name != ...
go
func (z *Writer) Write(p []byte) (int, error) { if z.err != nil { return 0, z.err } var n int // Write the GZIP header lazily. if !z.wroteHeader { z.wroteHeader = true z.buf[0] = gzipID1 z.buf[1] = gzipID2 z.buf[2] = gzipDeflate z.buf[3] = 0 if z.Extra != nil { z.buf[3] |= 0x04 } if z.Name != ...
[ "func", "(", "z", "*", "Writer", ")", "Write", "(", "p", "[", "]", "byte", ")", "(", "int", ",", "error", ")", "{", "if", "z", ".", "err", "!=", "nil", "{", "return", "0", ",", "z", ".", "err", "\n", "}", "\n", "var", "n", "int", "\n", "/...
// Write writes a compressed form of p to the underlying io.Writer. The // compressed bytes are not necessarily flushed until the Writer is closed.
[ "Write", "writes", "a", "compressed", "form", "of", "p", "to", "the", "underlying", "io", ".", "Writer", ".", "The", "compressed", "bytes", "are", "not", "necessarily", "flushed", "until", "the", "Writer", "is", "closed", "." ]
ae52aff18558bd92cbe681549bfe9e8cbffd5903
https://github.com/klauspost/compress/blob/ae52aff18558bd92cbe681549bfe9e8cbffd5903/gzip/gzip.go#L140-L200
8,282
klauspost/compress
gzip/gzip.go
Flush
func (z *Writer) Flush() error { if z.err != nil { return z.err } if z.closed { return nil } if !z.wroteHeader { z.Write(nil) if z.err != nil { return z.err } } z.err = z.compressor.Flush() return z.err }
go
func (z *Writer) Flush() error { if z.err != nil { return z.err } if z.closed { return nil } if !z.wroteHeader { z.Write(nil) if z.err != nil { return z.err } } z.err = z.compressor.Flush() return z.err }
[ "func", "(", "z", "*", "Writer", ")", "Flush", "(", ")", "error", "{", "if", "z", ".", "err", "!=", "nil", "{", "return", "z", ".", "err", "\n", "}", "\n", "if", "z", ".", "closed", "{", "return", "nil", "\n", "}", "\n", "if", "!", "z", "."...
// Flush flushes any pending compressed data to the underlying writer. // // It is useful mainly in compressed network protocols, to ensure that // a remote reader has enough data to reconstruct a packet. Flush does // not return until the data has been written. If the underlying // writer returns an error, Flush retur...
[ "Flush", "flushes", "any", "pending", "compressed", "data", "to", "the", "underlying", "writer", ".", "It", "is", "useful", "mainly", "in", "compressed", "network", "protocols", "to", "ensure", "that", "a", "remote", "reader", "has", "enough", "data", "to", ...
ae52aff18558bd92cbe681549bfe9e8cbffd5903
https://github.com/klauspost/compress/blob/ae52aff18558bd92cbe681549bfe9e8cbffd5903/gzip/gzip.go#L210-L225
8,283
klauspost/compress
zstd/blockdec.go
reset
func (b *blockDec) reset(br byteBuffer, windowSize uint64) error { b.WindowSize = windowSize tmp := br.readSmall(3) if tmp == nil { if debug { println("Reading block header:", io.ErrUnexpectedEOF) } return io.ErrUnexpectedEOF } bh := uint32(tmp[0]) | (uint32(tmp[1]) << 8) | (uint32(tmp[2]) << 16) b.Last ...
go
func (b *blockDec) reset(br byteBuffer, windowSize uint64) error { b.WindowSize = windowSize tmp := br.readSmall(3) if tmp == nil { if debug { println("Reading block header:", io.ErrUnexpectedEOF) } return io.ErrUnexpectedEOF } bh := uint32(tmp[0]) | (uint32(tmp[1]) << 8) | (uint32(tmp[2]) << 16) b.Last ...
[ "func", "(", "b", "*", "blockDec", ")", "reset", "(", "br", "byteBuffer", ",", "windowSize", "uint64", ")", "error", "{", "b", ".", "WindowSize", "=", "windowSize", "\n", "tmp", ":=", "br", ".", "readSmall", "(", "3", ")", "\n", "if", "tmp", "==", ...
// reset will reset the block. // Input must be a start of a block and will be at the end of the block when returned.
[ "reset", "will", "reset", "the", "block", ".", "Input", "must", "be", "a", "start", "of", "a", "block", "and", "will", "be", "at", "the", "end", "of", "the", "block", "when", "returned", "." ]
ae52aff18558bd92cbe681549bfe9e8cbffd5903
https://github.com/klauspost/compress/blob/ae52aff18558bd92cbe681549bfe9e8cbffd5903/zstd/blockdec.go#L111-L166
8,284
klauspost/compress
zstd/blockdec.go
sendErr
func (b *blockDec) sendErr(err error) { b.Last = true b.Type = blockTypeReserved b.err = err b.input <- struct{}{} }
go
func (b *blockDec) sendErr(err error) { b.Last = true b.Type = blockTypeReserved b.err = err b.input <- struct{}{} }
[ "func", "(", "b", "*", "blockDec", ")", "sendErr", "(", "err", "error", ")", "{", "b", ".", "Last", "=", "true", "\n", "b", ".", "Type", "=", "blockTypeReserved", "\n", "b", ".", "err", "=", "err", "\n", "b", ".", "input", "<-", "struct", "{", ...
// sendEOF will make the decoder send EOF on this frame.
[ "sendEOF", "will", "make", "the", "decoder", "send", "EOF", "on", "this", "frame", "." ]
ae52aff18558bd92cbe681549bfe9e8cbffd5903
https://github.com/klauspost/compress/blob/ae52aff18558bd92cbe681549bfe9e8cbffd5903/zstd/blockdec.go#L169-L174
8,285
klauspost/compress
zstd/blockdec.go
Close
func (b *blockDec) Close() { close(b.input) close(b.history) close(b.result) }
go
func (b *blockDec) Close() { close(b.input) close(b.history) close(b.result) }
[ "func", "(", "b", "*", "blockDec", ")", "Close", "(", ")", "{", "close", "(", "b", ".", "input", ")", "\n", "close", "(", "b", ".", "history", ")", "\n", "close", "(", "b", ".", "result", ")", "\n", "}" ]
// Close will release resources. // Closed blockDec cannot be reset.
[ "Close", "will", "release", "resources", ".", "Closed", "blockDec", "cannot", "be", "reset", "." ]
ae52aff18558bd92cbe681549bfe9e8cbffd5903
https://github.com/klauspost/compress/blob/ae52aff18558bd92cbe681549bfe9e8cbffd5903/zstd/blockdec.go#L178-L182
8,286
klauspost/compress
zstd/blockdec.go
startDecoder
func (b *blockDec) startDecoder() { for range b.input { //println("blockDec: Got block input") switch b.Type { case blockTypeRLE: if cap(b.dst) < int(b.RLESize) { if b.lowMem { b.dst = make([]byte, b.RLESize) } else { b.dst = make([]byte, maxBlockSize) } } o := decodeOutput{ d:...
go
func (b *blockDec) startDecoder() { for range b.input { //println("blockDec: Got block input") switch b.Type { case blockTypeRLE: if cap(b.dst) < int(b.RLESize) { if b.lowMem { b.dst = make([]byte, b.RLESize) } else { b.dst = make([]byte, maxBlockSize) } } o := decodeOutput{ d:...
[ "func", "(", "b", "*", "blockDec", ")", "startDecoder", "(", ")", "{", "for", "range", "b", ".", "input", "{", "//println(\"blockDec: Got block input\")", "switch", "b", ".", "Type", "{", "case", "blockTypeRLE", ":", "if", "cap", "(", "b", ".", "dst", ")...
// decodeAsync will prepare decoding the block when it receives input. // This will separate output and history.
[ "decodeAsync", "will", "prepare", "decoding", "the", "block", "when", "it", "receives", "input", ".", "This", "will", "separate", "output", "and", "history", "." ]
ae52aff18558bd92cbe681549bfe9e8cbffd5903
https://github.com/klauspost/compress/blob/ae52aff18558bd92cbe681549bfe9e8cbffd5903/zstd/blockdec.go#L186-L246
8,287
klauspost/compress
zstd/blockdec.go
decodeBuf
func (b *blockDec) decodeBuf(hist *history) error { switch b.Type { case blockTypeRLE: if cap(b.dst) < int(b.RLESize) { if b.lowMem { b.dst = make([]byte, b.RLESize) } else { b.dst = make([]byte, maxBlockSize) } } b.dst = b.dst[:b.RLESize] v := b.data[0] for i := range b.dst { b.dst[i] =...
go
func (b *blockDec) decodeBuf(hist *history) error { switch b.Type { case blockTypeRLE: if cap(b.dst) < int(b.RLESize) { if b.lowMem { b.dst = make([]byte, b.RLESize) } else { b.dst = make([]byte, maxBlockSize) } } b.dst = b.dst[:b.RLESize] v := b.data[0] for i := range b.dst { b.dst[i] =...
[ "func", "(", "b", "*", "blockDec", ")", "decodeBuf", "(", "hist", "*", "history", ")", "error", "{", "switch", "b", ".", "Type", "{", "case", "blockTypeRLE", ":", "if", "cap", "(", "b", ".", "dst", ")", "<", "int", "(", "b", ".", "RLESize", ")", ...
// decodeAsync will prepare decoding the block when it receives the history. // If history is provided, it will not fetch it from the channel.
[ "decodeAsync", "will", "prepare", "decoding", "the", "block", "when", "it", "receives", "the", "history", ".", "If", "history", "is", "provided", "it", "will", "not", "fetch", "it", "from", "the", "channel", "." ]
ae52aff18558bd92cbe681549bfe9e8cbffd5903
https://github.com/klauspost/compress/blob/ae52aff18558bd92cbe681549bfe9e8cbffd5903/zstd/blockdec.go#L250-L287
8,288
klauspost/compress
zstd/bitreader.go
init
func (b *bitReader) init(in []byte) error { if len(in) < 1 { return errors.New("corrupt stream: too short") } b.in = in b.off = uint(len(in)) // The highest bit of the last byte indicates where to start v := in[len(in)-1] if v == 0 { return errors.New("corrupt stream, did not find end of stream") } b.bitsR...
go
func (b *bitReader) init(in []byte) error { if len(in) < 1 { return errors.New("corrupt stream: too short") } b.in = in b.off = uint(len(in)) // The highest bit of the last byte indicates where to start v := in[len(in)-1] if v == 0 { return errors.New("corrupt stream, did not find end of stream") } b.bitsR...
[ "func", "(", "b", "*", "bitReader", ")", "init", "(", "in", "[", "]", "byte", ")", "error", "{", "if", "len", "(", "in", ")", "<", "1", "{", "return", "errors", ".", "New", "(", "\"", "\"", ")", "\n", "}", "\n", "b", ".", "in", "=", "in", ...
// init initializes and resets the bit reader.
[ "init", "initializes", "and", "resets", "the", "bit", "reader", "." ]
ae52aff18558bd92cbe681549bfe9e8cbffd5903
https://github.com/klauspost/compress/blob/ae52aff18558bd92cbe681549bfe9e8cbffd5903/zstd/bitreader.go#L24-L41
8,289
klauspost/compress
zstd/bitreader.go
close
func (b *bitReader) close() error { // Release reference. b.in = nil if b.bitsRead > 64 { return io.ErrUnexpectedEOF } return nil }
go
func (b *bitReader) close() error { // Release reference. b.in = nil if b.bitsRead > 64 { return io.ErrUnexpectedEOF } return nil }
[ "func", "(", "b", "*", "bitReader", ")", "close", "(", ")", "error", "{", "// Release reference.", "b", ".", "in", "=", "nil", "\n", "if", "b", ".", "bitsRead", ">", "64", "{", "return", "io", ".", "ErrUnexpectedEOF", "\n", "}", "\n", "return", "nil"...
// close the bitstream and returns an error if out-of-buffer reads occurred.
[ "close", "the", "bitstream", "and", "returns", "an", "error", "if", "out", "-", "of", "-", "buffer", "reads", "occurred", "." ]
ae52aff18558bd92cbe681549bfe9e8cbffd5903
https://github.com/klauspost/compress/blob/ae52aff18558bd92cbe681549bfe9e8cbffd5903/zstd/bitreader.go#L110-L117
8,290
klauspost/compress
zip/register.go
RegisterDecompressor
func RegisterDecompressor(method uint16, d Decompressor) { mu.Lock() defer mu.Unlock() if _, ok := decompressors[method]; ok { panic("decompressor already registered") } decompressors[method] = d }
go
func RegisterDecompressor(method uint16, d Decompressor) { mu.Lock() defer mu.Unlock() if _, ok := decompressors[method]; ok { panic("decompressor already registered") } decompressors[method] = d }
[ "func", "RegisterDecompressor", "(", "method", "uint16", ",", "d", "Decompressor", ")", "{", "mu", ".", "Lock", "(", ")", "\n", "defer", "mu", ".", "Unlock", "(", ")", "\n\n", "if", "_", ",", "ok", ":=", "decompressors", "[", "method", "]", ";", "ok"...
// RegisterDecompressor allows custom decompressors for a specified method ID.
[ "RegisterDecompressor", "allows", "custom", "decompressors", "for", "a", "specified", "method", "ID", "." ]
ae52aff18558bd92cbe681549bfe9e8cbffd5903
https://github.com/klauspost/compress/blob/ae52aff18558bd92cbe681549bfe9e8cbffd5903/zip/register.go#L79-L87
8,291
klauspost/compress
zip/register.go
RegisterCompressor
func RegisterCompressor(method uint16, comp Compressor) { mu.Lock() defer mu.Unlock() if _, ok := compressors[method]; ok { panic("compressor already registered") } compressors[method] = comp }
go
func RegisterCompressor(method uint16, comp Compressor) { mu.Lock() defer mu.Unlock() if _, ok := compressors[method]; ok { panic("compressor already registered") } compressors[method] = comp }
[ "func", "RegisterCompressor", "(", "method", "uint16", ",", "comp", "Compressor", ")", "{", "mu", ".", "Lock", "(", ")", "\n", "defer", "mu", ".", "Unlock", "(", ")", "\n\n", "if", "_", ",", "ok", ":=", "compressors", "[", "method", "]", ";", "ok", ...
// RegisterCompressor registers custom compressors for a specified method ID. // The common methods Store and Deflate are built in.
[ "RegisterCompressor", "registers", "custom", "compressors", "for", "a", "specified", "method", "ID", ".", "The", "common", "methods", "Store", "and", "Deflate", "are", "built", "in", "." ]
ae52aff18558bd92cbe681549bfe9e8cbffd5903
https://github.com/klauspost/compress/blob/ae52aff18558bd92cbe681549bfe9e8cbffd5903/zip/register.go#L91-L99
8,292
klauspost/compress
zstd/sequencedec.go
init
func (s *sequenceDec) init(br *bitReader) error { if s.fse == nil { return errors.New("sequence decoder not defined") } s.state.init(br, s.fse.actualTableLog, s.fse.dt[:1<<s.fse.actualTableLog]) return nil }
go
func (s *sequenceDec) init(br *bitReader) error { if s.fse == nil { return errors.New("sequence decoder not defined") } s.state.init(br, s.fse.actualTableLog, s.fse.dt[:1<<s.fse.actualTableLog]) return nil }
[ "func", "(", "s", "*", "sequenceDec", ")", "init", "(", "br", "*", "bitReader", ")", "error", "{", "if", "s", ".", "fse", "==", "nil", "{", "return", "errors", ".", "New", "(", "\"", "\"", ")", "\n", "}", "\n", "s", ".", "state", ".", "init", ...
// init the state of the decoder with input from stream.
[ "init", "the", "state", "of", "the", "decoder", "with", "input", "from", "stream", "." ]
ae52aff18558bd92cbe681549bfe9e8cbffd5903
https://github.com/klauspost/compress/blob/ae52aff18558bd92cbe681549bfe9e8cbffd5903/zstd/sequencedec.go#L36-L42
8,293
klauspost/compress
zstd/sequencedec.go
initialize
func (s *sequenceDecs) initialize(br *bitReader, hist *history, literals, out []byte) error { if err := s.litLengths.init(br); err != nil { return errors.New("litLengths:" + err.Error()) } if err := s.offsets.init(br); err != nil { return errors.New("litLengths:" + err.Error()) } if err := s.matchLengths.init(...
go
func (s *sequenceDecs) initialize(br *bitReader, hist *history, literals, out []byte) error { if err := s.litLengths.init(br); err != nil { return errors.New("litLengths:" + err.Error()) } if err := s.offsets.init(br); err != nil { return errors.New("litLengths:" + err.Error()) } if err := s.matchLengths.init(...
[ "func", "(", "s", "*", "sequenceDecs", ")", "initialize", "(", "br", "*", "bitReader", ",", "hist", "*", "history", ",", "literals", ",", "out", "[", "]", "byte", ")", "error", "{", "if", "err", ":=", "s", ".", "litLengths", ".", "init", "(", "br",...
// initialize all 3 decoders from the stream input.
[ "initialize", "all", "3", "decoders", "from", "the", "stream", "input", "." ]
ae52aff18558bd92cbe681549bfe9e8cbffd5903
https://github.com/klauspost/compress/blob/ae52aff18558bd92cbe681549bfe9e8cbffd5903/zstd/sequencedec.go#L57-L73
8,294
klauspost/compress
zstd/sequencedec.go
nextFast
func (s *sequenceDecs) nextFast(br *bitReader) (ll, mo, ml int) { // Final will not read from stream. ll, llB := s.litLengths.state.final() ml, mlB := s.matchLengths.state.final() mo, moB := s.offsets.state.final() // extra bits are stored in reverse order. br.fillFast() if s.maxBits <= 32 { mo += br.getBits(...
go
func (s *sequenceDecs) nextFast(br *bitReader) (ll, mo, ml int) { // Final will not read from stream. ll, llB := s.litLengths.state.final() ml, mlB := s.matchLengths.state.final() mo, moB := s.offsets.state.final() // extra bits are stored in reverse order. br.fillFast() if s.maxBits <= 32 { mo += br.getBits(...
[ "func", "(", "s", "*", "sequenceDecs", ")", "nextFast", "(", "br", "*", "bitReader", ")", "(", "ll", ",", "mo", ",", "ml", "int", ")", "{", "// Final will not read from stream.", "ll", ",", "llB", ":=", "s", ".", "litLengths", ".", "state", ".", "final...
// nextFast will return new states when there are at least 4 unused bytes left on the stream when done.
[ "nextFast", "will", "return", "new", "states", "when", "there", "are", "at", "least", "4", "unused", "bytes", "left", "on", "the", "stream", "when", "done", "." ]
ae52aff18558bd92cbe681549bfe9e8cbffd5903
https://github.com/klauspost/compress/blob/ae52aff18558bd92cbe681549bfe9e8cbffd5903/zstd/sequencedec.go#L239-L299
8,295
klauspost/compress
zstd/sequencedec.go
mergeHistory
func (s *sequenceDecs) mergeHistory(hist *sequenceDecs) (*sequenceDecs, error) { for i := uint(0); i < 3; i++ { var sNew, sHist *sequenceDec switch i { default: // same as "case 0": sNew = &s.litLengths sHist = &hist.litLengths case 1: sNew = &s.offsets sHist = &hist.offsets case 2: sNew = ...
go
func (s *sequenceDecs) mergeHistory(hist *sequenceDecs) (*sequenceDecs, error) { for i := uint(0); i < 3; i++ { var sNew, sHist *sequenceDec switch i { default: // same as "case 0": sNew = &s.litLengths sHist = &hist.litLengths case 1: sNew = &s.offsets sHist = &hist.offsets case 2: sNew = ...
[ "func", "(", "s", "*", "sequenceDecs", ")", "mergeHistory", "(", "hist", "*", "sequenceDecs", ")", "(", "*", "sequenceDecs", ",", "error", ")", "{", "for", "i", ":=", "uint", "(", "0", ")", ";", "i", "<", "3", ";", "i", "++", "{", "var", "sNew", ...
// mergeHistory will merge history.
[ "mergeHistory", "will", "merge", "history", "." ]
ae52aff18558bd92cbe681549bfe9e8cbffd5903
https://github.com/klauspost/compress/blob/ae52aff18558bd92cbe681549bfe9e8cbffd5903/zstd/sequencedec.go#L365-L395
8,296
klauspost/compress
huff0/compress.go
Compress1X
func Compress1X(in []byte, s *Scratch) (out []byte, reUsed bool, err error) { s, err = s.prepare(in) if err != nil { return nil, false, err } return compress(in, s, s.compress1X) }
go
func Compress1X(in []byte, s *Scratch) (out []byte, reUsed bool, err error) { s, err = s.prepare(in) if err != nil { return nil, false, err } return compress(in, s, s.compress1X) }
[ "func", "Compress1X", "(", "in", "[", "]", "byte", ",", "s", "*", "Scratch", ")", "(", "out", "[", "]", "byte", ",", "reUsed", "bool", ",", "err", "error", ")", "{", "s", ",", "err", "=", "s", ".", "prepare", "(", "in", ")", "\n", "if", "err"...
// Compress1X will compress the input. // The output can be decoded using Decompress1X. // Supply a Scratch object. The scratch object contains state about re-use, // So when sharing across independent encodes, be sure to set the re-use policy.
[ "Compress1X", "will", "compress", "the", "input", ".", "The", "output", "can", "be", "decoded", "using", "Decompress1X", ".", "Supply", "a", "Scratch", "object", ".", "The", "scratch", "object", "contains", "state", "about", "re", "-", "use", "So", "when", ...
ae52aff18558bd92cbe681549bfe9e8cbffd5903
https://github.com/klauspost/compress/blob/ae52aff18558bd92cbe681549bfe9e8cbffd5903/huff0/compress.go#L13-L19
8,297
klauspost/compress
huff0/compress.go
Compress4X
func Compress4X(in []byte, s *Scratch) (out []byte, reUsed bool, err error) { s, err = s.prepare(in) if err != nil { return nil, false, err } if false { // TODO: compress4Xp only slightly faster. const parallelThreshold = 8 << 10 if len(in) < parallelThreshold || runtime.GOMAXPROCS(0) == 1 { return compr...
go
func Compress4X(in []byte, s *Scratch) (out []byte, reUsed bool, err error) { s, err = s.prepare(in) if err != nil { return nil, false, err } if false { // TODO: compress4Xp only slightly faster. const parallelThreshold = 8 << 10 if len(in) < parallelThreshold || runtime.GOMAXPROCS(0) == 1 { return compr...
[ "func", "Compress4X", "(", "in", "[", "]", "byte", ",", "s", "*", "Scratch", ")", "(", "out", "[", "]", "byte", ",", "reUsed", "bool", ",", "err", "error", ")", "{", "s", ",", "err", "=", "s", ".", "prepare", "(", "in", ")", "\n", "if", "err"...
// Compress4X will compress the input. The input is split into 4 independent blocks // and compressed similar to Compress1X. // The output can be decoded using Decompress4X. // Supply a Scratch object. The scratch object contains state about re-use, // So when sharing across independent encodes, be sure to set the re-u...
[ "Compress4X", "will", "compress", "the", "input", ".", "The", "input", "is", "split", "into", "4", "independent", "blocks", "and", "compressed", "similar", "to", "Compress1X", ".", "The", "output", "can", "be", "decoded", "using", "Decompress4X", ".", "Supply"...
ae52aff18558bd92cbe681549bfe9e8cbffd5903
https://github.com/klauspost/compress/blob/ae52aff18558bd92cbe681549bfe9e8cbffd5903/huff0/compress.go#L26-L40
8,298
klauspost/compress
huff0/compress.go
compress4Xp
func (s *Scratch) compress4Xp(src []byte) ([]byte, error) { if len(src) < 12 { return nil, ErrIncompressible } // Add placeholder for output length s.Out = s.Out[:6] segmentSize := (len(src) + 3) / 4 var wg sync.WaitGroup var errs [4]error wg.Add(4) for i := 0; i < 4; i++ { toDo := src if len(toDo) > se...
go
func (s *Scratch) compress4Xp(src []byte) ([]byte, error) { if len(src) < 12 { return nil, ErrIncompressible } // Add placeholder for output length s.Out = s.Out[:6] segmentSize := (len(src) + 3) / 4 var wg sync.WaitGroup var errs [4]error wg.Add(4) for i := 0; i < 4; i++ { toDo := src if len(toDo) > se...
[ "func", "(", "s", "*", "Scratch", ")", "compress4Xp", "(", "src", "[", "]", "byte", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "if", "len", "(", "src", ")", "<", "12", "{", "return", "nil", ",", "ErrIncompressible", "\n", "}", "\n", "/...
// compress4Xp will compress 4 streams using separate goroutines.
[ "compress4Xp", "will", "compress", "4", "streams", "using", "separate", "goroutines", "." ]
ae52aff18558bd92cbe681549bfe9e8cbffd5903
https://github.com/klauspost/compress/blob/ae52aff18558bd92cbe681549bfe9e8cbffd5903/huff0/compress.go#L216-L257
8,299
klauspost/compress
huff0/compress.go
minTableLog
func (s *Scratch) minTableLog() uint8 { minBitsSrc := highBit32(uint32(s.br.remain()-1)) + 1 minBitsSymbols := highBit32(uint32(s.symbolLen-1)) + 2 if minBitsSrc < minBitsSymbols { return uint8(minBitsSrc) } return uint8(minBitsSymbols) }
go
func (s *Scratch) minTableLog() uint8 { minBitsSrc := highBit32(uint32(s.br.remain()-1)) + 1 minBitsSymbols := highBit32(uint32(s.symbolLen-1)) + 2 if minBitsSrc < minBitsSymbols { return uint8(minBitsSrc) } return uint8(minBitsSymbols) }
[ "func", "(", "s", "*", "Scratch", ")", "minTableLog", "(", ")", "uint8", "{", "minBitsSrc", ":=", "highBit32", "(", "uint32", "(", "s", ".", "br", ".", "remain", "(", ")", "-", "1", ")", ")", "+", "1", "\n", "minBitsSymbols", ":=", "highBit32", "("...
// minTableLog provides the minimum logSize to safely represent a distribution.
[ "minTableLog", "provides", "the", "minimum", "logSize", "to", "safely", "represent", "a", "distribution", "." ]
ae52aff18558bd92cbe681549bfe9e8cbffd5903
https://github.com/klauspost/compress/blob/ae52aff18558bd92cbe681549bfe9e8cbffd5903/huff0/compress.go#L310-L317